dmaengine: fsl-sdma: Some improvement for fsl-sdma
Subsystems (2)
Frank Li
maintainerv2 cover dmaengine: fsl-sdma: Some improvement for fsl-sdma
To: Vinod Koul <[email protected]>
To: Shawn Guo <[email protected]>
To: Sascha Hauer <[email protected]>
To: Pengutronix Kernel Team <[email protected]>
To: Fabio Estevam <[email protected]>
To: NXP Linux Team <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Changes in v2:
- remove ccb_phy from struct sdma_engine
- add i2c test platform and sdma script version informaiton at commit message.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Joy Zou (1):
dmaengine: imx-sdma: Add multi fifo for DEV_TO_DEV
Nicolin Chen (1):
dmaengine: imx-sdma: Support allocate memory from internal SRAM (iram)
Robin Gong (1):
dmaengine: imx-sdma: Add i2c dma support
Shengjiu Wang (1):
dmaengine: imx-sdma: Support 24bit/3bytes for sg mode
drivers/dma/imx-sdma.c | 64 ++++++++++++++++++++++++++++++++++++++------- include/linux/dma/imx-dma.h | 1 + 2 files changed, 55 insertions(+), 10 deletions(-)
---
base-commit: af20f396b91f335f907422249285cc499fb4e0d8
change-id: 20240303-sdma_upstream-acebfa5b97f7
Best regards,
Signature · 1 line
Frank Li <[email protected]>
Frank Li
maintainerPATCH v2 1/4 dmaengine: imx-sdma: Support allocate memory from internal SRAM (iram)
From: Nicolin Chen <[email protected]>
Allocate memory from SoC internal SRAM to reduce DDR access and keep DDR in lower power state (such as self-referesh) longer.
Check iram_pool before sdma_init() so that ccb/context could be allocated from iram because DDR maybe in self-referesh in lower power audio case while sdma still running.
--- drivers/dma/imx-sdma.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-)
drivers/dma/imx-sdma.c +36 -10
@@ -24,6 +24,7 @@#include <linux/semaphore.h> #include <linux/spinlock.h> #include <linux/device.h> +#include <linux/genalloc.h> #include <linux/dma-mapping.h> #include <linux/firmware.h> #include <linux/slab.h>
@@ -531,6 +532,7 @@ struct sdma_engine {/* clock ratio for AHB:SDMA core. 1:1 is 1, 2:1 is 0*/ bool clk_ratio;bool fw_loaded; +struct gen_pool *iram_pool; }; static int sdma_config_write(struct dma_chan *chan,
@@ -1358,8 +1360,14 @@ static int sdma_request_channel0(struct sdma_engine *sdma) {int ret = -EBUSY ; - sdma->bd0 =dma_alloc_coherent (sdma->dev,PAGE_SIZE , &sdma->bd0_phys, -GFP_NOWAIT ); +if (sdma->iram_pool) + sdma->bd0 =gen_pool_dma_alloc (sdma->iram_pool, +sizeof (struct sdma_buffer_descriptor ), + &sdma->bd0_phys); +else + sdma->bd0 =dma_alloc_coherent (sdma->dev, +sizeof (struct sdma_buffer_descriptor ), + &sdma->bd0_phys,GFP_NOWAIT );if (!sdma->bd0) { ret = -ENOMEM ; goto out;
@@ -1379,10 +1387,14 @@ static int sdma_request_channel0(struct sdma_engine *sdma)static int sdma_alloc_bd (struct sdma_desc *desc) {u32 bd_size = desc->num_bd *sizeof (struct sdma_buffer_descriptor ); +struct sdma_engine *sdma = desc->sdmac->sdma;int ret =0 ; - desc->bd =dma_alloc_coherent (desc->sdmac->sdma->dev, bd_size, - &desc->bd_phys,GFP_NOWAIT ); +if (sdma->iram_pool) + desc->bd =gen_pool_dma_alloc (sdma->iram_pool, bd_size, &desc->bd_phys); +else + desc->bd =dma_alloc_coherent (sdma->dev, bd_size, &desc->bd_phys,GFP_NOWAIT ); +if (!desc->bd) { ret = -ENOMEM ; goto out;
@@ -1394,9 +1406,12 @@ static int sdma_alloc_bd(struct sdma_desc *desc)static void sdma_free_bd (struct sdma_desc *desc) {u32 bd_size = desc->num_bd *sizeof (struct sdma_buffer_descriptor ); +struct sdma_engine *sdma = desc->sdmac->sdma; -dma_free_coherent (desc->sdmac->sdma->dev, bd_size, desc->bd, - desc->bd_phys); +if (sdma->iram_pool) +gen_pool_free (sdma->iram_pool, (unsigned long )desc->bd, bd_size); +else +dma_free_coherent (desc->sdmac->sdma->dev, bd_size, desc->bd, desc->bd_phys); }static void sdma_desc_free (struct virt_dma_desc *vd)
@@ -2068,6 +2083,7 @@ static int sdma_init(struct sdma_engine *sdma) {int i, ret;dma_addr_t ccb_phys; +int ccbsize; ret =clk_enable (sdma->clk_ipg);if (ret)
@@ -2083,10 +2099,14 @@ static int sdma_init(struct sdma_engine *sdma)/* Be sure SDMA has not started yet */ writel_relaxed (0 , sdma->regs +SDMA_H_C0PTR ); - sdma->channel_control =dma_alloc_coherent (sdma->dev, -MAX_DMA_CHANNELS *sizeof (struct sdma_channel_control ) + -sizeof (struct sdma_context_data ), - &ccb_phys,GFP_KERNEL ); + ccbsize =MAX_DMA_CHANNELS * (sizeof (struct sdma_channel_control ) + +sizeof (struct sdma_context_data )); + +if (sdma->iram_pool) + sdma->channel_control =gen_pool_dma_alloc (sdma->iram_pool, ccbsize, &ccb_phys); +else + sdma->channel_control =dma_alloc_coherent (sdma->dev, ccbsize, &ccb_phys, +GFP_KERNEL );if (!sdma->channel_control) { ret = -ENOMEM ;
@@ -2272,6 +2292,12 @@ static int sdma_probe(struct platform_device *pdev)vchan_init (&sdmac->vc, &sdma->dma_device); } +if (np) { + sdma->iram_pool =of_gen_pool_get (np,"iram" ,0 ); +if (sdma->iram_pool) +dev_info (&pdev->dev,"alloc bd from iram.\n" ); + } + ret =sdma_init (sdma);if (ret) goto err_init;
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH v2 2/4 dmaengine: imx-sdma: Support 24bit/3bytes for sg mode
In reply to Frank LiFrom: Shengjiu Wang <[email protected]>
Update 3bytes buswidth that is supported by sdma.
--- drivers/dma/imx-sdma.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/dma/imx-sdma.c +4 -0
@@ -176,6 +176,7 @@#define SDMA_DMA_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \ BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \ + BIT(DMA_SLAVE_BUSWIDTH_3_BYTES) | \ BIT(DMA_SLAVE_BUSWIDTH_4_BYTES))#define SDMA_DMA_DIRECTIONS (BIT(DMA_DEV_TO_MEM) | \
@@ -1658,6 +1659,9 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg(if (count &3 || sg->dma_address &3 ) goto err_bd_out;break ; +case DMA_SLAVE_BUSWIDTH_3_BYTES : + bd->mode.command =3 ; +break ;case DMA_SLAVE_BUSWIDTH_2_BYTES : bd->mode.command =2 ;if (count &1 || sg->dma_address &1 )
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH v2 3/4 dmaengine: imx-sdma: Add multi fifo for DEV_TO_DEV
In reply to Frank LiFrom: Joy Zou <[email protected]>
Support multi fifo for DEV_TO_DEV.
--- drivers/dma/imx-sdma.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/dma/imx-sdma.c +7 -0
@@ -169,6 +169,8 @@#define SDMA_WATERMARK_LEVEL_SPDIF BIT(10)#define SDMA_WATERMARK_LEVEL_SP BIT(11)#define SDMA_WATERMARK_LEVEL_DP BIT(12) +#define SDMA_WATERMARK_LEVEL_SD BIT(13) +#define SDMA_WATERMARK_LEVEL_DD BIT(14)#define SDMA_WATERMARK_LEVEL_HWML (0xFF << 16)#define SDMA_WATERMARK_LEVEL_LWE BIT(28)#define SDMA_WATERMARK_LEVEL_HWE BIT(29)
@@ -1258,6 +1260,11 @@ static void sdma_set_watermarklevel_for_p2p(struct sdma_channel *sdmac) sdmac->watermark_level |=SDMA_WATERMARK_LEVEL_DP ; sdmac->watermark_level |=SDMA_WATERMARK_LEVEL_CONT ; + +if (sdmac->n_fifos_src >1 ) + sdmac->watermark_level |=SDMA_WATERMARK_LEVEL_SD ; +if (sdmac->n_fifos_dst >1 ) + sdmac->watermark_level |=SDMA_WATERMARK_LEVEL_DD ; }static void sdma_set_watermarklevel_for_sais (struct sdma_channel *sdmac)
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH v2 4/4 dmaengine: imx-sdma: Add i2c dma support
In reply to Frank LiFrom: Robin Gong <[email protected]>
New sdma script (sdma-6q: v3.5, sdma-7d: v4.5) support i2c at imx8mp and imx6ull. So add I2C dma support.
--- drivers/dma/imx-sdma.c | 7 +++++++ include/linux/dma/imx-dma.h | 1 + 2 files changed, 8 insertions(+)
drivers/dma/imx-sdma.c +7 -0
@@ -247,6 +247,8 @@ struct sdma_script_start_addrs {s32 sai_2_mcu_addr;s32 uart_2_mcu_rom_addr;s32 uartsh_2_mcu_rom_addr; +s32 i2c_2_mcu_addr; +s32 mcu_2_i2c_addr;/* End of v3 array */ s32 mcu_2_zqspi_addr;/* End of v4 array */
@@ -1077,6 +1079,11 @@ static int sdma_get_pc(struct sdma_channel *sdmac, per_2_emi = sdma->script_addrs->sai_2_mcu_addr; emi_2_per = sdma->script_addrs->mcu_2_sai_addr;break ; +case IMX_DMATYPE_I2C : + per_2_emi = sdma->script_addrs->i2c_2_mcu_addr; + emi_2_per = sdma->script_addrs->mcu_2_i2c_addr; + sdmac->is_ram_script = true; +break ;case IMX_DMATYPE_HDMI : emi_2_per = sdma->script_addrs->hdmi_dma_addr; sdmac->is_ram_script = true;
include/linux/dma/imx-dma.h +1 -0
@@ -41,6 +41,7 @@ enum sdma_peripheral_type {IMX_DMATYPE_SAI ,/* SAI */ IMX_DMATYPE_MULTI_SAI ,/* MULTI FIFOs For Audio */ IMX_DMATYPE_HDMI ,/* HDMI Audio */ + IMX_DMATYPE_I2C, /* I2C */ }; enum imx_dma_prio {
Signature · 1 line
2.34.1
RE: [PATCH v2 4/4] dmaengine: imx-sdma: Add i2c dma support
Hi Frank,
Quoted 24 lines
-----Original Message-----
From: Frank Li <[email protected]>
Sent: 2024年3月8日 1:33
To: Vinod Koul <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Frank Li <[email protected]>; Robin Gong <[email protected]>; Clark Wang <[email protected]>; Joy Zou <[email protected]>; Daniel Baluta <[email protected]>
Subject: [PATCH v2 4/4] dmaengine: imx-sdma: Add i2c dma supportFrom: Robin Gong <[email protected]>
New sdma script (sdma-6q: v3.5, sdma-7d: v4.5) support i2c at imx8mp and imx6ull. So add I2C dma support.
Signed-off-by Robin Gong <[email protected]>Acked-by Clark Wang <[email protected]>Reviewed-by Joy Zou <[email protected]>Reviewed-by Daniel Baluta <[email protected]>Signed-off-by Frank Li <[email protected]>
Quoted 5 lines
--- drivers/dma/imx-sdma.c | 7 +++++++ include/linux/dma/imx-dma.h | 1 + 2 files changed, 8 insertions(+)
You are adding i2c dma support in sdma driver. Should we add new peripheral types ID for I2C in Documentation/devicetree/bindings/dma/fsl,imx-sdma.yaml? Could you help check again?
BR
Joy Zou
Fabio Estevam
reviewerRe: [PATCH v2 4/4] dmaengine: imx-sdma: Add i2c dma support
In reply to Frank LiQuoted 4 lines · Frank Li
From: Robin Gong <[email protected]>
New sdma script (sdma-6q: v3.5, sdma-7d: v4.5) support i2c at imx8mp and
v3.5/ v4.5 is from 2019, so not "new".
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/commit/imx/sdma/sdma-imx6q.bin?id=55edf5202154de59ee1c6a5b6b6ba6fa54571515
I think you meant v3.6/v4.6 that Joy Zou has just submitted:
https://lore.kernel.org/linux-firmware/[email protected]/T/#u
Frank Li
maintainerRe: [PATCH v2 4/4] dmaengine: imx-sdma: Add i2c dma support
Quoted 4 lines · Fabio Estevam
Quoted 3 lines · Frank Li
From: Robin Gong <[email protected]>
Quoted 8 lines
Quoted 1 line
New sdma script (sdma-6q: v3.5, sdma-7d: v4.5) support i2c at imx8mp and
v3.5/ v4.5 is from 2019, so not "new".
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/commit/imx/sdma/sdma-imx6q.bin?id=55edf5202154de59ee1c6a5b6b6ba6fa54571515I think you meant v3.6/v4.6 that Joy Zou has just submitted:
https://lore.kernel.org/linux-firmware/[email protected]/T/#u
Thank you point it out. Previous an internal git commit miss lead it. After confirm with joy zou, it should be v3.6/v4.6. Will update next version.
Frank