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: <CACD3sJa0g=JR3utj=U8-zJm31W3gT_4Hb4wxGhAmdGhOSw=rSQ@mail.gmail.com>
Date: Wed, 9 Oct 2024 13:48:00 +0800
From: Tyrone Ting <warp5tw@...il.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: avifishman70@...il.com, tmaimon77@...il.com, tali.perry1@...il.com, 
	venture@...gle.com, yuenn@...gle.com, benjaminfair@...gle.com, 
	andi.shyti@...nel.org, wsa@...nel.org, rand.sec96@...il.com, 
	wsa+renesas@...g-engineering.com, tali.perry@...oton.com, 
	Avi.Fishman@...oton.com, tomer.maimon@...oton.com, KWLIU@...oton.com, 
	JJLIU0@...oton.com, kfting@...oton.com, openbmc@...ts.ozlabs.org, 
	linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 4/6] i2c: npcm: Modify the client address assignment

Hi Andy:

Thank you for your comments and they'll be addressed.

Andy Shevchenko <andriy.shevchenko@...ux.intel.com> 於 2024年10月9日 週三 上午12:21寫道:
>
> On Fri, Oct 04, 2024 at 10:29:10AM +0800, Tyrone Ting wrote:
> > Hi Andy:
> >
> > Thank you for your comments.
> >
> > After a second thought, I'll explain why slave_addr << 1 is given here.
> >
> > Tyrone Ting <warp5tw@...il.com> 於 2024年10月4日 週五 上午9:49寫道:
> > >
> > > Hi Andy:
> > >
> > > Thank you for your comments and they'll be addressed.
> > >
> > > Andy Shevchenko <andriy.shevchenko@...ux.intel.com> 於 2024年10月1日 週二 下午9:17寫道:
> > > >
> > > > On Tue, Oct 01, 2024 at 02:28:53PM +0800, Tyrone Ting wrote:
> > > > > From: Tyrone Ting <kfting@...oton.com>
> > > > >
> > > > > Store the client address earlier since it might get called in
> > > > > the i2c_recover_bus() logic flow at the early stage of
> > > > > npcm_i2c_master_xfer().
> > > >
> > > > ...
> > > >
> > > > > +     /*
> > > > > +      * Previously, the address was stored w/o left-shift by one bit and
> > > > > +      * with that shift in the following call to npcm_i2c_master_start_xmit().
> > > > > +      *
> > > > > +      * Since there are cases that the i2c_recover_bus() gets called at the
> > > > > +      * early stage of npcm_i2c_master_xfer(), the address is stored with
> > > > > +      * the shift and used in the i2c_recover_bus().
> > > > > +      *
> > > > > +      * The address is stored from bit 1 to bit 7 in the register for
> > > > > +      * sending the i2c address later so it's left-shifted by 1 bit.
> > > > > +      */
> > > > > +     bus->dest_addr = slave_addr << 1;
> > > >
> > > > I'm wondering if it's better to use i2c_8bit_addr_from_msg() here?
> > > >
> >
> > The current implementation of i2c_8bit_addr_from_msg() (ref link:
> > https://github.com/torvalds/linux/blob/master/include/linux/i2c.h#L947)
> > is
> > "return (msg->addr << 1) | (msg->flags & I2C_M_RD);" and it takes
> > extra consideration about the read flag when retrieving the i2c
> > address.
> > IOW, if there is a read event, the i2c address contains a read
> > indication (bit 0 of the i2c address is 1).
> >
> > The patch code "bus->dest_addr = slave_addr << 1;" might get used in
> > i2c_recover_bus() later. (ref link:
> > https://github.com/torvalds/linux/blob/master/drivers/i2c/busses/i2c-npcm7xx.c#L1691)
> >
> > Suppose there is a read event and the i2c address is 0x60.
> >
> > With i2c_8bit_addr_from_msg(), bus->dest_addr will be 0xc1.
> > With the original patch, bus->dest_addr will be 0xc0.
> >
> > If some error condition occurs and it requires i2c_recover_bus() to
> > recover the bus, according to the description at
> > https://github.com/torvalds/linux/blob/master/drivers/i2c/busses/i2c-npcm7xx.c#L1742,
> > the address "0xc1" is used
> > as a parameter to npcm_i2c_wr_byte() which is used to send the address
> > in the write direction.
> >
> > If i2c_8bit_addr_from_msg() is applied, it might not fit the scenario
> > described at
> > https://github.com/torvalds/linux/blob/master/drivers/i2c/busses/i2c-npcm7xx.c#L1742,
> > which is about to send
> > an address in a write direction since the address from
> > i2c_8bit_addr_from_msg() contains a read indication.
>
> Okay, then I would do the i2c_8bit_addr_from_msg() call here as AFAICS
> this is the real event where you save the address *of the event*.
>
> And in the respective user update the comment to summarize above and do
> rather ->dest_addr & ~I2C_M_RD there.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

Thank you.

Regards,
Tyrone

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ