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] [day] [month] [year] [list]
Date:   Wed, 16 Sep 2020 17:09:18 +0300
From:   Jarkko Nikula <jarkko.nikula@...ux.intel.com>
To:     Sultan Alsawaf <sultan@...neltoast.com>
Cc:     aaron.ma@...onical.com, admin@...ma.net,
        andriy.shevchenko@...ux.intel.com, benjamin.tissoires@...hat.com,
        hdegoede@...hat.com, hn.chen@...dahitech.com, jikos@...nel.org,
        kai.heng.feng@...onical.com, linux-i2c@...r.kernel.org,
        linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
        mika.westerberg@...ux.intel.com, vicamo.yang@...onical.com,
        wsa@...nel.org
Subject: Re: [PATCH v3] i2c: Squash of SMBus block read patchset to save power

On 9/15/20 8:48 PM, Sultan Alsawaf wrote:
> On Tue, Sep 15, 2020 at 02:55:48PM +0300, Jarkko Nikula wrote:
>> I tested this on top of fc4f28bb3daf ("Merge tag 'for-5.9-rc5-tag' of
>> git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux") and seems to be
>> working fine. What was the key change compared to previous version that was
>> regressing for me?
> 
> This change fixed your issue (and my issue with 5.8):
> --- 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;
> 
> I've attributed this change with the following commit message:
> "i2c: designware: Ensure tx_buf_len is nonzero for SMBus block reads
> 
> 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."
> 
Ok, nice that you found it.

> Does the patch series look good to submit?
> 
Yes, go ahead.

Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ