From: Jani Nikula <jani.nikula@linux.intel.com>
To: Maarten Lankhorst <dev@lankhorst.se>, intel-xe@lists.freedesktop.org
Cc: Maarten Lankhorst <dev@lankhorst.se>
Subject: Re: [PATCH v3 2/2] drm/xe/display: Use xe_bo_addr_iter in remapped DPT pinning
Date: Wed, 28 Oct 2026 12:40:36 +0200 [thread overview]
Message-ID: <c9bbe8de41cb7ef856b6da950f0f57bc7b0d9456@intel.com> (raw)
In-Reply-To: <20261027180354.340849-4-dev@lankhorst.se>
On Tue, 27 Oct 2026, Maarten Lankhorst <dev@lankhorst.se> wrote:
> Right now we're using xe_bo_addr() on each individual address, which gives
> problems at larger resolution and sizes, since it's a O(N²).
>
> By using xe_bo_addr_iter_first() + xe_bo_addr_iter_addr(), the time
> complexity is reduced again to O(N).
>
> To fix rotated pinning requires some thinking.
>
> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
> ---
> Changes since v1:
> - handle plane->src_stride != plane->width
> Changes since v2:
> - Add missing u32 casts.
> ---
> drivers/gpu/drm/xe/display/xe_fb_pin.c | 29 ++++++++++++++------------
> 1 file changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> index e09116265ae95..e6c375f47a65b 100644
> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> @@ -17,6 +17,7 @@
> #include "xe_ggtt.h"
> #include "xe_pat.h"
> #include "xe_pm.h"
> +#include "xe_res_cursor.h"
> #include "xe_vram_types.h"
>
> static void
> @@ -67,15 +68,15 @@ write_dpt_remapped_linear(struct xe_bo *bo, struct iosys_map *map,
> struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
> const u64 pte = xe_ggtt_encode_pte_flags(ggtt, bo,
> xe_cache_pat_idx(xe, XE_CACHE_NONE));
> - unsigned int offset = plane->offset * XE_PAGE_SIZE;
> - unsigned int size = plane->size;
> + unsigned int offset = (u32)plane->offset * XE_PAGE_SIZE;
> + unsigned int size = (u32)plane->size * XE_PAGE_SIZE;
What do you need the casts for? Useless?
> + struct xe_res_cursor cur;
>
> - while (size--) {
> - u64 addr = xe_bo_addr(bo, offset, XE_PAGE_SIZE);
> + for (xe_bo_addr_iter_first(bo, &cur, offset, size); cur.remaining; xe_res_next(&cur, XE_PAGE_SIZE)) {
> + u64 addr = xe_bo_addr_iter_addr(&cur);
>
> iosys_map_wr(map, dest, u64, addr | pte);
> dest += sizeof(u64);
> - offset += XE_PAGE_SIZE;
> }
>
> return dest;
> @@ -90,20 +91,22 @@ write_dpt_remapped_tiled(struct xe_bo *bo, struct iosys_map *map,
> struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
> const u64 pte = xe_ggtt_encode_pte_flags(ggtt, bo,
> xe_cache_pat_idx(xe, XE_CACHE_NONE));
> - unsigned int offset, column, row;
> + u32 offset = (u32)plane->offset * XE_PAGE_SIZE;
Ditto.
> + struct xe_res_cursor cur;
>
> - for (row = 0; row < plane->height; row++) {
> - offset = (plane->offset + plane->src_stride * row) *
> - XE_PAGE_SIZE;
> -
> - for (column = 0; column < plane->width; column++) {
> - u64 addr = xe_bo_addr(bo, offset, XE_PAGE_SIZE);
> + xe_bo_addr_iter_first(bo, &cur, offset, (u32)plane->height * plane->src_stride * XE_PAGE_SIZE);
> + while (cur.remaining) {
> + for (u32 column = 0; column < plane->width; column++) {
> + u64 addr = xe_bo_addr_iter_addr(&cur);
>
> iosys_map_wr(map, dest, u64, addr | pte);
> dest += sizeof(u64);
> - offset += XE_PAGE_SIZE;
> + xe_res_next(&cur, XE_PAGE_SIZE);
> }
>
> + if (plane->src_stride != plane->width)
> + xe_res_next(&cur, (u32)(plane->src_stride - plane->width) * XE_PAGE_SIZE);
> +
> dest = write_dpt_padding(map, dest,
> plane->dst_stride - plane->width);
> }
--
Jani Nikula, Intel
next prev parent reply other threads:[~2026-10-28 10:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 18:03 [PATCH v3 1/2] drm/xe/bo: Add xe_bo_addr_iter Maarten Lankhorst
2026-10-27 18:03 ` [PATCH v3 2/2] drm/xe/display: Use xe_bo_addr_iter in remapped DPT pinning Maarten Lankhorst
2026-10-28 10:40 ` Jani Nikula [this message]
2026-10-27 18:09 ` ✗ CI.checkpatch: warning for series starting with [v3,1/2] drm/xe/bo: Add xe_bo_addr_iter Patchwork
2026-10-27 18:11 ` ✓ CI.KUnit: success " Patchwork
2026-10-27 18:49 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-27 22:26 ` ✗ Xe.CI.FULL: 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=c9bbe8de41cb7ef856b6da950f0f57bc7b0d9456@intel.com \
--to=jani.nikula@linux.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