Skip to contentSkip to conversation

mmc: sdhci: Fix issue with uninitialized dma_slave_config

PATCH In review Tony Lindgren 4 participants 8 messages Aug 10, 2021 – Aug 16, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 mmc: sdhci: Fix issue with uninitialized dma_slave_config

Depending on the DMA driver being used, the struct dma_slave_config may need to be initialized to zero for the unused data.

For example, we have three DMA drivers using src_port_window_size and dst_port_window_size. If these are left uninitialized, it can cause DMA failures at least if external TI SDMA is ever configured for sdhci.

For other external DMA cases, this is probably not currently an issue but is still good to fix though.

Fixes 18e762e3b7a7 ("mmc: sdhci: add support for using external DMA devices")
Cc Adrian Hunter <[email protected]>
Cc Chunyan Zhang <[email protected]>
Cc Faiz Abbas <[email protected]>
Cc Peter Ujfalusi <[email protected]>
Cc Vinod Koul <[email protected]>
---
 drivers/mmc/host/sdhci.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci.c +1 -0
@@ -1222,6 +1222,7 @@ static int sdhci_external_dma_setup(struct sdhci_host *host,
 	if (!host->mapbase)
 		return -EINVAL;
 
+	memset(&cfg, 0, sizeof(cfg));
 	cfg.src_addr = host->mapbase + SDHCI_BUFFER;
 	cfg.dst_addr = host->mapbase + SDHCI_BUFFER;
 	cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
Signature · 1 line
2.32.0
#1 lore raw

PATCH 2/3 mmc: dw_mmc: Fix issue with uninitialized dma_slave_config

Depending on the DMA driver being used, the struct dma_slave_config may need to be initialized to zero for the unused data.

For example, we have three DMA drivers using src_port_window_size and dst_port_window_size. If these are left uninitialized, it can cause DMA failures.

For dw_mmc, this is probably not currently an issue but is still good to fix though.

Fixes 3fc7eaef44db ("mmc: dw_mmc: Add external dma interface support")
Cc Shawn Lin <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Peter Ujfalusi <[email protected]>
Cc Vinod Koul <[email protected]>
---
 drivers/mmc/host/dw_mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/dw_mmc.c +1 -0
@@ -782,6 +782,7 @@ static int dw_mci_edmac_start_dma(struct dw_mci *host,
 	int ret = 0;
 
 	/* Set external dma config: burst size, burst width */
+	memset(&cfg, 0, sizeof(cfg));
 	cfg.dst_addr = host->phy_regs + fifo_offset;
 	cfg.src_addr = cfg.dst_addr;
 	cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
Signature · 1 line
2.32.0
#2 lore raw

Re: [PATCH 2/3] mmc: dw_mmc: Fix issue with uninitialized dma_slave_config

Quoted 11 lines · Tony Lindgren

Depending on the DMA driver being used, the struct dma_slave_config may need to be initialized to zero for the unused data.

For example, we have three DMA drivers using src_port_window_size and dst_port_window_size. If these are left uninitialized, it can cause DMA failures.

For dw_mmc, this is probably not currently an issue but is still good to fix though.

Quoted 6 lines
Fixes 3fc7eaef44db ("mmc: dw_mmc: Add external dma interface support")
Cc Shawn Lin <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Peter Ujfalusi <[email protected]>
Cc Vinod Koul <[email protected]>

Applied for next, thanks!

Kind regards
Uffe

Quoted 17 lines
---
 drivers/mmc/host/dw_mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/dw_mmc.c +1 -1
@@ -782,6 +782,7 @@ static int dw_mci_edmac_start_dma(struct dw_mci *host,
        int ret = 0;
 
        /* Set external dma config: burst size, burst width */
+       memset(&cfg, 0, sizeof(cfg));
        cfg.dst_addr = host->phy_regs + fifo_offset;
        cfg.src_addr = cfg.dst_addr;
        cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
--

2.32.0

#3 lore raw

PATCH 3/3 mmc: moxart: Fix issue with uninitialized dma_slave_config

In reply to Tony Lindgren

Depending on the DMA driver being used, the struct dma_slave_config may need to be initialized to zero for the unused data.

For example, we have three DMA drivers using src_port_window_size and dst_port_window_size. If these are left uninitialized, it can cause DMA failures.

For moxart, this is probably not currently an issue but is still good to fix though.

Fixes 1b66e94e6b99 ("mmc: moxart: Add MOXA ART SD/MMC driver")
Cc Jonas Jensen <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Peter Ujfalusi <[email protected]>
---
 drivers/mmc/host/moxart-mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/moxart-mmc.c +1 -0
@@ -628,6 +628,7 @@ static int moxart_probe(struct platform_device *pdev)
 			 host->dma_chan_tx, host->dma_chan_rx);
 		host->have_dma = true;
 
+		memset(&cfg, 0, sizeof(cfg));
 		cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
 		cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
 
Signature · 1 line
2.32.0
#4 lore raw

Re: [PATCH 3/3] mmc: moxart: Fix issue with uninitialized dma_slave_config

Quoted 8 lines · Tony Lindgren

Depending on the DMA driver being used, the struct dma_slave_config may need to be initialized to zero for the unused data.

For example, we have three DMA drivers using src_port_window_size and dst_port_window_size. If these are left uninitialized, it can cause DMA failures.

Quoted 8 lines

For moxart, this is probably not currently an issue but is still good to fix though.

Fixes 1b66e94e6b99 ("mmc: moxart: Add MOXA ART SD/MMC driver")
Cc Jonas Jensen <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Peter Ujfalusi <[email protected]>

Applied for next, thanks!

Kind regards
Uffe

Quoted 17 lines
---
 drivers/mmc/host/moxart-mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/moxart-mmc.c +1 -1
@@ -628,6 +628,7 @@ static int moxart_probe(struct platform_device *pdev)
                         host->dma_chan_tx, host->dma_chan_rx);
                host->have_dma = true;
 
+               memset(&cfg, 0, sizeof(cfg));
                cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
                cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
 
--

2.32.0

maintainer Acked-by on v1 1/3
#5 lore raw
In reply to Tony Lindgren
Quoted 10 lines · Tony Lindgren

Depending on the DMA driver being used, the struct dma_slave_config may need to be initialized to zero for the unused data.

For example, we have three DMA drivers using src_port_window_size and dst_port_window_size. If these are left uninitialized, it can cause DMA failures at least if external TI SDMA is ever configured for sdhci.

For other external DMA cases, this is probably not currently an issue but is still good to fix though.

Quoted 7 lines
Fixes 18e762e3b7a7 ("mmc: sdhci: add support for using external DMA devices")
Cc Adrian Hunter <[email protected]>
Cc Chunyan Zhang <[email protected]>
Cc Faiz Abbas <[email protected]>
Cc Peter Ujfalusi <[email protected]>
Cc Vinod Koul <[email protected]>
Quoted 16 lines
---
 drivers/mmc/host/sdhci.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci.c +1 -0
@@ -1222,6 +1222,7 @@ static int sdhci_external_dma_setup(struct sdhci_host *host,
 	if (!host->mapbase)
 		return -EINVAL;
 
+	memset(&cfg, 0, sizeof(cfg));
 	cfg.src_addr = host->mapbase + SDHCI_BUFFER;
 	cfg.dst_addr = host->mapbase + SDHCI_BUFFER;
 	cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
Reviewed-by on v1 1/3
#6 lore raw
In reply to Tony Lindgren
Quoted 9 lines · Tony Lindgren

Depending on the DMA driver being used, the struct dma_slave_config may need to be initialized to zero for the unused data.

For example, we have three DMA drivers using src_port_window_size and dst_port_window_size. If these are left uninitialized, it can cause DMA failures at least if external TI SDMA is ever configured for sdhci.

For other external DMA cases, this is probably not currently an issue but is still good to fix though.

Quoted 23 lines
Fixes 18e762e3b7a7 ("mmc: sdhci: add support for using external DMA devices")
Cc Adrian Hunter <[email protected]>
Cc Chunyan Zhang <[email protected]>
Cc Faiz Abbas <[email protected]>
Cc Peter Ujfalusi <[email protected]>
Cc Vinod Koul <[email protected]>
---
 drivers/mmc/host/sdhci.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci.c +1 -0
@@ -1222,6 +1222,7 @@ static int sdhci_external_dma_setup(struct sdhci_host *host,
 	if (!host->mapbase)
 		return -EINVAL;
 
+	memset(&cfg, 0, sizeof(cfg));
 	cfg.src_addr = host->mapbase + SDHCI_BUFFER;
 	cfg.dst_addr = host->mapbase + SDHCI_BUFFER;
 	cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
Signature · 1 line
Péter
#7 lore raw
In reply to Tony Lindgren
Quoted 11 lines · Tony Lindgren

Depending on the DMA driver being used, the struct dma_slave_config may need to be initialized to zero for the unused data.

For example, we have three DMA drivers using src_port_window_size and dst_port_window_size. If these are left uninitialized, it can cause DMA failures at least if external TI SDMA is ever configured for sdhci.

For other external DMA cases, this is probably not currently an issue but is still good to fix though.

Quoted 7 lines
Fixes 18e762e3b7a7 ("mmc: sdhci: add support for using external DMA devices")
Cc Adrian Hunter <[email protected]>
Cc Chunyan Zhang <[email protected]>
Cc Faiz Abbas <[email protected]>
Cc Peter Ujfalusi <[email protected]>
Cc Vinod Koul <[email protected]>

Applied for next, thanks!

Kind regards
Uffe

Quoted 17 lines
---
 drivers/mmc/host/sdhci.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci.c +1 -1
@@ -1222,6 +1222,7 @@ static int sdhci_external_dma_setup(struct sdhci_host *host,
        if (!host->mapbase)
                return -EINVAL;
 
+       memset(&cfg, 0, sizeof(cfg));
        cfg.src_addr = host->mapbase + SDHCI_BUFFER;
        cfg.dst_addr = host->mapbase + SDHCI_BUFFER;
        cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
--

2.32.0