From dea8cd3fcf0f40144be78dd7ce917c0f95a393b2 Mon Sep 17 00:00:00 2001 From: Yicheng Li Date: Fri, 11 Oct 2024 15:43:37 -0700 Subject: [PATCH] dma_mcux_lpc: Fix descriptor address conversion when used by DSP The SDK FSL DMA driver converts descriptor addresses to DMA's address space when linking descriptors. The Zephyr dma_mcux_lpc driver is missing the inverse conversion when dereferencing the linked next descriptor pointer. This isn't a problem when this driver is used on the M33 core of the MIMXRT595S because the M33 can access the address space of the DMA (0x20000000+). But when the Fusion F1 DSP core uses this driver, the DSP cannot access the DMA's address space so the inverse conversion is needed. Signed-off-by: Yicheng Li --- drivers/dma/dma_mcux_lpc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/dma/dma_mcux_lpc.c b/drivers/dma/dma_mcux_lpc.c index 964fc52231b..2375c4d30c3 100644 --- a/drivers/dma/dma_mcux_lpc.c +++ b/drivers/dma/dma_mcux_lpc.c @@ -13,6 +13,9 @@ #include #include #include +#if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && (FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET == 1) +#include "fsl_memory.h" +#endif #include #include #include @@ -206,6 +209,14 @@ static int dma_mcux_lpc_queue_descriptors(struct channel_data *data, * is called from a reload function */ next_descriptor = data->curr_descriptor->linkToNextDesc; + /* The SDK converts next descriptor addresses to DMA's + * address space when linking the descriptors, so + * convert it back. + */ +#if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && (FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET == 1) + next_descriptor = (void *)MEMORY_ConvertMemoryMapAddress( + (uint32_t)next_descriptor, kMEMORY_DMA2Local); +#endif } /* SPI TX transfers need to queue a DMA descriptor to