* [PATCH -next 0/3] HID: amd_sfh: operating-mode telemetry sysfs and accel report fix
@ 2026-10-04 15:59 Basavaraj Natikar
2026-10-04 15:59 ` [PATCH -next 1/3] HID: amd_sfh: Move sysfs attributes to a separate file Basavaraj Natikar
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Basavaraj Natikar @ 2026-10-04 15:59 UTC (permalink / raw)
To: jikos, bentiss; +Cc: linux-input, Basavaraj Natikar
This series extends the amd-sfh sysfs interface with operating-mode
telemetry and fixes an accelerometer report-descriptor mismatch.
Patch 1 moves the existing sysfs attribute handling into a dedicated file
in preparation for adding more attributes (no functional change).
Patch 2 exposes the operating-mode telemetry reported by the SRA sensor
(in-bag, out-of-bag, on-table, hinge angle, lid status and device mode)
as read-only sysfs attributes.
Patch 3 removes an unsupported motion-state field from the accelerometer
HID report descriptor that the hardware never populates, which caused
hid-core to drop every accelerometer input report.
Basavaraj Natikar (3):
HID: amd_sfh: Move sysfs attributes to a separate file
HID: amd_sfh: Add operating-mode telemetry sysfs attributes
HID: amd_sfh: Remove unsupported motion-state field from accelerometer
report
.../ABI/testing/sysfs-driver-amd-sfh | 60 ++++++++
MAINTAINERS | 1 +
drivers/hid/amd-sfh-hid/Makefile | 1 +
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 55 +------
drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c | 134 ++++++++++++++++++
drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h | 19 +++
.../hid_descriptor/amd_sfh_hid_desc.h | 2 -
.../hid_descriptor/amd_sfh_hid_report_desc.h | 7 -
8 files changed, 217 insertions(+), 62 deletions(-)
create mode 100644 drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
create mode 100644 drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH -next 1/3] HID: amd_sfh: Move sysfs attributes to a separate file
2026-10-04 15:59 [PATCH -next 0/3] HID: amd_sfh: operating-mode telemetry sysfs and accel report fix Basavaraj Natikar
@ 2026-10-04 15:59 ` Basavaraj Natikar
2026-10-04 15:59 ` [PATCH -next 2/3] HID: amd_sfh: Add operating-mode telemetry sysfs attributes Basavaraj Natikar
2026-10-04 15:59 ` [PATCH -next 3/3] HID: amd_sfh: Remove unsupported motion-state field from accelerometer report Basavaraj Natikar
2 siblings, 0 replies; 5+ messages in thread
From: Basavaraj Natikar @ 2026-10-04 15:59 UTC (permalink / raw)
To: jikos, bentiss; +Cc: linux-input, Basavaraj Natikar
The sysfs attribute handling is defined in amd_sfh_pcie.c along with the
PCIe transport code. More attributes will be added and the same handling
is useful across SFH versions.
Therefore, move the attribute definitions, the visibility callback and
the group update helper into a dedicated amd_sfh_sysfs.c file.
No functional change intended.
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
drivers/hid/amd-sfh-hid/Makefile | 1 +
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 55 +------------------
drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c | 73 +++++++++++++++++++++++++
drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h | 19 +++++++
4 files changed, 95 insertions(+), 53 deletions(-)
create mode 100644 drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
create mode 100644 drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h
diff --git a/drivers/hid/amd-sfh-hid/Makefile b/drivers/hid/amd-sfh-hid/Makefile
index 106514b54d16..a0e4113c94cb 100644
--- a/drivers/hid/amd-sfh-hid/Makefile
+++ b/drivers/hid/amd-sfh-hid/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_AMD_SFH_HID) += amd_sfh.o
amd_sfh-objs := amd_sfh_hid.o
amd_sfh-objs += amd_sfh_client.o
amd_sfh-objs += amd_sfh_pcie.o
+amd_sfh-objs += amd_sfh_sysfs.o
amd_sfh-objs += hid_descriptor/amd_sfh_hid_desc.o
amd_sfh-objs += sfh1_1/amd_sfh_init.o
amd_sfh-objs += sfh1_1/amd_sfh_interface.o
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index aa09a9538f4f..b3cb13b8c5e8 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -20,9 +20,9 @@
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/slab.h>
-#include <linux/string_choices.h>
#include "amd_sfh_pcie.h"
+#include "amd_sfh_sysfs.h"
#include "sfh1_1/amd_sfh_init.h"
#define DRIVER_NAME "pcie_mp2_amd"
@@ -340,57 +340,6 @@ static const struct dmi_system_id dmi_nodevs[] = {
{ }
};
-static ssize_t hpd_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
-
- return sysfs_emit(buf, "%s\n", str_enabled_disabled(mp2->dev_en.is_hpd_enabled));
-}
-
-static ssize_t hpd_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
- bool enabled;
- int ret;
-
- ret = kstrtobool(buf, &enabled);
- if (ret)
- return ret;
-
- mp2->sfh1_1_ops->toggle_hpd(mp2, enabled);
-
- return count;
-}
-static DEVICE_ATTR_RW(hpd);
-
-static umode_t sfh_attr_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
-{
- struct device *dev = kobj_to_dev(kobj);
- struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
-
- if (!mp2->sfh1_1_ops || !mp2->dev_en.is_hpd_present)
- return 0;
-
- return attr->mode;
-}
-
-static struct attribute *sfh_attrs[] = {
- &dev_attr_hpd.attr,
- NULL,
-};
-
-static struct attribute_group sfh_attr_group = {
- .attrs = sfh_attrs,
- .is_visible = sfh_attr_is_visible,
-};
-
-static const struct attribute_group *amd_sfh_groups[] = {
- &sfh_attr_group,
- NULL,
-};
-
static DEFINE_IDA(sfh_tm_ida);
static void amd_sfh_maybe_register_tm(struct amd_mp2_dev *mp2)
@@ -448,7 +397,7 @@ static void sfh1_1_init_work(struct work_struct *work)
amd_sfh_clear_intr(mp2);
mp2->init_done = 1;
- rc = sysfs_update_group(&mp2->pdev->dev.kobj, &sfh_attr_group);
+ rc = amd_sfh_update_sysfs(mp2);
if (rc)
dev_warn(&mp2->pdev->dev, "failed to update sysfs group\n");
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
new file mode 100644
index 000000000000..db1cc205d25b
--- /dev/null
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * AMD SFH sysfs attributes
+ *
+ * Copyright (c) 2026, Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
+ */
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/string_choices.h>
+#include <linux/sysfs.h>
+
+#include "amd_sfh_common.h"
+#include "amd_sfh_sysfs.h"
+#include "sfh1_1/amd_sfh_init.h"
+
+static ssize_t hpd_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%s\n", str_enabled_disabled(mp2->dev_en.is_hpd_enabled));
+}
+
+static ssize_t hpd_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
+ bool enabled;
+ int ret;
+
+ ret = kstrtobool(buf, &enabled);
+ if (ret)
+ return ret;
+
+ mp2->sfh1_1_ops->toggle_hpd(mp2, enabled);
+
+ return count;
+}
+static DEVICE_ATTR_RW(hpd);
+
+static umode_t sfh_attr_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
+{
+ struct device *dev = kobj_to_dev(kobj);
+ struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
+
+ if (!mp2->sfh1_1_ops || !mp2->dev_en.is_hpd_present)
+ return 0;
+
+ return attr->mode;
+}
+
+static struct attribute *sfh_attrs[] = {
+ &dev_attr_hpd.attr,
+ NULL,
+};
+
+static struct attribute_group sfh_attr_group = {
+ .attrs = sfh_attrs,
+ .is_visible = sfh_attr_is_visible,
+};
+
+const struct attribute_group *amd_sfh_groups[] = {
+ &sfh_attr_group,
+ NULL,
+};
+
+int amd_sfh_update_sysfs(struct amd_mp2_dev *mp2)
+{
+ return sysfs_update_group(&mp2->pdev->dev.kobj, &sfh_attr_group);
+}
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h
new file mode 100644
index 000000000000..941b995e2c8f
--- /dev/null
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * AMD SFH sysfs attributes
+ *
+ * Copyright (c) 2026, Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
+ */
+#ifndef AMD_SFH_SYSFS_H
+#define AMD_SFH_SYSFS_H
+
+#include "amd_sfh_common.h"
+
+extern const struct attribute_group *amd_sfh_groups[];
+
+int amd_sfh_update_sysfs(struct amd_mp2_dev *mp2);
+
+#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH -next 2/3] HID: amd_sfh: Add operating-mode telemetry sysfs attributes
2026-10-04 15:59 [PATCH -next 0/3] HID: amd_sfh: operating-mode telemetry sysfs and accel report fix Basavaraj Natikar
2026-10-04 15:59 ` [PATCH -next 1/3] HID: amd_sfh: Move sysfs attributes to a separate file Basavaraj Natikar
@ 2026-10-04 15:59 ` Basavaraj Natikar
2026-10-04 16:11 ` sashiko-bot
2026-10-04 15:59 ` [PATCH -next 3/3] HID: amd_sfh: Remove unsupported motion-state field from accelerometer report Basavaraj Natikar
2 siblings, 1 reply; 5+ messages in thread
From: Basavaraj Natikar @ 2026-10-04 15:59 UTC (permalink / raw)
To: jikos, bentiss; +Cc: linux-input, Basavaraj Natikar
The Sensor Fusion Hub reports additional operating-mode telemetry
through the SRA sensor, such as in-bag and out-of-bag detection,
on-table or on-lap placement, hinge angle, lid status and the platform
device mode.
Expose these states read-only through sysfs so that userspace can
consume them. The attributes are visible only on SFH 1.1 or greater when
the SRA sensor is present.
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
.../ABI/testing/sysfs-driver-amd-sfh | 60 ++++++++++++++++++
MAINTAINERS | 1 +
drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c | 63 ++++++++++++++++++-
3 files changed, 123 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/sysfs-driver-amd-sfh b/Documentation/ABI/testing/sysfs-driver-amd-sfh
index c053126a83bb..15abd994e9ee 100644
--- a/Documentation/ABI/testing/sysfs-driver-amd-sfh
+++ b/Documentation/ABI/testing/sysfs-driver-amd-sfh
@@ -11,3 +11,63 @@ Description:
Access: Read/Write
Valid values: enabled/disabled
+
+What: /sys/bus/pci/drivers/pcie_mp2_amd/*/in_bag_state
+Date: August 2026
+Contact: Basavaraj.Natikar@amd.com
+Description:
+ Operating-mode telemetry reported by the SRA sensor that
+ indicates whether the device is detected inside a bag.
+
+ Access: Read only
+ Valid values: unsigned integer
+
+What: /sys/bus/pci/drivers/pcie_mp2_amd/*/out_bag_state
+Date: August 2026
+Contact: Basavaraj.Natikar@amd.com
+Description:
+ Operating-mode telemetry reported by the SRA sensor that
+ indicates whether the device is detected outside a bag.
+
+ Access: Read only
+ Valid values: unsigned integer
+
+What: /sys/bus/pci/drivers/pcie_mp2_amd/*/on_table_state
+Date: August 2026
+Contact: Basavaraj.Natikar@amd.com
+Description:
+ Operating-mode telemetry reported by the SRA sensor that
+ indicates whether the device is placed on a table or on a lap.
+
+ Access: Read only
+ Valid values: unsigned integer
+
+What: /sys/bus/pci/drivers/pcie_mp2_amd/*/hinge_angle
+Date: August 2026
+Contact: Basavaraj.Natikar@amd.com
+Description:
+ Operating-mode telemetry reported by the SRA sensor that
+ reports the hinge angle of the device in degrees.
+
+ Access: Read only
+ Valid values: unsigned integer (degrees)
+
+What: /sys/bus/pci/drivers/pcie_mp2_amd/*/lid_status
+Date: August 2026
+Contact: Basavaraj.Natikar@amd.com
+Description:
+ Operating-mode telemetry reported by the SRA sensor that
+ indicates whether the device lid is open or closed.
+
+ Access: Read only
+ Valid values: unsigned integer
+
+What: /sys/bus/pci/drivers/pcie_mp2_amd/*/device_mode
+Date: August 2026
+Contact: Basavaraj.Natikar@amd.com
+Description:
+ Operating-mode telemetry reported by the SRA sensor that
+ reports the platform/device mode.
+
+ Access: Read only
+ Valid values: unsigned integer
diff --git a/MAINTAINERS b/MAINTAINERS
index 5c57cbb68060..ad3477693db5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1331,6 +1331,7 @@ AMD SENSOR FUSION HUB DRIVER
M: Basavaraj Natikar <basavaraj.natikar@amd.com>
L: linux-input@vger.kernel.org
S: Maintained
+F: Documentation/ABI/testing/sysfs-driver-amd-sfh
F: Documentation/hid/amd-sfh*
F: drivers/hid/amd-sfh-hid/
F: drivers/input/misc/amd_sfh_tabletmode.c
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
index db1cc205d25b..8af4df09760f 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
@@ -8,6 +8,7 @@
* Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
*/
#include <linux/device.h>
+#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/string_choices.h>
#include <linux/sysfs.h>
@@ -15,6 +16,7 @@
#include "amd_sfh_common.h"
#include "amd_sfh_sysfs.h"
#include "sfh1_1/amd_sfh_init.h"
+#include "sfh1_1/amd_sfh_interface.h"
static ssize_t hpd_show(struct device *dev, struct device_attribute *attr, char *buf)
{
@@ -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));
+ mode->val = accel_data.c2p3_data;
+ } else {
+ mode->val = readl(mp2->mmio + amd_get_c2p_val(mp2, 3));
+ }
+
+ return 0;
+}
+
+#define SFH_OP_MODE_ATTR(_name, _field) \
+static ssize_t _name##_show(struct device *dev, \
+ struct device_attribute *attr, char *buf) \
+{ \
+ struct amd_mp2_dev *mp2 = dev_get_drvdata(dev); \
+ struct sfh_op_mode mode; \
+ int ret; \
+ \
+ ret = amd_sfh_read_op_mode(mp2, &mode); \
+ if (ret) \
+ return ret; \
+ \
+ return sysfs_emit(buf, "%u\n", mode.op_mode._field); \
+} \
+static DEVICE_ATTR_RO(_name)
+
+SFH_OP_MODE_ATTR(in_bag_state, inbagstate);
+SFH_OP_MODE_ATTR(out_bag_state, outbagstate);
+SFH_OP_MODE_ATTR(on_table_state, ontablestate);
+SFH_OP_MODE_ATTR(hinge_angle, angle);
+SFH_OP_MODE_ATTR(lid_status, lidstatus);
+SFH_OP_MODE_ATTR(device_mode, devicemode);
+
static umode_t sfh_attr_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
{
struct device *dev = kobj_to_dev(kobj);
struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
- if (!mp2->sfh1_1_ops || !mp2->dev_en.is_hpd_present)
+ if (!mp2->sfh1_1_ops)
+ return 0;
+
+ if (attr == &dev_attr_hpd.attr) {
+ if (!mp2->dev_en.is_hpd_present)
+ return 0;
+ } else if (!mp2->dev_en.is_sra_present) {
+ /* operating-mode telemetry requires the SRA sensor */
return 0;
+ }
return attr->mode;
}
static struct attribute *sfh_attrs[] = {
&dev_attr_hpd.attr,
+ &dev_attr_in_bag_state.attr,
+ &dev_attr_out_bag_state.attr,
+ &dev_attr_on_table_state.attr,
+ &dev_attr_hinge_angle.attr,
+ &dev_attr_lid_status.attr,
+ &dev_attr_device_mode.attr,
NULL,
};
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH -next 3/3] HID: amd_sfh: Remove unsupported motion-state field from accelerometer report
2026-10-04 15:59 [PATCH -next 0/3] HID: amd_sfh: operating-mode telemetry sysfs and accel report fix Basavaraj Natikar
2026-10-04 15:59 ` [PATCH -next 1/3] HID: amd_sfh: Move sysfs attributes to a separate file Basavaraj Natikar
2026-10-04 15:59 ` [PATCH -next 2/3] HID: amd_sfh: Add operating-mode telemetry sysfs attributes Basavaraj Natikar
@ 2026-10-04 15:59 ` Basavaraj Natikar
2 siblings, 0 replies; 5+ messages in thread
From: Basavaraj Natikar @ 2026-10-04 15:59 UTC (permalink / raw)
To: jikos, bentiss; +Cc: linux-input, Basavaraj Natikar, Andrej Scek, stable
The accelerometer HID report descriptor declares a trailing motion-state
field (usage 0x0451), but the Sensor Fusion Hub never reports this data,
so each accelerometer input report is one byte shorter than the descriptor
advertises.
This was previously harmless because hid-core zero-padded short reports.
Since commit 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing
bogus memset()") such reports are rejected instead:
hid-sensor-hub 0020:1022:0001.0003: Event data for report 1 was too short (15 vs 14)
As a result the accelerometer input events are dropped and screen
auto-rotation stops working on AMD SFH systems.
Remove the motion-state field from the accelerometer report descriptor and
drop the unused in_accel_shake_detection member, so the descriptor matches
the report actually provided by the hardware.
Fixes: 1434f9fc0e47 ("SFH: Create HID report to Enable support of AMD sensor fusion Hub (SFH)")
Reported-by: Andrej Scek <scek.andrej@gmail.com>
Closes: https://lore.kernel.org/linux-input/CADrS85612m-Hh-G4BJmOhy-y6r3Ni3kD8_GM-2QRBeWWEEZWuA@mail.gmail.com/
Cc: stable@vger.kernel.org
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h | 2 --
.../amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h | 7 -------
2 files changed, 9 deletions(-)
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
index 882434b1501f..230fb69cacfd 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
@@ -48,8 +48,6 @@ struct accel3_input_report {
int in_accel_x_value;
int in_accel_y_value;
int in_accel_z_value;
- /* include if required to support the "shake" event */
- u8 in_accel_shake_detection;
} __packed;
struct gyro_feature_report {
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
index 67ec2d6a417d..64cff842e5f2 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
@@ -169,13 +169,6 @@ static const u8 accel3_report_descriptor[] = {
0x95, 1, /* HID report count (1) */
0x55, 0x0E, /* HID unit exponent(0x0E) */
0X81, 0x02, /* HID Input (Data_Arr_Abs) */
-
-0x0A, 0x51, 0x04, /* HID usage sensor data motion state */
-0x15, 0, /* HID logical Min_8(0) False = Still*/
-0x25, 1, /* HID logical Min_8(1) True = In motion */
-0x75, 8, /* HID report size(8) */
-0x95, 1, /* HID report count (1) */
-0X81, 0x02, /* HID Input (Data_Arr_Abs) */
0xC0 /* HID end collection */
};
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH -next 2/3] HID: amd_sfh: Add operating-mode telemetry sysfs attributes
2026-10-04 15:59 ` [PATCH -next 2/3] HID: amd_sfh: Add operating-mode telemetry sysfs attributes Basavaraj Natikar
@ 2026-10-04 16:11 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-10-04 16:11 UTC (permalink / raw)
To: Basavaraj Natikar; +Cc: dmitry.torokhov, linux-input
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] amd_sfh: torn read of telemetry data via memcpy_fromio()
- [Low] amd_sfh: build failures due to undefined identifiers
--
commit 74c8f353108e77a41e51aa1613b0b46c89693fcd
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, such as in-bag and out-of-bag detection,
on-table or on-lap placement, hinge angle, lid status and the platform
device mode.
> 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) {
[Severity: Low]
Is MP2_VER_1_2 defined in this tree? Compiling this patch results in a build
failure because MP2_VER_1_2 is undeclared.
> + 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]
Could this memcpy_fromio() lead to torn reads? Since memcpy_fromio() performs
bulk non-atomic reads, concurrent firmware updates to the shared MMIO region
might expose a corrupted mixture of old and new telemetry states to userspace
when reading these sysfs attributes.
Should this use an atomic read like readl() instead?
> + mode->val = accel_data.c2p3_data;
[Severity: Low]
Does struct sfh_accel_data contain a c2p3_data field? Looking at
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h:
struct sfh_accel_data {
struct sfh_common_data commondata;
struct sfh_float32 acceldata;
u32 accelstatus;
};
It appears the field c2p3_data is missing, which causes a build failure
when compiling this driver.
> + } else {
> + mode->val = readl(mp2->mmio + amd_get_c2p_val(mp2, 3));
> + }
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261004155919.726226-1-Basavaraj.Natikar@amd.com?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-04 16:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-04 15:59 [PATCH -next 0/3] HID: amd_sfh: operating-mode telemetry sysfs and accel report fix Basavaraj Natikar
2026-10-04 15:59 ` [PATCH -next 1/3] HID: amd_sfh: Move sysfs attributes to a separate file Basavaraj Natikar
2026-10-04 15:59 ` [PATCH -next 2/3] HID: amd_sfh: Add operating-mode telemetry sysfs attributes Basavaraj Natikar
2026-10-04 16:11 ` sashiko-bot
2026-10-04 15:59 ` [PATCH -next 3/3] HID: amd_sfh: Remove unsupported motion-state field from accelerometer report Basavaraj Natikar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox