intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Raag Jadav <raag.jadav@intel.com>
To: Badal Nilawar <badal.nilawar@intel.com>
Cc: intel-xe@lists.freedesktop.org, anshuman.gupta@intel.com,
	rodrigo.vivi@intel.com, daniele.ceraolospurio@intel.com,
	riana.tauro@intel.com, mallesh.koujalagi@intel.com,
	aravind.iddamsetty@intel.com, himal.prasad.ghimiray@intel.com,
	arvind.yadav@intel.com, syed.abdul.muqthyar.ahmed@intel.com,
	nitin.r.gote@intel.com, pravalika.gurram@intel.com
Subject: Re: [PATCH v4 07/12] drm/xe/cper: Log CPER records for aggregate counter retrieval
Date: Thu, 15 Oct 2026 12:36:00 +0200	[thread overview]
Message-ID: <atCskNwSDQC95paq@black.igk.intel.com> (raw)
In-Reply-To: <20261009104602.1075405-21-badal.nilawar@intel.com>

On Fri, Oct 09, 2026 at 04:16:10PM +0530, Badal Nilawar wrote:
> Log CPER records for aggregate counter retrieval from userspace when
> cper_on_query sysfs is enabled.

...

> -static void xe_cper_emit_hw_err(struct xe_device *xe, int cper_sev, enum xe_sigid sigid,
> -				const struct xe_ras_error_class *error_class)
> +/**
> + * xe_cper_emit_counter() - Emit CPER records for an already fetched error counter
> + * @xe: The &xe_device
> + * @cper_sev: CPER severity
> + * @sigid: Error signature identifier
> + * @error_class: RAS error class of the counter
> + * @resp: Counter response returned by firmware for @error_class
> + *
> + * Build and emit CPER records from @resp, including any info queue data.
> + * Must be called from a sleepable context with a runtime PM reference held.
> + */
> +void xe_cper_emit_counter(struct xe_device *xe, int cper_sev, enum xe_sigid sigid,
> +			  const struct xe_ras_error_class *error_class,
> +			  const struct xe_ras_get_counter_response *resp)
>  {
>  	struct xe_cper_einfo_entry *einfo_arr = NULL, *entries;
> -	struct xe_ras_get_counter_response local_resp;
>  	struct xe_cper_einfo_entry single = {};
>  	u32 einfo_count = 0, count, i;
>  
> -	/* Fetching the counter sends a sysctrl command */
> +	if (!is_hw_sigid(sigid))

Nack. No guardrails for abusers, they are expected to fail.

> +		return;
> +
> +	/* Draining the info queue sends sysctrl commands */
>  	might_sleep();
>  	xe_device_assert_mem_access(xe);
>  
> -	if (xe_ras_get_counter_response(xe, error_class, &local_resp)) {
> -		xe_err(xe, "CPER: failed to get counter, skipping record\n");
> -		return;
> -	}
> -
>  	/* Without info queue data, emit a single record from the counter itself */
>  	single.hdr.error_class = *error_class;
> -	single.hdr.counter = local_resp.value;
> -	single.timestamp = local_resp.timestamp;
> +	single.hdr.counter = resp->value;
> +	single.timestamp = resp->timestamp;
>  	entries = &single;
>  	count = 1;
>  
> -	if (local_resp.has_info_queue) {
> -		einfo_arr = xe_prepare_cper_error_info(xe, &local_resp, error_class, &einfo_count);
> +	if (resp->has_info_queue) {
> +		einfo_arr = xe_prepare_cper_error_info(xe, resp, error_class, &einfo_count);
>  		if (einfo_arr) {
>  			entries = einfo_arr;
>  			count = einfo_count;
> @@ -425,6 +436,23 @@ static void xe_cper_emit_hw_err(struct xe_device *xe, int cper_sev, enum xe_sigi
>  	free_einfo_arr(einfo_arr, einfo_count);
>  }
>  
> +static void xe_cper_emit_hw_err(struct xe_device *xe, int cper_sev, enum xe_sigid sigid,
> +				const struct xe_ras_error_class *error_class)
> +{
> +	struct xe_ras_get_counter_response resp;
> +
> +	/* Fetching the counter sends a sysctrl command */
> +	might_sleep();
> +	xe_device_assert_mem_access(xe);
> +
> +	if (xe_ras_get_counter_response(xe, error_class, &resp)) {
> +		xe_err(xe, "CPER: failed to get counter, skipping record\n");
> +		return;
> +	}
> +
> +	xe_cper_emit_counter(xe, cper_sev, sigid, error_class, &resp);
> +}

This is how I think it should've been introduced in the original
patch, so we don't churn here.

...

> @@ -616,6 +649,11 @@ int xe_ras_get_counter(struct xe_device *xe, u8 severity, u8 component, u32 *val
>  		return ret;
>  
>  	*value = response.value;
> +
> +	if (READ_ONCE(xe->cper.on_query))

Following the comments on patch 2, this condition will now be passed as
a bool argument to get_counter(). Based on which, it will go on to call
xe_cper_emit_counter().

The callers that aren't interesed in the entire response will pass
explicit false to get_counter(), so cper isn't emitted in those cases.

Raag

> +		xe_cper_emit_counter(xe, ras_sev_to_cper_sev(counter.common.severity),
> +				     ras_comp_to_hw_sigid(counter.common.component),
> +				     &counter, &response);
>  	return 0;
>  }
>  
> @@ -1067,4 +1105,8 @@ void xe_ras_init(struct xe_device *xe)
>  	ret = devm_device_add_group(xe->drm.dev, &gpu_health_group);
>  	if (ret)
>  		xe_err(xe, "Failed to create GPU health sysfs, err=%d\n", ret);
> +
> +	ret = xe_cper_sysfs_init(xe);
> +	if (ret)
> +		xe_err(xe, "Failed to create cper_on_query sysfs, err=%d\n", ret);
>  }
> -- 
> 2.54.0
> 

  reply	other threads:[~2026-10-15 10:36 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 10:46 [PATCH v4 00/12] Add CPER logging support for CRI Badal Nilawar
2026-10-09 10:46 ` [PATCH v4 01/12] drm/xe/cper: Add CPER reporting entry point for xe_log Badal Nilawar
2026-10-09 10:43   ` sashiko-bot
2026-10-09 12:17     ` Nilawar, Badal
2026-10-12  6:18   ` Raag Jadav
2026-10-09 10:46 ` [PATCH v4 02/12] drm/xe/cper: Retrieve the error counter record for CPER reporting Badal Nilawar
2026-10-09 10:46   ` sashiko-bot
2026-10-09 12:27     ` Nilawar, Badal
2026-10-12  9:07   ` Raag Jadav
2026-10-09 10:46 ` [PATCH v4 03/12] drm/xe/cper: Initialize Intel-specific error section header Badal Nilawar
2026-10-14  7:27   ` Raag Jadav
2026-10-09 10:46 ` [PATCH v4 04/12] drm/xe/cper: Construct CPER record for hardware errors Badal Nilawar
2026-10-14 10:30   ` Raag Jadav
2026-10-09 10:46 ` [PATCH v4 05/12] drm/xe/xe_ras: Add support to retrieve info queue data for CRI Badal Nilawar
2026-10-09 10:40   ` sashiko-bot
2026-10-09 12:45     ` Nilawar, Badal
2026-10-14 15:19   ` Raag Jadav
2026-10-09 10:46 ` [PATCH v4 06/12] drm/xe/cper: Prepare Intel CPER error info records Badal Nilawar
2026-10-09 10:41   ` sashiko-bot
2026-10-09 13:07     ` Nilawar, Badal
2026-10-15  9:45   ` Raag Jadav
2026-10-09 10:46 ` [PATCH v4 07/12] drm/xe/cper: Log CPER records for aggregate counter retrieval Badal Nilawar
2026-10-15 10:36   ` Raag Jadav [this message]
2026-10-09 10:46 ` [PATCH v4 08/12] drm/xe/cper: Emit cper record to trace buf Badal Nilawar
2026-10-09 10:38   ` sashiko-bot
2026-10-09 10:46 ` [PATCH v4 09/12] drm/xe/xe_ras: Report device memory errors using SIGID Badal Nilawar
2026-10-14  9:05   ` Mallesh, Koujalagi
2026-10-09 10:46 ` [PATCH v4 10/12] drm/xe/xe_ras: Report core compute " Badal Nilawar
2026-10-14  9:28   ` Mallesh, Koujalagi
2026-10-14  9:30     ` Tauro, Riana
2026-10-16  2:55   ` Raag Jadav
2026-10-09 10:46 ` [PATCH v4 11/12] drm/xe/xe_ras: Report soc internal " Badal Nilawar
2026-10-14  9:31   ` Mallesh, Koujalagi
2026-10-16  3:01   ` Raag Jadav
2026-10-09 10:46 ` [PATCH v4 12/12] drm/xe/xe_ras: Report correctable " Badal Nilawar
2026-10-09 10:50   ` sashiko-bot
2026-10-16  3:05   ` Raag Jadav
2026-10-09 10:54 ` ✗ CI.checkpatch: warning for Add CPER logging support for CRI (rev4) Patchwork
2026-10-09 10:56 ` ✓ CI.KUnit: success " Patchwork
2026-10-09 12:03 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-10-09 15:13 ` ✓ Xe.CI.FULL: success " Patchwork
2026-10-12  6:14 ` [PATCH v4 00/12] Add CPER logging support for CRI Raag Jadav

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=atCskNwSDQC95paq@black.igk.intel.com \
    --to=raag.jadav@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=aravind.iddamsetty@intel.com \
    --cc=arvind.yadav@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=daniele.ceraolospurio@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=mallesh.koujalagi@intel.com \
    --cc=nitin.r.gote@intel.com \
    --cc=pravalika.gurram@intel.com \
    --cc=riana.tauro@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=syed.abdul.muqthyar.ahmed@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;
as well as URLs for NNTP newsgroup(s).