Skip to contentSkip to conversation

HID: amd_sfh: Fix SRA sensor when it's the only sensor

PATCH Applied Mario Limonciello 4 participants 4 messages Apr 3, 2025 – Apr 24, 2025

Subsystems (3)

v1 of 4 Applied Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: amd_sfh: Fix SRA sensor when it's the only sensor

From: Mario Limonciello <[email protected]>

On systems that only have an SRA sensor connected to SFH the sensor doesn't get enabled due to a bad optimization condition of breaking the sensor walk loop.

This optimization is unnecessary in the first place because if there is only one device then the loop only runs once. Drop the condition and explicitly mark sensor as enabled.

Fixes d1c444b47100d ("HID: amd_sfh: Add support to export device operating states")
---
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +3 -4
index 25f0ebfcbd5f5..c1bdf1e0d44af 100644
@@ -134,9 +134,6 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
 	for (i = 0; i < cl_data->num_hid_devices; i++) {
 		cl_data->sensor_sts[i] = SENSOR_DISABLED;
 
-		if (cl_data->num_hid_devices == 1 && cl_data->sensor_idx[0] == SRA_IDX)
-			break;
-
 		if (cl_data->sensor_idx[i] == SRA_IDX) {
 			info.sensor_idx = cl_data->sensor_idx[i];
 			writel(0, privdata->mmio + amd_get_p2c_val(privdata, 0));
@@ -145,8 +142,10 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
 				(privdata, cl_data->sensor_idx[i], ENABLE_SENSOR);
 
 			cl_data->sensor_sts[i] = (status == 0) ? SENSOR_ENABLED : SENSOR_DISABLED;
-			if (cl_data->sensor_sts[i] == SENSOR_ENABLED)
+			if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
+				cl_data->is_any_sensor_enabled = true;
 				privdata->dev_en.is_sra_present = true;
+			}
 			continue;
 		}
 
Signature · 1 line
2.43.0
Tested-by Yijun Shen on v1 1/1
#1 lore raw

Internal Use - Confidential

Quoted 23 lines

-----Original Message-----
From: Mario Limonciello <[email protected]>
Sent: Thursday, April 3, 2025 11:12 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Shyam- [email protected]; [email protected]
Cc: Shen, Yijun <[email protected]>; [email protected]; linux- [email protected]
Subject: [PATCH] HID: amd_sfh: Fix SRA sensor when it's the only sensor

[EXTERNAL EMAIL]

From: Mario Limonciello <[email protected]>

On systems that only have an SRA sensor connected to SFH the sensor doesn't get enabled due to a bad optimization condition of breaking the sensor walk loop.

This optimization is unnecessary in the first place because if there is only one device then the loop only runs once. Drop the condition and explicitly mark sensor as enabled.

Quoted 5 lines
Fixes d1c444b47100d ("HID: amd_sfh: Add support to export device

operating states")

Verified the patch on the issued system, the issue is gone.

Quoted 38 lines
---
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 7 +-+-+-----
 1 file changed, 3 insertions(+-), 4 deletions(-)
drivers/hid/amd- renamed from drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +0 -0

sfh-hid/sfh1_1/amd_sfh_init.c
index 25f0ebfcbd5f5..c1bdf1e0d44af 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +-+-+- b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c @@ -134,9 +-134,6 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)

      for (i = 0; i < cl_data->num_hid_devices; i+-+-) {
              cl_data->sensor_sts[i] = SENSOR_DISABLED;

- if (cl_data->num_hid_devices == 1 && cl_data->sensor_idx[0]
== SRA_IDX)

drivers/hid/amd- renamed from drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +0 -2
-                     break;
-
              if (cl_data->sensor_idx[i] == SRA_IDX) {
                      info.sensor_idx = cl_data->sensor_idx[i];
                      writel(0, privdata->mmio +-

amd_get_p2c_val(privdata, 0)); @@ -145,8 +-142,10 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)

                              (privdata, cl_data->sensor_idx[i],

ENABLE_SENSOR);

                      cl_data->sensor_sts[i] = (status == 0) ?
SENSOR_ENABLED : SENSOR_DISABLED;
-                     if (cl_data->sensor_sts[i] == SENSOR_ENABLED)
+-                     if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
+-                             cl_data->is_any_sensor_enabled = true;
                              privdata->dev_en.is_sra_present = true;
+-                     }
                      continue;
              }

--
2.43.0

#2 lore raw
In reply to Mario Limonciello
Quoted 34 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

On systems that only have an SRA sensor connected to SFH the sensor doesn't get enabled due to a bad optimization condition of breaking the sensor walk loop.

This optimization is unnecessary in the first place because if there is only one device then the loop only runs once. Drop the condition and explicitly mark sensor as enabled.

Fixes d1c444b47100d ("HID: amd_sfh: Add support to export device operating states")
---
  drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +0 -3
index 25f0ebfcbd5f5..c1bdf1e0d44af 100644
@@ -134,9 +134,6 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
  	for (i = 0; i < cl_data->num_hid_devices; i++) {
  		cl_data->sensor_sts[i] = SENSOR_DISABLED;
 
-		if (cl_data->num_hid_devices == 1 && cl_data->sensor_idx[0] == SRA_IDX)
-			break;
-
  		if (cl_data->sensor_idx[i] == SRA_IDX) {
  			info.sensor_idx = cl_data->sensor_idx[i];
  			writel(0, privdata->mmio + amd_get_p2c_val(privdata, 0));
@@ -145,8 +142,10 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
  				(privdata, cl_data->sensor_idx[i], ENABLE_SENSOR);

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata) · line 151

Quoted 10 lines
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +3 -1
 
  			cl_data->sensor_sts[i] = (status == 0) ? SENSOR_ENABLED : SENSOR_DISABLED;
-			if (cl_data->sensor_sts[i] == SENSOR_ENABLED)
+			if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
+				cl_data->is_any_sensor_enabled = true;
  				privdata->dev_en.is_sra_present = true;
+			}
  			continue;
  		}
 

Looks like once SRA is enabled then SRA is not handled properly in failure cases.

Thanks,
--
Basavaraj

maintainer Applied
#3 lore raw
In reply to Mario Limonciello
Quoted 6 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

On systems that only have an SRA sensor connected to SFH the sensor doesn't get enabled due to a bad optimization condition of breaking the sensor walk loop.

Quoted 8 lines

This optimization is unnecessary in the first place because if there is only one device then the loop only runs once. Drop the condition and explicitly mark sensor as enabled.

Fixes d1c444b47100d ("HID: amd_sfh: Add support to export device operating states")

Applied, thank you.

Signature · 2 lines
Jiri Kosina
SUSE Labs