linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* dmaengine: usage of dmaengine_get() and dma_find_channel()
@ 2019-01-21 16:41 Federico Vaga
  2019-01-23 12:15 ` Vinod Koul
  0 siblings, 1 reply; 3+ messages in thread
From: Federico Vaga @ 2019-01-21 16:41 UTC (permalink / raw)
  To: Vinod Koul, linux-kernel; +Cc: dmaengine

Hello,

I am a bit puzzle about the proper usage these two functions:

void dmaengine_get(void)
struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)

Looking into the kernel sources dma_find_channel is not used, despite the fact 
that it looks as one of the suggested mechanism to access a DMA engine. So, I 
cannot find a valid example of its usage.

The same for dmaengine_get(). On the other hand, at least this function is 
used in: drivers/video/fbdev/mx3fb.c. But I believe that its usage is wrong 
because it uses: dmaengine_get() + dma_request_channel(), instead of 
dmaengine_get() + dma_find_channel().

Reading the code my understanding is that dmaengine_get() + dma_find_channel() 
should be used for "public" (not private) DMA engine channels.

It's here where things are getting obscure to me. My understanding is that DMA 
channels which are not private can be used by several drivers at the same 
time. In principle they submit all their transfers and the DMA engine will 
process them and then the DMA engine will notify the drivers about their 
completion.

My understanding is also that the dmaengine subsystem assumes that "public" 
channels of the same type are interchangeable.

In my use case I wrote a DMA engine which is specific for a subset of driver, 
and it cannot be used by others (so is sharable among a group of drivers). All 
these drivers, potentially, they can submit their transfers to the DMA engine 
in parallel; but I cannot do it because I'm forced to use 
dma_request_channel() in order to be able to filter the DMA channels, and this 
will make automatically the channel PRIVATE which prevents other drivers to 
use the same channel.

With the current API I do not see alternative for me. I have to use 
dma_request_channel() in order to filter DMA channels. But I am wondering if 
it make sense for you, and if it does, is there a solution today? Or, is it 
possibile to design one?

Thanks (I do not know if this message is clear enough)



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dmaengine: usage of dmaengine_get() and dma_find_channel()
  2019-01-21 16:41 dmaengine: usage of dmaengine_get() and dma_find_channel() Federico Vaga
@ 2019-01-23 12:15 ` Vinod Koul
  2019-01-23 12:36   ` Federico Vaga
  0 siblings, 1 reply; 3+ messages in thread
From: Vinod Koul @ 2019-01-23 12:15 UTC (permalink / raw)
  To: Federico Vaga; +Cc: linux-kernel, dmaengine

On 21-01-19, 17:41, Federico Vaga wrote:
> Hello,
> 
> I am a bit puzzle about the proper usage these two functions:
> 
> void dmaengine_get(void)
> struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)
> 
> Looking into the kernel sources dma_find_channel is not used, despite the fact 
> that it looks as one of the suggested mechanism to access a DMA engine. So, I 
> cannot find a valid example of its usage.
> 
> The same for dmaengine_get(). On the other hand, at least this function is 
> used in: drivers/video/fbdev/mx3fb.c. But I believe that its usage is wrong 
> because it uses: dmaengine_get() + dma_request_channel(), instead of 
> dmaengine_get() + dma_find_channel().
> 
> Reading the code my understanding is that dmaengine_get() + dma_find_channel() 
> should be used for "public" (not private) DMA engine channels.
> 
> It's here where things are getting obscure to me. My understanding is that DMA 
> channels which are not private can be used by several drivers at the same 
> time. In principle they submit all their transfers and the DMA engine will 
> process them and then the DMA engine will notify the drivers about their 
> completion.

The concept of public channel is a channel capable of doing any dma
transfer for example a system dmaengine capable of flipping bits from
system memory to memory/devices.

For peripherals, we cannot do a generic transfer and the transfer is
specific given a set of parameters for it to work, thus the channel is
private... These channels can be used by many users as long as that is
supported by engine. In an idle world, the dmaengine should have N
channels and provide M software channels and lets users use them and
schedule these for best throughput, we are not there yet :(

> My understanding is also that the dmaengine subsystem assumes that "public" 
> channels of the same type are interchangeable.
> 
> In my use case I wrote a DMA engine which is specific for a subset of driver, 
> and it cannot be used by others (so is sharable among a group of drivers). All 
> these drivers, potentially, they can submit their transfers to the DMA engine 
> in parallel; but I cannot do it because I'm forced to use 
> dma_request_channel() in order to be able to filter the DMA channels, and this 
> will make automatically the channel PRIVATE which prevents other drivers to 
> use the same channel.

Please use virtual channels for that, clients can use virtual channels
and they can be submitted to a hardware channel.

> With the current API I do not see alternative for me. I have to use 
> dma_request_channel() in order to filter DMA channels. But I am wondering if 
> it make sense for you, and if it does, is there a solution today? Or, is it 
> possibile to design one?
> 
> Thanks (I do not know if this message is clear enough)
> 

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dmaengine: usage of dmaengine_get() and dma_find_channel()
  2019-01-23 12:15 ` Vinod Koul
@ 2019-01-23 12:36   ` Federico Vaga
  0 siblings, 0 replies; 3+ messages in thread
From: Federico Vaga @ 2019-01-23 12:36 UTC (permalink / raw)
  To: Vinod Koul; +Cc: linux-kernel, dmaengine

Thanks for your suggestion

On Wednesday, January 23, 2019 1:15:21 PM CET Vinod Koul wrote:
> On 21-01-19, 17:41, Federico Vaga wrote:
> > Hello,
> > 
> > I am a bit puzzle about the proper usage these two functions:
> > 
> > void dmaengine_get(void)
> > struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)
> > 
> > Looking into the kernel sources dma_find_channel is not used, despite the
> > fact that it looks as one of the suggested mechanism to access a DMA
> > engine. So, I cannot find a valid example of its usage.
> > 
> > The same for dmaengine_get(). On the other hand, at least this function is
> > used in: drivers/video/fbdev/mx3fb.c. But I believe that its usage is
> > wrong
> > because it uses: dmaengine_get() + dma_request_channel(), instead of
> > dmaengine_get() + dma_find_channel().
> > 
> > Reading the code my understanding is that dmaengine_get() +
> > dma_find_channel() should be used for "public" (not private) DMA engine
> > channels.
> > 
> > It's here where things are getting obscure to me. My understanding is that
> > DMA channels which are not private can be used by several drivers at the
> > same time. In principle they submit all their transfers and the DMA
> > engine will process them and then the DMA engine will notify the drivers
> > about their completion.
> 
> The concept of public channel is a channel capable of doing any dma
> transfer for example a system dmaengine capable of flipping bits from
> system memory to memory/devices.
> 
> For peripherals, we cannot do a generic transfer and the transfer is
> specific given a set of parameters for it to work, thus the channel is
> private... These channels can be used by many users as long as that is
> supported by engine. In an idle world, the dmaengine should have N
> channels and provide M software channels and lets users use them and
> schedule these for best throughput, we are not there yet :(
> 
> > My understanding is also that the dmaengine subsystem assumes that
> > "public"
> > channels of the same type are interchangeable.
> > 
> > In my use case I wrote a DMA engine which is specific for a subset of
> > driver, and it cannot be used by others (so is sharable among a group of
> > drivers). All these drivers, potentially, they can submit their transfers
> > to the DMA engine in parallel; but I cannot do it because I'm forced to
> > use
> > dma_request_channel() in order to be able to filter the DMA channels, and
> > this will make automatically the channel PRIVATE which prevents other
> > drivers to use the same channel.
> 
> Please use virtual channels for that, clients can use virtual channels
> and they can be submitted to a hardware channel.
> 
> > With the current API I do not see alternative for me. I have to use
> > dma_request_channel() in order to filter DMA channels. But I am wondering
> > if it make sense for you, and if it does, is there a solution today? Or,
> > is it possibile to design one?
> > 
> > Thanks (I do not know if this message is clear enough)





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-23 12:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-21 16:41 dmaengine: usage of dmaengine_get() and dma_find_channel() Federico Vaga
2019-01-23 12:15 ` Vinod Koul
2019-01-23 12:36   ` Federico Vaga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).