Skip to content

Commit 49b1c21

Browse files
ADESTMvinodkoul
authored andcommitted
dmaengine: stm32-dma3: defer channel registration to specify channel name
On STM32 DMA3, channels can be reserved, so they are non available for Linux. This non-availability creates a mismatch between dma_chan id and DMA3 channel id. Use dma_async_device_channel_register() to register the channels after controller registration and change the default channel name, so that it can match the name in the Reference Manual and ease requesting a channel thanks to its name. Signed-off-by: Amelie Delaunay <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 10b8e0f commit 49b1c21

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

drivers/dma/stm32/stm32-dma3.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,24 +1732,33 @@ static int stm32_dma3_probe(struct platform_device *pdev)
17321732
chan->fifo_size = get_chan_hwcfg(i, G_FIFO_SIZE(i), hwcfgr);
17331733
/* If chan->fifo_size > 0 then half of the fifo size, else no burst when no FIFO */
17341734
chan->max_burst = (chan->fifo_size) ? (1 << (chan->fifo_size + 1)) / 2 : 0;
1735-
chan->vchan.desc_free = stm32_dma3_chan_vdesc_free;
1736-
1737-
vchan_init(&chan->vchan, dma_dev);
17381735
}
17391736

17401737
ret = dmaenginem_async_device_register(dma_dev);
17411738
if (ret)
17421739
goto err_clk_disable;
17431740

17441741
for (i = 0; i < ddata->dma_channels; i++) {
1742+
char name[12];
1743+
17451744
if (chan_reserved & BIT(i))
17461745
continue;
17471746

1747+
chan = &ddata->chans[i];
1748+
snprintf(name, sizeof(name), "dma%dchan%d", ddata->dma_dev.dev_id, chan->id);
1749+
1750+
chan->vchan.desc_free = stm32_dma3_chan_vdesc_free;
1751+
vchan_init(&chan->vchan, dma_dev);
1752+
1753+
ret = dma_async_device_channel_register(&ddata->dma_dev, &chan->vchan.chan, name);
1754+
if (ret) {
1755+
dev_err_probe(&pdev->dev, ret, "Failed to register channel %s\n", name);
1756+
goto err_clk_disable;
1757+
}
1758+
17481759
ret = platform_get_irq(pdev, i);
17491760
if (ret < 0)
17501761
goto err_clk_disable;
1751-
1752-
chan = &ddata->chans[i];
17531762
chan->irq = ret;
17541763

17551764
ret = devm_request_irq(&pdev->dev, chan->irq, stm32_dma3_chan_irq, 0,

0 commit comments

Comments
 (0)