dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Matthew Auld <matthew.auld@intel.com>, intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v4 03/14] drm/ttm: move ttm_tt_{add,clear}_mapping into amdgpu
Date: Tue, 21 Sep 2021 13:29:28 +0200	[thread overview]
Message-ID: <a93a36b6-d7b6-c2b3-51eb-46e44975e43c@amd.com> (raw)
In-Reply-To: <20210921110121.3783395-3-matthew.auld@intel.com>

Am 21.09.21 um 13:01 schrieb Matthew Auld:
> Now that setting page->index shouldn't be needed anymore, we are just
> left with setting page->mapping, and here it looks like amdgpu is the
> only user, where pointing the page->mapping at the dev_mapping is used
> to verify that the pages do indeed belong to the device, if userspace
> later tries to touch them.
>
> v2(Christian):
>    - Drop the functions altogether and just inline modifying
>      the page->mapping
>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Christian König <christian.koenig@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 ++++++++++++++-
>   drivers/gpu/drm/ttm/ttm_tt.c            | 25 -------------------------
>   2 files changed, 14 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 820fcb24231f..438377a89aa3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -1119,6 +1119,8 @@ static int amdgpu_ttm_tt_populate(struct ttm_device *bdev,
>   {
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
>   	struct amdgpu_ttm_tt *gtt = (void *)ttm;
> +	pgoff_t i;
> +	int ret;
>   
>   	/* user pages are bound by amdgpu_ttm_tt_pin_userptr() */
>   	if (gtt->userptr) {
> @@ -1131,7 +1133,14 @@ static int amdgpu_ttm_tt_populate(struct ttm_device *bdev,
>   	if (ttm->page_flags & TTM_PAGE_FLAG_SG)
>   		return 0;
>   
> -	return ttm_pool_alloc(&adev->mman.bdev.pool, ttm, ctx);
> +	ret = ttm_pool_alloc(&adev->mman.bdev.pool, ttm, ctx);
> +	if (ret)
> +		return ret;
> +
> +	for (i = 0; i < ttm->num_pages; ++i)
> +		ttm->pages[i]->mapping = bdev->dev_mapping;
> +
> +	return 0;
>   }
>   
>   /*
> @@ -1145,6 +1154,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev,
>   {
>   	struct amdgpu_ttm_tt *gtt = (void *)ttm;
>   	struct amdgpu_device *adev;
> +	pgoff_t i;
>   
>   	amdgpu_ttm_backend_unbind(bdev, ttm);
>   
> @@ -1158,6 +1168,9 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev,
>   	if (ttm->page_flags & TTM_PAGE_FLAG_SG)
>   		return;
>   
> +	for (i = 0; i < ttm->num_pages; ++i)
> +		ttm->pages[i]->mapping = NULL;
> +
>   	adev = amdgpu_ttm_adev(bdev);
>   	return ttm_pool_free(&adev->mman.bdev.pool, ttm);
>   }
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> index 1cc04c224988..980ecb079b2c 100644
> --- a/drivers/gpu/drm/ttm/ttm_tt.c
> +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> @@ -289,17 +289,6 @@ int ttm_tt_swapout(struct ttm_device *bdev, struct ttm_tt *ttm,
>   	return ret;
>   }
>   
> -static void ttm_tt_add_mapping(struct ttm_device *bdev, struct ttm_tt *ttm)
> -{
> -	pgoff_t i;
> -
> -	if (ttm->page_flags & TTM_PAGE_FLAG_SG)
> -		return;
> -
> -	for (i = 0; i < ttm->num_pages; ++i)
> -		ttm->pages[i]->mapping = bdev->dev_mapping;
> -}
> -
>   int ttm_tt_populate(struct ttm_device *bdev,
>   		    struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
>   {
> @@ -336,7 +325,6 @@ int ttm_tt_populate(struct ttm_device *bdev,
>   	if (ret)
>   		goto error;
>   
> -	ttm_tt_add_mapping(bdev, ttm);
>   	ttm->page_flags |= TTM_PAGE_FLAG_PRIV_POPULATED;
>   	if (unlikely(ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)) {
>   		ret = ttm_tt_swapin(ttm);
> @@ -359,24 +347,11 @@ int ttm_tt_populate(struct ttm_device *bdev,
>   }
>   EXPORT_SYMBOL(ttm_tt_populate);
>   
> -static void ttm_tt_clear_mapping(struct ttm_tt *ttm)
> -{
> -	pgoff_t i;
> -	struct page **page = ttm->pages;
> -
> -	if (ttm->page_flags & TTM_PAGE_FLAG_SG)
> -		return;
> -
> -	for (i = 0; i < ttm->num_pages; ++i)
> -		(*page)->mapping = NULL;
> -}
> -
>   void ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm)
>   {
>   	if (!ttm_tt_is_populated(ttm))
>   		return;
>   
> -	ttm_tt_clear_mapping(ttm);
>   	if (bdev->funcs->ttm_tt_unpopulate)
>   		bdev->funcs->ttm_tt_unpopulate(bdev, ttm);
>   	else


  reply	other threads:[~2021-09-21 11:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 11:01 [PATCH v4 01/14] drm/ttm: stop calling tt_swapin in vm_access Matthew Auld
2021-09-21 11:01 ` [PATCH v4 02/14] drm/ttm: stop setting page->index for the ttm_tt Matthew Auld
2021-09-21 11:01 ` [PATCH v4 03/14] drm/ttm: move ttm_tt_{add, clear}_mapping into amdgpu Matthew Auld
2021-09-21 11:29   ` Christian König [this message]
2021-09-21 11:01 ` [PATCH v4 04/14] drm/ttm: remove TTM_PAGE_FLAG_NO_RETRY Matthew Auld
2021-09-21 11:01 ` [PATCH v4 05/14] drm/ttm: s/FLAG_SG/FLAG_EXTERNAL/ Matthew Auld
2021-09-21 11:30   ` Christian König
2021-09-21 11:01 ` [PATCH v4 06/14] drm/ttm: add some kernel-doc for TTM_TT_FLAG_* Matthew Auld
2021-09-21 11:33   ` Christian König
2021-09-21 11:01 ` [PATCH v4 07/14] drm/ttm: add TTM_TT_FLAG_EXTERNAL_MAPPABLE Matthew Auld
2021-09-21 11:01 ` [PATCH v4 08/14] drm/i915/gem: Break out some shmem backend utils Matthew Auld
2021-09-21 11:01 ` [PATCH v4 09/14] drm/i915/ttm: add tt shmem backend Matthew Auld
2021-09-22 12:14   ` Thomas Hellström
2021-09-21 11:01 ` [PATCH v4 10/14] drm/i915/ttm: hide shmem objects from TTM LRU Matthew Auld
2021-09-21 11:48   ` Christian König
2021-09-22 13:34     ` Matthew Auld
2021-09-22 13:59       ` Christian König
2021-09-21 11:01 ` [PATCH v4 11/14] drm/i915/ttm: use cached system pages when evicting lmem Matthew Auld
2021-09-21 11:01 ` [PATCH v4 12/14] drm/i915: try to simplify make_{un}shrinkable Matthew Auld
2021-09-21 11:01 ` [PATCH v4 13/14] drm/i915/ttm: make evicted shmem pages visible to the shrinker Matthew Auld
2021-09-21 11:01 ` [PATCH v4 14/14] drm/i915/ttm: enable shmem tt backend Matthew Auld
2021-09-21 11:28 ` [PATCH v4 01/14] drm/ttm: stop calling tt_swapin in vm_access Christian König
2021-09-21 11:37   ` Thomas Hellström
2021-09-21 11:42     ` 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=a93a36b6-d7b6-c2b3-51eb-46e44975e43c@amd.com \
    --to=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox