All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Reinette Chatre <reinette.chatre@intel.com>, kristen@linux.intel.com
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Stable@vger.kernel.org
Subject: Re: [PATCH 1/3] hid-sensor: Fix suspend/resume delay
Date: Sat, 11 Jul 2015 18:25:02 +0100	[thread overview]
Message-ID: <55A1516E.7070300@kernel.org> (raw)
In-Reply-To: <029d68fb1cb4342167f10fea3663acf520233487.1436306952.git.reinette.chatre@intel.com>

On 07/07/15 23:35, Reinette Chatre wrote:
> From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> 
> 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>
been queued up for a while, but various day job issues mean I am somewhat
behind with sending pull requests.  Will get one out in the next day or so.

Jonathan
> ---
>  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 610fc98..5955110 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 0408421..cd224df 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;
> 


      reply	other threads:[~2015-07-11 17:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1436306952.git.reinette.chatre@intel.com>
2015-07-07 22:35 ` [PATCH 1/3] hid-sensor: Fix suspend/resume delay Reinette Chatre
2015-07-11 17:25   ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55A1516E.7070300@kernel.org \
    --to=jic23@kernel.org \
    --cc=Stable@vger.kernel.org \
    --cc=kristen@linux.intel.com \
    --cc=reinette.chatre@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.