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

Ramalingam C ramalingam.c at intel.com
Wed Nov 6 16:25:12 UTC 2019


On 2019-11-06 at 21:45:44 +0530, Tang, CQ wrote:
> 
> 
> > -----Original Message-----
> > From: Intel-gfx <intel-gfx-bounces at lists.freedesktop.org> On Behalf Of
> > Ramalingam C
> > Sent: Wednesday, November 6, 2019 8:08 AM
> > To: intel-gfx <intel-gfx at lists.freedesktop.org>; Chris Wilson <chris at chris-
> > wilson.co.uk>
> > Cc: Auld, Matthew <matthew.auld at intel.com>
> > Subject: [Intel-gfx] [PATCH v4 1/2] drm/i915: lookup for mem_region of a
> > mem_type
> > 
> > Lookup function to retrieve the pointer to a memory region of a mem_type.
> 
> We could have multi-regions with the same memory type. Your code just returns the first one. Is this desired?
At present even i915_gem_object_create_lmem i915_gem_object_create_shmem
retrieve the mem_region in this manner only. may be when we have more
region_ids per type we could extend based on a need. This is just my
thoughts.

-Ram
> 
> --CQ
> 
> > 
> > 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)
> > +			return i915->mm.regions[id];
> > +	return NULL;
> > +}
> > +
> >  static u64
> >  intel_memory_region_free_pages(struct intel_memory_region *mem,
> >  			       struct list_head *blocks)
> > diff --git a/drivers/gpu/drm/i915/intel_memory_region.h
> > b/drivers/gpu/drm/i915/intel_memory_region.h
> > index 238722009677..d210936c4d72 100644
> > --- a/drivers/gpu/drm/i915/intel_memory_region.h
> > +++ b/drivers/gpu/drm/i915/intel_memory_region.h
> > @@ -125,5 +125,8 @@ void intel_memory_region_put(struct
> > intel_memory_region *mem);
> > 
> >  int intel_memory_regions_hw_probe(struct drm_i915_private *i915);  void
> > intel_memory_regions_driver_release(struct drm_i915_private *i915);
> > +struct intel_memory_region *
> > +intel_memory_region_lookup(struct drm_i915_private *i915,
> > +			   enum intel_memory_type mem_type);
> > 
> >  #endif
> > --
> > 2.20.1
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx


More information about the Intel-gfx mailing list