Skip to content

Commit

Permalink
arch/arm64/src/imx9/imx9_lpspi.c: Small cache operation optimization
Browse files Browse the repository at this point in the history
There is no need to invalidate the RX buffer before every transfer.
It is never gets dirty, so it is good to invalidate initially after allocation,
and after each transfer.

Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine authored and xiaoxiang781216 committed Oct 23, 2024
1 parent 6cadfc1 commit cdd1111
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions arch/arm64/src/imx9/imx9_lpspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1386,14 +1386,6 @@ static void imx9_lpspi_exchange(struct spi_dev_s *dev,
(uintptr_t)priv->txbuf + nbytes);
}

if (rxbuffer)
{
/* Prepare the RX buffer for DMA */

up_invalidate_dcache((uintptr_t)priv->rxbuf,
(uintptr_t)priv->rxbuf + nbytes);
}

/* Set up the DMA */

adjust = (priv->nbits > 8) ? 2 : 1;
Expand Down Expand Up @@ -2079,6 +2071,12 @@ struct spi_dev_s *imx9_lpspibus_initialize(int bus)
priv->txbuf = imx9_dma_alloc(CONFIG_IMX9_LPSPI_DMA_BUFFER_SIZE);
priv->rxbuf = imx9_dma_alloc(CONFIG_IMX9_LPSPI_DMA_BUFFER_SIZE);
DEBUGASSERT(priv->txbuf && priv->rxbuf);

/* Invalidate the RX buffer area initially */

up_invalidate_dcache((uintptr_t)priv->rxbuf,
(uintptr_t)priv->rxbuf +
CONFIG_IMX9_LPSPI_DMA_BUFFER_SIZE);
}
}
else
Expand Down

0 comments on commit cdd1111

Please sign in to comment.