[Intel-gfx] [PATCH] drm/i915: Update size upon return from GEM_CREATE
Chris Wilson
chris at chris-wilson.co.uk
Tue Mar 26 16:44:56 UTC 2019
Quoting Michał Winiarski (2019-03-26 16:33:45)
> Since GEM_CREATE is trying to outsmart the user by rounding up unaligned
> objects, we used to update the size returned to userspace.
> This update seems to have been lost throughout the history.
>
> References: ff72145badb8 ("drm: dumb scanout create/mmap for intel/radeon (v3)")
> Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Janusz Krzysztofik <janusz.krzysztofik at intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_gem.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index f6cdd5fb9deb..77b82cb81a6c 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -622,14 +622,15 @@ i915_gem_phys_pwrite(struct drm_i915_gem_object *obj,
> static int
> i915_gem_create(struct drm_file *file,
> struct drm_i915_private *dev_priv,
> - u64 size,
> + u64 *size_p,
> u32 *handle_p)
> {
> struct drm_i915_gem_object *obj;
> int ret;
> + u64 size;
> u32 handle;
>
> - size = roundup(size, PAGE_SIZE);
> + size = roundup(*size_p, PAGE_SIZE);
You could have snuck in a round_up() and reordered the locals.
> if (size == 0)
> return -EINVAL;
>
> @@ -645,6 +646,8 @@ i915_gem_create(struct drm_file *file,
> return ret;
>
> *handle_p = handle;
> + *size_p = obj->base.size;
No need for whitespace between the out params and return. Without the
break, it reinforces that they are all part of the return imo.
Sneak in a round_up, and have
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris
More information about the Intel-gfx
mailing list