From: Maarten Lankhorst <dev@lankhorst.se>
To: intel-xe@lists.freedesktop.org
Cc: Maarten Lankhorst <dev@lankhorst.se>
Subject: [PATCH 1/2] drm/xe/bo: Add xe_bo_addr_iter.
Date: Wed, 21 Oct 2026 17:01:17 +0200 [thread overview]
Message-ID: <20261021150116.516131-3-dev@lankhorst.se> (raw)
For display we iterate often over the pinned VRAM/system memory BO.
Add some code to speed up DPT/GGTT programming.
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/xe/xe_bo.c | 45 ++++++++++++++++++++++----------------
drivers/gpu/drm/xe/xe_bo.h | 3 +++
2 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 12e523c61c1f3..5e48669732fdd 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -3434,6 +3434,30 @@ bool xe_bo_is_xe_bo(struct ttm_buffer_object *bo)
return false;
}
+void xe_bo_addr_iter_first(struct xe_bo *bo, struct xe_res_cursor *cur, u64 offset, u64 size)
+{
+ struct xe_device *xe = xe_bo_device(bo);
+
+ if (!xe_bo_is_vram(bo) && !xe_bo_is_stolen(bo)) {
+ xe_assert(xe, bo->ttm.ttm);
+
+ xe_res_first_sg(xe_bo_sg(bo), offset, size, cur);
+ } else {
+ xe_res_first(bo->ttm.resource, offset, size, cur);
+
+ xe_assert(xe, !cur->dma_addr);
+ cur->dma_start = vram_region_gpu_offset(bo->ttm.resource);
+ }
+}
+
+dma_addr_t xe_bo_addr_iter_addr(struct xe_res_cursor *cur)
+{
+ if (cur->mem_type == XE_PL_TT)
+ return xe_res_dma(cur);
+
+ return cur->start + cur->dma_start;
+}
+
/*
* Resolve a BO address. There is no assert to check if the proper lock is held
* so it should only be used in cases where it is not fatal to get the wrong
@@ -3442,27 +3466,10 @@ bool xe_bo_is_xe_bo(struct ttm_buffer_object *bo)
*/
dma_addr_t __xe_bo_addr(struct xe_bo *bo, u64 offset, size_t page_size)
{
- struct xe_device *xe = xe_bo_device(bo);
struct xe_res_cursor cur;
- u64 page;
-
- xe_assert(xe, page_size <= PAGE_SIZE);
- page = offset >> PAGE_SHIFT;
- offset &= (PAGE_SIZE - 1);
- if (!xe_bo_is_vram(bo) && !xe_bo_is_stolen(bo)) {
- xe_assert(xe, bo->ttm.ttm);
-
- xe_res_first_sg(xe_bo_sg(bo), page << PAGE_SHIFT,
- page_size, &cur);
- return xe_res_dma(&cur) + offset;
- } else {
- struct xe_res_cursor cur;
-
- xe_res_first(bo->ttm.resource, page << PAGE_SHIFT,
- page_size, &cur);
- return cur.start + offset + vram_region_gpu_offset(bo->ttm.resource);
- }
+ xe_bo_addr_iter_first(bo, &cur, offset, page_size);
+ return xe_bo_addr_iter_addr(&cur);
}
dma_addr_t xe_bo_addr(struct xe_bo *bo, u64 offset, size_t page_size)
diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
index 77b3a02e9b8eb..286f52225bc79 100644
--- a/drivers/gpu/drm/xe/xe_bo.h
+++ b/drivers/gpu/drm/xe/xe_bo.h
@@ -113,6 +113,7 @@ enum xe_madv_purgeable_state {
};
struct sg_table;
+struct xe_res_cursor;
struct xe_bo *xe_bo_alloc(void);
void xe_bo_free(struct xe_bo *bo);
@@ -375,6 +376,8 @@ static inline void xe_bo_unpin_map_no_vm(struct xe_bo *bo)
}
bool xe_bo_is_xe_bo(struct ttm_buffer_object *bo);
+void xe_bo_addr_iter_first(struct xe_bo *bo, struct xe_res_cursor *cur, u64 offset, u64 size);
+dma_addr_t xe_bo_addr_iter_addr(struct xe_res_cursor *cur);
dma_addr_t __xe_bo_addr(struct xe_bo *bo, u64 offset, size_t page_size);
dma_addr_t xe_bo_addr(struct xe_bo *bo, u64 offset, size_t page_size);
--
2.55.0
next reply other threads:[~2026-10-21 15:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 15:01 Maarten Lankhorst [this message]
2026-10-21 15:01 ` [PATCH 2/2] drm/xe/display: Use xe_bo_addr_iter in remapped DPT pinning Maarten Lankhorst
2026-10-21 15:20 ` sashiko-bot
2026-10-21 15:06 ` ✗ CI.checkpatch: warning for series starting with [1/2] drm/xe/bo: Add xe_bo_addr_iter Patchwork
2026-10-21 15:08 ` ✓ CI.KUnit: success " Patchwork
2026-10-21 15:46 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-21 18:11 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-10-21 18:33 ` [PATCH 1/2] " Matthew Brost
-- strict thread matches above, loose matches on Subject: below --
2026-06-12 14:11 [PATCH 0/2] drm/xe/display: Optimize remapped DPT pinning Maarten Lankhorst
2026-06-12 14:11 ` [PATCH 1/2] drm/xe/bo: Add xe_bo_addr_iter Maarten Lankhorst
2026-06-12 16:10 ` Matthew Brost
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=20261021150116.516131-3-dev@lankhorst.se \
--to=dev@lankhorst.se \
--cc=intel-xe@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 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.