drm/amdgpu: Verify bo size can fit framebuffer size
Subsystems (2)
PATCH 1/1 drm/amdgpu: Verify bo size can fit framebuffer size
When creating a new framebuffer, verify that the bo size associated with it can handle the fb size.drm_gem_fb_init_with_funcs implements this check by calculating the minimum expected size of each plane. amdgpu now uses this function to initialize its fb as it performs the required checks.
The bug was caught using igt-gpu-tools test: kms_addfb_basic.too-high and kms_addfb_basic.bo-too-small
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 1 + 3 files changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +5 -3
@@ -872,13 +872,14 @@ static int amdgpu_display_get_fb_info(const struct amdgpu_framebuffer *amdgpu_fbint amdgpu_display_framebuffer_init (struct drm_device *dev,struct amdgpu_framebuffer *rfb, +struct drm_file *file,const struct drm_mode_fb_cmd2 *mode_cmd,struct drm_gem_object *obj) {int ret, i; rfb->base.obj[0 ] = obj; -drm_helper_mode_fill_fb_struct (dev, &rfb->base, mode_cmd); - ret =drm_framebuffer_init (dev, &rfb->base, &amdgpu_fb_funcs); + ret =drm_gem_fb_init_with_funcs (dev, &rfb->base, file, mode_cmd, + &amdgpu_fb_funcs);if (ret) goto fail;
@@ -953,7 +954,8 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,return ERR_PTR (-ENOMEM ); } - ret =amdgpu_display_framebuffer_init (dev, amdgpu_fb, mode_cmd, obj); + ret =amdgpu_display_framebuffer_init (dev, amdgpu_fb, file_priv, + mode_cmd, obj);if (ret) {kfree (amdgpu_fb);drm_gem_object_put (obj);
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +2 -1
@@ -233,7 +233,8 @@ static int amdgpufb_create(struct drm_fb_helper *helper, } ret =amdgpu_display_framebuffer_init (adev_to_drm (adev), &rfbdev->rfb, - &mode_cmd, gobj); + helper->client.file, &mode_cmd, + gobj);if (ret) {DRM_ERROR ("failed to initialize framebuffer %d\n" , ret); goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +1 -0
@@ -604,6 +604,7 @@ int amdgpu_display_get_crtc_scanoutpos(struct drm_device *dev,int amdgpu_display_framebuffer_init (struct drm_device *dev,struct amdgpu_framebuffer *rfb, +struct drm_file *file,const struct drm_mode_fb_cmd2 *mode_cmd,struct drm_gem_object *obj);
Signature · 6 lines
2.30.1.766.gb4fecdf3b7-goog _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
AppliedQuoted 7 lines · Mark Yacoub
When creating a new framebuffer, verify that the bo size associated with it can handle the fb size.
drm_gem_fb_init_with_funcsimplements this check by calculating the minimum expected size of each plane. amdgpu now uses this function to initialize its fb as it performs the required checks.
Quoted 8 lines
The bug was caught using igt-gpu-tools test: kms_addfb_basic.too-high and kms_addfb_basic.bo-too-small
Suggested-by Sean Paul <[email protected]>Cc Alex Deucher <[email protected]>Signed-off-by Mark Yacoub <[email protected]>
Applied. Thanks!
Alex
Quoted 66 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 +++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 1 + 3 files changed, 8 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +5
-3@@ -872,13 +872,14 @@ static int amdgpu_display_get_fb_info(const struct amdgpu_framebuffer *amdgpu_fbint amdgpu_display_framebuffer_init (struct drm_device *dev,struct amdgpu_framebuffer *rfb, +struct drm_file *file,const struct drm_mode_fb_cmd2 *mode_cmd,struct drm_gem_object *obj) {int ret, i; rfb->base.obj[0 ] = obj; -drm_helper_mode_fill_fb_struct (dev, &rfb->base, mode_cmd); - ret =drm_framebuffer_init (dev, &rfb->base, &amdgpu_fb_funcs); + ret =drm_gem_fb_init_with_funcs (dev, &rfb->base, file, mode_cmd, + &amdgpu_fb_funcs);if (ret) goto fail;@@ -953,7 +954,8 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,return ERR_PTR (-ENOMEM ); } - ret =amdgpu_display_framebuffer_init (dev, amdgpu_fb, mode_cmd, obj); + ret =amdgpu_display_framebuffer_init (dev, amdgpu_fb, file_priv, + mode_cmd, obj);if (ret) {kfree (amdgpu_fb);drm_gem_object_put (obj);drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +2
-1@@ -233,7 +233,8 @@ static int amdgpufb_create(struct drm_fb_helper *helper, } ret =amdgpu_display_framebuffer_init (adev_to_drm (adev), &rfbdev->rfb, - &mode_cmd, gobj); + helper->client.file, &mode_cmd, + gobj);if (ret) {DRM_ERROR ("failed to initialize framebuffer %d\n" , ret); goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +1
-1@@ -604,6 +604,7 @@ int amdgpu_display_get_crtc_scanoutpos(struct drm_device *dev,int amdgpu_display_framebuffer_init (struct drm_device *dev,struct amdgpu_framebuffer *rfb, +struct drm_file *file,const struct drm_mode_fb_cmd2 *mode_cmd,struct drm_gem_object *obj); --2.30.1.766.gb4fecdf3b7-goog
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel