From: Marek Vasut <marex@denx.de>
To: Raviteja Narayanam <rna@xilinx.com>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>
Cc: Michal Simek <michals@xilinx.com>,
Shubhrajyoti Datta <shubhraj@xilinx.com>,
Wolfram Sang <wsa@kernel.org>
Subject: Re: [PATCH 4/5] i2c: xiic: Switch from waitqueue to completion
Date: Mon, 29 Jun 2020 23:52:20 +0200 [thread overview]
Message-ID: <21266683-095d-b8b7-6a23-62a07db846cb@denx.de> (raw)
In-Reply-To: <SN4PR0201MB34863D361821EE403530A9CFCA6E0@SN4PR0201MB3486.namprd02.prod.outlook.com>
On 6/29/20 2:53 PM, Raviteja Narayanam wrote:
Hi,
[...]
>>>> @@ -703,23 +704,24 @@ static int xiic_xfer(struct i2c_adapter *adap,
>>>> struct i2c_msg *msgs, int num)
>>>> err = xiic_start_xfer(i2c, msgs, num);
>>>> if (err < 0) {
>>>> dev_err(adap->dev.parent, "Error xiic_start_xfer\n");
>>>> - goto out;
>>>> + return err;
>>>> }
>>>>
>>>> - if (wait_event_timeout(i2c->wait, (i2c->state == STATE_ERROR) ||
>>>> - (i2c->state == STATE_DONE), HZ)) {
>>>> - mutex_lock(&i2c->lock);
>>>> - err = (i2c->state == STATE_DONE) ? num : -EIO;
>>>> - goto out;
>>>> - } else {
>>>> - mutex_lock(&i2c->lock);
>>>> + err = wait_for_completion_interruptible_timeout(&i2c->completion,
>>>> + XIIC_I2C_TIMEOUT);
>>>
>>> This is causing random lock up of bus. Since it is "interruptible"
>>> API, once we enter Ctrl+C, It is coming out of wait state, the message
>> pointers are made NULL and the ongoing transaction is not completed.
>>> Can use " wait_for_completion_timeout" API in place of this.
>>>
>>>> + mutex_lock(&i2c->lock);
>>
>> So in case this is interrupted, we would have to somehow reset the controller ?
>
> Yes, but the cleanup is not straight forward because we do not know the exact state
> Of controller and the I2C bus. That’s why preferring a non-interruptible API.
Ah, right, that makes sense, thanks.
>> What sort of lockups do you see exactly ?
>
> There is an i2ctransfer going on (let's say a read of 255 bytes), we get interrupt everytime the Rx FIFO is full.
> While the controller is receiving data, if there is a signal, this is exiting abruptly and there is no STOP condition
> on the bus. So, no master can communicate on that bus further.
>
> Can you share some sort of test case,
>> so I can replicate it ?
>
> I have 3 scripts running with commands like below, and I am randomly giving Ctrl+C.
OK, thanks.
next prev parent reply other threads:[~2020-06-29 21:53 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-13 15:07 [PATCH 1/5] i2c: xiic: Fix broken locking on tx_msg Marek Vasut
2020-06-13 15:07 ` [PATCH 2/5] i2c: xiic: Drop broken interrupt handler Marek Vasut
2020-06-17 12:25 ` Shubhrajyoti Datta
2020-06-17 12:31 ` Marek Vasut
2020-06-26 12:13 ` Raviteja Narayanam
2020-06-28 23:41 ` Marek Vasut
2020-06-29 12:52 ` Raviteja Narayanam
2020-06-29 21:50 ` Marek Vasut
2020-07-08 15:23 ` Raviteja Narayanam
2020-08-19 17:42 ` Marek Vasut
2020-08-24 8:27 ` Raviteja Narayanam
2020-08-24 11:58 ` Marek Vasut
2020-08-25 9:44 ` Raviteja Narayanam
2020-08-25 20:50 ` Marek Vasut
2020-09-07 8:51 ` Raviteja Narayanam
2020-09-08 14:04 ` Marek Vasut
2020-09-11 10:28 ` Michal Simek
2020-06-13 15:07 ` [PATCH 3/5] i2c: xiic: Defer xiic_wakeup() and __xiic_start_xfer() in xiic_process() Marek Vasut
2020-06-26 12:13 ` Raviteja Narayanam
2020-07-08 15:23 ` Raviteja Narayanam
2020-06-13 15:07 ` [PATCH 4/5] i2c: xiic: Switch from waitqueue to completion Marek Vasut
2020-06-26 12:13 ` Raviteja Narayanam
2020-06-28 23:41 ` Marek Vasut
2020-06-29 12:53 ` Raviteja Narayanam
2020-06-29 21:52 ` Marek Vasut [this message]
2020-06-13 15:07 ` [PATCH 5/5] i2c: xiic: Only ever transfer single message Marek Vasut
2020-06-13 19:33 ` Wolfram Sang
2020-06-13 19:37 ` Marek Vasut
2020-06-13 19:42 ` Wolfram Sang
2020-07-13 8:37 ` Michal Simek
2020-06-26 12:14 ` Raviteja Narayanam
2020-06-26 12:11 ` [PATCH 1/5] i2c: xiic: Fix broken locking on tx_msg Raviteja Narayanam
2020-06-28 23:18 ` Marek Vasut
2020-06-29 12:52 ` Raviteja Narayanam
2020-07-08 15:23 ` Raviteja Narayanam
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=21266683-095d-b8b7-6a23-62a07db846cb@denx.de \
--to=marex@denx.de \
--cc=linux-i2c@vger.kernel.org \
--cc=michals@xilinx.com \
--cc=rna@xilinx.com \
--cc=shubhraj@xilinx.com \
--cc=wsa@kernel.org \
/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).