amdgpu,radeon: Test fbdev GEM object in helper
Subsystems (3)
Thomas Zimmermann
maintainercover amdgpu,radeon: Test fbdev GEM object in helper
Amdgpu and radeon handle GEM objects that refer to fbdev framebuffers separately from the other GEM objects. Share the test logic in a single helper that works for all.
This series is purely for cleaning up the drivers. No functional changes intended.
Thomas Zimmermann (2):
drm/amdgpu: Move test for fbdev GEM object into generic helper drm/radeon: Test for fbdev GEM object with generic helper
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 21 +++------------ drivers/gpu/drm/drm_fb_helper.c | 29 +++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_device.c | 7 ++--- drivers/gpu/drm/radeon/radeon_fbdev.c | 17 ------------ drivers/gpu/drm/radeon/radeon_mode.h | 5 ---- include/drm/drm_fb_helper.h | 9 +++++++ 6 files changed, 45 insertions(+), 43 deletions(-)
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH 1/2 drm/amdgpu: Move test for fbdev GEM object into generic helper
Provide a generic helper that tests if fbdev emulation is backed by a specific GEM object. Not all drivers use client buffers (yet), hence also test against the first GEM object in the fbdev framebuffer.
Convert amdgpu. The helper will also be useful for radeon.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 21 +++------------ drivers/gpu/drm/drm_fb_helper.c | 29 +++++++++++++++++++++ include/drm/drm_fb_helper.h | 9 +++++++ 3 files changed, 41 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +3 -18
@@ -1738,21 +1738,6 @@ bool amdgpu_crtc_get_scanout_position(struct drm_crtc *crtc, stime, etime, mode); } -static bool -amdgpu_display_robj_is_fb (struct amdgpu_device *adev,struct amdgpu_bo *robj) -{ -struct drm_device *dev =adev_to_drm (adev); -struct drm_fb_helper *fb_helper = dev->fb_helper; - -if (!fb_helper || !fb_helper->buffer) -return false; - -if (gem_to_amdgpu_bo (fb_helper->buffer->gem) != robj) -return false; - -return true; -} -int amdgpu_display_suspend_helper (struct amdgpu_device *adev) {struct drm_device *dev =adev_to_drm (adev);
@@ -1775,7 +1760,6 @@ int amdgpu_display_suspend_helper(struct amdgpu_device *adev)list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {struct amdgpu_crtc *amdgpu_crtc =to_amdgpu_crtc (crtc);struct drm_framebuffer *fb = crtc->primary->fb; -struct amdgpu_bo *robj;if (amdgpu_crtc->cursor_bo && !adev->enable_virtual_display) {struct amdgpu_bo *aobj =gem_to_amdgpu_bo (amdgpu_crtc->cursor_bo);
@@ -1790,8 +1774,9 @@ int amdgpu_display_suspend_helper(struct amdgpu_device *adev)if (!fb || !fb->obj[0 ])continue ; - robj =gem_to_amdgpu_bo (fb->obj[0 ]); -if (!amdgpu_display_robj_is_fb (adev, robj)) { +if (!drm_fb_helper_gem_is_fb (dev->fb_helper, fb->obj[0 ])) { +struct amdgpu_bo *robj =gem_to_amdgpu_bo (fb->obj[0 ]); + r =amdgpu_bo_reserve (robj, true);if (r ==0 ) {amdgpu_bo_unpin (robj);
drivers/gpu/drm/drm_fb_helper.c +29 -0
@@ -37,6 +37,7 @@#include <drm/drm_fb_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> +#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper_vtables.h> #include <drm/drm_print.h> #include <drm/drm_vblank.h>
@@ -1771,3 +1772,31 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)return 0 ; }EXPORT_SYMBOL (drm_fb_helper_hotplug_event); + +/** +* drm_fb_helper_gem_is_fb - Tests if GEM object is framebuffer +* @fb_helper: fb_helper instance, can be NULL +* @obj: The GEM object to test, can be NULL +* +* Call drm_fb_helper_gem_is_fb to test is a DRM device's fbdev emulation +* uses the specified GEM object for its framebuffer. The result is always +* false if either poiner is NULL. +* +* Returns: +* True if fbdev emulation uses the provided GEM object, or false otherwise. +*/ +bool drm_fb_helper_gem_is_fb (const struct drm_fb_helper *fb_helper, +const struct drm_gem_object *obj) +{ +const struct drm_gem_object *gem =NULL ; + +if (!fb_helper || !obj) +return false; +if (fb_helper->buffer && fb_helper->buffer->gem) + gem = fb_helper->buffer->gem; +else if (fb_helper->fb) + gem =drm_gem_fb_get_obj (fb_helper->fb,0 ); + +return gem == obj; +} +EXPORT_SYMBOL_GPL (drm_fb_helper_gem_is_fb);
include/drm/drm_fb_helper.h +9 -0
@@ -271,6 +271,15 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd,int drm_fb_helper_hotplug_event (struct drm_fb_helper *fb_helper);int drm_fb_helper_initial_config (struct drm_fb_helper *fb_helper); + +bool drm_fb_helper_gem_is_fb (const struct drm_fb_helper *fb_helper, +const struct drm_gem_object *obj); +#else +static inline bool drm_fb_helper_gem_is_fb (const struct drm_fb_helper *fb_helper, +const struct drm_gem_object *obj) +{ +return false; +}#endif #endif
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH 2/2 drm/radeon: Test for fbdev GEM object with generic helper
In reply to Thomas ZimmermannReplace radeon's test for the fbdev GEM object with a call to the generic helper.
--- drivers/gpu/drm/radeon/radeon_device.c | 7 ++++--- drivers/gpu/drm/radeon/radeon_fbdev.c | 17 ----------------- drivers/gpu/drm/radeon/radeon_mode.h | 5 ----- 3 files changed, 4 insertions(+), 25 deletions(-)
drivers/gpu/drm/radeon/radeon_device.c +4 -3
@@ -37,6 +37,7 @@#include <drm/drm_client_event.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_device.h> +#include <drm/drm_fb_helper.h> #include <drm/drm_file.h> #include <drm/drm_framebuffer.h> #include <drm/drm_probe_helper.h>
@@ -1574,7 +1575,6 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {struct radeon_crtc *radeon_crtc =to_radeon_crtc (crtc);struct drm_framebuffer *fb = crtc->primary->fb; -struct radeon_bo *robj;if (radeon_crtc->cursor_bo) {struct radeon_bo *robj =gem_to_radeon_bo (radeon_crtc->cursor_bo);
@@ -1588,9 +1588,10 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,if (fb ==NULL || fb->obj[0 ] ==NULL ) {continue ; } - robj =gem_to_radeon_bo (fb->obj[0 ]);/* don't unpin kernel fb objects */ -if (!radeon_fbdev_robj_is_fb (rdev, robj)) { +if (!drm_fb_helper_gem_is_fb (dev->fb_helper, fb->obj[0 ])) { +struct radeon_bo *robj =gem_to_radeon_bo (fb->obj[0 ]); + r =radeon_bo_reserve (robj, false);if (r ==0 ) {radeon_bo_unpin (robj);
drivers/gpu/drm/radeon/radeon_fbdev.c +0 -17
@@ -274,20 +274,3 @@ int radeon_fbdev_driver_fbdev_probe(struct drm_fb_helper *fb_helper,radeon_fbdev_destroy_pinned_object (gobj);return ret; } - -bool radeon_fbdev_robj_is_fb (struct radeon_device *rdev,struct radeon_bo *robj) -{ -struct drm_fb_helper *fb_helper =rdev_to_drm (rdev)->fb_helper; -struct drm_gem_object *gobj; - -if (!fb_helper) -return false; - - gobj =drm_gem_fb_get_obj (fb_helper->fb,0 ); -if (!gobj) -return false; -if (gobj != &robj->tbo.base) -return false; - -return true; -}
drivers/gpu/drm/radeon/radeon_mode.h +0 -5
@@ -936,14 +936,9 @@ int radeon_fbdev_driver_fbdev_probe(struct drm_fb_helper *fb_helper, struct drm_fb_helper_surface_size *sizes);#define RADEON_FBDEV_DRIVER_OPS \ .fbdev_probe = radeon_fbdev_driver_fbdev_probe -bool radeon_fbdev_robj_is_fb (struct radeon_device *rdev,struct radeon_bo *robj);#else #define RADEON_FBDEV_DRIVER_OPS \ .fbdev_probe = NULL -static inline bool radeon_fbdev_robj_is_fb (struct radeon_device *rdev,struct radeon_bo *robj) -{ -return false; -}#endif void radeon_crtc_handle_vblank (struct radeon_device *rdev,int crtc_id);
Signature · 1 line
2.53.0
Re: [PATCH 2/2] drm/radeon: Test for fbdev GEM object with generic helper
Quoted 5 lines · Thomas Zimmermann
Replace radeon's test for the fbdev GEM object with a call to the generic helper.
Signed-off-by Thomas Zimmermann <[email protected]>
Series is:
Did you want me to pick these up or did you want to land them in drm-misc?
Alex
Quoted 86 lines
--- drivers/gpu/drm/radeon/radeon_device.c | 7 ++++--- drivers/gpu/drm/radeon/radeon_fbdev.c | 17 ----------------- drivers/gpu/drm/radeon/radeon_mode.h | 5 ----- 3 files changed, 4 insertions(+), 25 deletions(-)drivers/gpu/drm/radeon/radeon_device.c +4
-3@@ -37,6 +37,7 @@#include <drm/drm_client_event.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_device.h> +#include <drm/drm_fb_helper.h> #include <drm/drm_file.h> #include <drm/drm_framebuffer.h> #include <drm/drm_probe_helper.h> @@ -1574,7 +1575,6 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {struct radeon_crtc *radeon_crtc =to_radeon_crtc (crtc);struct drm_framebuffer *fb = crtc->primary->fb; -struct radeon_bo *robj;if (radeon_crtc->cursor_bo) {struct radeon_bo *robj =gem_to_radeon_bo (radeon_crtc->cursor_bo);@@ -1588,9 +1588,10 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,if (fb ==NULL || fb->obj[0 ] ==NULL ) {continue ; } - robj =gem_to_radeon_bo (fb->obj[0 ]);/* don't unpin kernel fb objects */ -if (!radeon_fbdev_robj_is_fb (rdev, robj)) { +if (!drm_fb_helper_gem_is_fb (dev->fb_helper, fb->obj[0 ])) { +struct radeon_bo *robj =gem_to_radeon_bo (fb->obj[0 ]); + r =radeon_bo_reserve (robj, false);if (r ==0 ) {radeon_bo_unpin (robj);drivers/gpu/drm/radeon/radeon_fbdev.c +0
-17@@ -274,20 +274,3 @@ int radeon_fbdev_driver_fbdev_probe(struct drm_fb_helper *fb_helper,radeon_fbdev_destroy_pinned_object (gobj);return ret; } - -bool radeon_fbdev_robj_is_fb (struct radeon_device *rdev,struct radeon_bo *robj) -{ -struct drm_fb_helper *fb_helper =rdev_to_drm (rdev)->fb_helper; -struct drm_gem_object *gobj; - -if (!fb_helper) -return false; - - gobj =drm_gem_fb_get_obj (fb_helper->fb,0 ); -if (!gobj) -return false; -if (gobj != &robj->tbo.base) -return false; - -return true; -}drivers/gpu/drm/radeon/radeon_mode.h +0
-6@@ -936,14 +936,9 @@ int radeon_fbdev_driver_fbdev_probe(struct drm_fb_helper *fb_helper, struct drm_fb_helper_surface_size *sizes);#define RADEON_FBDEV_DRIVER_OPS \ .fbdev_probe = radeon_fbdev_driver_fbdev_probe -bool radeon_fbdev_robj_is_fb (struct radeon_device *rdev,struct radeon_bo *robj);#else #define RADEON_FBDEV_DRIVER_OPS \ .fbdev_probe = NULL -static inline bool radeon_fbdev_robj_is_fb (struct radeon_device *rdev,struct radeon_bo *robj) -{ -return false; -}#endif void radeon_crtc_handle_vblank (struct radeon_device *rdev,int crtc_id); --2.53.0
Thomas Zimmermann
maintainerRe: [PATCH 2/2] drm/radeon: Test for fbdev GEM object with generic helper
Hi
Am 04.03.26 um 16:32 schrieb Alex Deucher:
Quoted 7 lines · Thomas Zimmermann
Quoted 4 lines
Replace radeon's test for the fbdev GEM object with a call to the generic helper.
Signed-off-by Thomas Zimmermann <[email protected]>Series is:
Reviewed-by Alex Deucher <[email protected]>
Thanks
Quoted 2 lines
Did you want me to pick these up or did you want to land them in drm-misc?
Please add it to your tree.
Best regards
Thomas
Quoted 89 lines
Alex
Quoted 86 lines
--- drivers/gpu/drm/radeon/radeon_device.c | 7 ++++--- drivers/gpu/drm/radeon/radeon_fbdev.c | 17 ----------------- drivers/gpu/drm/radeon/radeon_mode.h | 5 ----- 3 files changed, 4 insertions(+), 25 deletions(-)drivers/gpu/drm/radeon/radeon_device.c +4
-3@@ -37,6 +37,7 @@#include <drm/drm_client_event.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_device.h> +#include <drm/drm_fb_helper.h> #include <drm/drm_file.h> #include <drm/drm_framebuffer.h> #include <drm/drm_probe_helper.h> @@ -1574,7 +1575,6 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {struct radeon_crtc *radeon_crtc =to_radeon_crtc (crtc);struct drm_framebuffer *fb = crtc->primary->fb; -struct radeon_bo *robj;if (radeon_crtc->cursor_bo) {struct radeon_bo *robj =gem_to_radeon_bo (radeon_crtc->cursor_bo);@@ -1588,9 +1588,10 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,if (fb ==NULL || fb->obj[0 ] ==NULL ) {continue ; } - robj =gem_to_radeon_bo (fb->obj[0 ]);/* don't unpin kernel fb objects */ -if (!radeon_fbdev_robj_is_fb (rdev, robj)) { +if (!drm_fb_helper_gem_is_fb (dev->fb_helper, fb->obj[0 ])) { +struct radeon_bo *robj =gem_to_radeon_bo (fb->obj[0 ]); + r =radeon_bo_reserve (robj, false);if (r ==0 ) {radeon_bo_unpin (robj);drivers/gpu/drm/radeon/radeon_fbdev.c +0
-17@@ -274,20 +274,3 @@ int radeon_fbdev_driver_fbdev_probe(struct drm_fb_helper *fb_helper,radeon_fbdev_destroy_pinned_object (gobj);return ret; } - -bool radeon_fbdev_robj_is_fb (struct radeon_device *rdev,struct radeon_bo *robj) -{ -struct drm_fb_helper *fb_helper =rdev_to_drm (rdev)->fb_helper; -struct drm_gem_object *gobj; - -if (!fb_helper) -return false; - - gobj =drm_gem_fb_get_obj (fb_helper->fb,0 ); -if (!gobj) -return false; -if (gobj != &robj->tbo.base) -return false; - -return true; -}drivers/gpu/drm/radeon/radeon_mode.h +0
-6@@ -936,14 +936,9 @@ int radeon_fbdev_driver_fbdev_probe(struct drm_fb_helper *fb_helper, struct drm_fb_helper_surface_size *sizes);#define RADEON_FBDEV_DRIVER_OPS \ .fbdev_probe = radeon_fbdev_driver_fbdev_probe -bool radeon_fbdev_robj_is_fb (struct radeon_device *rdev,struct radeon_bo *robj);#else #define RADEON_FBDEV_DRIVER_OPS \ .fbdev_probe = NULL -static inline bool radeon_fbdev_robj_is_fb (struct radeon_device *rdev,struct radeon_bo *robj) -{ -return false; -}#endif void radeon_crtc_handle_vblank (struct radeon_device *rdev,int crtc_id); --2.53.0
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)