Mason <slash.tmp@xxxxxxx> writes: > On 15/11/2016 12:02, Mason wrote: > >> I would like to be able to setup my board's DMA engine at the time when >> dma_request_chan() is called by the driver using that specific channel. >> (Or some time later, but before an actual transfer is requested.) >> >> Does dma_request_chan() call back into the DMA driver at some point? >> If yes, through which function pointer? >> >> I see that of_dma_request_slave_channel() calls ofdma->of_dma_xlate() >> which is the function registered through of_dma_controller_register() >> in the DMA driver, right? >> >> Currently, the driver sets up the DMA engine at the time when the >> device_issue_pending() method is called, but this creates a catch-22 >> situation where A must be before B, and B must be before A. >> >> Looking at struct dma_device ... >> http://lxr.free-electrons.com/source/include/linux/dmaengine.h#L637 >> Could I use the device_config() call-back for this? >> >> https://www.kernel.org/doc/Documentation/dmaengine/client.txt > > Let me try describing the problem on a higher level. > > I'm currently using this DMA driver on my board: > https://github.com/mansr/linux-tangox/blob/master/drivers/dma/tangox-dma.c You're aware it doesn't work on tango4 and later, right? It's probably enough to update the register bitfield locations, but I'm not sure. > The driver configures the DMA HW in device_issue_pending() in two steps > A) switch box (sbox) setup > B) memory bus (mbus) channel setup Since there are more client devices than DMA channels, the driver multiplexes them like this. > And the DMA engine client (a NAND Flash controller driver) starts a > transfer by programming the NFC registers. > > The problem is that the steps need to be done in this order: > 1) SBOX > 2) NAND > 3) MBUS > > But in the current design, there is no way to have the NAND step > *between* SBOX and MBUS steps. > > For now, I have hard-coded the SBOX setup in the driver's probe function, > but that's just a hack. IMO, it makes sense to configure the SBOX > only once, when the client driver "registers" with the DMA driver > (dma_request_chan if I understand correctly) and release the HW > channel when the client driver "unbinds". Then you can only use as many devices as you have channels. -- Måns Rullgård -- To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html