All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Badal Nilawar <badal.nilawar@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <anshuman.gupta@intel.com>,
	<raag.jadav@intel.com>, <riana.tauro@intel.com>,
	<mallesh.koujalagi@intel.com>, <aravind.iddamsetty@intel.com>,
	<heikki.krogerus@linux.intel.com>,
	<himal.prasad.ghimiray@intel.com>
Subject: Re: [PATCH v2 4/5] drm/xe/i2c: Expose AMC alert reason through sysfs
Date: Tue, 1 Dec 2026 16:10:58 -0500	[thread overview]
Message-ID: <aw834lch5EssVuyq@intel.com> (raw)
In-Reply-To: <20261201091109.1343470-11-badal.nilawar@intel.com>

On Tue, Dec 01, 2026 at 02:41:14PM +0530, Badal Nilawar wrote:
> AMC raises an SMBus alert before a power-removal or power-cycle
> operation. The xe driver uses the alert reason to select a recovery
> method.
> 
> Expose the reason in a read-only sysfs attribute so userspace can
> identify the appropriate recovery action.
> 
> Signed-off-by: Badal Nilawar <badal.nilawar@intel.com>
> ---
> v2:
>   - Correct the documented sysfs attribute name (Sashiko)
>   - Ensure the alert reason is visible before publishing the
>     alert-seen state (Sashiko)

Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  .../ABI/testing/sysfs-driver-intel-xe-amc     | 24 +++++++
>  drivers/gpu/drm/xe/xe_amc.c                   | 67 ++++++++++++++++++-
>  2 files changed, 89 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/ABI/testing/sysfs-driver-intel-xe-amc
> 
> diff --git a/Documentation/ABI/testing/sysfs-driver-intel-xe-amc b/Documentation/ABI/testing/sysfs-driver-intel-xe-amc
> new file mode 100644
> index 000000000000..385b6519a1ca
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-driver-intel-xe-amc
> @@ -0,0 +1,24 @@
> +What:		/sys/bus/pci/drivers/xe/.../amc_alert_reason
> +Date:		November 2026
> +KernelVersion:	7.5
> +Contact:	intel-xe@lists.freedesktop.org
> +Description:
> +		This file exposes the reason for the most recent Add-In
> +		Management Controller (AMC) alert on supported Intel Xe platforms.
> +
> +		An AMC alert is delivered via an SMBus interrupt. The device may
> +		be wedged; the required recovery method depends on the alert.
> +		The attribute is read-only and available to all users.
> +
> +		Read returns a single line containing one of the following
> +		alert reasons:
> +
> +			"none"
> +				No AMC alert has been received
> +			"unknown"
> +				AMC alert received but with unknown reason
> +			"Firmware Download"
> +			"Thermal Trip"
> +			"OOB Request"
> +			"OOB Reset"
> +			"Catastrophic"
> diff --git a/drivers/gpu/drm/xe/xe_amc.c b/drivers/gpu/drm/xe/xe_amc.c
> index 613f5434d7d8..f23abee5eb5c 100644
> --- a/drivers/gpu/drm/xe/xe_amc.c
> +++ b/drivers/gpu/drm/xe/xe_amc.c
> @@ -50,6 +50,7 @@ enum xe_amc_alert {
>  };
>  
>  static const char * const amc_alert[] = {
> +	[AMC_ALERT_UNKNOWN]		= "unknown",
>  	[AMC_ALERT_FW_DOWNLOAD]		= "Firmware Download",
>  	[AMC_ALERT_THERMAL_TRIP]	= "Thermal Trip",
>  	[AMC_ALERT_OOB_REQUEST]		= "OOB Request",
> @@ -60,6 +61,8 @@ static const char * const amc_alert[] = {
>  struct xe_amc {
>  	struct xe_i2c *i2c;
>  	struct work_struct work;
> +	enum xe_amc_alert alert_reason;
> +	bool alert_seen;
>  };
>  
>  struct amc_header {
> @@ -108,6 +111,51 @@ static const struct amc_request amc_get_alert_reason = {
>  	},
>  };
>  
> +/**
> + * DOC: AMC Alert Reason
> + *
> + * Expose the most recent AMC alert reason through device sysfs.
> + *
> + * See Documentation/ABI/testing/sysfs-driver-intel-xe-amc for the ABI
> + * specification.
> + */
> +
> +static enum xe_amc_alert amc_alert_reason(struct xe_amc *amc)
> +{
> +	return READ_ONCE(amc->alert_reason);
> +}
> +
> +static ssize_t amc_alert_reason_show(struct device *dev,
> +				     struct device_attribute *attr, char *buf)
> +{
> +	struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
> +	struct xe_amc *amc = xe->i2c->amc;
> +	enum xe_amc_alert alert_reason;
> +
> +	/* Pairs with smp_store_release() to make alert_reason visible. */
> +	if (!smp_load_acquire(&amc->alert_seen))
> +		return sysfs_emit(buf, "none\n");
> +
> +	alert_reason = amc_alert_reason(amc);
> +
> +	return sysfs_emit(buf, "%s\n", amc_alert[alert_reason]);
> +}
> +static DEVICE_ATTR_RO(amc_alert_reason);
> +
> +static void amc_remove_alert_sysfs(struct xe_i2c *i2c)
> +{
> +	struct device *dev = i2c->drm_dev;
> +
> +	device_remove_file(dev, &dev_attr_amc_alert_reason);
> +}
> +
> +static int amc_create_alert_sysfs(struct xe_i2c *i2c)
> +{
> +	struct device *dev = i2c->drm_dev;
> +
> +	return device_create_file(dev, &dev_attr_amc_alert_reason);
> +}
> +
>  static void xe_amc_work(struct work_struct *work)
>  {
>  	const struct amc_request *request = &amc_get_alert_reason;
> @@ -162,6 +210,11 @@ static void xe_amc_work(struct work_struct *work)
>  out_reassert_interrupt:
>  	xe_mmio_rmw32(amc->i2c->mmio, I2C_CONFIG_CMD, PCI_COMMAND_INTX_DISABLE, 0);
>  
> +	WRITE_ONCE(amc->alert_reason, alert_reason < ARRAY_SIZE(amc_alert) ?
> +		   alert_reason : AMC_ALERT_UNKNOWN);
> +	/* Publish alert_reason to readers using smp_load_acquire(). */
> +	smp_store_release(&amc->alert_seen, true);
> +
>  	switch (alert_reason) {
>  	case AMC_ALERT_FW_DOWNLOAD:
>  	case AMC_ALERT_OOB_RESET:
> @@ -175,11 +228,12 @@ static void xe_amc_work(struct work_struct *work)
>  		recovery = DRM_WEDGE_RECOVERY_COLD_RESET;
>  		break;
>  	default:
> -		alert_str = "unknown";
> +		alert_str = amc_alert[AMC_ALERT_UNKNOWN];
>  		break;
>  	}
>  
>  	drm_warn(&xe->drm, "AMC Alert: %s (%u)\n", alert_str, alert_reason);
> +
>  	if (recovery)
>  		xe_wedge_declare(xe, recovery);
>  
> @@ -194,6 +248,7 @@ void xe_amc_handle_alert(struct xe_i2c *i2c)
>  int xe_amc_init(struct xe_i2c *i2c)
>  {
>  	struct xe_amc *amc;
> +	int ret;
>  
>  	amc = kzalloc_obj(*amc);
>  	if (!amc)
> @@ -203,13 +258,21 @@ int xe_amc_init(struct xe_i2c *i2c)
>  	i2c->amc = amc;
>  	amc->i2c = i2c;
>  
> -	return 0;
> +	ret = amc_create_alert_sysfs(i2c);
> +	if (ret) {
> +		kfree(i2c->amc);
> +		i2c->amc = NULL;
> +	}
> +
> +	return ret;
>  }
>  
>  void xe_amc_exit(struct xe_i2c *i2c)
>  {
>  	if (i2c->amc) {
> +		amc_remove_alert_sysfs(i2c);
>  		cancel_work_sync(&i2c->amc->work);
>  		kfree(i2c->amc);
> +		i2c->amc = NULL;
>  	}
>  }
> -- 
> 2.56.0
> 

  parent reply	other threads:[~2026-12-01 21:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  9:11 [PATCH v2 0/5] Process AMC alert Badal Nilawar
2026-12-01  9:11 ` [PATCH v2 1/5] drm/xe: Request cold-reset recovery on AMC thermal trip alert Badal Nilawar
2026-12-01 10:58   ` Gupta, Anshuman
2026-12-01 11:12   ` Raag Jadav
2026-12-01  9:11 ` [PATCH v2 2/5] drm/xe: Request cold-reset recovery on AMC OOB request alert Badal Nilawar
2026-12-01 11:03   ` Gupta, Anshuman
2026-12-01  9:11 ` [PATCH v2 3/5] drm/xe: Request cold-reset recovery on AMC CATERR alert Badal Nilawar
2026-12-01 11:04   ` Gupta, Anshuman
2026-12-01  9:11 ` [PATCH v2 4/5] drm/xe/i2c: Expose AMC alert reason through sysfs Badal Nilawar
2026-12-01 15:54   ` Gupta, Anshuman
2026-12-01 21:10   ` Rodrigo Vivi [this message]
2026-12-01  9:11 ` [PATCH v2 5/5] drm/xe: Request vendor recovery for AMC firmware download alert Badal Nilawar
2026-12-01 16:24   ` Gupta, Anshuman
2026-12-01 21:10   ` Rodrigo Vivi

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=aw834lch5EssVuyq@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=aravind.iddamsetty@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=mallesh.koujalagi@intel.com \
    --cc=raag.jadav@intel.com \
    --cc=riana.tauro@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.