All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Badal Nilawar" <badal.nilawar@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v3] drm/xe/i2c: Expose AMC Alert reason sysfs
Date: Thu, 01 Oct 2026 12:07:45 +0000	[thread overview]
Message-ID: <20261001120746.06F791F00898@smtp.kernel.org> (raw)
In-Reply-To: <20261001121302.4102629-2-badal.nilawar@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] xe: data race and incorrect ordering in AMC alert sysfs read
- [Low] sysfs: ABI documentation mismatch for xe_amc_alert_reason attribute
--

commit 18d032c7e5837ea6476300e788f566784a9575ac
Author: Badal Nilawar <badal.nilawar@intel.com>
Subject: drm/xe/i2c: Expose AMC Alert reason sysfs

This commit introduces a read-only sysfs attribute to expose the AMC
(Add-In Management Controller) alert reason. It adds documentation and
implements the sysfs creation and value update logic in xe_amc.c.

> 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 0000000000000..34927fa5dcfe8
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-driver-intel-xe-amc
> @@ -0,0 +1,24 @@
> +What:		/sys/bus/pci/drivers/xe/.../xe_amc_alert_reason

[ ... ]

> diff --git a/drivers/gpu/drm/xe/xe_amc.c b/drivers/gpu/drm/xe/xe_amc.c
> index edd50bf8261ec..7f21044fd1b7b 100644
> --- a/drivers/gpu/drm/xe/xe_amc.c
> +++ b/drivers/gpu/drm/xe/xe_amc.c

[ ... ]

> @@ -104,6 +108,45 @@ static const struct amc_request amc_get_alert_reason = {
>  	},
>  };
>  
> +/**
> + * DOC: AMC Alert Reason
> + *
> + * Expose AMC alert reason through device sysfs
> + *
> + * See Documentation/ABI/testing/sysfs-driver-intel-xe-amc for the ABI
> + * specification.
> + */
> +
> +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;
> +	u8 alert_reason;
> +
> +	if (!amc->alert_seen)

[Severity: Medium]
Could this read of amc->alert_seen cause a data race?

The sysfs reader relies on this boolean flag to decide whether to read
alert_reason, but it lacks memory barriers or READ_ONCE(). A concurrent
sysfs reader might observe an inconsistent state here while a new alert
is being processed.

> +		return sysfs_emit(buf, "none\n");
> +
> +	alert_reason = READ_ONCE(amc->alert_reason);
> +
> +	return sysfs_emit(buf, "%s\n", amc_alert[alert_reason]);
> +}
> +static DEVICE_ATTR_RO(amc_alert_reason);

[Severity: Low]
Does this macro create an attribute named amc_alert_reason, rather than the
documented ABI name?

The ABI documentation specifies the attribute name as xe_amc_alert_reason,
but this macro creates it without the xe_ prefix. Userspace tools relying on
the ABI documentation might fail to find the sysfs file.

[ ... ]

> @@ -153,17 +196,26 @@ 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);
>  
> +	amc->alert_seen = true;
> +

[Severity: Medium]
Does setting amc->alert_seen to true before updating amc->alert_reason
expose a race window?

A concurrent sysfs read of the alert attribute could observe
alert_seen == true and then read an uninitialized or stale alert_reason value,
returning an incorrect or default alert reason to userspace.

>  	switch (alert_reason) {
>  	case AMC_ALERT_FW_DOWNLOAD:
>  	case AMC_ALERT_THERMAL_TRIP:
>  	case AMC_ALERT_OOB_REQUEST:
>  	case AMC_ALERT_OOB_RESET:
> -	case AMC_ALERT_CATERR:
> -		dev_warn(amc->i2c->drm_dev, "AMC Alert: %s\n", amc_alert[alert_reason]);
> -		xe_device_declare_wedged(i2c_client_to_xe_device(client));
> +	case AMC_ALERT_CATERR: {
> +		struct xe_device *xe = i2c_client_to_xe_device(client);
> +
> +		WRITE_ONCE(amc->alert_reason, alert_reason);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261001121302.4102629-2-badal.nilawar@intel.com?part=1

  parent reply	other threads:[~2026-10-01 12:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 12:13 [PATCH v3] drm/xe/i2c: Expose AMC Alert reason sysfs Badal Nilawar
2026-10-01 12:02 ` ✗ CI.checkpatch: warning for " Patchwork
2026-10-01 12:04 ` ✓ CI.KUnit: success " Patchwork
2026-10-01 12:07 ` sashiko-bot [this message]
2026-10-01 13:29   ` [PATCH v3] " Nilawar, Badal
2026-10-01 14:17   ` Nilawar, Badal
2026-10-01 14:54 ` Jani Nikula
2026-10-01 16:26 ` ✓ Xe.CI.BAT: success for " Patchwork
2026-10-01 19:33 ` ✗ 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=20261001120746.06F791F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.