stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* patch "hid-sensor: Fix suspend/resume delay" added to staging-linus
@ 2015-07-13 21:18 gregkh
  2015-07-14  2:18 ` Brown, Len
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2015-07-13 21:18 UTC (permalink / raw)
  To: srinivas.pandruvada, Stable, jic23, len.brown


This is a note to let you know that I've just added the patch titled

    hid-sensor: Fix suspend/resume delay

to my staging git tree which can be found at
    git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-linus branch.

The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the
next -rc kernel release.

If you have any questions about this process, please let me know.


>From 1e25aa9641e8f3fa39cd5e46b4afcafd7f12a44b Mon Sep 17 00:00:00 2001
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date: Mon, 1 Jun 2015 16:36:27 -0700
Subject: 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.

Note this is a regression fix as the increase in suspend / resume
times can be substantial (report of 8 seconds on Len's laptop!)

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Tested-by: Len Brown <len.brown@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 11 ++++++++++-
 include/linux/hid-sensor-hub.h                      |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 610fc98f88ef..595511022795 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -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
 }
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index 0408421d885f..cd224dfd94d8 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -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;
-- 
2.4.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: patch "hid-sensor: Fix suspend/resume delay" added to staging-linus
  2015-07-13 21:18 gregkh
@ 2015-07-14  2:18 ` Brown, Len
  0 siblings, 0 replies; 3+ messages in thread
From: Brown, Len @ 2015-07-14  2:18 UTC (permalink / raw)
  To: gregkh@linuxfoundation.org, srinivas.pandruvada@linux.intel.com,
	Stable@vger.kernel.org, jic23@kernel.org

This patch fixes a regression starting in Linux-4.0,
and thus should also be targeted to -stable.

I do not recommend that distros ship Linux Linux-4.0 or Linux-4.1
to users until this regression is fixed -- as some users
will much prefer the kernel without the regression.

thanks,
-Len


> -----Original Message-----
> From: gregkh@linuxfoundation.org [mailto:gregkh@linuxfoundation.org]
> Sent: Monday, July 13, 2015 5:19 PM
> To: srinivas.pandruvada@linux.intel.com; Stable@vger.kernel.org;
> jic23@kernel.org; Brown, Len
> Subject: patch "hid-sensor: Fix suspend/resume delay" added to staging-
> linus
> 
> 
> This is a note to let you know that I've just added the patch titled
> 
>     hid-sensor: Fix suspend/resume delay
> 
> to my staging git tree which can be found at
>     git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
> in the staging-linus branch.
> 
> The patch will show up in the next release of the linux-next tree
> (usually sometime within the next 24 hours during the week.)
> 
> The patch will hopefully also be merged in Linus's tree for the
> next -rc kernel release.
> 
> If you have any questions about this process, please let me know.
> 
> 
> From 1e25aa9641e8f3fa39cd5e46b4afcafd7f12a44b Mon Sep 17 00:00:00 2001
> From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Date: Mon, 1 Jun 2015 16:36:27 -0700
> Subject: 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.
> 
> Note this is a regression fix as the increase in suspend / resume
> times can be substantial (report of 8 seconds on Len's laptop!)
> 
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Tested-by: Len Brown <len.brown@intel.com>
> Cc: <Stable@vger.kernel.org>
> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
> ---
>  drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 11 ++++++++++-
>  include/linux/hid-sensor-hub.h                      |  1 +
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> index 610fc98f88ef..595511022795 100644
> --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> @@ -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
>  }
> diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-
> hub.h
> index 0408421d885f..cd224dfd94d8 100644
> --- a/include/linux/hid-sensor-hub.h
> +++ b/include/linux/hid-sensor-hub.h
> @@ -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;
> --
> 2.4.5
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* patch "hid-sensor: Fix suspend/resume delay" added to staging-linus
@ 2015-07-23 20:33 gregkh
  0 siblings, 0 replies; 3+ messages in thread
From: gregkh @ 2015-07-23 20:33 UTC (permalink / raw)
  To: srinivas.pandruvada, Stable, jic23, len.brown


This is a note to let you know that I've just added the patch titled

    hid-sensor: Fix suspend/resume delay

to my staging git tree which can be found at
    git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-linus branch.

The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the
next -rc kernel release.

If you have any questions about this process, please let me know.


>From 88cc7b4eee1e7b9bca1a64dae5adaa044cf72312 Mon Sep 17 00:00:00 2001
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date: Mon, 1 Jun 2015 16:36:27 -0700
Subject: 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.

Note this is a regression fix as the increase in suspend / resume
times can be substantial (report of 8 seconds on Len's laptop!)

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Tested-by: Len Brown <len.brown@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 11 ++++++++++-
 include/linux/hid-sensor-hub.h                      |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 610fc98f88ef..595511022795 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -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
 }
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index 0042bf330b99..c02b5ce6c5cd 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -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;
-- 
2.4.6



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-23 20:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-23 20:33 patch "hid-sensor: Fix suspend/resume delay" added to staging-linus gregkh
  -- strict thread matches above, loose matches on Subject: below --
2015-07-13 21:18 gregkh
2015-07-14  2:18 ` Brown, Len

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).