[Intel-gfx] [PATCH 3/3] drm/i915/dumb: return the allocated memory size

Chris Wilson chris at chris-wilson.co.uk
Tue Dec 31 23:50:27 UTC 2019


Quoting Ramalingam C (2019-12-30 13:23:51)
> On successful allocation, instead returning the requested size
> return the total size of allocated pages.
> 
> Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 7f39df3fab7f..5a53de797852 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -241,7 +241,9 @@ i915_gem_dumb_create(struct drm_file *file,
>  {
>         enum intel_memory_type mem_type = INTEL_MEMORY_SYSTEM;
>         int cpp = DIV_ROUND_UP(args->bpp, 8);
> +       struct intel_memory_region *mr;
>         u32 format;
> +       int ret;
>  
>         switch (cpp) {
>         case 1:
> @@ -270,8 +272,15 @@ i915_gem_dumb_create(struct drm_file *file,
>         if (HAS_LMEM(to_i915(dev)))
>                 mem_type = INTEL_MEMORY_LOCAL;
>  
> -       return i915_gem_create(file, to_i915(dev), mem_type,
> -                              &args->size, &args->handle);
> +       ret = i915_gem_create(file, to_i915(dev), mem_type,
> +                             &args->size, &args->handle);
> +       if (ret)
> +               goto out;
> +
> +       mr = intel_memory_region_by_type(to_i915(dev), mem_type);
> +       args->size = ALIGN(args->size, mr->min_page_size);

How? How did we create an object that was not a multiple of the minimum
page size?

(Besides you should be using obj->mm.region here rather than assuming,
so more rearrangement if this is the right approach.)
-Chris


More information about the Intel-gfx mailing list