Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Gupta, Varun" <varun.gupta@intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <matthew.d.roper@intel.com>,
	<himal.prasad.ghimiray@intel.com>, <priyanka.dandamudi@intel.com>,
	<stuart.summers@intel.com>
Subject: Re: [PATCH v4 2/2] drm/xe: Add prefetch fault support for Xe3p
Date: Fri, 20 Feb 2026 16:18:54 +0530	[thread overview]
Message-ID: <0c063f2b-ab79-40fb-991d-ed7da61c1ddd@intel.com> (raw)
In-Reply-To: <aZfrapNUURrx5J7c@lstrano-desk.jf.intel.com>


On 20-Feb-26 10:34 AM, Matthew Brost wrote:
> On Fri, Feb 20, 2026 at 10:05:02AM +0530, Varun Gupta wrote:
>> Xe3p hardware prefetches memory ranges and notifies software via an
>> additional bit (bit 11) in the page fault descriptor that the fault
>> was caused by prefetch.
>>
>> Extract the prefetch bit from the fault descriptor and echo it in the
>> response (bit 6) only when the page fault handling fails. This allows
>> the HW to suppress CAT errors for unsuccessful prefetch faults.
>>
>> For prefetch faults that fail, increment stats counter without verbose
>> logging to avoid spamming the log. Clear the prefetch bit on successful
>> handling so it's not echoed in the response.
>>
>> Based on original patches by Brian Welty <brian.welty@intel.com> and
>> Priyanka Dandamudi <priyanka.dandamudi@intel.com>.
>>
>> Bspec: 59311
>> Originally-by: Lucas De Marchi <lucas.demarchi@intel.com>
>> Cc: Matthew Brost <matthew.brost@intel.com>
>> Cc: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
>> Cc: Matt Roper <matthew.d.roper@intel.com>
>> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
>> Signed-off-by: Varun Gupta <varun.gupta@intel.com>
>>
>> ---
>> v4:
>>   - Downgrade prefetch error log to xe_gt_dbg to avoid spam (Matt Brost/ Stuart)
>>
>> v3:
>>   - Drop the rename patch, keep xe_pagefault_print() unchanged (Matt Brost)
>>   - Move prefetch check to caller instead of inside print function (Matt Brost)
>>   - Remove XE3P_ prefix from prefetch bit defines and add platform comment (Matt Brost)
>>   - Show prefetch bit in error messages for debugging (Matt Brost)
>>   - Split stats counter into separate patch (Matt Brost)
>>
>> v2:
>>   - Changed comment wording from "repairs" to "handling" for clarity (Matt Roper)
>> ---
>>   drivers/gpu/drm/xe/xe_guc_fwif.h        |  5 +++--
>>   drivers/gpu/drm/xe/xe_guc_pagefault.c   |  2 ++
>>   drivers/gpu/drm/xe/xe_pagefault.c       | 18 +++++++++++++++---
>>   drivers/gpu/drm/xe/xe_pagefault_types.h |  6 ++++++
>>   4 files changed, 26 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_guc_fwif.h b/drivers/gpu/drm/xe/xe_guc_fwif.h
>> index a33ea288b907..bb8f71d38611 100644
>> --- a/drivers/gpu/drm/xe/xe_guc_fwif.h
>> +++ b/drivers/gpu/drm/xe/xe_guc_fwif.h
>> @@ -261,7 +261,8 @@ struct xe_guc_pagefault_desc {
>>   #define PFD_ACCESS_TYPE		GENMASK(1, 0)
>>   #define PFD_FAULT_TYPE		GENMASK(3, 2)
>>   #define PFD_VFID		GENMASK(9, 4)
>> -#define PFD_RSVD_1		GENMASK(11, 10)
>> +#define PFD_RSVD_1		BIT(10)
>> +#define PFD_PREFETCH		BIT(11) /* Only valid on Xe3+, reserved on prior platforms */
>>   #define PFD_VIRTUAL_ADDR_LO	GENMASK(31, 12)
>>   #define PFD_VIRTUAL_ADDR_LO_SHIFT 12
>>   
>> @@ -281,7 +282,7 @@ struct xe_guc_pagefault_reply {
>>   
>>   	u32 dw1;
>>   #define PFR_VFID		GENMASK(5, 0)
>> -#define PFR_RSVD_1		BIT(6)
>> +#define PFR_PREFETCH		BIT(6)  /* Only valid on Xe3+, reserved on prior platforms */
>>   #define PFR_ENG_INSTANCE	GENMASK(12, 7)
>>   #define PFR_ENG_CLASS		GENMASK(15, 13)
>>   #define PFR_PDATA		GENMASK(31, 16)
>> diff --git a/drivers/gpu/drm/xe/xe_guc_pagefault.c b/drivers/gpu/drm/xe/xe_guc_pagefault.c
>> index d48f6ed103bb..0cb68e956af9 100644
>> --- a/drivers/gpu/drm/xe/xe_guc_pagefault.c
>> +++ b/drivers/gpu/drm/xe/xe_guc_pagefault.c
>> @@ -28,6 +28,7 @@ static void guc_ack_fault(struct xe_pagefault *pf, int err)
>>   		FIELD_PREP(PFR_ASID, asid),
>>   
>>   		FIELD_PREP(PFR_VFID, vfid) |
>> +		FIELD_PREP(PFR_PREFETCH, pf->consumer.prefetch) |
> You can set this up based on the producer data and error.
>
> I'd like to avoid touching consumer fields in this path, see [1].
>
> I think the logic would be...
>
> u32 prefetch = FIELD_GET(PFD_PREFETCH, pf->producer.msg[2]);
> ....
>
> FIELD_PREP(PFR_PREFETCH, !err ? 0 : prefetch);
>
> This is a better logical divide as the producer is the one who knows if
> it should set the PFR_PREFETCH in the acknowledgement - not the
> consumer.
>
> [1] https://patchwork.freedesktop.org/patch/704579/?series=161560&rev=1
>
>>   		FIELD_PREP(PFR_ENG_INSTANCE, engine_instance) |
>>   		FIELD_PREP(PFR_ENG_CLASS, engine_class) |
>>   		FIELD_PREP(PFR_PDATA, pdata),
>> @@ -77,6 +78,7 @@ int xe_guc_pagefault_handler(struct xe_guc *guc, u32 *msg, u32 len)
>>   		 PFD_VIRTUAL_ADDR_LO_SHIFT);
>>   	pf.consumer.asid = FIELD_GET(PFD_ASID, msg[1]);
>>   	pf.consumer.access_type = FIELD_GET(PFD_ACCESS_TYPE, msg[2]);
>> +	pf.consumer.prefetch = FIELD_GET(PFD_PREFETCH, msg[2]);
>>   	if (FIELD_GET(XE2_PFD_TRVA_FAULT, msg[0]))
>>   		pf.consumer.fault_type_level = XE_PAGEFAULT_TYPE_LEVEL_NACK;
>>   	else
>> diff --git a/drivers/gpu/drm/xe/xe_pagefault.c b/drivers/gpu/drm/xe/xe_pagefault.c
>> index 72f589fd2b64..b05860b3607d 100644
>> --- a/drivers/gpu/drm/xe/xe_pagefault.c
>> +++ b/drivers/gpu/drm/xe/xe_pagefault.c
>> @@ -261,9 +261,21 @@ static void xe_pagefault_queue_work(struct work_struct *w)
>>   
>>   		err = xe_pagefault_service(&pf);
>>   		if (err) {
>> -			xe_pagefault_print(&pf);
>> -			xe_gt_info(pf.gt, "Fault response: Unsuccessful %pe\n",
>> -				   ERR_PTR(err));
>> +			if (!pf.consumer.prefetch) {
>> +				xe_pagefault_print(&pf);
>> +				xe_gt_info(pf.gt, "Fault response: Unsuccessful %pe\n",
>> +					   ERR_PTR(err));
>> +			} else {
>> +				xe_gt_stats_incr(pf.gt, XE_GT_STATS_ID_INVALID_PREFETCH_PAGEFAULT_COUNT, 1);
>> +				xe_gt_dbg(pf.gt, "Fault response: Unsuccessful %pe, prefetch=%d\n",
>> +					  ERR_PTR(err), pf.consumer.prefetch);
>> +			}
>> +		} else {
>> +			/*
>> +			 * Clear prefetch bit - only needed to suppress CAT errors
>> +			 * on unsuccessful handling.
>> +			 */
>> +			pf.consumer.prefetch = 0;
> With above you can drop this logic.
>
>>   		}
>>   
>>   		pf.producer.ops->ack_fault(&pf, err);
>> diff --git a/drivers/gpu/drm/xe/xe_pagefault_types.h b/drivers/gpu/drm/xe/xe_pagefault_types.h
>> index 0e378f41ede6..23a6a986d5b2 100644
>> --- a/drivers/gpu/drm/xe/xe_pagefault_types.h
>> +++ b/drivers/gpu/drm/xe/xe_pagefault_types.h
>> @@ -84,6 +84,12 @@ struct xe_pagefault {
>>   		u8 engine_class;
>>   		/** @consumer.engine_instance: engine instance */
>>   		u8 engine_instance;
>> +		/**
>> +		 * @consumer.prefetch: fault is caused by HW prefetch.
>> +		 * Echo in response to suppress CAT errors on
>> +		 * unsuccessful handling.
>> +		 */
>> +		u8 prefetch;
> This will grow this structure from 64 bytes in the page fault queue to
> 128 which is not desirable.
>
>>   		/** consumer.reserved: reserved bits for future expansion */
>>   		u64 reserved;
> I also we like to leave this u64 reserved as I plan on using it as
> single linked list of pagefaults that come in a storm that all match the
> same address [2]. This is reason I'd packed fault type and level into a
> single u8 here [3]. Maybe pack prefetch into the upper bits of the
> access_type field?
>
> Matt
>
> [2] https://gitlab.freedesktop.org/mbrost/xe-kernel-driver-svn-perf-6-15-2025/-/commit/93669c7f4e00ec13d0a18e28d34dfcb41803b7c9#d0e961d15e218e9be8819f1311674d537b25ebdd_91_109
> [3] https://patchwork.freedesktop.org/patch/704578/?series=161560&rev=1

Noted, will the necessary changes.

Thanks,
Varun

>>   	} consumer;
>> -- 
>> 2.43.0
>>

  reply	other threads:[~2026-02-20 10:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-20  4:35 [PATCH v4 0/2] drm/xe: Add prefetch pagefault support for Xe3p Varun Gupta
2026-02-20  4:35 ` [PATCH v4 1/2] drm/xe: Add counter for invalid prefetch pagefaults Varun Gupta
2026-02-20  4:35 ` [PATCH v4 2/2] drm/xe: Add prefetch fault support for Xe3p Varun Gupta
2026-02-20  5:04   ` Matthew Brost
2026-02-20 10:48     ` Gupta, Varun [this message]
2026-02-20  4:40 ` ✗ CI.checkpatch: warning for drm/xe: Add prefetch pagefault support for Xe3p (rev4) Patchwork
2026-02-20  4:42 ` ✓ CI.KUnit: success " Patchwork
2026-02-20  9:13 ` ✓ Xe.CI.BAT: " Patchwork
2026-02-20 18:55 ` ✗ 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=0c063f2b-ab79-40fb-991d-ed7da61c1ddd@intel.com \
    --to=varun.gupta@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=priyanka.dandamudi@intel.com \
    --cc=stuart.summers@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