linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
To: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Alexandre Belloni
	<alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Christoph Baumann <cb-/RsSufbtIHM@public.gmane.org>,
	Fabio Estevam <r49496-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
	Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Torsten Fleischer
	<to-fleischer-zqRNUXuvxA0b1SvskN2V4Q@public.gmane.org>
Subject: Re: [PATCH V2 2/3] i2c: mxs: Rework the PIO mode operation
Date: Tue, 6 Aug 2013 15:35:50 +0200	[thread overview]
Message-ID: <201308061535.50470.marex@denx.de> (raw)
In-Reply-To: <20130806082029.GA2979@katana>

Dear Wolfram Sang,

> > > One question: Wouldn't it be more logical to have this patch first (fix
> > > pio) and then squash patches 1 and 3 as one on the top (add mx23 to now
> > > working pio)? I am not pushing too hard if this means a lot of work,
> > > but it sounds a bit more logical to me.
> > 
> > I would prefer to keep Juergens' patch separate from mine if you don't
> > mind to be clear on the authorship.
> 
> If you add both SoB, everything should be fine. We often work on someone
> else's patches, no?

I agree, but I still don't like squashing the two patches together. I forgot to 
mention it last time, but please, look at the patches one more time. Jurgens' 
does the DT change and mine fixes the PIO on MX23, I'd like to keep these 
changes separate.

> > > >  	if (msg->flags & I2C_M_RD) {
> > > > 
> > > > +		/*
> > > > +		 * PIO READ transfer:
> > > > +		 *
> > > > +		 * This transfer MUST be limited to 4 bytes maximum. It 
is not
> > > > +		 * possible to transfer more than four bytes via PIO, 
since we
> > > > +		 * can not in any way make sure we can read the data 
from the
> > > > +		 * DATA register fast enough. Besides, the RX FIFO is 
only four
> > > > +		 * bytes deep, thus we can only really read up to four 
bytes at
> > > > +		 * time. Finally, there is no bit indicating us that new 
data
> > > > +		 * arrived at the FIFO and can thus be fetched from the 
DATA
> > > > +		 * register.
> > > > +		 */
> > > > +		BUG_ON(msg->len > 4);
> > > 
> > > How could this happen? There is a check in mxs_i2c_xfer_msg.
> > 
> > It cannot happen, I added the check here to make sure when someone
> > becomes adventurous enough to start messing with these constants, it
> > will stop him early enough.
> 
> Then, add the comment to the check so ppl will notice there?

If I could add a big red flashing sign into the code stating "If you go over 4 
bytes here, a kitten will die", then by all means, I would add it. 
Unfortunatelly, there is no such thing possible.

> I like to
> keep BUG_ON sparse, since it is hard to tell if the occasion is really
> worth stopping the machine.

While I agree with you on this, I would also like for the kernel to check if 
someone accidentally screwed up and thoroughly warn him. We cannot continue 
anyway, because if more than 4 bytes are requested, the controller would simply 
not give us more than the last 4 bytes and this would result in an undefined 
behavior and data corruption during reception. We simply do not want that.

Maybe WARN_ONCE and return with error might just work?

Best regards,
Marek Vasut

  reply	other threads:[~2013-08-06 13:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-30 21:20 [PATCH RESEND 1/3] i2c: mxs: distinguish i.MX23 and i.MX28 based I2C controller Marek Vasut
     [not found] ` <1375219237-9594-1-git-send-email-marex-ynQEQJNshbs@public.gmane.org>
2013-07-30 21:20   ` [PATCH V2 2/3] i2c: mxs: Rework the PIO mode operation Marek Vasut
     [not found]     ` <1375219237-9594-2-git-send-email-marex-ynQEQJNshbs@public.gmane.org>
2013-08-05 10:36       ` Wolfram Sang
2013-08-05 11:11         ` Alexandre Belloni
2013-08-05 14:21         ` Marek Vasut
     [not found]           ` <201308051621.51146.marex-ynQEQJNshbs@public.gmane.org>
2013-08-06  8:20             ` Wolfram Sang
2013-08-06 13:35               ` Marek Vasut [this message]
     [not found]                 ` <201308061535.50470.marex-ynQEQJNshbs@public.gmane.org>
2013-08-06 21:13                   ` Wolfram Sang
2013-08-06 22:18                     ` Marek Vasut
     [not found]                       ` <201308070018.12773.marex-ynQEQJNshbs@public.gmane.org>
2013-08-07 14:14                         ` Wolfram Sang
2013-08-07 14:15                           ` Marek Vasut
2013-08-06  7:53         ` Shawn Guo
2013-08-15 17:08       ` Torsten Fleischer
     [not found]         ` <8771910.JgfUXiMKri-BVXpyJtzy6LO1Ldfs0Uenw@public.gmane.org>
2013-08-25 16:19           ` Marek Vasut
     [not found]             ` <201308251819.57351.marex-ynQEQJNshbs@public.gmane.org>
2013-08-26 15:32               ` Torsten Fleischer
     [not found]                 ` <11990305.k2WdFfCnhA-BVXpyJtzy6LO1Ldfs0Uenw@public.gmane.org>
2013-08-26 18:51                   ` Marek Vasut
     [not found]                     ` <201308262051.43123.marex-ynQEQJNshbs@public.gmane.org>
2013-09-02 17:00                       ` Torsten Fleischer
2013-07-30 21:20   ` [PATCH RESEND 3/3] i2c: mxs: Fix PIO mode on i.MX23 Marek Vasut

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=201308061535.50470.marex@denx.de \
    --to=marex-ynqeqjnshbs@public.gmane.org \
    --cc=alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=cb-/RsSufbtIHM@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=r49496-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=to-fleischer-zqRNUXuvxA0b1SvskN2V4Q@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.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).