Re: [PATCH v2] HID: i2c-hid: Use block reads when possible to save power

From: Sultan Alsawaf
Date: Wed Jul 01 2020 - 11:00:17 EST


On Wed, Jul 01, 2020 at 11:04:01AM +0300, Jarkko Nikula wrote:
> On 6/29/20 8:43 PM, Sultan Alsawaf wrote:
> > Hmm, for some reason in 5.8 I get the same problem, but 5.7 is fine. Could you
> > try this on 5.7 and see if it works?
> >
> > In the meantime I'll bisect 5.8 to see why it's causing problems for me...
> >
> I see the same issue on top of v5.7:

Try reverting my "i2c: designware: Only check the first byte for SMBus block
read length" patch and apply the following change instead:

--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -394,10 +394,12 @@ i2c_dw_read(struct dw_i2c_dev *dev)
u32 flags = msgs[dev->msg_read_idx].flags;

*buf = dw_readl(dev, DW_IC_DATA_CMD);
- /* Ensure length byte is a valid value */
- if (flags & I2C_M_RECV_LEN &&
- *buf <= I2C_SMBUS_BLOCK_MAX && *buf > 0) {
- len = i2c_dw_recv_len(dev, *buf);
+ if (flags & I2C_M_RECV_LEN) {
+ /* Ensure length byte is a valid value */
+ if (*buf <= I2C_SMBUS_BLOCK_MAX && *buf > 0)
+ len = i2c_dw_recv_len(dev, *buf);
+ else
+ len = i2c_dw_recv_len(dev, len);
}
buf++;
dev->rx_outstanding--;