From: Matthew Auld <matthew.auld@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Christian König" <christian.koenig@amd.com>
Subject: [Intel-gfx] [PATCH v3 02/12] drm/ttm: move ttm_tt_{add, clear}_mapping into amdgpu
Date: Wed, 15 Sep 2021 19:59:44 +0100 [thread overview]
Message-ID: <20210915185954.3114858-2-matthew.auld@intel.com> (raw)
In-Reply-To: <20210915185954.3114858-1-matthew.auld@intel.com>
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.
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>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 27 ++++++++++++++++++++++++-
drivers/gpu/drm/ttm/ttm_tt.c | 25 -----------------------
2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 1129e17e9f09..c5fa6e62f6ca 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1107,6 +1107,24 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_buffer_object *bo,
return >t->ttm;
}
+static void amdgpu_ttm_tt_add_mapping(struct ttm_device *bdev,
+ struct ttm_tt *ttm)
+{
+ pgoff_t i;
+
+ for (i = 0; i < ttm->num_pages; ++i)
+ ttm->pages[i]->mapping = bdev->dev_mapping;
+}
+
+static void amdgpu_ttm_tt_clear_mapping(struct ttm_tt *ttm)
+{
+ struct page **page = ttm->pages;
+ pgoff_t i;
+
+ for (i = 0; i < ttm->num_pages; ++i)
+ (*page)->mapping = NULL;
+}
+
/*
* amdgpu_ttm_tt_populate - Map GTT pages visible to the device
*
@@ -1119,6 +1137,7 @@ 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;
+ int ret;
/* user pages are bound by amdgpu_ttm_tt_pin_userptr() */
if (gtt->userptr) {
@@ -1131,7 +1150,12 @@ 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;
+
+ amdgpu_ttm_tt_add_mapping(bdev, ttm);
+ return 0;
}
/*
@@ -1159,6 +1183,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev,
return;
adev = amdgpu_ttm_adev(bdev);
+ amdgpu_ttm_tt_clear_mapping(ttm);
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
--
2.26.3
next prev parent reply other threads:[~2021-09-15 19:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-15 18:59 [Intel-gfx] [PATCH v3 01/12] drm/ttm: stop setting page->index for the ttm_tt Matthew Auld
2021-09-15 18:59 ` Matthew Auld [this message]
2021-09-16 6:45 ` [Intel-gfx] [PATCH v3 02/12] drm/ttm: move ttm_tt_{add, clear}_mapping into amdgpu Christian König
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 03/12] drm/ttm: remove TTM_PAGE_FLAG_NO_RETRY Matthew Auld
2021-09-16 6:46 ` Christian König
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 04/12] drm/ttm: s/FLAG_SG/FLAG_EXTERNAL/ Matthew Auld
2021-09-16 6:50 ` Christian König
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 05/12] drm/ttm: add some kernel-doc for TTM_PAGE_FLAG_* Matthew Auld
2021-09-16 6:52 ` Christian König
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 06/12] drm/ttm: add TTM_PAGE_FLAG_EXTERNAL_MAPPABLE Matthew Auld
2021-09-16 6:55 ` Christian König
2021-09-16 9:03 ` Thomas Hellström
2021-09-16 9:58 ` Matthew Auld
2021-09-16 10:06 ` Thomas Hellström
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 07/12] drm/i915/gem: Break out some shmem backend utils Matthew Auld
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 08/12] drm/i915/ttm: add tt shmem backend Matthew Auld
2021-09-16 13:45 ` Thomas Hellström
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 09/12] drm/i915/ttm: use cached system pages when evicting lmem Matthew Auld
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 10/12] drm/i915: try to simplify make_{un}shrinkable Matthew Auld
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 11/12] drm/i915/ttm: make evicted shmem pages visible to the shrinker Matthew Auld
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 12/12] drm/i915/ttm: enable shmem tt backend Matthew Auld
2021-09-15 19:32 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v3,01/12] drm/ttm: stop setting page->index for the ttm_tt Patchwork
2021-09-15 19:34 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-09-15 20:01 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2021-09-16 6:47 ` [Intel-gfx] [PATCH v3 01/12] " 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=20210915185954.3114858-2-matthew.auld@intel.com \
--to=matthew.auld@intel.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox