Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: allow drm_atomic_print_state() to accept any drm_printer

Currently drm_atomic_print_state() internally allocates and uses a
drm_info printer. Allow it to accept any drm_printer type so that
the API can be leveraged even for taking drm snapshot.

Rename the drm_atomic_print_state() to drm_atomic_print_new_state()
so that it reflects its functionality better.

changes in v5:
- none

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Abhinav Kumar <abhinavk@codeaurora.org>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/1618606645-19695-2-git-send-email-abhinavk@codeaurora.org
Signed-off-by: Rob Clark <robdclark@chromium.org>

authored by

Abhinav Kumar and committed by
Rob Clark
a4324a7a f21c8a27

+30 -7
+23 -5
drivers/gpu/drm/drm_atomic.c
··· 1 1 /* 2 2 * Copyright (C) 2014 Red Hat 3 3 * Copyright (C) 2014 Intel Corp. 4 + * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. 4 5 * 5 6 * Permission is hereby granted, free of charge, to any person obtaining a 6 7 * copy of this software and associated documentation files (the "Software"), ··· 1609 1608 } 1610 1609 EXPORT_SYMBOL(__drm_atomic_helper_set_config); 1611 1610 1612 - void drm_atomic_print_state(const struct drm_atomic_state *state) 1611 + /** 1612 + * drm_atomic_print_new_state - prints drm atomic state 1613 + * @state: atomic configuration to check 1614 + * @p: drm printer 1615 + * 1616 + * This functions prints the drm atomic state snapshot using the drm printer 1617 + * which is passed to it. This snapshot can be used for debugging purposes. 1618 + * 1619 + * Note that this function looks into the new state objects and hence its not 1620 + * safe to be used after the call to drm_atomic_helper_commit_hw_done(). 1621 + */ 1622 + void drm_atomic_print_new_state(const struct drm_atomic_state *state, 1623 + struct drm_printer *p) 1613 1624 { 1614 - struct drm_printer p = drm_info_printer(state->dev->dev); 1615 1625 struct drm_plane *plane; 1616 1626 struct drm_plane_state *plane_state; 1617 1627 struct drm_crtc *crtc; ··· 1631 1619 struct drm_connector_state *connector_state; 1632 1620 int i; 1633 1621 1622 + if (!p) { 1623 + DRM_ERROR("invalid drm printer\n"); 1624 + return; 1625 + } 1626 + 1634 1627 DRM_DEBUG_ATOMIC("checking %p\n", state); 1635 1628 1636 1629 for_each_new_plane_in_state(state, plane, plane_state, i) 1637 - drm_atomic_plane_print_state(&p, plane_state); 1630 + drm_atomic_plane_print_state(p, plane_state); 1638 1631 1639 1632 for_each_new_crtc_in_state(state, crtc, crtc_state, i) 1640 - drm_atomic_crtc_print_state(&p, crtc_state); 1633 + drm_atomic_crtc_print_state(p, crtc_state); 1641 1634 1642 1635 for_each_new_connector_in_state(state, connector, connector_state, i) 1643 - drm_atomic_connector_print_state(&p, connector_state); 1636 + drm_atomic_connector_print_state(p, connector_state); 1644 1637 } 1638 + EXPORT_SYMBOL(drm_atomic_print_new_state); 1645 1639 1646 1640 static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p, 1647 1641 bool take_locks)
+3 -1
drivers/gpu/drm/drm_atomic_uapi.c
··· 2 2 * Copyright (C) 2014 Red Hat 3 3 * Copyright (C) 2014 Intel Corp. 4 4 * Copyright (C) 2018 Intel Corp. 5 + * Copyright (c) 2020, The Linux Foundation. All rights reserved. 5 6 * 6 7 * Permission is hereby granted, free of charge, to any person obtaining a 7 8 * copy of this software and associated documentation files (the "Software"), ··· 1322 1321 struct drm_out_fence_state *fence_state; 1323 1322 int ret = 0; 1324 1323 unsigned int i, j, num_fences; 1324 + struct drm_printer p = drm_info_printer(dev->dev); 1325 1325 1326 1326 /* disallow for drivers not supporting atomic: */ 1327 1327 if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) ··· 1455 1453 ret = drm_atomic_nonblocking_commit(state); 1456 1454 } else { 1457 1455 if (drm_debug_enabled(DRM_UT_STATE)) 1458 - drm_atomic_print_state(state); 1456 + drm_atomic_print_new_state(state, &p); 1459 1457 1460 1458 ret = drm_atomic_commit(state); 1461 1459 }
+3 -1
drivers/gpu/drm/drm_crtc_internal.h
··· 5 5 * Jesse Barnes <jesse.barnes@intel.com> 6 6 * Copyright © 2014 Intel Corporation 7 7 * Daniel Vetter <daniel.vetter@ffwll.ch> 8 + * Copyright (c) 2020, The Linux Foundation. All rights reserved. 8 9 * 9 10 * Permission is hereby granted, free of charge, to any person obtaining a 10 11 * copy of this software and associated documentation files (the "Software"), ··· 237 236 int __drm_atomic_helper_set_config(struct drm_mode_set *set, 238 237 struct drm_atomic_state *state); 239 238 240 - void drm_atomic_print_state(const struct drm_atomic_state *state); 239 + void drm_atomic_print_new_state(const struct drm_atomic_state *state, 240 + struct drm_printer *p); 241 241 242 242 /* drm_atomic_uapi.c */ 243 243 int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,
+1
drivers/gpu/drm/selftests/test-drm_framebuffer.c
··· 8 8 #include <drm/drm_device.h> 9 9 #include <drm/drm_mode.h> 10 10 #include <drm/drm_fourcc.h> 11 + #include <drm/drm_print.h> 11 12 12 13 #include "../drm_crtc_internal.h" 13 14