Skip to content

Commit

Permalink
drm/vc4: bo: Split out Dumb buffers fixup
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Maxime Ripard committed Jun 16, 2022
1 parent dd2dfd4 commit 3d76374
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/gpu/drm/vc4/vc4_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,12 @@ int vc4_bo_dumb_create(struct drm_file *file_priv,
struct drm_device *dev,
struct drm_mode_create_dumb *args)
{
int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
struct vc4_bo *bo = NULL;
int ret;

if (args->pitch < min_pitch)
args->pitch = min_pitch;

if (args->size < args->pitch * args->height)
args->size = args->pitch * args->height;
ret = vc4_dumb_fixup_args(args);
if (ret)
return ret;

bo = vc4_bo_create(dev, args->size, false, VC4_BO_TYPE_DUMB);
if (IS_ERR(bo))
Expand Down
13 changes: 13 additions & 0 deletions drivers/gpu/drm/vc4/vc4_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ void __iomem *vc4_ioremap_regs(struct platform_device *pdev, int index)
return map;
}

int vc4_dumb_fixup_args(struct drm_mode_create_dumb *args)
{
int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);

if (args->pitch < min_pitch)
args->pitch = min_pitch;

if (args->size < args->pitch * args->height)
args->size = args->pitch * args->height;

return 0;
}

static int vc4_get_param_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/vc4/vc4_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ static inline void vc4_debugfs_add_regset32(struct drm_device *drm,

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

/* vc4_dpi.c */
extern struct platform_driver vc4_dpi_driver;
Expand Down

0 comments on commit 3d76374

Please sign in to comment.