From: Matthew Brost <matthew.brost@intel.com>
To: Maarten Lankhorst <dev@lankhorst.se>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 1/2] drm/xe/bo: Add xe_bo_addr_iter.
Date: Fri, 12 Jun 2026 09:10:12 -0700 [thread overview]
Message-ID: <aiwvZMflMd3lpeR0@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <20260612141122.17959-2-dev@lankhorst.se>
On Fri, Jun 12, 2026 at 04:11:20PM +0200, Maarten Lankhorst wrote:
> 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 5275badb024cd..38223bb8b74c6 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -3143,6 +3143,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)
Kernel doc.
> +{
> + 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)
Kernel doc.
> +{
> + 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
> @@ -3151,27 +3175,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);
I'd mention in the commit message the code which aligns the addeess to a
page in __xe_bo_addr has been droppped.
Otherwise LGTM.
Matt
>
> - 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 4128dbf7fe695..9155e424f081c 100644
> --- a/drivers/gpu/drm/xe/xe_bo.h
> +++ b/drivers/gpu/drm/xe/xe_bo.h
> @@ -111,6 +111,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);
> @@ -370,6 +371,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.53.0
>
next prev parent reply other threads:[~2026-06-12 16:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-06-12 14:11 ` [PATCH 2/2] drm/xe/display: Use xe_bo_addr_iter in remapped DPT pinning Maarten Lankhorst
2026-06-12 14:17 ` ✗ CI.checkpatch: warning for drm/xe/display: Optimize " Patchwork
2026-06-12 14:18 ` ✓ CI.KUnit: success " Patchwork
2026-06-12 14:58 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-13 5:57 ` ✗ Xe.CI.FULL: failure " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2026-10-21 15:01 [PATCH 1/2] drm/xe/bo: Add xe_bo_addr_iter Maarten Lankhorst
2026-10-21 18:33 ` 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=aiwvZMflMd3lpeR0@gsse-cloud1.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox