From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Robert Beckett <bob.beckett@collabora.com>,
dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>
Cc: Matthew Auld <matthew.auld@intel.com>, linux-kernel@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH v3 1/5] drm/i915: instantiate ttm ranger manager for stolen memory
Date: Thu, 14 Apr 2022 15:23:26 +0200 [thread overview]
Message-ID: <28042cc2-be62-eeb7-35a7-f2e33c43bad5@linux.intel.com> (raw)
In-Reply-To: <20220412193817.2098308-2-bob.beckett@collabora.com>
On 4/12/22 21:38, Robert Beckett wrote:
> prepare for ttm based stolen region by using ttm range manager
> as the resource manager for stolen region.
>
> Signed-off-by: Robert Beckett <bob.beckett@collabora.com>
LGTM.
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 6 ++--
> drivers/gpu/drm/i915/intel_region_ttm.c | 31 +++++++++++++++-----
> 2 files changed, 27 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
> index a10716f4e717..358f8a1a30ce 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
> @@ -58,11 +58,13 @@ i915_ttm_region(struct ttm_device *bdev, int ttm_mem_type)
> struct drm_i915_private *i915 = container_of(bdev, typeof(*i915), bdev);
>
> /* There's some room for optimization here... */
> - GEM_BUG_ON(ttm_mem_type != I915_PL_SYSTEM &&
> - ttm_mem_type < I915_PL_LMEM0);
> + GEM_BUG_ON(ttm_mem_type == I915_PL_GGTT);
> +
> if (ttm_mem_type == I915_PL_SYSTEM)
> return intel_memory_region_lookup(i915, INTEL_MEMORY_SYSTEM,
> 0);
> + if (ttm_mem_type == I915_PL_STOLEN)
> + return i915->mm.stolen_region;
>
> return intel_memory_region_lookup(i915, INTEL_MEMORY_LOCAL,
> ttm_mem_type - I915_PL_LMEM0);
> diff --git a/drivers/gpu/drm/i915/intel_region_ttm.c b/drivers/gpu/drm/i915/intel_region_ttm.c
> index 62ff77445b01..7d49ea72e33f 100644
> --- a/drivers/gpu/drm/i915/intel_region_ttm.c
> +++ b/drivers/gpu/drm/i915/intel_region_ttm.c
> @@ -49,7 +49,7 @@ void intel_region_ttm_device_fini(struct drm_i915_private *dev_priv)
>
> /*
> * Map the i915 memory regions to TTM memory types. We use the
> - * driver-private types for now, reserving TTM_PL_VRAM for stolen
> + * driver-private types for now, reserving I915_PL_STOLEN for stolen
> * memory and TTM_PL_TT for GGTT use if decided to implement this.
> */
> int intel_region_to_ttm_type(const struct intel_memory_region *mem)
> @@ -58,11 +58,17 @@ int intel_region_to_ttm_type(const struct intel_memory_region *mem)
>
> GEM_BUG_ON(mem->type != INTEL_MEMORY_LOCAL &&
> mem->type != INTEL_MEMORY_MOCK &&
> - mem->type != INTEL_MEMORY_SYSTEM);
> + mem->type != INTEL_MEMORY_SYSTEM &&
> + mem->type != INTEL_MEMORY_STOLEN_SYSTEM &&
> + mem->type != INTEL_MEMORY_STOLEN_LOCAL);
>
> if (mem->type == INTEL_MEMORY_SYSTEM)
> return TTM_PL_SYSTEM;
>
> + if (mem->type == INTEL_MEMORY_STOLEN_SYSTEM ||
> + mem->type == INTEL_MEMORY_STOLEN_LOCAL)
> + return I915_PL_STOLEN;
> +
> type = mem->instance + TTM_PL_PRIV;
> GEM_BUG_ON(type >= TTM_NUM_MEM_TYPES);
>
> @@ -86,10 +92,16 @@ int intel_region_ttm_init(struct intel_memory_region *mem)
> int mem_type = intel_region_to_ttm_type(mem);
> int ret;
>
> - ret = i915_ttm_buddy_man_init(bdev, mem_type, false,
> - resource_size(&mem->region),
> - mem->io_size,
> - mem->min_page_size, PAGE_SIZE);
> + if (mem_type == I915_PL_STOLEN) {
> + ret = ttm_range_man_init(bdev, mem_type, false,
> + resource_size(&mem->region) >> PAGE_SHIFT);
> + mem->is_range_manager = true;
> + } else {
> + ret = i915_ttm_buddy_man_init(bdev, mem_type, false,
> + resource_size(&mem->region),
> + mem->io_size,
> + mem->min_page_size, PAGE_SIZE);
> + }
> if (ret)
> return ret;
>
> @@ -109,6 +121,7 @@ int intel_region_ttm_init(struct intel_memory_region *mem)
> int intel_region_ttm_fini(struct intel_memory_region *mem)
> {
> struct ttm_resource_manager *man = mem->region_private;
> + int mem_type = intel_region_to_ttm_type(mem);
> int ret = -EBUSY;
> int count;
>
> @@ -139,8 +152,10 @@ int intel_region_ttm_fini(struct intel_memory_region *mem)
> if (ret || !man)
> return ret;
>
> - ret = i915_ttm_buddy_man_fini(&mem->i915->bdev,
> - intel_region_to_ttm_type(mem));
> + if (mem_type == I915_PL_STOLEN)
> + ret = ttm_range_man_fini(&mem->i915->bdev, mem_type);
> + else
> + ret = i915_ttm_buddy_man_fini(&mem->i915->bdev, mem_type);
> GEM_WARN_ON(ret);
> mem->region_private = NULL;
>
next prev parent reply other threads:[~2022-04-14 13:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 19:38 [Intel-gfx] [PATCH v3 0/5] drm/i915: ttm for stolen region Robert Beckett
2022-04-12 19:38 ` [Intel-gfx] [PATCH v3 1/5] drm/i915: instantiate ttm ranger manager for stolen memory Robert Beckett
2022-04-14 13:23 ` Thomas Hellström [this message]
2022-04-12 19:38 ` [Intel-gfx] [PATCH v3 2/5] drm/i915: sanitize mem_flags for stolen buffers Robert Beckett
2022-04-12 19:38 ` [Intel-gfx] [PATCH v3 3/5] drm/i915: ttm move/clear logic fix Robert Beckett
2022-04-12 19:38 ` [Intel-gfx] [PATCH v3 4/5] drm/i915: ttm backend dont provide mmap_offset for kernel buffers Robert Beckett
2022-04-12 19:38 ` [Intel-gfx] [PATCH v3 5/5] drm/i915: stolen memory use ttm backend Robert Beckett
2022-04-14 14:41 ` Thomas Hellström
2022-04-14 17:29 ` Robert Beckett
2022-04-18 13:52 ` [Intel-gfx] [drm/i915] 9c20c625e8: WARNING:possible_recursive_locking_detected kernel test robot
2022-04-13 13:34 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915: ttm for stolen region (rev3) Patchwork
2022-04-13 13:45 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=28042cc2-be62-eeb7-35a7-f2e33c43bad5@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=airlied@linux.ie \
--cc=bob.beckett@collabora.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.auld@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=tvrtko.ursulin@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox