HID: amd_sfh: Increase sensor command timeout
Subsystems (2)
PATCH 1/6 HID: amd_sfh: Increase sensor command timeout
From: Basavaraj Natikar <[email protected]>
During the initialization sensors may take some time to respond. Hence, increase the sensor command timeouts in order to obtain status responses within a maximum timeout.
(Li: backport for s0ix issue, these patches have landed on 6.9)
--- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +2 -2
@@ -39,11 +39,11 @@ static int amd_sfh_wait_response_v2(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_ {union cmd_response cmd_resp; -/* Get response with status within a max of 1600 ms timeout */ +/* Get response with status within a max of 10 seconds timeout */ if (!readl_poll_timeout (mp2->mmio +AMD_P2C_MSG (0 ), cmd_resp.resp, (cmd_resp.response_v2.response == sensor_sts && cmd_resp.response_v2.status ==0 && (sid ==0xff || - cmd_resp.response_v2.sensor_id == sid)),500 ,1600000 )) + cmd_resp.response_v2.sensor_id == sid)),500 ,10000000 ))return cmd_resp.response_v2.response;return SENSOR_DISABLED ;
Signature · 1 line
2.25.1
PATCH 2/6 HID: amd_sfh: Update HPD sensor structure elements
From: Basavaraj Natikar <[email protected]>
HPD sensor data is not populating properly because of wrong order of HPD sensor structure elements. So update the order of structure elements to match the HPD sensor data received from the firmware.
--- drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +3 -3
@@ -90,10 +90,10 @@ enum mem_use_type {struct hpd_status {union {struct { -u32 human_presence_report :4 ; -u32 human_presence_actual :4 ; -u32 probablity :8 ;u32 object_distance :16 ; +u32 probablity :8 ; +u32 human_presence_actual :4 ; +u32 human_presence_report :4 ; } shpd;u32 val; };
Signature · 1 line
2.25.1
PATCH 3/6 HID: amd_sfh: Avoid disabling the interrupt
In reply to Li MaFrom: Basavaraj Natikar <[email protected]>
HP ProBook x360 435 G7 using older version of firmware which doesn't support disabling the interrupt for all commands. Hence avoid disabling the interrupt for that particular model.
--- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 30 +++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +27 -3
@@ -35,6 +35,8 @@ static int sensor_mask_override = -1;module_param_named (sensor_mask, sensor_mask_override, int,0444 );MODULE_PARM_DESC (sensor_mask,"override the detected sensors mask" ); +static bool intr_disable = true; +static int amd_sfh_wait_response_v2 (struct amd_mp2_dev *mp2,u8 sid,u32 sensor_sts) {union cmd_response cmd_resp;
@@ -55,7 +57,7 @@ static void amd_start_sensor_v2(struct amd_mp2_dev *privdata, struct amd_mp2_sen cmd_base.ul =0 ; cmd_base.cmd_v2.cmd_id =ENABLE_SENSOR ; - cmd_base.cmd_v2.intr_disable =1 ; + cmd_base.cmd_v2.intr_disable = intr_disable; cmd_base.cmd_v2.period = info.period; cmd_base.cmd_v2.sensor_id = info.sensor_idx; cmd_base.cmd_v2.length =16 ;
@@ -73,7 +75,7 @@ static void amd_stop_sensor_v2(struct amd_mp2_dev *privdata, u16 sensor_idx) cmd_base.ul =0 ; cmd_base.cmd_v2.cmd_id =DISABLE_SENSOR ; - cmd_base.cmd_v2.intr_disable =1 ; + cmd_base.cmd_v2.intr_disable = intr_disable; cmd_base.cmd_v2.period =0 ; cmd_base.cmd_v2.sensor_id = sensor_idx; cmd_base.cmd_v2.length =16 ;
@@ -87,7 +89,7 @@ static void amd_stop_all_sensor_v2(struct amd_mp2_dev *privdata)union sfh_cmd_base cmd_base; cmd_base.cmd_v2.cmd_id =STOP_ALL_SENSORS ; - cmd_base.cmd_v2.intr_disable =1 ; + cmd_base.cmd_v2.intr_disable = intr_disable; cmd_base.cmd_v2.period =0 ; cmd_base.cmd_v2.sensor_id =0 ;
@@ -292,6 +294,26 @@ int amd_sfh_irq_init(struct amd_mp2_dev *privdata)return 0 ; } +static int mp2_disable_intr (const struct dmi_system_id *id) +{ + intr_disable = false; +return 0 ; +} + +static const struct dmi_system_id dmi_sfh_table[] = { + { +/* +* https://bugzilla.kernel.org/show_bug.cgi?id=218104 +*/ + .callback = mp2_disable_intr, + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"HP ProBook x360 435 G7" ), + }, + }, + {} +}; +static const struct dmi_system_id dmi_nodevs[] = { {/*
@@ -315,6 +337,8 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *iif (dmi_first_match (dmi_nodevs))return -ENODEV ; +dmi_check_system (dmi_sfh_table); + privdata =devm_kzalloc (&pdev->dev,sizeof (*privdata),GFP_KERNEL );if (!privdata)return -ENOMEM ;
Signature · 1 line
2.25.1
PATCH 4/6 HID: amd_sfh: Improve boot time when SFH is available
In reply to Li MaFrom: Basavaraj Natikar <[email protected]>
AMD SFH load takes longer time in initialization. Hence split and defer initialization code to improve SFH module load time and boot time of the system when SFH is available.
--- drivers/hid/amd-sfh-hid/amd_sfh_common.h | 2 + drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 75 ++++++++++++++++++++---- 2 files changed, 64 insertions(+), 13 deletions(-)
drivers/hid/amd-sfh-hid/amd_sfh_common.h +2 -0
@@ -53,6 +53,8 @@ struct amd_mp2_dev {/* mp2 active control status */ u32 mp2_acs;struct sfh_dev_status dev_en; +struct work_struct work; +u8 init_done; };struct amd_mp2_ops {
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +62 -13
130 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 5/6 HID: amd_sfh: Extend MP2 register access to SFH
In reply to Li MaFrom: Basavaraj Natikar <[email protected]>
Various MP2 register sets are supported by newer processors. Therefore, extend MP2 register access to SFH.
--- drivers/hid/amd-sfh-hid/amd_sfh_common.h | 14 ++++++++++++++ drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 9 ++++++--- drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c | 2 +- drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 4 ++-- drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c | 10 +++++----- 5 files changed, 28 insertions(+), 11 deletions(-)
drivers/hid/amd-sfh-hid/amd_sfh_common.h +14 -0
@@ -19,6 +19,9 @@#define AMD_C2P_MSG (regno) (0x10500 + ((regno) * 4))#define AMD_P2C_MSG (regno) (0x10680 + ((regno) * 4)) +#define AMD_C2P_MSG_V1 (regno) (0x10900 + ((regno) * 4)) +#define AMD_P2C_MSG_V1 (regno) (0x10500 + ((regno) * 4)) +#define SENSOR_ENABLED 4#define SENSOR_DISABLED 5
@@ -55,6 +58,7 @@ struct amd_mp2_dev {struct sfh_dev_status dev_en;struct work_struct work;u8 init_done; +u8 rver; };struct amd_mp2_ops {
@@ -81,4 +85,14 @@ void amd_sfh_clear_intr_v2(struct amd_mp2_dev *privdata);int amd_sfh_irq_init_v2 (struct amd_mp2_dev *privdata);void amd_sfh_clear_intr (struct amd_mp2_dev *privdata);int amd_sfh_irq_init (struct amd_mp2_dev *privdata); + +static inline u64 amd_get_c2p_val (struct amd_mp2_dev *mp2,u32 idx) +{ +return mp2->rver ==1 ?AMD_C2P_MSG_V1 (idx) :AMD_C2P_MSG (idx); +} + +static inline u64 amd_get_p2c_val (struct amd_mp2_dev *mp2,u32 idx) +{ +return mp2->rver ==1 ?AMD_P2C_MSG_V1 (idx) :AMD_P2C_MSG (idx); +}#endif
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +6 -3
@@ -99,9 +99,9 @@ static void amd_stop_all_sensor_v2(struct amd_mp2_dev *privdata)void amd_sfh_clear_intr_v2 (struct amd_mp2_dev *privdata) { -if (readl (privdata->mmio +AMD_P2C_MSG (4 ))) { -writel (0 , privdata->mmio +AMD_P2C_MSG (4 )); -writel (0xf , privdata->mmio +AMD_P2C_MSG (5 )); +if (readl (privdata->mmio +amd_get_p2c_val (privdata,4 ))) { +writel (0 , privdata->mmio +amd_get_p2c_val (privdata,4 )); +writel (0xf , privdata->mmio +amd_get_p2c_val (privdata,5 )); } }
@@ -410,6 +410,9 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i privdata->sfh1_1_ops = (const struct amd_sfh1_1_ops *)id->driver_data;if (privdata->sfh1_1_ops) { +if (boot_cpu_data.x86 >=0x1A ) + privdata->rver =1 ; + rc =devm_work_autocancel (&pdev->dev, &privdata->work, sfh1_1_init_work);if (rc)return rc;
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c +1 -1
@@ -251,7 +251,7 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,break ;case HPD_IDX :get_common_inputs (&hpd_input.common_property, report_id); - hpdstatus.val =readl (mp2->mmio +AMD_C2P_MSG (4 )); + hpdstatus.val =readl (mp2->mmio +amd_get_c2p_val (mp2,4 )); hpd_input.human_presence = hpdstatus.shpd.presence; report_size =sizeof (hpd_input);memcpy (input_report, &hpd_input,sizeof (hpd_input));
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +2 -2
@@ -172,7 +172,7 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)if (rc) goto cleanup; -writel (0 , privdata->mmio +AMD_P2C_MSG (0 )); +writel (0 , privdata->mmio +amd_get_p2c_val (privdata,0 )); mp2_ops->start (privdata, info); status =amd_sfh_wait_for_response (privdata, cl_data->sensor_idx[i],ENABLE_SENSOR );
@@ -298,7 +298,7 @@ static void amd_sfh_set_ops(struct amd_mp2_dev *mp2)int amd_sfh1_1_init (struct amd_mp2_dev *mp2) { -u32 phy_base =readl (mp2->mmio +AMD_C2P_MSG (22 )); +u32 phy_base =readl (mp2->mmio +amd_get_c2p_val (mp2,22 ));struct device *dev = &mp2->pdev->dev;struct sfh_base_info binfo;int rc;
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c +5 -5
@@ -20,7 +20,7 @@ static int amd_sfh_wait_response(struct amd_mp2_dev *mp2, u8 sid, u32 cmd_id)struct sfh_cmd_response cmd_resp;/* Get response with status within a max of 10000 ms timeout */ -if (!readl_poll_timeout (mp2->mmio +AMD_P2C_MSG (0 ), cmd_resp.resp, +if (!readl_poll_timeout (mp2->mmio +amd_get_p2c_val (mp2,0 ), cmd_resp.resp, (cmd_resp.response.response ==0 && cmd_resp.response.cmd_id == cmd_id && (sid ==0xff || cmd_resp.response.sensor_id == sid)),500 ,10000000 ))
@@ -39,7 +39,7 @@ static void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor cmd_base.cmd.sub_cmd_value =1 ; cmd_base.cmd.sensor_id = info.sensor_idx; -writel (cmd_base.ul, privdata->mmio +AMD_C2P_MSG (0 )); +writel (cmd_base.ul, privdata->mmio +amd_get_c2p_val (privdata,0 )); }static void amd_stop_sensor (struct amd_mp2_dev *privdata,u16 sensor_idx)
@@ -52,8 +52,8 @@ static void amd_stop_sensor(struct amd_mp2_dev *privdata, u16 sensor_idx) cmd_base.cmd.sub_cmd_value =1 ; cmd_base.cmd.sensor_id = sensor_idx; -writeq (0x0 , privdata->mmio +AMD_C2P_MSG (1 )); -writel (cmd_base.ul, privdata->mmio +AMD_C2P_MSG (0 )); +writeq (0x0 , privdata->mmio +amd_get_c2p_val (privdata,1 )); +writel (cmd_base.ul, privdata->mmio +amd_get_c2p_val (privdata,0 )); }static void amd_stop_all_sensor (struct amd_mp2_dev *privdata)
@@ -66,7 +66,7 @@ static void amd_stop_all_sensor(struct amd_mp2_dev *privdata)/* 0xf indicates all sensors */ cmd_base.cmd.sensor_id =0xf ; -writel (cmd_base.ul, privdata->mmio +AMD_C2P_MSG (0 )); +writel (cmd_base.ul, privdata->mmio +amd_get_c2p_val (privdata,0 )); }static struct amd_mp2_ops amd_sfh_ops = {
Signature · 1 line
2.25.1
PATCH 6/6 HID: amd_sfh: Set the AMD SFH driver to depend on x86
In reply to Li MaFrom: Basavaraj Natikar <[email protected]>
Considering that amd_sfh exists only on AMD platforms, set the AMD SFH driver to depend on x86 to avoid build warnings or errors on other architectures, as shown below.
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c: In function 'amd_mp2_pci_probe':drivers/hid/amd-sfh-hid/amd_sfh_pcie.c:413:21: error: 'boot_cpu_data' undeclared (first use in this function); did you mean 'boot_cpu_hwid'?
413 | if (boot_cpu_data.x86 >= 0x1A)
| ^~~~~~~~~~~~~
| boot_cpu_hwid--- drivers/hid/amd-sfh-hid/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/hid/amd-sfh-hid/Kconfig +1 -0
@@ -6,6 +6,7 @@ menu "AMD SFH HID Support" config AMD_SFH_HID tristate "AMD Sensor Fusion Hub" depends on HID + depends on X86 help If you say yes to this option, support will be included for the AMD Sensor Fusion Hub.
Signature · 1 line
2.25.1
Quoted 11 lines · Li Ma
From: Basavaraj Natikar <[email protected]>
During the initialization sensors may take some time to respond. Hence, increase the sensor command timeouts in order to obtain status responses within a maximum timeout.
(Li: backport for s0ix issue, these patches have landed on 6.9)Co-developed-by Akshata MukundShetty <[email protected]>Signed-off-by Akshata MukundShetty <[email protected]>Signed-off-by Basavaraj Natikar <[email protected]>Signed-off-by Jiri Kosina <[email protected]>(cherry picked from commit 333861f4cca6d2c959ca2876587c42767853dccc)
All these patches seem to already have been merged, why am I receiving them again with some strange metadata?
Signature · 2 lines
Jiri Kosina Director, SUSE Labs Core
Quoted 15 lines · Jiri Kosina
Quoted 11 lines · Li Ma
From: Basavaraj Natikar <[email protected]>
During the initialization sensors may take some time to respond. Hence, increase the sensor command timeouts in order to obtain status responses within a maximum timeout.
(Li: backport for s0ix issue, these patches have landed on 6.9)Co-developed-by Akshata MukundShetty <[email protected]>Signed-off-by Akshata MukundShetty <[email protected]>Signed-off-by Basavaraj Natikar <[email protected]>Signed-off-by Jiri Kosina <[email protected]>(cherry picked from commit 333861f4cca6d2c959ca2876587c42767853dccc)
Quoted 2 lines
All these patches seem to already have been merged, why am I receiving them again with some strange metadata?
They were sent to amd-gfx as well since they are required for full functionality of the entire platform (including the iGPU). Sorry for the confusion.
Alex