From: Huang Rui <ray.huang@amd.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: "thomas.hellstrom@linux.intel.com"
<thomas.hellstrom@linux.intel.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 02/12] drm/ttm: add back a reference to the bdev to the res manager
Date: Fri, 26 Nov 2021 14:52:06 +0800 [thread overview]
Message-ID: <YaCEFo6rzjn3I/B4@amd.com> (raw)
In-Reply-To: <20211124124430.20859-3-christian.koenig@amd.com>
On Wed, Nov 24, 2021 at 08:44:20PM +0800, Christian König wrote:
> It is simply a lot cleaner to have this around instead of adding
> the device throughout the call chain.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 3 ++-
> drivers/gpu/drm/amd/amdgpu/amdgpu_preempt_mgr.c | 2 +-
> drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 3 ++-
> drivers/gpu/drm/i915/i915_ttm_buddy_manager.c | 2 +-
> drivers/gpu/drm/nouveau/nouveau_ttm.c | 4 ++--
> drivers/gpu/drm/ttm/ttm_range_manager.c | 2 +-
> drivers/gpu/drm/ttm/ttm_resource.c | 3 +++
> drivers/gpu/drm/ttm/ttm_sys_manager.c | 2 +-
> drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 2 +-
> drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 2 +-
> include/drm/ttm/ttm_resource.h | 16 +++++++++-------
> 11 files changed, 24 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index ea5470c8c921..9e7685a4878c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -293,7 +293,8 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
> man->use_tt = true;
> man->func = &amdgpu_gtt_mgr_func;
>
> - ttm_resource_manager_init(man, gtt_size >> PAGE_SHIFT);
> + ttm_resource_manager_init(man, &adev->mman.bdev,
> + gtt_size >> PAGE_SHIFT);
>
> start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS;
> size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_preempt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_preempt_mgr.c
> index ffddec08e931..6f7189d32f0a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_preempt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_preempt_mgr.c
> @@ -153,7 +153,7 @@ int amdgpu_preempt_mgr_init(struct amdgpu_device *adev)
> man->use_tt = true;
> man->func = &amdgpu_preempt_mgr_func;
>
> - ttm_resource_manager_init(man, (1 << 30));
> + ttm_resource_manager_init(man, &adev->mman.bdev, (1 << 30));
>
> atomic64_set(&mgr->used, 0);
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 55d68408951d..ddd0b6d74070 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -699,7 +699,8 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
> struct amdgpu_vram_mgr *mgr = &adev->mman.vram_mgr;
> struct ttm_resource_manager *man = &mgr->manager;
>
> - ttm_resource_manager_init(man, adev->gmc.real_vram_size >> PAGE_SHIFT);
> + ttm_resource_manager_init(man, &adev->mman.bdev,
> + adev->gmc.real_vram_size >> PAGE_SHIFT);
>
> man->func = &amdgpu_vram_mgr_func;
>
> diff --git a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
> index ca3ca1f7f850..ef535e04a88a 100644
> --- a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
> +++ b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
> @@ -203,7 +203,7 @@ int i915_ttm_buddy_man_init(struct ttm_device *bdev,
> man = &bman->manager;
> man->use_tt = use_tt;
> man->func = &i915_ttm_buddy_manager_func;
> - ttm_resource_manager_init(man, bman->mm.size >> PAGE_SHIFT);
> + ttm_resource_manager_init(man, bdev, bman->mm.size >> PAGE_SHIFT);
>
> ttm_resource_manager_set_used(man, true);
> ttm_set_driver_manager(bdev, type, man);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index 91ef33f8f22c..85f1f5a0fe5d 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -164,7 +164,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
>
> man->func = &nouveau_vram_manager;
>
> - ttm_resource_manager_init(man,
> + ttm_resource_manager_init(man, &drm->ttm.bdev,
> drm->gem.vram_available >> PAGE_SHIFT);
> ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man);
> ttm_resource_manager_set_used(man, true);
> @@ -211,7 +211,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
>
> man->func = func;
> man->use_tt = true;
> - ttm_resource_manager_init(man, size_pages);
> + ttm_resource_manager_init(man, &drm->ttm.bdev, size_pages);
> ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
> ttm_resource_manager_set_used(man, true);
> return 0;
> diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
> index 25fcf0d63c2d..062dabe6a10e 100644
> --- a/drivers/gpu/drm/ttm/ttm_range_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
> @@ -156,7 +156,7 @@ int ttm_range_man_init_nocheck(struct ttm_device *bdev,
>
> man->func = &ttm_range_manager_func;
>
> - ttm_resource_manager_init(man, p_size);
> + ttm_resource_manager_init(man, bdev, p_size);
>
> drm_mm_init(&rman->mm, 0, p_size);
> spin_lock_init(&rman->lock);
> diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
> index 89bcfe22a0ca..41e7bf195168 100644
> --- a/drivers/gpu/drm/ttm/ttm_resource.c
> +++ b/drivers/gpu/drm/ttm/ttm_resource.c
> @@ -126,16 +126,19 @@ EXPORT_SYMBOL(ttm_resource_compat);
> * ttm_resource_manager_init
> *
> * @man: memory manager object to init
> + * @bdev: ttm device this manager belongs to
> * @p_size: size managed area in pages.
> *
> * Initialise core parts of a manager object.
> */
> void ttm_resource_manager_init(struct ttm_resource_manager *man,
> + struct ttm_device *bdev,
> unsigned long p_size)
> {
> unsigned i;
>
> spin_lock_init(&man->move_lock);
> + man->bdev = bdev;
> man->size = p_size;
>
> for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
> diff --git a/drivers/gpu/drm/ttm/ttm_sys_manager.c b/drivers/gpu/drm/ttm/ttm_sys_manager.c
> index 135394dcca95..2ced169513cb 100644
> --- a/drivers/gpu/drm/ttm/ttm_sys_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_sys_manager.c
> @@ -43,7 +43,7 @@ void ttm_sys_man_init(struct ttm_device *bdev)
> man->use_tt = true;
> man->func = &ttm_sys_manager_func;
>
> - ttm_resource_manager_init(man, 0);
> + ttm_resource_manager_init(man, bdev, 0);
> ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
> ttm_resource_manager_set_used(man, true);
> }
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> index bfd686bb8d19..4fe4eeb95bf3 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> @@ -150,7 +150,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
> man->func = &vmw_gmrid_manager_func;
> /* TODO: This is most likely not correct */
> man->use_tt = true;
> - ttm_resource_manager_init(man, 0);
> + ttm_resource_manager_init(man, &dev_priv->bdev, 0);
> spin_lock_init(&gman->lock);
> gman->used_gmr_pages = 0;
> ida_init(&gman->gmr_ida);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> index 4fcbd94ccc11..b8cd89cd624c 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> @@ -135,7 +135,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)
> if (!rman)
> return -ENOMEM;
>
> - ttm_resource_manager_init(&rman->manager,
> + ttm_resource_manager_init(&rman->manager, &dev_priv->bdev,
> dev_priv->vram_size >> PAGE_SHIFT);
>
> rman->manager.func = &vmw_thp_func;
> diff --git a/include/drm/ttm/ttm_resource.h b/include/drm/ttm/ttm_resource.h
> index df1f06b7b504..6bf37383002b 100644
> --- a/include/drm/ttm/ttm_resource.h
> +++ b/include/drm/ttm/ttm_resource.h
> @@ -105,11 +105,11 @@ struct ttm_resource_manager_func {
> * @use_type: The memory type is enabled.
> * @use_tt: If a TT object should be used for the backing store.
> * @size: Size of the managed region.
> + * @bdev: ttm device this manager belongs to
> * @func: structure pointer implementing the range manager. See above
> * @move_lock: lock for move fence
> - * static information. bdev::driver::io_mem_free is never used.
> - * @lru: The lru list for this memory type.
> * @move: The fence of the last pipelined move operation.
> + * @lru: The lru list for this memory type.
> *
> * This structure is used to identify and manage memory types for a device.
> */
> @@ -119,20 +119,21 @@ struct ttm_resource_manager {
> */
> bool use_type;
> bool use_tt;
> + struct ttm_device *bdev;
> uint64_t size;
> const struct ttm_resource_manager_func *func;
> spinlock_t move_lock;
>
> /*
> - * Protected by the global->lru_lock.
> + * Protected by @move_lock.
> */
> -
> - struct list_head lru[TTM_MAX_BO_PRIORITY];
> + struct dma_fence *move;
>
> /*
> - * Protected by @move_lock.
> + * Protected by the global->lru_lock.
> */
> - struct dma_fence *move;
> +
> + struct list_head lru[TTM_MAX_BO_PRIORITY];
> };
>
> /**
> @@ -272,6 +273,7 @@ bool ttm_resource_compat(struct ttm_resource *res,
> struct ttm_placement *placement);
>
> void ttm_resource_manager_init(struct ttm_resource_manager *man,
> + struct ttm_device *bdev,
> unsigned long p_size);
>
> int ttm_resource_manager_evict_all(struct ttm_device *bdev,
> --
> 2.25.1
>
next prev parent reply other threads:[~2021-11-26 6:52 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 12:44 drm/ttm: moving the LRU into the resource Christian König
2021-11-24 12:44 ` [PATCH 01/12] drm/ttm: add ttm_resource_fini Christian König
2021-11-26 6:48 ` Huang Rui
2021-11-26 7:39 ` Christian König
2021-11-26 7:47 ` Huang Rui
2021-11-24 12:44 ` [PATCH 02/12] drm/ttm: add back a reference to the bdev to the res manager Christian König
2021-11-26 6:52 ` Huang Rui [this message]
2021-11-24 12:44 ` [PATCH 03/12] drm/ttm: add a weak BO reference to the resource v3 Christian König
2021-11-26 7:10 ` Huang Rui
2021-11-26 7:43 ` Thomas Hellström
2021-11-24 12:44 ` [PATCH 04/12] drm/ttm: add common accounting to the resource mgr v2 Christian König
2021-11-26 7:35 ` Huang Rui
2021-11-24 12:44 ` [PATCH 05/12] drm/ttm: move the LRU into resource handling v2 Christian König
2021-11-24 12:44 ` [PATCH 06/12] drm/ttm: add resource iterator Christian König
2021-11-26 7:43 ` Huang Rui
2021-11-24 12:44 ` [PATCH 07/12] drm/radeon: use ttm_resource_manager_debug Christian König
2021-11-24 12:44 ` [PATCH 08/12] drm/radeon: remove resource accounting Christian König
2021-11-24 12:44 ` [PATCH 09/12] drm/amdgpu: use ttm_resource_manager_debug Christian König
2021-11-24 12:44 ` [PATCH 10/12] drm/amdgpu: remove GTT accounting Christian König
2021-11-24 12:44 ` [PATCH 11/12] drm/amdgpu: remove VRAM accounting Christian König
2021-11-24 12:44 ` [PATCH 12/12] drm/amdgpu: drop amdgpu_gtt_node Christian König
2021-11-26 7:53 ` Huang Rui
2021-11-26 7:47 ` drm/ttm: moving the LRU into the resource Thomas Hellström
-- strict thread matches above, loose matches on Subject: below --
2022-01-24 12:25 Christian König
2022-01-24 12:25 ` [PATCH 02/12] drm/ttm: add back a reference to the bdev to the res manager Christian König
2022-01-25 16:30 ` Daniel Vetter
2021-08-30 8:56 [PATCH 01/12] drm/ttm: add ttm_resource_fini Christian König
2021-08-30 8:56 ` [PATCH 02/12] drm/ttm: add back a reference to the bdev to the res manager Christian König
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=YaCEFo6rzjn3I/B4@amd.com \
--to=ray.huang@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=thomas.hellstrom@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.