Fix suspend/resume delay
Subsystems (3)
Srinivas Pandruvada
maintainerPATCH 1/1 Fix suspend/resume delay
v1
Simplified patch to match user request before runtime resume. This is very similar to USB xhci where runtime resume function is checking any outstanding XHCI request to wake up before proceeding to resume.
v0
Optimize using Linux PM notifiers to get notification of PM states
Srinivas Pandruvada (1):
hid-sensor: Fix suspend/resume delay
drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 11 ++++++++++- include/linux/hid-sensor-hub.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.1.4
Srinivas Pandruvada
maintainerPATCH 1/1 hid-sensor: Fix suspend/resume delay
By default all the sensors are runtime suspended state (lowest power state). During Linux suspend process, all the run time suspended devices are resumed and then suspended. This caused all sensors to power up and introduced delay in suspend time, when we introduced runtime PM for HID sensors. The opposite process happens during resume process.
To fix this, we do powerup process of the sensors only when the request is issued from user (raw or tiggerred). In this way when runtime, resume calls for powerup it will simply return as this will not match user requested state.
--- drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 11 ++++++++++- include/linux/hid-sensor-hub.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +10 -1
@@ -36,6 +36,8 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)s32 poll_value =0 ;if (state) { +if (!atomic_read (&st->user_requested_state)) +return 0 ;if (sensor_hub_device_open (st->hsdev))return -EIO ;
@@ -52,8 +54,12 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state) poll_value =hid_sensor_read_poll_value (st); }else { -if (!atomic_dec_and_test (&st->data_ready)) +int val; + + val =atomic_dec_if_positive (&st->data_ready); +if (val <0 )return 0 ; +sensor_hub_device_close (st->hsdev); state_val = hid_sensor_get_usage_index(st->hsdev, st->power_state.report_id,
@@ -92,9 +98,11 @@ EXPORT_SYMBOL(hid_sensor_power_state);int hid_sensor_power_state (struct hid_sensor_common *st,bool state) { +#ifdef CONFIG_PM int ret; +atomic_set (&st->user_requested_state, state);if (state) ret =pm_runtime_get_sync (&st->pdev->dev);else {
@@ -109,6 +117,7 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)return 0 ;#else +atomic_set (&st->user_requested_state, state);return _hid_sensor_power_state (st, state);#endif }
include/linux/hid-sensor-hub.h +1 -0
@@ -230,6 +230,7 @@ struct hid_sensor_common {struct platform_device *pdev;unsigned usage_id;atomic_t data_ready; +atomic_t user_requested_state;struct iio_trigger *trigger;struct hid_sensor_hub_attribute_info poll;struct hid_sensor_hub_attribute_info report_state;
Signature · 1 line
2.1.4
RE: [PATCH v1] hid-sensor: Fix suspend/resume delay
This regression increased the resume time on my Dell XPS11 laptop by 8 seco= nds.
This patch makes that regression go away.
I assume that this is targeted for .stable?
thanks,
Jonathan Cameron
maintainerRe: [PATCH v1] hid-sensor: Fix suspend/resume delay
Quoted 8 lines · Len
This regression increased the resume time on my Dell XPS11 laptop by 8 seconds. This patch makes that regression go away.
I assume that this is targeted for .stable?
thanks,
Tested-by Len Brown <[email protected]>
Applied to the fixes-togreg branch of iio.git which will get pushed out when I am back on a network. Thanks for providing this number Len. I've added a note to the commit to make it clear that the timing regression was substantial and marked it for stable.
Thanks,
Jonathan