]> git.baikalelectronics.ru Git - kernel.git/commit
i2c: qup: fix buffer overflow for multiple msg of maximum xfer len
authorAbhishek Sahu <absahu@codeaurora.org>
Mon, 12 Mar 2018 13:14:59 +0000 (18:44 +0530)
committerWolfram Sang <wsa@the-dreams.de>
Sat, 24 Mar 2018 12:20:30 +0000 (13:20 +0100)
commit0ee4977a25353e48816faded5953947cfa82414a
tree41df7b2cc692e1da09ef8caab2f5e0c800e76c81
parentda102b348e23b7bbac2ac7b698010a344afe2413
i2c: qup: fix buffer overflow for multiple msg of maximum xfer len

The BAM mode requires buffer for start tag data and tx, rx SG
list. Currently, this is being taken for maximum transfer length
(65K). But an I2C transfer can have multiple messages and each
message can be of this maximum length so the buffer overflow will
happen in this case. Since increasing buffer length won’t be
feasible since an I2C transfer can contain any number of messages
so this patch does following changes to make i2c transfers working
for multiple messages case.

1. Calculate the required buffers for 2 maximum length messages
   (65K * 2).
2. Split the descriptor formation and descriptor scheduling.
   The idea is to fit as many messages in one DMA transfers for 65K
   threshold value (max_xfer_sg_len). Whenever the sg_cnt is
   crossing this, then schedule the BAM transfer and subsequent
   transfer will again start from zero.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Reviewed-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-qup.c