[Intel-gfx] [PATCH v3 19/37] drm/i915: enumerate and init each supported region

Chris Wilson chris at chris-wilson.co.uk
Sat Aug 10 10:54:51 UTC 2019


Quoting Matthew Auld (2019-08-09 23:26:25)
> From: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
> 
> Nothing to enumerate yet...
> 
> Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
> Signed-off-by: Matthew Auld <matthew.auld at intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h               |  3 +
>  drivers/gpu/drm/i915/i915_gem_gtt.c           | 70 +++++++++++++++++--
>  .../gpu/drm/i915/selftests/mock_gem_device.c  |  6 ++
>  3 files changed, 72 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index f7be8cee4709..3d7da69f0d1b 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2436,6 +2436,9 @@ int __must_check i915_gem_evict_for_node(struct i915_address_space *vm,
>                                          unsigned int flags);
>  int i915_gem_evict_vm(struct i915_address_space *vm);
>  
> +void i915_gem_cleanup_memory_regions(struct drm_i915_private *i915);
> +int i915_gem_init_memory_regions(struct drm_i915_private *i915);
> +
>  /* i915_gem_internal.c */
>  struct drm_i915_gem_object *
>  i915_gem_object_create_internal(struct drm_i915_private *dev_priv,
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 83a02e773c58..a1dd3e7e1ad9 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c

Note this is not a GEM file. This is a hardware interface that I haven't
renamed due to expected conflicted...

> @@ -2713,6 +2713,66 @@ int i915_init_ggtt(struct drm_i915_private *i915)
>         return 0;
>  }
>  
> +void i915_gem_cleanup_memory_regions(struct drm_i915_private *i915)
> +{
> +       int i;
> +
> +       i915_gem_cleanup_stolen(i915);
> +
> +       for (i = 0; i < ARRAY_SIZE(i915->regions); ++i) {
> +               struct intel_memory_region *region = i915->regions[i];
> +
> +               if (region)
> +                       intel_memory_region_destroy(region);
> +       }
> +}
> +
> +int i915_gem_init_memory_regions(struct drm_i915_private *i915)
> +{
> +       int err, i;
> +
> +       /*
> +        * Initialise stolen early so that we may reserve preallocated
> +        * objects for the BIOS to KMS transition.
> +        */
> +       /* XXX: stolen will become a region at some point */
> +       err = i915_gem_init_stolen(i915);
> +       if (err)
> +               return err;
> +
> +       for (i = 0; i < INTEL_MEMORY_UKNOWN; i++) {
> +               struct intel_memory_region *mem = NULL;
> +               u32 type;
> +
> +               if (!HAS_REGION(i915, BIT(i)))
> +                       continue;
> +
> +               type = MEMORY_TYPE_FROM_REGION(intel_region_map[i]);
> +               switch (type) {
> +               default:
> +                       break;
> +               }
> +
> +               if (IS_ERR(mem)) {
> +                       err = PTR_ERR(mem);
> +                       DRM_ERROR("Failed to setup region(%d) type=%d\n", err, type);
> +                       goto out_cleanup;
> +               }
> +
> +               mem->id = intel_region_map[i];
> +               mem->type = type;
> +               mem->instance = MEMORY_INSTANCE_FROM_REGION(intel_region_map[i]);
> +
> +               i915->regions[i] = mem;
> +       }
> +
> +       return 0;
> +
> +out_cleanup:
> +       i915_gem_cleanup_memory_regions(i915);
> +       return err;
> +}
> +
>  static void ggtt_cleanup_hw(struct i915_ggtt *ggtt)
>  {
>         struct drm_i915_private *i915 = ggtt->vm.i915;
> @@ -2754,6 +2814,8 @@ void i915_ggtt_driver_release(struct drm_i915_private *i915)
>  {
>         struct pagevec *pvec;
>  
> +       i915_gem_cleanup_memory_regions(i915);

What are you doing here? Just because ggtt and stolen were related?
-Chris


More information about the Intel-gfx mailing list