Message ID | 20250109150310.219442-20-tzimmermann@suse.de (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | drm/dumb-buffers: Fix and improve buffer-size calculation | expand |
Am Donnerstag, 9. Januar 2025, 15:57:13 CET schrieb Thomas Zimmermann: > Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and > buffer size. Align the pitch to a multiple of 64. > > Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> > Cc: Sandy Huang <hjc@rock-chips.com> > Cc: "Heiko Stübner" <heiko@sntech.de> > Cc: Andy Yan <andy.yan@rock-chips.com> I've looked up the patch implementing the new functionality - patch2 of this series [0] and that looks really nice to get proper helpers and not having many drivers open-coding the same functionality in different ways. So for the Rockchip adaptation: Acked-by: Heiko Stuebner <heiko@sntech.de> and looking forward to this getting merged :-) Thanks a lot for working on that Heiko [0] https://patchwork.kernel.org/project/linux-rockchip/patch/20250109150310.219442-3-tzimmermann@suse.de/ > --- > drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c > index 6330b883efc3..3bd06202e232 100644 > --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c > @@ -9,6 +9,7 @@ > #include <linux/vmalloc.h> > > #include <drm/drm.h> > +#include <drm/drm_dumb_buffers.h> > #include <drm/drm_fb_helper.h> > #include <drm/drm_gem.h> > #include <drm/drm_gem_dma_helper.h> > @@ -403,13 +404,12 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv, > struct drm_mode_create_dumb *args) > { > struct rockchip_gem_object *rk_obj; > - int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8); > + int ret; > > - /* > - * align to 64 bytes since Mali requires it. > - */ > - args->pitch = ALIGN(min_pitch, 64); > - args->size = args->pitch * args->height; > + /* 64-byte alignment required by Mali */ > + ret = drm_mode_size_dumb(dev, args, SZ_64, 0); > + if (ret) > + return ret; > > rk_obj = rockchip_gem_create_with_handle(file_priv, dev, args->size, > &args->handle); >
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 6330b883efc3..3bd06202e232 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -9,6 +9,7 @@ #include <linux/vmalloc.h> #include <drm/drm.h> +#include <drm/drm_dumb_buffers.h> #include <drm/drm_fb_helper.h> #include <drm/drm_gem.h> #include <drm/drm_gem_dma_helper.h> @@ -403,13 +404,12 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv, struct drm_mode_create_dumb *args) { struct rockchip_gem_object *rk_obj; - int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8); + int ret; - /* - * align to 64 bytes since Mali requires it. - */ - args->pitch = ALIGN(min_pitch, 64); - args->size = args->pitch * args->height; + /* 64-byte alignment required by Mali */ + ret = drm_mode_size_dumb(dev, args, SZ_64, 0); + if (ret) + return ret; rk_obj = rockchip_gem_create_with_handle(file_priv, dev, args->size, &args->handle);
Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and buffer size. Align the pitch to a multiple of 64. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Cc: Sandy Huang <hjc@rock-chips.com> Cc: "Heiko Stübner" <heiko@sntech.de> Cc: Andy Yan <andy.yan@rock-chips.com> --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)