linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Christian Eggers <ceggers@arri.de>
Cc: Fabio Estevam <festevam@gmail.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Oleksij Rempel <linux@rempel-privat.de>,
	NXP Linux Team <linux-imx@nxp.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Shawn Guo <shawnguo@kernel.org>,
	linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org
Subject: Re: [PATCH 1/3] i2c: imx: Fix reset of I2SR_IAL flag
Date: Fri, 2 Oct 2020 12:21:03 +0200	[thread overview]
Message-ID: <20201002102103.36uqajmvl5w2dqdv@pengutronix.de> (raw)
In-Reply-To: <3615207.ozermb6hxN@n95hx1g2>

[-- Attachment #1: Type: text/plain, Size: 3856 bytes --]

Hello Christian,

On Fri, Oct 02, 2020 at 10:01:30AM +0200, Christian Eggers wrote:
> On Friday, 25 September 2020, 10:11:01 CEST, Uwe Kleine-König wrote:
> > On Thu, Sep 17, 2020 at 04:13:50PM +0200, Christian Eggers wrote:
> > IMHO the intention here (and also what happens on i.MX) is that exactly
> > the AL interrupt pending bit should be cleared and the IF irq is
> > supposed to be untouched.
> 
> Yes.
> 
> > Given there are only two irq flags in the I2SR register (which is called
> > IBSR on Vybrid) ...
> 
> Vybrid:
> =======
> +-------+-----+------+-----+------+-----+-----+------+------+
> | BIT   |  7  |  6   |  5  |  4   |  3  |  2  |  1   |  0   |
> +-------+-----+------+-----+------+-----+-----+------+------+
> | READ  | TCF | IAAS | IBB | IBAL |  0  | SRW | IBIF | RXAK |
> +-------+-----+------+-----+------+-----+-----+------+------+
> | WRITE |  -  |  -   |  -  | W1C  |  -  |  -  | W1C  |  -   |
> +-------+-----+------+-----+-^^^--+-----+-----+-^^^--+------+
> 
> i.MX:
> =======
> +-------+-----+------+-----+------+-----+-----+------+------+
> | BIT   |  7  |  6   |  5  |  4   |  3  |  2  |  1   |  0   |
> +-------+-----+------+-----+------+-----+-----+------+------+
> | READ  | ICF | IAAS | IBB | IAL  |  0  | SRW | IIF  | RXAK |
> +-------+-----+------+-----+------+-----+-----+------+------+
> | WRITE |  -  |  -   |  -  | W0C  |  -  |  -  | W0C  |  -   |
> +-------+-----+------+-----+-^^^--+-----+-----+-^^^--+------+
> 
> 
> > ... the status quo (i.e. without your patch) is:
> >
> >   On i.MX IAL is cleared
> 
> Yes
> 
> >   On Vybrid IIF (which is called IBIF there) is cleared.
> If IBIF is set, then it's cleared (probably by accident).
> But in the "if (temp & I2SR_IAL)" condition, I focus on
> the IBAL flag, not IBIF.
> 
> > With your patch we get:
> >
> >   On i.MX IAL is cleared
> 
> Yes
> 
> >   On Vybrid both IIF (aka IBIF) and IAL (aka IBAL) are cleared.
> Agree. IBAL is cleared by intention, IBIF by accident (if set).
> Do you see any problem if IBIF is also cleared?

Yes. If there is a real problem I'm not sure, but it's enough of an
issue that there are possible side effects on Vybrid. I refuse to think
about real problems given that it is so easy to make it right.

> > To get it right for both SoC types you have to do (e.g.):
> >
> >       temp = ~i2c_imx->hwdata->i2sr_clr_opcode ^ I2SR_IAL;
> Sorry, even if this is correct, it looks hard to understand for me.

Maybe a comment would be appropriate, something like:

	/*
	 * i2sr_clr_opcode is the value to clear all interrupts. Here we
	 * want to clear no irq but I2SR_IAL, so we write
	 * ~i2sr_clr_opcode with just the I2SR_IAL bit toggled.
	 */

Maybe put this comment together with the code in a new function to have
it only once.

> > (and in i2c_imx_isr() the same using I2SR_IIF instead of I2SR_IAL
> > because there currently IAL might be cleared by mistake on Vybrid).
> >
> > I considered creating a patch, but as I don't have a Vybrid on my desk
> > and on i.MX there is no change, I let you do this.
> I also don't own a Vybrid system. I consider my patch correct in terms of
> clearing the IBAL flag (which was wrong before). Additional work may be
> useful for NOT clearing the other status flag. I also would like to keep
> this task for somebody who owns a Vybrid system. But the other patches
> in this series fixes some more important problems, so maybe you could
> give your acknowledge anyhow.

No, please don't replace one bug found by another (now) known bug. Still
more given that the newly introduced bug is much harder to trigger and
debug.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-10-02 10:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-17 12:20 [PATCH 0/3] i2c: imx: Fix handling of arbitration loss Christian Eggers
2020-09-17 12:20 ` [PATCH 1/3] i2c: imx: Fix reset of I2SR_IAL flag Christian Eggers
2020-09-17 14:02   ` Uwe Kleine-König
2020-09-17 14:13     ` Christian Eggers
2020-09-25  8:11       ` Uwe Kleine-König
2020-10-02  8:01         ` Christian Eggers
2020-10-02 10:21           ` Uwe Kleine-König [this message]
2020-09-17 12:20 ` [PATCH 2/3] i2c: imx: Check for I2SR_IAL after every byte Christian Eggers
2020-09-17 12:20 ` [PATCH 3/3] i2c: imx: Don't generate STOP condition if arbitration has been lost Christian Eggers
2020-09-25  7:03 ` [PATCH 0/3] i2c: imx: Fix handling of arbitration loss Oleksij Rempel

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=20201002102103.36uqajmvl5w2dqdv@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=ceggers@arri.de \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rempel-privat.de \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=stable@vger.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).