From: Thomas Zimmermann <tzimmermann@suse.de>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
airlied@gmail.com, daniel@ffwll.ch, lucas.demarchi@intel.com,
rodrigo.vivi@intel.com, jani.nikula@linux.intel.com,
ray.huang@amd.com, christian.koenig@amd.com, kraxel@redhat.com,
airlied@redhat.com, suijingfeng@loongson.cn
Cc: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org,
Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH 6/6] drm/xe: Replace ttm_bo_kmap() with ttm_bo_vmap()
Date: Fri, 14 Jun 2024 15:22:00 +0200 [thread overview]
Message-ID: <20240614133556.11378-7-tzimmermann@suse.de> (raw)
In-Reply-To: <20240614133556.11378-1-tzimmermann@suse.de>
Use the newer ttm_bo_vmap() instead of ttm_bo_kmap(). The new interface
uses struct iomap_map, which helps with pointer setup and memcpy() ops.
Removes a TODO item and quite a bit of workarounds from the code.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
| 17 +++-------
drivers/gpu/drm/xe/xe_bo.c | 32 ++++---------------
drivers/gpu/drm/xe/xe_bo_types.h | 2 --
3 files changed, 10 insertions(+), 41 deletions(-)
--git a/drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_object.h b/drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_object.h
index 777c20ceabab1..25ae56d700431 100644
--- a/drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_object.h
@@ -34,28 +34,19 @@ static inline bool i915_gem_object_is_userptr(const struct xe_bo *bo)
static inline int i915_gem_object_read_from_page(struct xe_bo *bo,
u32 ofs, u64 *ptr, u32 size)
{
- struct ttm_bo_kmap_obj map;
- void *src;
- bool is_iomem;
+ struct iosys_map src;
int ret;
ret = xe_bo_lock(bo, true);
if (ret)
return ret;
- ret = ttm_bo_kmap(&bo->ttm, ofs >> PAGE_SHIFT, 1, &map);
+ ret = ttm_bo_vmap(&bo->ttm, ofs, size, &src);
if (ret)
goto out_unlock;
+ iosys_map_memcpy_from(ptr, &src, ofs & ~PAGE_MASK, size);
+ ttm_bo_vunmap(&bo->ttm, &src);
- ofs &= ~PAGE_MASK;
- src = ttm_kmap_obj_virtual(&map, &is_iomem);
- src += ofs;
- if (is_iomem)
- memcpy_fromio(ptr, (void __iomem *)src, size);
- else
- memcpy(ptr, src, size);
-
- ttm_bo_kunmap(&map);
out_unlock:
xe_bo_unlock(bo);
return ret;
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index a98d857ff1e5a..6158e1a959cd4 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -1888,10 +1888,6 @@ dma_addr_t xe_bo_addr(struct xe_bo *bo, u64 offset, size_t page_size)
int xe_bo_vmap(struct xe_bo *bo)
{
- void *virtual;
- bool is_iomem;
- int ret;
-
xe_bo_assert_held(bo);
if (!(bo->flags & XE_BO_FLAG_NEEDS_CPU_ACCESS))
@@ -1900,32 +1896,16 @@ int xe_bo_vmap(struct xe_bo *bo)
if (!iosys_map_is_null(&bo->vmap))
return 0;
- /*
- * We use this more or less deprecated interface for now since
- * ttm_bo_vmap() doesn't offer the optimization of kmapping
- * single page bos, which is done here.
- * TODO: Fix up ttm_bo_vmap to do that, or fix up ttm_bo_kmap
- * to use struct iosys_map.
- */
- ret = ttm_bo_kmap(&bo->ttm, 0, bo->size >> PAGE_SHIFT, &bo->kmap);
- if (ret)
- return ret;
-
- virtual = ttm_kmap_obj_virtual(&bo->kmap, &is_iomem);
- if (is_iomem)
- iosys_map_set_vaddr_iomem(&bo->vmap, (void __iomem *)virtual);
- else
- iosys_map_set_vaddr(&bo->vmap, virtual);
-
- return 0;
+ return ttm_bo_vmap(&bo->ttm, 0, bo->size, &bo->vmap);
}
static void __xe_bo_vunmap(struct xe_bo *bo)
{
- if (!iosys_map_is_null(&bo->vmap)) {
- iosys_map_clear(&bo->vmap);
- ttm_bo_kunmap(&bo->kmap);
- }
+ if (iosys_map_is_null(&bo->vmap))
+ return;
+
+ ttm_bo_vunmap(&bo->ttm, &bo->vmap);
+ iosys_map_clear(&bo->vmap);
}
void xe_bo_vunmap(struct xe_bo *bo)
diff --git a/drivers/gpu/drm/xe/xe_bo_types.h b/drivers/gpu/drm/xe/xe_bo_types.h
index 86422e113d396..5cba681ba73c2 100644
--- a/drivers/gpu/drm/xe/xe_bo_types.h
+++ b/drivers/gpu/drm/xe/xe_bo_types.h
@@ -42,8 +42,6 @@ struct xe_bo {
struct drm_mm_node ggtt_node;
/** @vmap: iosys map of this buffer */
struct iosys_map vmap;
- /** @ttm_kmap: TTM bo kmap object for internal use only. Keep off. */
- struct ttm_bo_kmap_obj kmap;
/** @pinned_link: link to present / evicted list of pinned BO */
struct list_head pinned_link;
#ifdef CONFIG_PROC_FS
--
2.45.2
next prev parent reply other threads:[~2024-06-14 13:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 13:21 [PATCH 0/6] drm/{ttm,xe}: Improve ttm_bo_vmap() and update xe Thomas Zimmermann
2024-06-14 13:21 ` [PATCH 1/6] iosys-map: Add allocator flags Thomas Zimmermann
2024-06-14 13:21 ` [PATCH 2/6] drm/ttm: Store the bo_kmap_type in struct iosys_map Thomas Zimmermann
2024-06-14 14:31 ` Christian König
2024-06-17 12:32 ` Thomas Zimmermann
2024-06-17 12:56 ` Christian König
2024-06-14 13:21 ` [PATCH 3/6] drm/ttm: Support partial buffer mappings for ttm_bo_vmap() Thomas Zimmermann
2024-06-14 14:33 ` Christian König
2024-06-17 13:00 ` Thomas Zimmermann
2024-06-14 13:21 ` [PATCH 4/6] drm/ttm: Support kmap for single-page mappings in ttm_bo_vmap() Thomas Zimmermann
2024-06-14 13:21 ` [PATCH 5/6] drm/xe: Remove vunmap calls object-freeing code Thomas Zimmermann
2024-06-14 13:22 ` Thomas Zimmermann [this message]
2024-06-14 13:41 ` ✓ CI.Patch_applied: success for drm/{ttm,xe}: Improve ttm_bo_vmap() and update xe Patchwork
2024-06-14 13:41 ` ✗ CI.checkpatch: warning " Patchwork
2024-06-14 13:42 ` ✓ CI.KUnit: success " Patchwork
2024-06-14 13:54 ` ✓ CI.Build: " Patchwork
2024-06-14 13:56 ` ✗ CI.Hooks: failure " Patchwork
2024-06-14 13:58 ` ✗ CI.checksparse: warning " Patchwork
2024-06-14 14:18 ` ✗ Fi.CI.CHECKPATCH: " Patchwork
2024-06-14 14:18 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-06-14 14:28 ` ✗ CI.BAT: failure " Patchwork
2024-06-14 14:32 ` ✓ Fi.CI.BAT: success " Patchwork
2024-06-16 21:28 ` ✗ Fi.CI.IGT: 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=20240614133556.11378-7-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=kraxel@redhat.com \
--cc=lucas.demarchi@intel.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=ray.huang@amd.com \
--cc=rodrigo.vivi@intel.com \
--cc=suijingfeng@loongson.cn \
/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.