From: "Christian König" <christian.koenig@amd.com>
To: Andrey Grodzovsky <andrey.grodzovsky@amd.com>,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Cc: ckoenig.leichtzumerken@gmail.com
Subject: Re: [PATCH 2/4] drm/ttm: Create pinned list
Date: Wed, 25 Aug 2021 08:40:41 +0200 [thread overview]
Message-ID: <f7db0442-398e-0e40-e640-80f435dd947b@amd.com> (raw)
In-Reply-To: <20210824210120.49812-3-andrey.grodzovsky@amd.com>
Am 24.08.21 um 23:01 schrieb Andrey Grodzovsky:
> This list will be used to capture all non VRAM BOs not
> on LRU so when device is hot unplugged we can iterate
> the list and unmap DMA mappings before device is removed.
>
> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
> Suggested-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/ttm/ttm_bo.c | 24 +++++++++++++++++++++---
> drivers/gpu/drm/ttm/ttm_resource.c | 1 +
> include/drm/ttm/ttm_resource.h | 1 +
> 3 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 1b950b45cf4b..84ba76ace58f 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -69,16 +69,34 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
> }
> }
>
> -static void ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
> +static void ttm_bo_del_from_lru_imp(struct ttm_buffer_object *bo, bool final)
I think we should rather inline the only user where we actually need to
delete the BO from the LRU and then rename the function here to
ttm_bo_move_to_pinned().
Apart from that looks good to me.
Regards,
Christian.
> {
> struct ttm_device *bdev = bo->bdev;
> + struct ttm_resource_manager *man = NULL;
>
> - list_del_init(&bo->lru);
> + if (bo->resource)
> + man = ttm_manager_type(bdev, bo->resource->mem_type);
> +
> +
> + if (!final && man && man->use_tt)
> + list_move_tail(&bo->lru, &man->pinned);
> + else
> + list_del_init(&bo->lru);
>
> if (bdev->funcs->del_from_lru_notify)
> bdev->funcs->del_from_lru_notify(bo);
> }
>
> +static inline void ttm_bo_del_from_lru_final(struct ttm_buffer_object *bo)
> +{
> + ttm_bo_del_from_lru_imp(bo, true);
> +}
> +
> +static inline void ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
> +{
> + ttm_bo_del_from_lru_imp(bo, false);
> +}
> +
> static void ttm_bo_bulk_move_set_pos(struct ttm_lru_bulk_move_pos *pos,
> struct ttm_buffer_object *bo)
> {
> @@ -453,7 +471,7 @@ static void ttm_bo_release(struct kref *kref)
> }
>
> spin_lock(&bo->bdev->lru_lock);
> - ttm_bo_del_from_lru(bo);
> + ttm_bo_del_from_lru_final(bo);
> list_del(&bo->ddestroy);
> spin_unlock(&bo->bdev->lru_lock);
>
> diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
> index 2431717376e7..91165f77fe0e 100644
> --- a/drivers/gpu/drm/ttm/ttm_resource.c
> +++ b/drivers/gpu/drm/ttm/ttm_resource.c
> @@ -85,6 +85,7 @@ void ttm_resource_manager_init(struct ttm_resource_manager *man,
>
> for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
> INIT_LIST_HEAD(&man->lru[i]);
> + INIT_LIST_HEAD(&man->pinned);
> man->move = NULL;
> }
> EXPORT_SYMBOL(ttm_resource_manager_init);
> diff --git a/include/drm/ttm/ttm_resource.h b/include/drm/ttm/ttm_resource.h
> index 140b6b9a8bbe..1ec0d5ebb59f 100644
> --- a/include/drm/ttm/ttm_resource.h
> +++ b/include/drm/ttm/ttm_resource.h
> @@ -130,6 +130,7 @@ struct ttm_resource_manager {
> */
>
> struct list_head lru[TTM_MAX_BO_PRIORITY];
> + struct list_head pinned;
>
> /*
> * Protected by @move_lock.
next prev parent reply other threads:[~2021-08-25 6:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 21:01 [PATCH 0/4] Various fixes to pass libdrm hotunplug tests Andrey Grodzovsky
2021-08-24 21:01 ` [PATCH 1/4] drm/amdgpu: Move flush VCE idle_work during HW fini Andrey Grodzovsky
2021-08-25 1:41 ` Quan, Evan
2021-08-25 3:20 ` Andrey Grodzovsky
2021-08-25 3:56 ` Quan, Evan
2021-08-24 21:01 ` [PATCH 2/4] drm/ttm: Create pinned list Andrey Grodzovsky
2021-08-25 6:40 ` Christian König [this message]
2021-08-24 21:01 ` [PATCH 3/4] drm/amdgpu: drm/amdgpu: Handle IOMMU enabled case Andrey Grodzovsky
2021-08-25 6:43 ` Christian König
2021-08-25 15:36 ` Andrey Grodzovsky
2021-08-26 13:43 ` Andrey Grodzovsky
2021-08-26 14:52 ` Christian König
2021-08-24 21:01 ` [PATCH 4/4] drm/amdgpu: Add a UAPI flag for hot plug/unplug Andrey Grodzovsky
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=f7db0442-398e-0e40-e640-80f435dd947b@amd.com \
--to=christian.koenig@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=andrey.grodzovsky@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
/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