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

drm/xlnx: Compute dumb-buffer sizes with drm_mode_size_dumb()

Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and
buffer size. Align the pitch according to hardware requirements.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Link: https://lore.kernel.org/r/20250821081918.79786-26-tzimmermann@suse.de

+5 -2
+5 -2
drivers/gpu/drm/xlnx/zynqmp_kms.c
··· 19 19 #include <drm/drm_crtc.h> 20 20 #include <drm/drm_device.h> 21 21 #include <drm/drm_drv.h> 22 + #include <drm/drm_dumb_buffers.h> 22 23 #include <drm/drm_encoder.h> 23 24 #include <drm/drm_fbdev_dma.h> 24 25 #include <drm/drm_fourcc.h> ··· 364 363 struct drm_mode_create_dumb *args) 365 364 { 366 365 struct zynqmp_dpsub *dpsub = to_zynqmp_dpsub(drm); 367 - unsigned int pitch = DIV_ROUND_UP(args->width * args->bpp, 8); 366 + int ret; 368 367 369 368 /* Enforce the alignment constraints of the DMA engine. */ 370 - args->pitch = ALIGN(pitch, dpsub->dma_align); 369 + ret = drm_mode_size_dumb(drm, args, dpsub->dma_align, 0); 370 + if (ret) 371 + return ret; 371 372 372 373 return drm_gem_dma_dumb_create_internal(file_priv, drm, args); 373 374 }