diff mbox series

[v2,3/4] drm/shmem-helper: Align to page size in dumb_create

Message ID 20210603150326.1326658-4-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show
Series shmem helpers for igt | expand

Commit Message

Daniel Vetter June 3, 2021, 3:03 p.m. UTC
shmem helpers seem a bit sloppy here by automatically rounding up when
actually creating the buffer, which results in under-reporting of what
we actually have. Caught by igt/vgem_basic tests.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Thomas Zimmermann June 3, 2021, 6:59 p.m. UTC | #1
Am 03.06.21 um 17:03 schrieb Daniel Vetter:
> shmem helpers seem a bit sloppy here by automatically rounding up when
> actually creating the buffer, which results in under-reporting of what
> we actually have. Caught by igt/vgem_basic tests.
> 
> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>   drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 32f1d7601ec6..2985744b4300 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -506,13 +506,13 @@ int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
>   
>   	if (!args->pitch || !args->size) {
>   		args->pitch = min_pitch;
> -		args->size = args->pitch * args->height;
> +		args->size = PAGE_ALIGN(args->pitch * args->height);
>   	} else {
>   		/* ensure sane minimum values */
>   		if (args->pitch < min_pitch)
>   			args->pitch = min_pitch;
>   		if (args->size < args->pitch * args->height)
> -			args->size = args->pitch * args->height;
> +			args->size = PAGE_ALIGN(args->pitch * args->height);
>   	}
>   
>   	shmem = drm_gem_shmem_create_with_handle(file, dev, args->size, &args->handle);
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index 32f1d7601ec6..2985744b4300 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -506,13 +506,13 @@  int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
 
 	if (!args->pitch || !args->size) {
 		args->pitch = min_pitch;
-		args->size = args->pitch * args->height;
+		args->size = PAGE_ALIGN(args->pitch * args->height);
 	} else {
 		/* ensure sane minimum values */
 		if (args->pitch < min_pitch)
 			args->pitch = min_pitch;
 		if (args->size < args->pitch * args->height)
-			args->size = args->pitch * args->height;
+			args->size = PAGE_ALIGN(args->pitch * args->height);
 	}
 
 	shmem = drm_gem_shmem_create_with_handle(file, dev, args->size, &args->handle);