i2c: cadence: Handle transfer_size rollover
authorAlex Williams <alex.williams@ni.com>
Thu, 31 Jan 2019 21:39:57 +0000 (13:39 -0800)
committerWolfram Sang <wsa@the-dreams.de>
Thu, 30 Jan 2020 08:01:27 +0000 (09:01 +0100)
commitbbf967b223b3f1b55eb494d735226152afbad64e
tree1530a3b802467b5aa8723d3c518bbbad854bf543
parentf53938d2c79ae3c768dc92b1c3d898dfe820a491
i2c: cadence: Handle transfer_size rollover

Under certain conditions, Cadence's I2C controller's transfer_size
register will roll over and generate invalid read transactions. Before
this change, the ISR relied solely on the RXDV bit to determine when to
write more data to the user's buffer. The invalid read data would cause
overruns, smashing stacks and worse.

This change stops the buffer writes to the requested boundary and
reports the error. The controller will be reset so normal transactions
may resume.

Signed-off-by: Alex Williams <alex.williams@ni.com>
Reviewed-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Reviewed-by: Michal Simek <michal.simek@xilinx.com> # in a seperate mail
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-cadence.c