Re: [PATCH v2 2/4] i2c: designware: Ensure tx_buf_len is nonzero for SMBus block reads

2020-09-17 Thread Andy Shevchenko
On Thu, Sep 17, 2020 at 04:44:18PM +0300, Jarkko Nikula wrote:
> On 9/17/20 8:22 AM, Sultan Alsawaf wrote:
> > From: Sultan Alsawaf 
> > 
> > The point of adding a byte to len in i2c_dw_recv_len() is to make sure
> > that tx_buf_len is nonzero, so that i2c_dw_xfer_msg() can let the i2c
> > controller know that the i2c transaction can end. Otherwise, the i2c
> > controller will think that the transaction can never end for block
> > reads, which results in the stop-detection bit never being set and thus
> > the transaction timing out.
> > 
> > Adding a byte to len is not a reliable way to do this though; sometimes
> > it lets tx_buf_len become zero, which results in the scenario described
> > above. Therefore, just directly ensure tx_buf_len cannot be zero to fix
> > the issue.
> > 
> > Fixes: c3ae106050b9 ("i2c: designware: Implement support for SMBus block 
> > read and write")
> > Signed-off-by: Sultan Alsawaf 
> > ---
> >   drivers/i2c/busses/i2c-designware-master.c | 5 +++--
> >   1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> Were other patches in series dropped somewhere? I received only this.

@linux.intel.com has some issues in delivery (accepting) messages. You may
download thru lore.kernel.org entire series and reply.

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v2 2/4] i2c: designware: Ensure tx_buf_len is nonzero for SMBus block reads

2020-09-17 Thread Jarkko Nikula

On 9/17/20 8:22 AM, Sultan Alsawaf wrote:

From: Sultan Alsawaf 

The point of adding a byte to len in i2c_dw_recv_len() is to make sure
that tx_buf_len is nonzero, so that i2c_dw_xfer_msg() can let the i2c
controller know that the i2c transaction can end. Otherwise, the i2c
controller will think that the transaction can never end for block
reads, which results in the stop-detection bit never being set and thus
the transaction timing out.

Adding a byte to len is not a reliable way to do this though; sometimes
it lets tx_buf_len become zero, which results in the scenario described
above. Therefore, just directly ensure tx_buf_len cannot be zero to fix
the issue.

Fixes: c3ae106050b9 ("i2c: designware: Implement support for SMBus block read and 
write")
Signed-off-by: Sultan Alsawaf 
---
  drivers/i2c/busses/i2c-designware-master.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)


Were other patches in series dropped somewhere? I received only this.

Jarkko


Re: [PATCH v2 2/4] i2c: designware: Ensure tx_buf_len is nonzero for SMBus block reads

2020-09-17 Thread Andy Shevchenko
On Wed, Sep 16, 2020 at 10:22:54PM -0700, Sultan Alsawaf wrote:
> From: Sultan Alsawaf 
> 
> The point of adding a byte to len in i2c_dw_recv_len() is to make sure
> that tx_buf_len is nonzero, so that i2c_dw_xfer_msg() can let the i2c
> controller know that the i2c transaction can end. Otherwise, the i2c
> controller will think that the transaction can never end for block
> reads, which results in the stop-detection bit never being set and thus
> the transaction timing out.
> 
> Adding a byte to len is not a reliable way to do this though; sometimes
> it lets tx_buf_len become zero, which results in the scenario described
> above. Therefore, just directly ensure tx_buf_len cannot be zero to fix
> the issue.

I got only patch 2/4, where the other 3 along with cover letter?

-- 
With Best Regards,
Andy Shevchenko




[PATCH v2 2/4] i2c: designware: Ensure tx_buf_len is nonzero for SMBus block reads

2020-09-16 Thread Sultan Alsawaf
From: Sultan Alsawaf 

The point of adding a byte to len in i2c_dw_recv_len() is to make sure
that tx_buf_len is nonzero, so that i2c_dw_xfer_msg() can let the i2c
controller know that the i2c transaction can end. Otherwise, the i2c
controller will think that the transaction can never end for block
reads, which results in the stop-detection bit never being set and thus
the transaction timing out.

Adding a byte to len is not a reliable way to do this though; sometimes
it lets tx_buf_len become zero, which results in the scenario described
above. Therefore, just directly ensure tx_buf_len cannot be zero to fix
the issue.

Fixes: c3ae106050b9 ("i2c: designware: Implement support for SMBus block read 
and write")
Signed-off-by: Sultan Alsawaf 
---
 drivers/i2c/busses/i2c-designware-master.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-master.c 
b/drivers/i2c/busses/i2c-designware-master.c
index d78f48ca4886..22f28516bca7 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -395,8 +395,9 @@ i2c_dw_recv_len(struct dw_i2c_dev *dev, u8 len)
 * Adjust the buffer length and mask the flag
 * after receiving the first byte.
 */
-   len += (flags & I2C_CLIENT_PEC) ? 2 : 1;
-   dev->tx_buf_len = len - min_t(u8, len, dev->rx_outstanding);
+   if (flags & I2C_CLIENT_PEC)
+   len++;
+   dev->tx_buf_len = len - min_t(u8, len - 1, dev->rx_outstanding);
msgs[dev->msg_read_idx].len = len;
msgs[dev->msg_read_idx].flags &= ~I2C_M_RECV_LEN;
 
-- 
2.28.0