This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit cdd11112fd2c492948a17f710ab1447fe5510a4b Author: Jukka Laitinen <juk...@ssrc.tii.ae> AuthorDate: Wed Oct 23 11:15:44 2024 +0300 arch/arm64/src/imx9/imx9_lpspi.c: Small cache operation optimization 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 <juk...@ssrc.tii.ae> --- arch/arm64/src/imx9/imx9_lpspi.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/arm64/src/imx9/imx9_lpspi.c b/arch/arm64/src/imx9/imx9_lpspi.c index 5d8e788115..610276a5f8 100644 --- a/arch/arm64/src/imx9/imx9_lpspi.c +++ b/arch/arm64/src/imx9/imx9_lpspi.c @@ -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; @@ -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