bcm2835: dma: strangeness of of_dma_request_slave_channel

Stephen Warren swarren at wwwdotorg.org
Mon Apr 27 13:24:10 PDT 2015


On 04/27/2015 12:37 PM, Martin Sperl wrote:
> Hi!
>
> While implementing DMA mode fro the spi-bcm2835 driver I have run
> into some strangeness:
>
> When loading unloading and reloading the module the call to
> of_dma_request_slave_channel fails on the second load and there
> only for the second dma channel requested.

Is this at all related to:

http://www.spinics.net/lists/dmaengine/msg03906.html
[PATCH] dmaengine: increment privatecnt when using dma_get_any_slave_channel

https://lkml.org/lkml/2015/4/27/261
[PATCH] dmaengine: Fix dma_get_any_slave_channel() handling of private 
channels

(quoting everything for the sake of those CC'd into the thread)

> Here the basics:
> void bcm2835_dma_release(struct spi_master *master)
> {
>          if (master->dma_tx) {
>                  dma_release_channel(master->dma_tx);
>                  master->dma_tx = NULL;
>          }
>          if (master->dma_rx) {
>                  dma_release_channel(master->dma_rx);
>                  master->dma_rx = NULL;
>          }
> }
>
> void bcm2835_dma_init(struct spi_master *master, struct device *dev)
> {
>          struct bcm2835_spi *bs = spi_master_get_devdata(master);
>          struct dma_slave_config slave_config;
>          int ret;
>
>          /* get tx/rx dma */
>          master->dma_tx = dma_request_slave_channel(dev, "tx");
>          if (!master->dma_tx) {
>                  dev_err(dev, "no tx-dma found - not using dma mode\n");
>                  goto err;
>          }
>          master->dma_rx = dma_request_slave_channel(dev, "rx");
>          if (!master->dma_rx) {
>                  dev_err(dev, "only tx-dma was found - not using dma mode\n");
>                  goto err_release;
>          }
>         	...
> 	ret = dmaengine_slave_config(master->dma_tx, &slave_config);
>         	...
> 	ret = dmaengine_slave_config(master->dma_rx, &slave_config);
>
> }
>
> here the portion in the device-tree:
>          dmas = <&dma 6>, <&dma 7>;
>          dma-names = "tx", "rx";
>
> So after a reboot I run:
> modprobe spi-bcm2835
> rmmod spi-bcm2835
> modprobe spi-bcm2835
>
> dmesg shows: "only tx-dma was found - not using dma mode"
> for the second modprobe - the first one is fine and the channels are
> found - the only way arround it is reboot!
>
> So it can get a channel for TX (typically channel 4) and for rx it
> fails for any module load besides the first (which returns channel 5
> on the first load)
>
> Tracing it further I see (inside bcm2835_dma_xlate) that
> 	chan = dma_get_any_slave_channel(&d->ddev);
>
> returns NULL the second (or any subsequent) times the module gets
> loaded.
>
> Has someone any insight why this could be the case and how to avoid it?
> I am tired of rebooting every time i apply a change!
>
> Thanks,
> 	Martin
>
> P.s: I have applied V2 of the patch to enable normal DMA operation.
>
> _______________________________________________
> linux-rpi-kernel mailing list
> linux-rpi-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel




More information about the linux-rpi-kernel mailing list