[Intel-gfx] [PATCH v4 1/2] drm/i915: lookup for mem_region of a mem_type

Matthew Auld matthew.william.auld at gmail.com
Thu Dec 5 11:40:13 UTC 2019


On Mon, 2 Dec 2019 at 06:55, Ramalingam C <ramalingam.c at intel.com> wrote:
>
> Lookup function to retrieve the pointer to a memory region of
> a mem_type.
>
> Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
> cc: Matthew Auld <matthew.auld at intel.com>
> ---
>  drivers/gpu/drm/i915/intel_memory_region.c | 12 ++++++++++++
>  drivers/gpu/drm/i915/intel_memory_region.h |  3 +++
>  2 files changed, 15 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_memory_region.c b/drivers/gpu/drm/i915/intel_memory_region.c
> index baaeaecc64af..ae899df7a1c2 100644
> --- a/drivers/gpu/drm/i915/intel_memory_region.c
> +++ b/drivers/gpu/drm/i915/intel_memory_region.c
> @@ -16,6 +16,18 @@ const u32 intel_region_map[] = {
>         [INTEL_REGION_STOLEN] = REGION_MAP(INTEL_MEMORY_STOLEN, 0),
>  };
>
> +struct intel_memory_region *
> +intel_memory_region_lookup(struct drm_i915_private *i915,
> +                          enum intel_memory_type mem_type)
> +{
> +       enum intel_region_id id;
> +
> +       for (id = INTEL_REGION_SMEM; id < INTEL_REGION_UNKNOWN; id++)
> +               if (i915->mm.regions[id]->type == mem_type)

Is it not worth doing:

if (region && region->type == mem_type)

?

I guess we can always extend and improve upon this later.
Reviewed-by: Matthew Auld <matthew.auld at intel.com>


More information about the Intel-gfx mailing list