Skip to content

Commit acb47aa

Browse files
geertubroonie
authored andcommitted
spi: sh-msiof: Double maximum DMA transfer size using two groups
The maximum DMA transfer size is limited by the maximum values that can be written to the word count fields (WDLENx) in the Transmit and Control Data Registers (SITDR2/SIRDR2). As all MSIOF variants support transferring data of multiple (two or four) groups, the maximum size can be doubled by using two groups instead of one, thus reducing setup overhead for very large SPI transfers. Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://patch.msgid.link/bad522c76b8d225c195433977b22f95015cf2612.1747401908.git.geert+renesas@glider.be Signed-off-by: Mark Brown <[email protected]>
1 parent 39d0856 commit acb47aa

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/spi/spi-sh-msiof.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -767,10 +767,12 @@ static void sh_msiof_dma_complete(void *arg)
767767
}
768768

769769
static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
770-
void *rx, unsigned int len)
770+
void *rx, unsigned int len,
771+
unsigned int max_wdlen)
771772
{
772773
u32 ier_bits = 0;
773774
struct dma_async_tx_descriptor *desc_tx = NULL, *desc_rx = NULL;
775+
unsigned int words1, words2;
774776
dma_cookie_t cookie;
775777
int ret;
776778

@@ -817,7 +819,9 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
817819
FIELD_PREP(SIFCTR_RFWM, SIFCTR_RFWM_1));
818820

819821
/* setup msiof transfer mode registers (32-bit words) */
820-
sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4, 0);
822+
words1 = min(len / 4, max_wdlen);
823+
words2 = len / 4 - words1;
824+
sh_msiof_spi_set_mode_regs(p, tx, rx, 32, words1, words2);
821825

822826
sh_msiof_write(p, SIIER, ier_bits);
823827

@@ -969,7 +973,7 @@ static int sh_msiof_transfer_one(struct spi_controller *ctlr,
969973
* DMA supports 32-bit words only, hence pack 8-bit and 16-bit
970974
* words, with byte resp. word swapping.
971975
*/
972-
unsigned int l = min(round_down(len, 4), max_wdlen * 4);
976+
unsigned int l = min(round_down(len, 4), 2 * max_wdlen * 4);
973977

974978
if (bits <= 8) {
975979
copy32 = copy_bswap32;
@@ -982,7 +986,7 @@ static int sh_msiof_transfer_one(struct spi_controller *ctlr,
982986
if (tx_buf)
983987
copy32(p->tx_dma_page, tx_buf, l / 4);
984988

985-
ret = sh_msiof_dma_once(p, tx_buf, rx_buf, l);
989+
ret = sh_msiof_dma_once(p, tx_buf, rx_buf, l, max_wdlen);
986990
if (ret == -EAGAIN) {
987991
dev_warn_once(&p->pdev->dev,
988992
"DMA not available, falling back to PIO\n");

0 commit comments

Comments
 (0)