Skip to content

Commit 7bcfdab

Browse files
superm1bentiss
authored andcommitted
HID: amd_sfh: if no sensors are enabled, clean up
It was reported that commit b300667 ("HID: amd_sfh: Disable the interrupt for all command") had caused increased resume time on HP Envy x360. Before this commit 3 sensors were reported, but they were not actually functional. After this commit the sensors are no longer reported, but also the resume time increased. To avoid this problem explicitly look for the number of disabled sensors. If all the sensors are disabled, clean everything up. Fixes: b300667 ("HID: amd_sfh: Disable the interrupt for all command") Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2115 Reported-by: Xaver Hugl <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Acked-by: Basavaraj Natikar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent 690eb7d commit 7bcfdab

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

drivers/hid/amd-sfh-hid/amd_sfh_client.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
227227
cl_data->num_hid_devices = amd_mp2_get_sensor_num(privdata, &cl_data->sensor_idx[0]);
228228
if (cl_data->num_hid_devices == 0)
229229
return -ENODEV;
230+
cl_data->is_any_sensor_enabled = false;
230231

231232
INIT_DELAYED_WORK(&cl_data->work, amd_sfh_work);
232233
INIT_DELAYED_WORK(&cl_data->work_buffer, amd_sfh_work_buffer);
@@ -287,6 +288,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
287288
status = amd_sfh_wait_for_response
288289
(privdata, cl_data->sensor_idx[i], SENSOR_ENABLED);
289290
if (status == SENSOR_ENABLED) {
291+
cl_data->is_any_sensor_enabled = true;
290292
cl_data->sensor_sts[i] = SENSOR_ENABLED;
291293
rc = amdtp_hid_probe(cl_data->cur_hid_dev, cl_data);
292294
if (rc) {
@@ -301,19 +303,26 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
301303
cl_data->sensor_sts[i]);
302304
goto cleanup;
303305
}
306+
} else {
307+
cl_data->sensor_sts[i] = SENSOR_DISABLED;
308+
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
309+
cl_data->sensor_idx[i],
310+
get_sensor_name(cl_data->sensor_idx[i]),
311+
cl_data->sensor_sts[i]);
304312
}
305313
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
306314
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
307315
cl_data->sensor_sts[i]);
308316
}
309-
if (mp2_ops->discovery_status && mp2_ops->discovery_status(privdata) == 0) {
317+
if (!cl_data->is_any_sensor_enabled ||
318+
(mp2_ops->discovery_status && mp2_ops->discovery_status(privdata) == 0)) {
310319
amd_sfh_hid_client_deinit(privdata);
311320
for (i = 0; i < cl_data->num_hid_devices; i++) {
312321
devm_kfree(dev, cl_data->feature_report[i]);
313322
devm_kfree(dev, in_data->input_report[i]);
314323
devm_kfree(dev, cl_data->report_descr[i]);
315324
}
316-
dev_warn(dev, "Failed to discover, sensors not enabled\n");
325+
dev_warn(dev, "Failed to discover, sensors not enabled is %d\n", cl_data->is_any_sensor_enabled);
317326
return -EOPNOTSUPP;
318327
}
319328
schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP));

drivers/hid/amd-sfh-hid/amd_sfh_hid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct amd_input_data {
3232
struct amdtp_cl_data {
3333
u8 init_done;
3434
u32 cur_hid_dev;
35+
bool is_any_sensor_enabled;
3536
u32 hid_dev_count;
3637
u32 num_hid_devices;
3738
struct device_info *hid_devices;

0 commit comments

Comments
 (0)