From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Tejas Upadhyay <tejas.upadhyay@intel.com>,
intel-xe@lists.freedesktop.org
Cc: matthew.auld@intel.com, carl.zhang@intel.com, jose.souza@intel.com
Subject: Re: [PATCH V5 1/4] drm/xe/xe3p_lpg: flush shrinker bo cachelines manually
Date: Thu, 05 Mar 2026 11:41:54 +0100 [thread overview]
Message-ID: <c2ba6e070b831001aeaab697fe179dd48a3b79cb.camel@linux.intel.com> (raw)
In-Reply-To: <20260303062441.1860959-7-tejas.upadhyay@intel.com>
Hi, Tejas
On Tue, 2026-03-03 at 11:54 +0530, Tejas Upadhyay wrote:
> XA, new pat_index introduced post xe3p_lpg, is memory shared between
> the
> CPU and GPU is treated differently from other GPU memory when the
> Media
> engine is power-gated.
>
> XA is *always* flushed, like at the end-of-submssion (and maybe other
> places), just that internally as an optimisation hw doesn't need to
> make
> that a full flush (which will also include XA) when Media is
> off/powergated, since it doesn't need to worry about GT caches vs
> Media
> coherency, and only CPU vs GPU coherency, so can make that flush a
> targeted XA flush, since stuff tagged with XA now means it's shared
> with
> the CPU. The main implication is that we now need to somehow flush
> non-XA
> before freeing system memory pages, otherwise dirty cachelines could
> be
> flushed after the free (like if Media suddenly turns on and does a
> full
> flush)
>
> V3(Thomas/MattA/MattR): Restrict userptr with non-xa, then no need to
> flush manually
> V2(MattA): Expand commit description
>
> Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
> ---
> drivers/gpu/drm/xe/xe_bo.c | 3 ++-
> drivers/gpu/drm/xe/xe_device.c | 23 +++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_device.h | 1 +
> 3 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> index d6c2cb959cdd..d2ee9701eae6 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -689,7 +689,8 @@ static int xe_bo_trigger_rebind(struct xe_device
> *xe, struct xe_bo *bo,
>
> if (!xe_vm_in_fault_mode(vm)) {
> drm_gpuvm_bo_evict(vm_bo, true);
> - continue;
> + if (!xe_device_is_l2_flush_optimized(xe))
> + continue;
Could you please add a code comment here something along the lines of
"L2 cache may not be flushed, so ensure that is done in
xe_vm_invalidate_vma() below"
With that,
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
I also think a possible follow-up here would be to check the PAT
indices of the vmas we loop over only invalidate if they indicate non-
XA? If that makes sense, please consider as a follow-up patch.
Thanks,
Thomas
> }
>
> if (!idle) {
> diff --git a/drivers/gpu/drm/xe/xe_device.c
> b/drivers/gpu/drm/xe/xe_device.c
> index 4b68a2d55651..94c9f17da4b4 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -1097,6 +1097,29 @@ static void tdf_request_sync(struct xe_device
> *xe)
> }
> }
>
> +/**
> + * xe_device_is_l2_flush_optimized - if L2 flush is optimized by HW
> + * @xe: The device to check.
> + *
> + * Return: true if the HW device optimizing L2 flush, false
> otherwise.
> + */
> +bool xe_device_is_l2_flush_optimized(struct xe_device *xe)
> +{
> + /* XA is *always* flushed, like at the end-of-submssion (and
> maybe other
> + * places), just that internally as an optimisation hw
> doesn't need to make
> + * that a full flush (which will also include XA) when Media
> is
> + * off/powergated, since it doesn't need to worry about GT
> caches vs Media
> + * coherency, and only CPU vs GPU coherency, so can make
> that flush a
> + * targeted XA flush, since stuff tagged with XA now means
> it's shared with
> + * the CPU. The main implication is that we now need to
> somehow flush non-XA before
> + * freeing system memory pages, otherwise dirty cachelines
> could be flushed after the free
> + * (like if Media suddenly turns on and does a full flush)
> + */
> + if (GRAPHICS_VER(xe) >= 35 && !IS_DGFX(xe))
> + return true;
> + return false;
> +}
> +
> void xe_device_l2_flush(struct xe_device *xe)
> {
> struct xe_gt *gt;
> diff --git a/drivers/gpu/drm/xe/xe_device.h
> b/drivers/gpu/drm/xe/xe_device.h
> index 39464650533b..dfbf96e12d2e 100644
> --- a/drivers/gpu/drm/xe/xe_device.h
> +++ b/drivers/gpu/drm/xe/xe_device.h
> @@ -184,6 +184,7 @@ void xe_device_snapshot_print(struct xe_device
> *xe, struct drm_printer *p);
> u64 xe_device_canonicalize_addr(struct xe_device *xe, u64 address);
> u64 xe_device_uncanonicalize_addr(struct xe_device *xe, u64
> address);
>
> +bool xe_device_is_l2_flush_optimized(struct xe_device *xe);
> void xe_device_td_flush(struct xe_device *xe);
> void xe_device_l2_flush(struct xe_device *xe);
>
next prev parent reply other threads:[~2026-03-05 10:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 6:24 [PATCH V5 0/4] drm/xe/xe3p_lpg: L2 flush optimization Tejas Upadhyay
2026-03-03 6:24 ` [PATCH V5 1/4] drm/xe/xe3p_lpg: flush shrinker bo cachelines manually Tejas Upadhyay
2026-03-05 10:41 ` Thomas Hellström [this message]
2026-03-03 6:24 ` [PATCH V5 2/4] drm/xe/pat: define coh_mode 2way Tejas Upadhyay
2026-03-03 6:24 ` [PATCH V5 3/4] drm/xe/xe3p_lpg: Restrict UAPI to enable L2 flush optimization Tejas Upadhyay
2026-03-03 14:56 ` Souza, Jose
2026-03-05 11:02 ` Thomas Hellström
2026-03-05 11:53 ` Upadhyay, Tejas
2026-03-03 6:24 ` [PATCH V5 4/4] drm/xe/xe3p: Skip TD flush Tejas Upadhyay
2026-03-05 11:15 ` Thomas Hellström
2026-03-03 7:27 ` ✓ CI.KUnit: success for drm/xe/xe3p_lpg: L2 flush optimization (rev6) Patchwork
2026-03-03 8:22 ` ✓ Xe.CI.BAT: " Patchwork
2026-03-03 17:06 ` ✓ Xe.CI.FULL: " 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=c2ba6e070b831001aeaab697fe179dd48a3b79cb.camel@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=carl.zhang@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jose.souza@intel.com \
--cc=matthew.auld@intel.com \
--cc=tejas.upadhyay@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