Skip to content

Commit 3d76374

Browse files
committed
drm/vc4: bo: Split out Dumb buffers fixup
The vc4_bo_dumb_create() both fixes up the allocation arguments to match the hardware constraints and actually performs the allocation. Since we're going to introduce a new function that uses a different allocator, let's split the arguments fixup to a separate function we will be able to reuse. Reviewed-by: Melissa Wen <mwen@igalia.com> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/20220610115149.964394-5-maxime@cerno.tech
1 parent dd2dfd4 commit 3d76374

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

drivers/gpu/drm/vc4/vc4_bo.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,15 +475,12 @@ int vc4_bo_dumb_create(struct drm_file *file_priv,
475475
struct drm_device *dev,
476476
struct drm_mode_create_dumb *args)
477477
{
478-
int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
479478
struct vc4_bo *bo = NULL;
480479
int ret;
481480

482-
if (args->pitch < min_pitch)
483-
args->pitch = min_pitch;
484-
485-
if (args->size < args->pitch * args->height)
486-
args->size = args->pitch * args->height;
481+
ret = vc4_dumb_fixup_args(args);
482+
if (ret)
483+
return ret;
487484

488485
bo = vc4_bo_create(dev, args->size, false, VC4_BO_TYPE_DUMB);
489486
if (IS_ERR(bo))

drivers/gpu/drm/vc4/vc4_drv.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ void __iomem *vc4_ioremap_regs(struct platform_device *pdev, int index)
6363
return map;
6464
}
6565

66+
int vc4_dumb_fixup_args(struct drm_mode_create_dumb *args)
67+
{
68+
int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
69+
70+
if (args->pitch < min_pitch)
71+
args->pitch = min_pitch;
72+
73+
if (args->size < args->pitch * args->height)
74+
args->size = args->pitch * args->height;
75+
76+
return 0;
77+
}
78+
6679
static int vc4_get_param_ioctl(struct drm_device *dev, void *data,
6780
struct drm_file *file_priv)
6881
{

drivers/gpu/drm/vc4/vc4_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ static inline void vc4_debugfs_add_regset32(struct drm_device *drm,
885885

886886
/* vc4_drv.c */
887887
void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index);
888+
int vc4_dumb_fixup_args(struct drm_mode_create_dumb *args);
888889

889890
/* vc4_dpi.c */
890891
extern struct platform_driver vc4_dpi_driver;

0 commit comments

Comments
 (0)