public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
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, Michal Mrozek <michal.mrozek@intel.com>
Subject: Re: [PATCH V5 3/4] drm/xe/xe3p_lpg: Restrict UAPI to enable L2 flush optimization
Date: Thu, 05 Mar 2026 12:02:33 +0100	[thread overview]
Message-ID: <2ecfbbf73b825da172c7176c7ae9c46096221bd4.camel@linux.intel.com> (raw)
In-Reply-To: <20260303062441.1860959-9-tejas.upadhyay@intel.com>

Hi, Tejas,

On Tue, 2026-03-03 at 11:54 +0530, Tejas Upadhyay wrote:
> When set, starting xe3p_lpg, the L2 flush optimization
> feature will control whether L2 is in Persistent or
> Transient mode through monitoring of media activity.
> 
> To enable L2 flush optimization include new feature flag
> GUC_CTL_ENABLE_L2FLUSH_OPT for Novalake platforms when
> media type is detected.
> 
> Tighten UAPI validation to restrict userptr, svm and
> dmabuf mappings to be either 2WAY or XA+1WAY
> 
> V4(MattA): Modify uapi doc and commit
> V3(MattA): check valid op and pat_index value
> V2(MattA): validate dma-buf bos and madvise pat-index
> 
> Acked-by: Michal Mrozek <michal.mrozek@intel.com>
> Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_guc.c        |  3 +++
>  drivers/gpu/drm/xe/xe_guc_fwif.h   |  1 +
>  drivers/gpu/drm/xe/xe_vm.c         |  8 ++++++++
>  drivers/gpu/drm/xe/xe_vm_madvise.c | 23 +++++++++++++++++++++++
>  include/uapi/drm/xe_drm.h          |  4 +++-
>  5 files changed, 38 insertions(+), 1 deletion(-)
> 

Claude has some suggestions on this patch:

"
commit 77271d8c323486ebe5dc6f1264fc318a43a29084
Author: Tejas Upadhyay <tejas.upadhyay@intel.com>

drm/xe/xe3p_lpg: Restrict UAPI to enable L2 flush optimization

This commit adds UAPI validation to restrict userptr, svm, and dmabuf
mappings on L2 flush optimized platforms (Xe3p+ non-DGFX) to use either
2WAY coherency or XA with 1WAY coherency (pat_index 19).

> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index 99fa36123f58..42356d73ca65 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c

[ ... ]

> @@ -3480,6 +3480,10 @@ static int vm_bind_ioctl_check_args(struct
xe_device *xe, struct xe_vm *vm,
>  			 op == DRM_XE_VM_BIND_OP_MAP_USERPTR) ||
>  	    XE_IOCTL_DBG(xe, coh_mode == XE_COH_NONE &&
>  			 op == DRM_XE_VM_BIND_OP_MAP_USERPTR) ||
> +	    XE_IOCTL_DBG(xe, xe_device_is_l2_flush_optimized(xe) &&
> +			 (op == DRM_XE_VM_BIND_OP_MAP_USERPTR ||
> +			  is_cpu_addr_mirror) &&
> +			 (pat_index != 19 || coh_mode != XE_COH_2WAY))
||

The condition uses || but should this use && instead?

The commit message says mappings should be allowed if they use "either
2WAY or XA+1WAY". The UAPI documentation also says "the kernel expects
either 2WAY or 1WAY and XA @pat_index".

Looking at xe3p_lpg_pat_table in xe_pat.c:

    [19] = XE2_PAT( 1, 0, 0, 2, 3, 2 )

The last parameter is coh_mode=2, which maps to XE_COH_1WAY based on
the XE2_PAT macro:

    .coh_mode = __coh_mode ? __coh_mode : XE_COH_NONE

So pat_index 19 has coh_mode=XE_COH_1WAY, not XE_COH_2WAY.

With the current || condition, for pat_index 19:
  - pat_index != 19 is false
  - coh_mode != XE_COH_2WAY is true (since coh_mode is XE_COH_1WAY)
  - false || true = true, validation fails

This means userptr/svm operations will always fail validation on L2
flush optimized platforms, even when using the correct pat_index 19.

Should the condition be:

    (pat_index != 19 && coh_mode != XE_COH_2WAY)

This would fail only if the mapping is neither pat_index 19 (XA+1WAY)
nor using 2WAY coherency, matching the commit message intent.

The same issue appears in xe_vm_bind_ioctl_validate_bo() and
xe_vm_madvise_ioctl() at the similar validation points.

"

Thanks,
Thomas


  parent reply	other threads:[~2026-03-05 11:02 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
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 [this message]
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=2ecfbbf73b825da172c7176c7ae9c46096221bd4.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=michal.mrozek@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