Message ID | 20210607182210.99036-5-matthew.auld@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add back the buddy allocator | expand |
Hi, On Mon, 2021-06-07 at 19:22 +0100, Matthew Auld wrote: > Currently we just ignore the I915_BO_ALLOC_CONTIGUOUS flag, which is > fine since everything is already contiguous with the ttm range > manager. > However in the next patch we want to switch over to the ttm buddy > manager, where allocations are by default not contiguous. > > Signed-off-by: Matthew Auld <matthew.auld@intel.com> > Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> > --- > drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c > b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c > index 73d52df8f2be..0b0fce445e9b 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c > @@ -86,10 +86,18 @@ i915_ttm_select_tt_caching(const struct > drm_i915_gem_object *obj) > > static void > i915_ttm_place_from_region(const struct intel_memory_region *mr, > - struct ttm_place *place) > + struct ttm_place *place, > + unsigned int flags) > { > memset(place, 0, sizeof(*place)); > place->mem_type = intel_region_to_ttm_type(mr); > + > + switch(mr->type) { > + case INTEL_MEMORY_LOCAL: > + if (flags & I915_BO_ALLOC_CONTIGUOUS) > + place->flags = TTM_PL_FLAG_CONTIGUOUS; > + break; > + } Do we need to restrict this to INTEL_MEMORY_LOCAL? While it doesn't currently make much sense for other memory regions, no point in not forwarding for all? /Thomas
On 08/06/2021 08:26, Thomas Hellström wrote: > Hi, > > On Mon, 2021-06-07 at 19:22 +0100, Matthew Auld wrote: >> Currently we just ignore the I915_BO_ALLOC_CONTIGUOUS flag, which is >> fine since everything is already contiguous with the ttm range >> manager. >> However in the next patch we want to switch over to the ttm buddy >> manager, where allocations are by default not contiguous. >> >> Signed-off-by: Matthew Auld <matthew.auld@intel.com> >> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> >> --- >> drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 15 ++++++++++++--- >> 1 file changed, 12 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >> b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >> index 73d52df8f2be..0b0fce445e9b 100644 >> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >> @@ -86,10 +86,18 @@ i915_ttm_select_tt_caching(const struct >> drm_i915_gem_object *obj) >> >> static void >> i915_ttm_place_from_region(const struct intel_memory_region *mr, >> - struct ttm_place *place) >> + struct ttm_place *place, >> + unsigned int flags) >> { >> memset(place, 0, sizeof(*place)); >> place->mem_type = intel_region_to_ttm_type(mr); >> + >> + switch(mr->type) { >> + case INTEL_MEMORY_LOCAL: >> + if (flags & I915_BO_ALLOC_CONTIGUOUS) >> + place->flags = TTM_PL_FLAG_CONTIGUOUS; >> + break; >> + } > > Do we need to restrict this to INTEL_MEMORY_LOCAL? While it doesn't > currently make much sense for other memory regions, no point in not > forwarding for all? Yeah, don't see why not. > > /Thomas > >
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c index 73d52df8f2be..0b0fce445e9b 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -86,10 +86,18 @@ i915_ttm_select_tt_caching(const struct drm_i915_gem_object *obj) static void i915_ttm_place_from_region(const struct intel_memory_region *mr, - struct ttm_place *place) + struct ttm_place *place, + unsigned int flags) { memset(place, 0, sizeof(*place)); place->mem_type = intel_region_to_ttm_type(mr); + + switch(mr->type) { + case INTEL_MEMORY_LOCAL: + if (flags & I915_BO_ALLOC_CONTIGUOUS) + place->flags = TTM_PL_FLAG_CONTIGUOUS; + break; + } } static void @@ -100,15 +108,16 @@ i915_ttm_placement_from_obj(const struct drm_i915_gem_object *obj, { unsigned int i; unsigned int num_allowed = obj->mm.n_placements; + unsigned int flags = obj->flags; placement->num_placement = 1; i915_ttm_place_from_region(num_allowed ? obj->mm.placements[0] : - obj->mm.region, requested); + obj->mm.region, requested, flags); /* Cache this on object? */ placement->num_busy_placement = num_allowed; for (i = 0; i < placement->num_busy_placement; ++i) - i915_ttm_place_from_region(obj->mm.placements[i], busy + i); + i915_ttm_place_from_region(obj->mm.placements[i], busy + i, flags); if (num_allowed == 0) { *busy = *requested;
Currently we just ignore the I915_BO_ALLOC_CONTIGUOUS flag, which is fine since everything is already contiguous with the ttm range manager. However in the next patch we want to switch over to the ttm buddy manager, where allocations are by default not contiguous. Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> --- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)