diff mbox series

[v2,2/2] spi: sh-msiof: Use DMA if possible

Message ID 1547803771-9564-2-git-send-email-na-hoan@jinso.co.jp (mailing list archive)
State Accepted
Delegated to: Geert Uytterhoeven
Headers show
Series [v2,1/2] spi: sh-msiof: fix *info pointer in request_dma() | expand

Commit Message

グェン・アン・ホァン Jan. 18, 2019, 9:29 a.m. UTC
From: Hoan Nguyen An <na-hoan@jinso.co.jp>

Currently, this driver only supports feature for DMA 32-bits.
In this case, only if the data length is divisible by 4 to use
DMA, otherwise PIO will be used. This patch will suggest use
the DMA 32-bits with 4bytes of words, then the remaining data
will be transmitted by PIO mode.

Signed-off-by: Hoan Nguyen An <na-hoan@jinso.co.jp>
---
 drivers/spi/spi-sh-msiof.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Geert Uytterhoeven Jan. 18, 2019, 1:18 p.m. UTC | #1
Hi Hoan-san,

On Fri, Jan 18, 2019 at 10:30 AM Nguyen An Hoan <na-hoan@jinso.co.jp> wrote:
> Currently, this driver only supports feature for DMA 32-bits.
> In this case, only if the data length is divisible by 4 to use
> DMA, otherwise PIO will be used. This patch will suggest use
> the DMA 32-bits with 4bytes of words, then the remaining data
> will be transmitted by PIO mode.
>
> Signed-off-by: Hoan Nguyen An <na-hoan@jinso.co.jp>

Thanks for the update!

DMA is now used for the first part, and PIO for the remainder.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 351470b..617cdf3 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -937,17 +937,13 @@  static int sh_msiof_transfer_one(struct spi_master *master,
 		unsigned int l = 0;
 
 		if (tx_buf)
-			l = min(len, p->tx_fifo_size * 4);
+			l = min(round_down(len, 4), p->tx_fifo_size * 4);
 		if (rx_buf)
-			l = min(len, p->rx_fifo_size * 4);
+			l = min(round_down(len, 4), p->rx_fifo_size * 4);
 
 		if (bits <= 8) {
-			if (l & 3)
-				break;
 			copy32 = copy_bswap32;
 		} else if (bits <= 16) {
-			if (l & 3)
-				break;
 			copy32 = copy_wswap32;
 		} else {
 			copy32 = copy_plain32;