From: Peter Rosin <peda@lysator.liu.se>
To: Daniel Baluta <daniel.baluta@intel.com>
Cc: Peter Rosin <peda@axentia.se>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Wolfram Sang <wsa@the-dreams.de>, Ge Gao <GGao@invensense.com>,
Jonathan Cameron <jic23@kernel.org>,
Peter Rosin <peda@lysator.liu.se>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org
Subject: Re: [RFC PATCH 0/9] iio: Fix ABBA deadlock in inv-mpu6050
Date: Fri, 4 Mar 2016 00:09:58 +0100 [thread overview]
Message-ID: <1457046598-15367-1-git-send-email-peda@lysator.liu.se> (raw)
In-Reply-To: <CAEnQRZCKJuYTxckGzcFvyTfvonwBqQW37D7Y5RqyeBbd2iPkKA@mail.gmail.com>
From: Peter Rosin <peda@axentia.se>
Hi Daniel,
Daniel Baluta wrote:
>On Mon, Feb 22, 2016 at 1:17 AM, Wolfram Sang wrote:
>> On Thu, Feb 18, 2016 at 05:53:05PM +0200, Daniel Baluta wrote:
>>> Sending this as an RFC because I don't know if style fixes are appropriate
>>> for this driver and also not sure if deadlock fix is the best solution.
*snip*
>> We recently had a bigger patch series fixing locking problems related to
>> muxes. I sadly didn't have the time to review it. Can you have a look if
>> it helps your case?
>>
>> http://thread.gmane.org/gmane.linux.drivers.i2c/26169
>
> Tested this and the deadlock is still there :(.
I assume that when you tested v3 of my series, you did nothing
to actually make use of the new stuff available in the mux-core?
If you didn't do anything to make use of the new stuff, the
driver should behave as before.
So, please try this patch on top of my recently posted v4 of the
"i2c mux cleanup and locking update" series [1]. I have not tested
this patch at all, but I have the feeling it could do the trick...
Cheers,
Peter
[1] https://marc.info/?l=linux-iio&m=145704469628330&w=3
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 642f22013d17..02b56e631973 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -79,35 +79,6 @@ int inv_mpu6050_write_reg(struct inv_mpu6050_state *st, int reg, u8 d)
return i2c_smbus_write_i2c_block_data(st->client, reg, 1, &d);
}
-/*
- * The i2c read/write needs to happen in unlocked mode. As the parent
- * adapter is common. If we use locked versions, it will fail as
- * the mux adapter will lock the parent i2c adapter, while calling
- * select/deselect functions.
- */
-static int inv_mpu6050_write_reg_unlocked(struct inv_mpu6050_state *st,
- u8 reg, u8 d)
-{
- int ret;
- u8 buf[2];
- struct i2c_msg msg[1] = {
- {
- .addr = st->client->addr,
- .flags = 0,
- .len = sizeof(buf),
- .buf = buf,
- }
- };
-
- buf[0] = reg;
- buf[1] = d;
- ret = __i2c_transfer(st->client->adapter, msg, 1);
- if (ret != 1)
- return ret;
-
- return 0;
-}
-
static int inv_mpu6050_select_bypass(struct i2c_mux_core *muxc, u32 chan_id)
{
struct iio_dev *indio_dev = i2c_mux_priv(muxc);
@@ -117,8 +88,7 @@ static int inv_mpu6050_select_bypass(struct i2c_mux_core *muxc, u32 chan_id)
/* Use the same mutex which was used everywhere to protect power-op */
mutex_lock(&indio_dev->mlock);
if (!st->powerup_count) {
- ret = inv_mpu6050_write_reg_unlocked(st, st->reg->pwr_mgmt_1,
- 0);
+ ret = inv_mpu6050_write_reg(st, st->reg->pwr_mgmt_1, 0);
if (ret)
goto write_error;
@@ -126,9 +96,9 @@ static int inv_mpu6050_select_bypass(struct i2c_mux_core *muxc, u32 chan_id)
}
if (!ret) {
st->powerup_count++;
- ret = inv_mpu6050_write_reg_unlocked(st, st->reg->int_pin_cfg,
- st->client->irq |
- INV_MPU6050_BIT_BYPASS_EN);
+ ret = inv_mpu6050_write_reg(st, st->reg->int_pin_cfg,
+ st->client->irq |
+ INV_MPU6050_BIT_BYPASS_EN);
}
write_error:
mutex_unlock(&indio_dev->mlock);
@@ -143,12 +113,11 @@ static int inv_mpu6050_deselect_bypass(struct i2c_mux_core *muxc, u32 chan_id)
mutex_lock(&indio_dev->mlock);
/* It doesn't really mattter, if any of the calls fails */
- inv_mpu6050_write_reg_unlocked(st, st->reg->int_pin_cfg,
- st->client->irq);
+ inv_mpu6050_write_reg(st, st->reg->int_pin_cfg, st->client->irq);
st->powerup_count--;
if (!st->powerup_count)
- inv_mpu6050_write_reg_unlocked(st, st->reg->pwr_mgmt_1,
- INV_MPU6050_BIT_SLEEP);
+ inv_mpu6050_write_reg(st, st->reg->pwr_mgmt_1,
+ INV_MPU6050_BIT_SLEEP);
mutex_unlock(&indio_dev->mlock);
return 0;
@@ -839,8 +808,8 @@ static int inv_mpu_probe(struct i2c_client *client,
goto out_remove_trigger;
}
- st->muxc = i2c_mux_one_adapter(client->adapter, &client->dev, 0, 0,
- 0, 0, 0,
+ st->muxc = i2c_mux_one_adapter(client->adapter, &client->dev, 0,
+ I2C_CONTROLLED_MUX, 0, 0, 0,
inv_mpu6050_select_bypass,
inv_mpu6050_deselect_bypass);
if (IS_ERR(st->muxc)) {
--
2.1.4
next prev parent reply other threads:[~2016-03-03 23:10 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-18 15:53 [RFC PATCH 0/9] iio: Fix ABBA deadlock in inv-mpu6050 Daniel Baluta
2016-02-18 15:53 ` [RFC PATCH 1/9] iio: imu: inv_mpu6050: Fix multiline comments style Daniel Baluta
2016-02-21 20:36 ` Jonathan Cameron
2016-02-18 15:53 ` [RFC PATCH 2/9] iio: imu: inv_mpu6050: Fix Yoda conditions Daniel Baluta
[not found] ` <1455810794-3188-3-git-send-email-daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-02-19 9:09 ` Crt Mori
[not found] ` <CAKv63us92Epe0go9JGNScbeOepg3_j8RyW9w2qgN01Jvnj3sUQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-21 20:38 ` Jonathan Cameron
2016-03-01 21:23 ` Wolfram Sang
2016-02-18 15:53 ` [RFC PATCH 3/9] iio: imu: inv_mpu6050: Fix newlines to make code easier to read Daniel Baluta
2016-02-21 20:38 ` Jonathan Cameron
2016-02-18 15:53 ` [RFC PATCH 4/9] iio: imu: inv_mpu6050: Remove unnecessary parentheses Daniel Baluta
2016-02-21 20:39 ` Jonathan Cameron
2016-02-18 15:53 ` [RFC PATCH 5/9] iio: imu: inv_mpu6050: Delete space before comma Daniel Baluta
2016-02-18 15:53 ` [RFC PATCH 6/9] iio: imu: inv_mpu6050: Fix code indent for if statement Daniel Baluta
2016-02-21 20:40 ` Jonathan Cameron
2016-02-18 15:53 ` [RFC PATCH 7/9] iio: imu: inv_mpu6050: Fix alignment with open parenthesis Daniel Baluta
[not found] ` <1455810794-3188-8-git-send-email-daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-02-21 20:41 ` Jonathan Cameron
[not found] ` <56CA2101.8050805-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-02-21 20:59 ` Joe Perches
[not found] ` <1456088384.31061.2.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2016-02-21 21:08 ` Jonathan Cameron
2016-02-18 15:53 ` [RFC PATCH 8/9] i2c: i2c-mux: Allow for NULL select callback Daniel Baluta
2016-03-01 20:30 ` Wolfram Sang
2016-03-01 20:38 ` Daniel Baluta
2016-02-18 15:53 ` [RFC PATCH 9/9] iio: imu: inv_mpu6050: Fix deadlock between i2c adapter lock and mpu lock Daniel Baluta
2016-02-18 18:17 ` Srinivas Pandruvada
[not found] ` <1455819430.7375.192.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-02-19 20:17 ` Ge Gao
[not found] ` <1455810794-3188-10-git-send-email-daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-03-01 20:50 ` Wolfram Sang
2016-03-02 16:33 ` Daniel Baluta
[not found] ` <CAEnQRZAF-tAjDwJkUNEVQXYqWDt7RsH2bH81UBAMUhsoWEt73g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-02 17:06 ` Wolfram Sang
2016-02-21 23:17 ` [RFC PATCH 0/9] iio: Fix ABBA deadlock in inv-mpu6050 Wolfram Sang
2016-02-22 9:43 ` Daniel Baluta
2016-02-26 15:52 ` Daniel Baluta
2016-03-03 23:09 ` Peter Rosin [this message]
[not found] ` <1457046598-15367-1-git-send-email-peda-SamgB31n2u5IcsJQ0EH25Q@public.gmane.org>
2016-03-04 10:20 ` Daniel Baluta
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=1457046598-15367-1-git-send-email-peda@lysator.liu.se \
--to=peda@lysator.liu.se \
--cc=GGao@invensense.com \
--cc=daniel.baluta@intel.com \
--cc=jic23@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=wsa@the-dreams.de \
/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 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).