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

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe: 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 to a multiple of 8. Align the
buffer size according to hardware requirements.

Xe's internal calculation allowed for 64-bit wide buffer sizes, but
the ioctl's internal checks always verified against 32-bit wide limits.
Hance, it is safe to limit the driver code to 32-bit calculations as
well.

v3:
- mention 32-bit calculation in commit description (Matthew)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Acked-by: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/20250821081918.79786-24-tzimmermann@suse.de

+4 -4
+4 -4
drivers/gpu/drm/xe/xe_bo.c
··· 9 9 #include <linux/nospec.h> 10 10 11 11 #include <drm/drm_drv.h> 12 + #include <drm/drm_dumb_buffers.h> 12 13 #include <drm/drm_gem_ttm_helper.h> 13 14 #include <drm/drm_managed.h> 14 15 #include <drm/ttm/ttm_backup.h> ··· 3161 3160 struct xe_device *xe = to_xe_device(dev); 3162 3161 struct xe_bo *bo; 3163 3162 uint32_t handle; 3164 - int cpp = DIV_ROUND_UP(args->bpp, 8); 3165 3163 int err; 3166 3164 u32 page_size = max_t(u32, PAGE_SIZE, 3167 3165 xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K ? SZ_64K : SZ_4K); 3168 3166 3169 - args->pitch = ALIGN(args->width * cpp, 64); 3170 - args->size = ALIGN(mul_u32_u32(args->pitch, args->height), 3171 - page_size); 3167 + err = drm_mode_size_dumb(dev, args, SZ_64, page_size); 3168 + if (err) 3169 + return err; 3172 3170 3173 3171 bo = xe_bo_create_user(xe, NULL, NULL, args->size, 3174 3172 DRM_XE_GEM_CPU_CACHING_WC,