lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100301191954.GA1811@pengutronix.de>
Date:	Mon, 1 Mar 2010 20:19:54 +0100
From:	Luotao Fu <l.fu@...gutronix.de>
To:	Kevin Wells <kevin.wells@....com>
Cc:	Luotao Fu <l.fu@...gutronix.de>,
	Vitaly Wool <vitalywool@...il.com>,
	Jean Delvare <khali@...ux-fr.org>,
	Ben Dooks <ben-linux@...ff.org>, Julia Lawall <julia@...u.dk>,
	Russell King <rmk+kernel@....linux.org.uk>,
	"linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] i2c-pnx: fix setting start/stop condition

On Mon, Mar 01, 2010 at 07:43:24PM +0100, Kevin Wells wrote:
> Hi Luotao,
> 
> > 
> > The start/stop condtions are set in different places repetedly in the i2c-
> > pnx
> > driver.  Beside in i2c_pnx_start and i2c_pnx_stop the start/stop bit are
> > also
> > set during the transfer of a i2c message in the master_xmit/rcv calls.
> > This is
> > wrong since we can't set the start/stop condition during the transaction
> > of a
> > single message any way. As a matter of fact, the driver will sometimes set
> > both
> > the start and the stop bits at one time. This can be easily reproduced by
> > sending a simple read request like e.g
> > struct i2c_msg msgs[] = {
> > { addr, 0, 1, buf },
> > { addr, I2C_M_RD, offset, buf }
> > };
> > While processing the first message the i2c_pnx_master_xmit will set both
> > the
> > start_bit and the stop_bit, which will eventually confuse the slave.
> > 
> > Fixed by remove setting start/stop condition from the transmit routines.
> > 
> > Signed-off-by: Luotao Fu <l.fu@...gutronix.de>
> > ---
> >  drivers/i2c/busses/i2c-pnx.c |   11 -----------
> >  1 files changed, 0 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
> > index 5d1c260..92c0e46 100644
> > --- a/drivers/i2c/busses/i2c-pnx.c
> > +++ b/drivers/i2c/busses/i2c-pnx.c
> > @@ -175,12 +175,6 @@ static int i2c_pnx_master_xmit(struct i2c_adapter
> > *adap)
> >  		/* We still have something to talk about... */
> >  		val = *alg_data->mif.buf++;
> > 
> > -		if (alg_data->mif.len == 1) {
> > -			val |= stop_bit;
> > -			if (!alg_data->last)
> > -				val |= start_bit;
> 
> Removing the start bit assertion here should be ok. The initial start
> condition is setup as part of the start of the transfer when the addr
> is sent out. The stop bit needs to stay or the I2C transfer will not
> correctly terminate on the last byte out and you will end up with a
> bus busy failure (clock low, data high) on the next transfer.

I had a closer look into this and think that you are right. I was
irritated by the unregular usage of start_bit and thought the stop bit
is asserted with the i2c_pnx_stop call, which is apparently only used
for zero sized transfers.

Fixed patch is attached with this mail.

cheers
Luotao Fu
-- 
Pengutronix e.K.                           | Dipl.-Ing. Luotao Fu        |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

View attachment "0001-i2c-pnx-fix-setting-start-condition.patch" of type "text/x-diff" (2079 bytes)

Download attachment "signature.asc" of type "application/pgp-signature" (198 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ