mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Gerald Loacker <gerald.loacker@wolfvision.net>
To: Sascha Hauer <sha@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/4] i2c: rockchip: ignore i2c transfers when another transfer is running
Date: Mon, 11 Sep 2023 13:46:38 +0200	[thread overview]
Message-ID: <d42f521a-08b3-14c2-3883-917259632bd2@wolfvision.net> (raw)
In-Reply-To: <20230908131305.GI637806@pengutronix.de>

Hi Sascha,

Am 08.09.2023 um 15:13 schrieb Sascha Hauer:
> On Fri, Sep 08, 2023 at 01:55:40PM +0200, Sascha Hauer wrote:
>> On Fri, Sep 08, 2023 at 01:51:32PM +0200, Sascha Hauer wrote:
>>> On Fri, Sep 08, 2023 at 12:16:47PM +0200, Gerald Loacker wrote:
>>>> It may happen that an i2c transfer is requested by a callback although
>>>> there is an other i2c transfer running. In this case do not interrupt the
>>>> transfer and return with an error.
>>>>
>>>> Signed-off-by: Gerald Loacker <gerald.loacker@wolfvision.net>
>>>> ---
>>>>  drivers/i2c/busses/i2c-rockchip.c | 14 +++++++++++++-
>>>>  1 file changed, 13 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/i2c/busses/i2c-rockchip.c b/drivers/i2c/busses/i2c-rockchip.c
>>>> index 1bca3e9913..a869b9d0b7 100644
>>>> --- a/drivers/i2c/busses/i2c-rockchip.c
>>>> +++ b/drivers/i2c/busses/i2c-rockchip.c
>>>> @@ -369,7 +369,19 @@ static int rockchip_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs,
>>>>  {
>>>>  	struct rk_i2c *i2c = to_rk_i2c(adapter);
>>>>  	struct device *dev = &adapter->dev;
>>>> -	int i, ret = 0;
>>>> +	struct i2c_regs *regs = i2c->regs;
>>>> +	int i, ret = 0, val;
>>>> +
>>>> +	val = readl(&regs->con);
>>>> +	if (val & I2C_CON_EN) {
>>>> +		val = readl(&regs->con);
>>>> +		if (val & I2C_IPD_ALL_CLEAN) {
>>>> +			dev_dbg(dev,
>>>> +				"i2c_xfer: %d messages dropped due to pending interrupts\n",
>>>> +				nmsgs);
>>>> +			return -EAGAIN;
>>>> +		}
>>>> +	}
>>>
>>> Can you have a look how this can happen? Normally this should only
>>> happen if you have a heartbeat LED behind a I2C GPIO expander or some
>>> other unusual setup. Adding a dump_stack() next to the dev_dbg() call
>>> might give a clue.
>>
>> I just realized you sent some ksz9477 along with this series. Are you
>> using that in I2C mode? In that case it could be the periodic link check
>> that does I2C accesses in the background.
> 
> Assuming that this is indeed your problem I have just sent a series that
> could fix this issue. It's untested yet, please give it a try.
> 

Yes, this solves the problem of interrupted I2C transfers from the
periodic link check and also makes the ksz9477 patches obsolete. Thanks!

Gerald

> Sascha
> 



  reply	other threads:[~2023-09-11 11:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 10:16 [PATCH 0/4] Fix rockchip I2C bus Gerald Loacker
2023-09-08 10:16 ` [PATCH 1/4] i2c: rockchip: fix i2c stop condition Gerald Loacker
2023-09-08 13:53   ` Sascha Hauer
2023-09-12  5:45     ` Gerald Loacker
2023-09-12  6:03       ` Sascha Hauer
2023-09-08 10:16 ` [PATCH 2/4] i2c: rockchip: ignore i2c transfers when another transfer is running Gerald Loacker
2023-09-08 11:51   ` Sascha Hauer
2023-09-08 11:55     ` Sascha Hauer
2023-09-08 13:13       ` Sascha Hauer
2023-09-11 11:46         ` Gerald Loacker [this message]
2023-09-08 10:16 ` [PATCH 3/4] net: ksz9477: propagate phy read error Gerald Loacker
2023-09-08 11:59   ` Ahmad Fatoum
2023-09-08 12:32     ` Oleksij Rempel
2023-09-08 10:16 ` [PATCH 4/4] net: ksz9477: propagate phy write error Gerald Loacker

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=d42f521a-08b3-14c2-3883-917259632bd2@wolfvision.net \
    --to=gerald.loacker@wolfvision.net \
    --cc=barebox@lists.infradead.org \
    --cc=sha@pengutronix.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