Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Basavaraj Natikar" <Basavaraj.Natikar@amd.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH -next v2 2/4] HID: amd_sfh: Add operating-mode telemetry sysfs attributes
Date: Tue, 06 Oct 2026 10:50:22 +0000	[thread overview]
Message-ID: <20261006105023.1DEBD1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261006103754.3614316-3-Basavaraj.Natikar@amd.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] hid: non-atomic copy into mismatched struct for SRA data
- [Low] hid: build failure due to non-existent c2p3_data member
--

commit ee7fce24f1e5a01f6f7e6e6cd19e09582b434ae4
Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>

HID: amd_sfh: Add operating-mode telemetry sysfs attributes

The Sensor Fusion Hub reports additional operating-mode telemetry through
the SRA sensor. This commit exposes these states read-only through sysfs
so that userspace can consume them.

> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
> index db1cc205d25b9..8af4df09760f0 100644
> --- a/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
[ ... ]
> @@ -41,19 +43,78 @@ static ssize_t hpd_store(struct device *dev,
>  }
>  static DEVICE_ATTR_RW(hpd);
>  
> +/* Operating-mode telemetry reported by the SRA sensor, exposed read-only. */
> +static int amd_sfh_read_op_mode(struct amd_mp2_dev *mp2, struct sfh_op_mode *mode)
> +{
> +	struct sfh_accel_data accel_data;
> +	void __iomem *sensoraddr;
> +
> +	if (!mp2->sfh1_1_ops || !mp2->dev_en.is_sra_present)
> +		return -ENODEV;
> +
> +	if (mp2->mp2_ver >= MP2_VER_1_2) {
> +		sensoraddr = mp2->vsbase +
> +			(SRA_IDX * SENSOR_DATA_MEM_SIZE_DEFAULT) +
> +			OFFSET_SENSOR_DATA_DEFAULT;
> +		memcpy_fromio(&accel_data, sensoraddr, sizeof(struct sfh_accel_data));

[Severity: Medium]
Does amd_sfh_read_op_mode() perform a multi-byte, non-atomic bulk I/O copy
from shared hardware memory using the wrong struct type (accelerometer instead
of SRA)?

Reading any of the new SRA telemetry sysfs attributes on a device with MP2
version >= 1.2 could risk torn reads from concurrent hardware updates.

Could a targeted, atomic readl() be used instead to read the single 32-bit
register value?

> +		mode->val = accel_data.c2p3_data;

[Severity: Low]
Does struct sfh_accel_data have a c2p3_data member?

It appears this member does not exist, which causes an immediate compilation
failure when compiling the amd_sfh module.

> +	} else {
> +		mode->val = readl(mp2->mmio + amd_get_c2p_val(mp2, 3));
> +	}
> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006103754.3614316-1-Basavaraj.Natikar@amd.com?part=2

  reply	other threads:[~2026-10-06 10:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 10:37 [PATCH -next v2 0/4] HID: amd_sfh: operating-mode telemetry sysfs and report fixes Basavaraj Natikar
2026-10-06 10:37 ` [PATCH -next v2 1/4] HID: amd_sfh: Move sysfs attributes to a separate file Basavaraj Natikar
2026-10-06 10:37 ` [PATCH -next v2 2/4] HID: amd_sfh: Add operating-mode telemetry sysfs attributes Basavaraj Natikar
2026-10-06 10:50   ` sashiko-bot [this message]
2026-10-06 10:37 ` [PATCH -next v2 3/4] HID: amd_sfh: Remove unsupported motion-state field from accelerometer report Basavaraj Natikar
2026-10-06 10:37 ` [PATCH -next v2 4/4] HID: amd_sfh: Use report type from request node Basavaraj Natikar
2026-10-06 10:51   ` sashiko-bot

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=20261006105023.1DEBD1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox