3d6869558822b2ab95f141c554d7c7b6cb6b2450
[openwrt/staging/jow.git] /
1 From 08f15963bc751bc818294c0f75a9aaca299c4052 Mon Sep 17 00:00:00 2001
2 From: Abhishek Sahu <absahu@codeaurora.org>
3 Date: Mon, 12 Mar 2018 18:44:57 +0530
4 Subject: [PATCH 08/13] i2c: qup: use the complete transfer length to choose
5 DMA mode
6
7 Currently each message length in complete transfer is being
8 checked for determining DMA mode and if any of the message length
9 is less than FIFO length then non DMA mode is being used which
10 will increase overhead. DMA can be used for any length and it
11 should be determined with complete transfer length. Now, this
12 patch selects DMA mode if the total length is greater than FIFO
13 length.
14
15 Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
16 Reviewed-by: Austin Christ <austinwc@codeaurora.org>
17 Reviewed-by: Andy Gross <andy.gross@linaro.org>
18 Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
19 ---
20 drivers/i2c/busses/i2c-qup.c | 13 +++++++------
21 1 file changed, 7 insertions(+), 6 deletions(-)
22
23 --- a/drivers/i2c/busses/i2c-qup.c
24 +++ b/drivers/i2c/busses/i2c-qup.c
25 @@ -1300,7 +1300,8 @@ static int qup_i2c_xfer_v2(struct i2c_ad
26 int num)
27 {
28 struct qup_i2c_dev *qup = i2c_get_adapdata(adap);
29 - int ret, len, idx = 0;
30 + int ret, idx = 0;
31 + unsigned int total_len = 0;
32
33 qup->bus_err = 0;
34 qup->qup_err = 0;
35 @@ -1326,14 +1327,14 @@ static int qup_i2c_xfer_v2(struct i2c_ad
36 goto out;
37 }
38
39 - len = (msgs[idx].len > qup->out_fifo_sz) ||
40 - (msgs[idx].len > qup->in_fifo_sz);
41 -
42 - if (is_vmalloc_addr(msgs[idx].buf) || !len)
43 + if (is_vmalloc_addr(msgs[idx].buf))
44 break;
45 +
46 + total_len += msgs[idx].len;
47 }
48
49 - if (idx == num)
50 + if (idx == num && (total_len > qup->out_fifo_sz ||
51 + total_len > qup->in_fifo_sz))
52 qup->use_dma = true;
53 }
54