Skip to contentSkip to conversation

Fixes and updates to amd-sfh

PATCH Applied Basavaraj Natikar 2 participants 5 messages May 7, 2024

Subsystems (2)
lore
Share & tools
lore

Basavaraj Natikar

author maintainer
#0 lore raw

cover Fixes and updates to amd-sfh

This patch series include changes for:
- Modify and log errors based on functionality.
- Handle "no sensors" exists in PM operations.
- Use amd_get_c2p_val() to read the C2P register for compatibility.

Basavaraj Natikar (3):
HID: amd_sfh: Modify and log error only if case of functionality
failures
HID: amd_sfh: Handle "no sensors" in PM operations
HID: amd_sfh: Use amd_get_c2p_val() to read C2P register

 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c          |  5 +----
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c   | 17 ++++++++++++++---
 .../hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c  |  2 +-
 3 files changed, 16 insertions(+), 8 deletions(-)
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH 1/3 HID: amd_sfh: Modify and log error only if case of functionality failures

Modify log messages, but only log errors when sensors are missing or a true failure occurs to avoid misleading "failed" messages.

---
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c        | 5 +----
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 7 ++++---
 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +1 -4
index 9e97c26c4482..0c28ca349bcd 100644
@@ -333,14 +333,11 @@ static const struct dmi_system_id dmi_nodevs[] = {
 static void sfh1_1_init_work(struct work_struct *work)
 {
 	struct amd_mp2_dev *mp2 = container_of(work, struct amd_mp2_dev, work);
-	struct pci_dev *pdev = mp2->pdev;
 	int rc;
 
 	rc = mp2->sfh1_1_ops->init(mp2);
-	if (rc) {
-		dev_err(&pdev->dev, "sfh1_1_init failed err %d\n", rc);
+	if (rc)
 		return;
-	}
 
 	amd_sfh_clear_intr(mp2);
 	mp2->init_done = 1;
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +4 -3
index 5b24d5f63701..f46f9c670c6b 100644
@@ -202,7 +202,7 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
 	}
 
 	if (!cl_data->is_any_sensor_enabled) {
-		dev_warn(dev, "Failed to discover, sensors not enabled is %d\n",
+		dev_warn(dev, "No sensor registered, sensors not enabled is %d\n",
 			 cl_data->is_any_sensor_enabled);
 		rc = -EOPNOTSUPP;
 		goto cleanup;
@@ -320,7 +320,7 @@ int amd_sfh1_1_init(struct amd_mp2_dev *mp2)
 
 	memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info));
 	if (binfo.sbase.fw_info.fw_ver == 0 || binfo.sbase.s_list.sl.sensors == 0) {
-		dev_dbg(dev, "failed to get sensors\n");
+		dev_dbg(dev, "No sensor registered\n");
 		return -EOPNOTSUPP;
 	}
 	dev_dbg(dev, "firmware version 0x%x\n", binfo.sbase.fw_info.fw_ver);
@@ -337,7 +337,8 @@ int amd_sfh1_1_init(struct amd_mp2_dev *mp2)
 	rc = amd_sfh1_1_hid_client_init(mp2);
 	if (rc) {
 		sfh_deinit_emp2();
-		dev_err(dev, "amd_sfh1_1_hid_client_init failed\n");
+		if ((rc != -ENODEV) && (rc != -EOPNOTSUPP))
+			dev_err(dev, "amd_sfh1_1_hid_client_init failed\n");
 		return rc;
 	}
 
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

PATCH 2/3 HID: amd_sfh: Handle "no sensors" in PM operations

In reply to Basavaraj Natikar

Resume or suspend each sensor device based on the num_hid_devices. Therefore, add a check to handle the special case where no sensors are present.

Fixes 93ce5e0231d7 ("HID: amd_sfh: Implement SFH1.1 functionality")
---
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +10 -0
index f46f9c670c6b..621793d92464 100644
@@ -227,6 +227,11 @@ static void amd_sfh_resume(struct amd_mp2_dev *mp2)
 	struct amd_mp2_sensor_info info;
 	int i, status;
 
+	if (!cl_data->is_any_sensor_enabled) {
+		amd_sfh_clear_intr(mp2);
+		return;
+	}
+
 	for (i = 0; i < cl_data->num_hid_devices; i++) {
 		if (cl_data->sensor_sts[i] == SENSOR_DISABLED) {
 			info.sensor_idx = cl_data->sensor_idx[i];
@@ -252,6 +257,11 @@ static void amd_sfh_suspend(struct amd_mp2_dev *mp2)
 	struct amdtp_cl_data *cl_data = mp2->cl_data;
 	int i, status;
 
+	if (!cl_data->is_any_sensor_enabled) {
+		amd_sfh_clear_intr(mp2);
+		return;
+	}
+
 	for (i = 0; i < cl_data->num_hid_devices; i++) {
 		if (cl_data->sensor_idx[i] != HPD_IDX &&
 		    cl_data->sensor_sts[i] == SENSOR_ENABLED) {
Signature · 1 line
2.25.1
author maintainer
#3 lore raw

PATCH 3/3 HID: amd_sfh: Use amd_get_c2p_val() to read C2P register

In reply to Basavaraj Natikar

Newer processors support various MP2 register sets. Therefore, to ensure compatibility and obtain C2P data, use the amd_get_c2p_val().

---
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c +1 -1
index 2de2668a0277..4676f060da26 100644
@@ -97,7 +97,7 @@ static int amd_sfh_hpd_info(u8 *user_present)
 	if (!emp2 || !emp2->dev_en.is_hpd_present)
 		return -ENODEV;
 
-	hpdstatus.val = readl(emp2->mmio + AMD_C2P_MSG(4));
+	hpdstatus.val = readl(emp2->mmio + amd_get_c2p_val(emp2, 4));
 	*user_present = hpdstatus.shpd.presence;
 
 	return 0;
Signature · 1 line
2.25.1
maintainer Applied
#4 lore raw
In reply to Basavaraj Natikar
Quoted 11 lines · Basavaraj Natikar

This patch series include changes for:
- Modify and log errors based on functionality.
- Handle "no sensors" exists in PM operations.
- Use amd_get_c2p_val() to read the C2P register for compatibility.

Basavaraj Natikar (3):
HID: amd_sfh: Modify and log error only if case of functionality
failures
HID: amd_sfh: Handle "no sensors" in PM operations
HID: amd_sfh: Use amd_get_c2p_val() to read C2P register

Quoted 4 lines
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c          |  5 +----
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c   | 17 ++++++++++++++---
 .../hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c  |  2 +-
 3 files changed, 16 insertions(+), 8 deletions(-)

Queued for 6.10, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs