From: Hartmut Knaack <knaack.h@gmx.de>
To: "Tirdea, Irina" <irina.tirdea@intel.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald <pmeerw@pmeerw.net>,
"Dogaru, Vlad" <vlad.dogaru@intel.com>
Subject: Re: [PATCH 6/8] iio:magnetometer:bmc150_magn: protect runtime_resume with mutex
Date: Wed, 22 Jul 2015 23:28:19 +0200 [thread overview]
Message-ID: <55B00AF3.4020609@gmx.de> (raw)
In-Reply-To: <1F3AC3675D538145B1661F571FE1805F2F06BBA6@irsmsx105.ger.corp.intel.com>
Tirdea, Irina schrieb am 20.07.2015 um 19:45:
>
>
>> -----Original Message-----
>> From: Hartmut Knaack [mailto:knaack.h@gmx.de]
>> Sent: 17 July, 2015 11:52
>> To: linux-iio@vger.kernel.org
>> Cc: Jonathan Cameron; Lars-Peter Clausen; Peter Meerwald; Tirdea, Irina; Dogaru, Vlad
>> Subject: [PATCH 6/8] iio:magnetometer:bmc150_magn: protect runtime_resume with mutex
>>
>> Protect bmc150_magn_runtime_resume() with a mutex, as done with other
>> suspend/resume functions.
>>
>> Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
>> ---
>> drivers/iio/magnetometer/bmc150_magn.c | 9 +++++++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c
>> index e1f804b2b244..ac0cdbde813b 100644
>> --- a/drivers/iio/magnetometer/bmc150_magn.c
>> +++ b/drivers/iio/magnetometer/bmc150_magn.c
>> @@ -1052,9 +1052,14 @@ static int bmc150_magn_runtime_resume(struct device *dev)
>> {
>> struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
>> struct bmc150_magn_data *data = iio_priv(indio_dev);
>> + int ret;
>>
>> - return bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_NORMAL,
>> - true);
>> + mutex_lock(&data->mutex);
>> + ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_NORMAL,
>> + true);
>> + mutex_unlock(&data->mutex);
>> +
>> + return ret;
>
> This function does not have mutex_lock/unlock because it is called with data->mutex locked.
> I should have added a comment to specify this.
>
> Whenever we wake up the device, bmc150_magn_set_power_state is called after locking
> data->mutex. This in turn calls pm_runtime_get_sync which will immediately call
> bmc150_magn_runtime_resume. Trying to lock the mutex here would lead to a deadlock
> (e.g. when trying to read a value through sysfs _raw).
>
> Since this driver uses autosuspend delay, the situation is different for runtime suspend since
> that is called after 2 seconds in a separate thread. This is why there is a mutex locked in runtime
> suspend but not in runtime resume.
>
Yes, please add such a comment. As for me, it seems I have to dig a bit
deeper into power management magic - maybe another day ;-)
Thanks,
Hartmut
>> }
>> #endif
>>
>> --
>> 2.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2015-07-22 21:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-17 8:52 [PATCH 0/8] bmc150_magn fix and cleanup Hartmut Knaack
2015-07-17 8:52 ` [PATCH 1/8] iio:magnetometer:bmc150_magn: add regmap dependency Hartmut Knaack
2015-07-19 10:02 ` Jonathan Cameron
2015-07-17 8:52 ` [PATCH 2/8] iio:magnetometer:bmc150_magn: sort entry alphabetically Hartmut Knaack
2015-07-19 10:03 ` Jonathan Cameron
2015-08-12 21:18 ` Jonathan Cameron
2015-07-17 8:52 ` [PATCH 3/8] iio:magnetometer:bmc150_magn: output intended variable Hartmut Knaack
2015-07-19 10:03 ` Jonathan Cameron
2015-07-17 8:52 ` [PATCH 4/8] iio:magnetometer:bmc150_magn: replace magic value Hartmut Knaack
2015-07-19 10:05 ` Jonathan Cameron
2015-07-17 8:52 ` [PATCH 5/8] iio:magnetometer:bmc150_magn: add error handling on gpio probe Hartmut Knaack
2015-07-19 10:06 ` Jonathan Cameron
2015-07-20 17:36 ` Tirdea, Irina
2015-07-20 17:44 ` Jonathan Cameron
2015-07-17 8:52 ` [PATCH 6/8] iio:magnetometer:bmc150_magn: protect runtime_resume with mutex Hartmut Knaack
2015-07-19 10:08 ` Jonathan Cameron
2015-07-20 17:45 ` Tirdea, Irina
2015-07-22 21:28 ` Hartmut Knaack [this message]
2015-07-17 8:52 ` [PATCH 7/8] iio:magnetometer:bmc150_magn: expand mutex in trigger_handler Hartmut Knaack
2015-07-20 17:48 ` Tirdea, Irina
2015-08-02 17:04 ` Jonathan Cameron
2015-07-17 8:52 ` [PATCH 8/8] iio:magnetometer:bmc150_magn: use descriptive name for mask Hartmut Knaack
2015-07-20 17:52 ` Tirdea, Irina
2015-08-02 17:05 ` Jonathan Cameron
2015-07-20 17:30 ` [PATCH 0/8] bmc150_magn fix and cleanup Tirdea, Irina
2015-07-20 17:48 ` Jonathan Cameron
2015-07-22 14:50 ` Tirdea, Irina
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=55B00AF3.4020609@gmx.de \
--to=knaack.h@gmx.de \
--cc=irina.tirdea@intel.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=vlad.dogaru@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.