Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-20 Thread Baolin Wang
On Wed, 20 Feb 2019 at 17:08, Arnd Bergmann  wrote:
>
> On Wed, Feb 20, 2019 at 4:13 AM Baolin Wang  wrote:
> > On Tue, 19 Feb 2019 at 20:20, Vinod Koul  wrote:
> > > On 19-02-19, 17:49, Baolin Wang wrote:
> > > > On Tue, 19 Feb 2019 at 17:30, Geert Uytterhoeven  
> > > > wrote:
> > > > > On Tue, Feb 19, 2019 at 4:15 AM Baolin Wang  
> > > > > wrote:
> > > > > > On Mon, 18 Feb 2019 at 20:23, Arnd Bergmann  wrote:
> > > > > > > On Mon, Feb 18, 2019 at 11:52 AM Baolin Wang 
> > > > > > >  wrote:
> > > > > > > > On Mon, 18 Feb 2019 at 18:31, Arnd Bergmann  
> > > > > > > > wrote:
> > > > > > > I did understand the need for a slave-id, I was instead wondering 
> > > > > > > about
> > > > > > > the channel-id number. On many SoCs, all channels are equal, and 
> > > > > > > you
> > > > > > > just have to pick one of those with the right capabilities for a 
> > > > > > > particular
> > > > > > > slave.
> > > > > >
> > > > > > Yes, all channels are equal. We just set a unique slave id for the
> > > > > > channel for a particular slave. For example, the SPI slave can use
> > > > > > channel 10 for tx transfer by setting slave id 11, or it also can 
> > > > > > use
> > > > > > channel 9 for tx transfer by setting same slave id 11.
> > > > >
> > > > > So the channel selection is software policy, not hardware 
> > > > > description, and
> > > > > thus doesn't belong in DT?
> > > > >
> > > > > Can't the DMA engine driver allocate channels dynamically, removing 
> > > > > the
> > > > > need to specify this in DT?
> > > >
> > > > In theory we can do as you suggested. But we still want to
> > > > manage/assign the DMA channel resources manually for one SoC, we can
> > > > make sure some important DMA slaves (such as audio)  can request a DMA
> > > > channel at runtime firstly, another benefit is that it is easy to
> > > > debug since we can easily know which channel is assigned for this
> > > > slave.
> > >
> > > Are  you suggesting that you have more users than channels available?
> >
> > Until now we have not met this issue, but we can not make sure if this
> > can happen in future. Moreover DMA channel resources are belonging to
> > the DMA engine's hardware resources, I think it should be described in
> > DT like many other drivers did.
>
> As far as I can tell, most platforms do not describe the assignment
> of resources in DT for dma engines, the numbers in there are meant to
> describe whatever is fixed, and most platforms should do it that way.
>
> The naming is sometimes a bit confusing, as a dma request line
> assignment can be called a slave-id or a channel-id depending whose
> documentation you read. The drivers/dma/virt-dma.c implementation
> is used in some cases to represent request numbers as virtual
> channels, so a dmaengine driver can allow one dma_request_chan()
> per slave, and then assign the hardware channels dynamically
> while doing a transfer, rather than having a fixed channel assignment
> when we first ask for a channel.

Okay, sounds reasonable to me, and I think no issues will happen if we
assign channels dynamically after some slave usages' investigation.

I will remove channel id from DT in next version. Thanks for all your help.

-- 
Baolin Wang
Best Regards


Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-20 Thread Arnd Bergmann
On Wed, Feb 20, 2019 at 4:13 AM Baolin Wang  wrote:
> On Tue, 19 Feb 2019 at 20:20, Vinod Koul  wrote:
> > On 19-02-19, 17:49, Baolin Wang wrote:
> > > On Tue, 19 Feb 2019 at 17:30, Geert Uytterhoeven  
> > > wrote:
> > > > On Tue, Feb 19, 2019 at 4:15 AM Baolin Wang  
> > > > wrote:
> > > > > On Mon, 18 Feb 2019 at 20:23, Arnd Bergmann  wrote:
> > > > > > On Mon, Feb 18, 2019 at 11:52 AM Baolin Wang 
> > > > > >  wrote:
> > > > > > > On Mon, 18 Feb 2019 at 18:31, Arnd Bergmann  wrote:
> > > > > > I did understand the need for a slave-id, I was instead wondering 
> > > > > > about
> > > > > > the channel-id number. On many SoCs, all channels are equal, and you
> > > > > > just have to pick one of those with the right capabilities for a 
> > > > > > particular
> > > > > > slave.
> > > > >
> > > > > Yes, all channels are equal. We just set a unique slave id for the
> > > > > channel for a particular slave. For example, the SPI slave can use
> > > > > channel 10 for tx transfer by setting slave id 11, or it also can use
> > > > > channel 9 for tx transfer by setting same slave id 11.
> > > >
> > > > So the channel selection is software policy, not hardware description, 
> > > > and
> > > > thus doesn't belong in DT?
> > > >
> > > > Can't the DMA engine driver allocate channels dynamically, removing the
> > > > need to specify this in DT?
> > >
> > > In theory we can do as you suggested. But we still want to
> > > manage/assign the DMA channel resources manually for one SoC, we can
> > > make sure some important DMA slaves (such as audio)  can request a DMA
> > > channel at runtime firstly, another benefit is that it is easy to
> > > debug since we can easily know which channel is assigned for this
> > > slave.
> >
> > Are  you suggesting that you have more users than channels available?
>
> Until now we have not met this issue, but we can not make sure if this
> can happen in future. Moreover DMA channel resources are belonging to
> the DMA engine's hardware resources, I think it should be described in
> DT like many other drivers did.

As far as I can tell, most platforms do not describe the assignment
of resources in DT for dma engines, the numbers in there are meant to
describe whatever is fixed, and most platforms should do it that way.

The naming is sometimes a bit confusing, as a dma request line
assignment can be called a slave-id or a channel-id depending whose
documentation you read. The drivers/dma/virt-dma.c implementation
is used in some cases to represent request numbers as virtual
channels, so a dmaengine driver can allow one dma_request_chan()
per slave, and then assign the hardware channels dynamically
while doing a transfer, rather than having a fixed channel assignment
when we first ask for a channel.

   Arnd


Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-19 Thread Baolin Wang
On Tue, 19 Feb 2019 at 20:20, Vinod Koul  wrote:
>
> On 19-02-19, 17:49, Baolin Wang wrote:
> > Hi Geert,
> >
> > On Tue, 19 Feb 2019 at 17:30, Geert Uytterhoeven  
> > wrote:
> > >
> > > Hi Baolin,
> > >
> > > On Tue, Feb 19, 2019 at 4:15 AM Baolin Wang  
> > > wrote:
> > > > On Mon, 18 Feb 2019 at 20:23, Arnd Bergmann  wrote:
> > > > > On Mon, Feb 18, 2019 at 11:52 AM Baolin Wang  
> > > > > wrote:
> > > > > > On Mon, 18 Feb 2019 at 18:31, Arnd Bergmann  wrote:
> > > > > > >
> > > > > > > On Tue, Feb 12, 2019 at 9:25 AM Baolin Wang 
> > > > > > >  wrote:
> > > > > > > > On Fri, 1 Feb 2019 at 19:53, Baolin Wang 
> > > > > > > >  wrote:
> > > > > > > > > On Thu, 31 Jan 2019 at 00:52, Arnd Bergmann  
> > > > > > > > > wrote:
> > > > > > > > > > On Tue, Jan 22, 2019 at 2:21 PM Baolin Wang 
> > > > > > > > > >  wrote:
> > > > > > > > > > >
> > > > > > > > > > >  Client:
> > > > > > > > > > >  DMA clients connected to the Spreadtrum DMA controller 
> > > > > > > > > > > must use the format
> > > > > > > > > > > -described in the dma.txt file, using a two-cell 
> > > > > > > > > > > specifier for each channel.
> > > > > > > > > > > -The two cells in order are:
> > > > > > > > > > > +described in the dma.txt file, using a three-cell 
> > > > > > > > > > > specifier for each channel.
> > > > > > > > > > > +The three cells in order are:
> > > > > > > > > > >  1. A phandle pointing to the DMA controller.
> > > > > > > > > > >  2. The channel id.
> > > > > > > > > > > +3. The hardware slave id which is used for clients to 
> > > > > > > > > > > trigger DMA engine
> > > > > > > > > > > +automatically.
> > > > > > > > > >
> > > > > > > > > > I notice that this is an incompatible binding change. Is 
> > > > > > > > > > that necessary?
> > > > > > > > > > If the current code works, I'd suggest allowing both 
> > > > > > > > > > #dma-cells=<2>
> > > > > > > > > > and <3>, and then implementing both in the driver.
> > > > > > > > >
> > > > > > > > > Yes, this is necessary.
> > > > > > > > >
> > > > > > > > > Yes, current code can work, but the problem is that the DMA 
> > > > > > > > > clients
> > > > > > > > > must add one property (something like "sprd,slave-id") to 
> > > > > > > > > specify the
> > > > > > > > > slave id. So considering this, we want to change the 
> > > > > > > > > dma-cells to 2,
> > > > > > > > > including dma channel and dma slave id, which can avoid 
> > > > > > > > > introducing
> > > > > > > > > some similar properties for DMA clients.
> > > > > > > > >
> > > > > > > > > Now there are no DMA clients in mainline for Spreadtrum 
> > > > > > > > > platform, and
> > > > > > > > > we want to upstream our first DMA clients: SPI controller. So 
> > > > > > > > > no other
> > > > > > > > > drivers need to change when we changing dma cells. Thanks.
> > > > > > > >
> > > > > > > > Do you have any other concerns about this patch set? If not, I 
> > > > > > > > think
> > > > > > > > Vinod can apply this patch set. Thanks.
> > > > > > >
> > > > > > > Sorry for the late reply. Yes, this makes sense since there are no
> > > > > > > existing users then. For the DT changes going through the 
> > > > > > > dmaengine
> > > > > > > tree
> > > > > > >
> > > > > > > Acked-by: Arnd Bergmann 
> > > > > >
> > > > > > Thanks for your reviewing.
> > > > > >
> > > > > > >
> > > > > > > One more question, to make sure we don't need to edit it again:
> > > > > > > Why do you need both a 'channel id' and a 'slave id' here? Is this
> > > > > > > a strict hardware requirement for your DMA engine? In many
> > > > > > > other designs, only a DMA request line number needs to
> > > > > > > be described, and I think this would correspond to what you
> > > > > > > call the 'hardware slave id' in your documentation.
> > > > > >
> > > > > > I try to explain why we need the slave id.
> > > > > >
> > > > > > For our DMA engine driver, we have software request mode and 
> > > > > > hardware
> > > > > > request mode. For software request mode, the DMA engine driver need
> > > > > > trigger DMA to start transfer manually. But for hardware request 
> > > > > > mode,
> > > > > > we just set one unique slave id corresponding to the slave hardware 
> > > > > > to
> > > > > > the DMA engine, then the slave hardware can trigger DMA 
> > > > > > automatically.
> > > > > > And the slave id is not always same with the channel id according to
> > > > > > the SoC design, so we add one cell to specify the slave id.
> > > > >
> > > > > I did understand the need for a slave-id, I was instead wondering 
> > > > > about
> > > > > the channel-id number. On many SoCs, all channels are equal, and you
> > > > > just have to pick one of those with the right capabilities for a 
> > > > > particular
> > > > > slave.
> > > >
> > > > Yes, all channels are equal. We just set a unique slave id for the
> > > > channel for a particular slave. For example, the SPI slave can use
> > > > channel 10 for tx transfer by setting slave id 11, or it also can use
> > > > 

Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-19 Thread Vinod Koul
On 19-02-19, 17:49, Baolin Wang wrote:
> Hi Geert,
> 
> On Tue, 19 Feb 2019 at 17:30, Geert Uytterhoeven  wrote:
> >
> > Hi Baolin,
> >
> > On Tue, Feb 19, 2019 at 4:15 AM Baolin Wang  wrote:
> > > On Mon, 18 Feb 2019 at 20:23, Arnd Bergmann  wrote:
> > > > On Mon, Feb 18, 2019 at 11:52 AM Baolin Wang  
> > > > wrote:
> > > > > On Mon, 18 Feb 2019 at 18:31, Arnd Bergmann  wrote:
> > > > > >
> > > > > > On Tue, Feb 12, 2019 at 9:25 AM Baolin Wang 
> > > > > >  wrote:
> > > > > > > On Fri, 1 Feb 2019 at 19:53, Baolin Wang  
> > > > > > > wrote:
> > > > > > > > On Thu, 31 Jan 2019 at 00:52, Arnd Bergmann  
> > > > > > > > wrote:
> > > > > > > > > On Tue, Jan 22, 2019 at 2:21 PM Baolin Wang 
> > > > > > > > >  wrote:
> > > > > > > > > >
> > > > > > > > > >  Client:
> > > > > > > > > >  DMA clients connected to the Spreadtrum DMA controller 
> > > > > > > > > > must use the format
> > > > > > > > > > -described in the dma.txt file, using a two-cell specifier 
> > > > > > > > > > for each channel.
> > > > > > > > > > -The two cells in order are:
> > > > > > > > > > +described in the dma.txt file, using a three-cell 
> > > > > > > > > > specifier for each channel.
> > > > > > > > > > +The three cells in order are:
> > > > > > > > > >  1. A phandle pointing to the DMA controller.
> > > > > > > > > >  2. The channel id.
> > > > > > > > > > +3. The hardware slave id which is used for clients to 
> > > > > > > > > > trigger DMA engine
> > > > > > > > > > +automatically.
> > > > > > > > >
> > > > > > > > > I notice that this is an incompatible binding change. Is that 
> > > > > > > > > necessary?
> > > > > > > > > If the current code works, I'd suggest allowing both 
> > > > > > > > > #dma-cells=<2>
> > > > > > > > > and <3>, and then implementing both in the driver.
> > > > > > > >
> > > > > > > > Yes, this is necessary.
> > > > > > > >
> > > > > > > > Yes, current code can work, but the problem is that the DMA 
> > > > > > > > clients
> > > > > > > > must add one property (something like "sprd,slave-id") to 
> > > > > > > > specify the
> > > > > > > > slave id. So considering this, we want to change the dma-cells 
> > > > > > > > to 2,
> > > > > > > > including dma channel and dma slave id, which can avoid 
> > > > > > > > introducing
> > > > > > > > some similar properties for DMA clients.
> > > > > > > >
> > > > > > > > Now there are no DMA clients in mainline for Spreadtrum 
> > > > > > > > platform, and
> > > > > > > > we want to upstream our first DMA clients: SPI controller. So 
> > > > > > > > no other
> > > > > > > > drivers need to change when we changing dma cells. Thanks.
> > > > > > >
> > > > > > > Do you have any other concerns about this patch set? If not, I 
> > > > > > > think
> > > > > > > Vinod can apply this patch set. Thanks.
> > > > > >
> > > > > > Sorry for the late reply. Yes, this makes sense since there are no
> > > > > > existing users then. For the DT changes going through the dmaengine
> > > > > > tree
> > > > > >
> > > > > > Acked-by: Arnd Bergmann 
> > > > >
> > > > > Thanks for your reviewing.
> > > > >
> > > > > >
> > > > > > One more question, to make sure we don't need to edit it again:
> > > > > > Why do you need both a 'channel id' and a 'slave id' here? Is this
> > > > > > a strict hardware requirement for your DMA engine? In many
> > > > > > other designs, only a DMA request line number needs to
> > > > > > be described, and I think this would correspond to what you
> > > > > > call the 'hardware slave id' in your documentation.
> > > > >
> > > > > I try to explain why we need the slave id.
> > > > >
> > > > > For our DMA engine driver, we have software request mode and hardware
> > > > > request mode. For software request mode, the DMA engine driver need
> > > > > trigger DMA to start transfer manually. But for hardware request mode,
> > > > > we just set one unique slave id corresponding to the slave hardware to
> > > > > the DMA engine, then the slave hardware can trigger DMA automatically.
> > > > > And the slave id is not always same with the channel id according to
> > > > > the SoC design, so we add one cell to specify the slave id.
> > > >
> > > > I did understand the need for a slave-id, I was instead wondering about
> > > > the channel-id number. On many SoCs, all channels are equal, and you
> > > > just have to pick one of those with the right capabilities for a 
> > > > particular
> > > > slave.
> > >
> > > Yes, all channels are equal. We just set a unique slave id for the
> > > channel for a particular slave. For example, the SPI slave can use
> > > channel 10 for tx transfer by setting slave id 11, or it also can use
> > > channel 9 for tx transfer by setting same slave id 11.
> >
> > So the channel selection is software policy, not hardware description, and
> > thus doesn't belong in DT?
> >
> > Can't the DMA engine driver allocate channels dynamically, removing the
> > need to specify this in DT?
> 
> In theory we can do as you suggested. But we still want to
> 

Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-19 Thread Baolin Wang
Hi Geert,

On Tue, 19 Feb 2019 at 17:30, Geert Uytterhoeven  wrote:
>
> Hi Baolin,
>
> On Tue, Feb 19, 2019 at 4:15 AM Baolin Wang  wrote:
> > On Mon, 18 Feb 2019 at 20:23, Arnd Bergmann  wrote:
> > > On Mon, Feb 18, 2019 at 11:52 AM Baolin Wang  
> > > wrote:
> > > > On Mon, 18 Feb 2019 at 18:31, Arnd Bergmann  wrote:
> > > > >
> > > > > On Tue, Feb 12, 2019 at 9:25 AM Baolin Wang  
> > > > > wrote:
> > > > > > On Fri, 1 Feb 2019 at 19:53, Baolin Wang  
> > > > > > wrote:
> > > > > > > On Thu, 31 Jan 2019 at 00:52, Arnd Bergmann  wrote:
> > > > > > > > On Tue, Jan 22, 2019 at 2:21 PM Baolin Wang 
> > > > > > > >  wrote:
> > > > > > > > >
> > > > > > > > >  Client:
> > > > > > > > >  DMA clients connected to the Spreadtrum DMA controller must 
> > > > > > > > > use the format
> > > > > > > > > -described in the dma.txt file, using a two-cell specifier 
> > > > > > > > > for each channel.
> > > > > > > > > -The two cells in order are:
> > > > > > > > > +described in the dma.txt file, using a three-cell specifier 
> > > > > > > > > for each channel.
> > > > > > > > > +The three cells in order are:
> > > > > > > > >  1. A phandle pointing to the DMA controller.
> > > > > > > > >  2. The channel id.
> > > > > > > > > +3. The hardware slave id which is used for clients to 
> > > > > > > > > trigger DMA engine
> > > > > > > > > +automatically.
> > > > > > > >
> > > > > > > > I notice that this is an incompatible binding change. Is that 
> > > > > > > > necessary?
> > > > > > > > If the current code works, I'd suggest allowing both 
> > > > > > > > #dma-cells=<2>
> > > > > > > > and <3>, and then implementing both in the driver.
> > > > > > >
> > > > > > > Yes, this is necessary.
> > > > > > >
> > > > > > > Yes, current code can work, but the problem is that the DMA 
> > > > > > > clients
> > > > > > > must add one property (something like "sprd,slave-id") to specify 
> > > > > > > the
> > > > > > > slave id. So considering this, we want to change the dma-cells to 
> > > > > > > 2,
> > > > > > > including dma channel and dma slave id, which can avoid 
> > > > > > > introducing
> > > > > > > some similar properties for DMA clients.
> > > > > > >
> > > > > > > Now there are no DMA clients in mainline for Spreadtrum platform, 
> > > > > > > and
> > > > > > > we want to upstream our first DMA clients: SPI controller. So no 
> > > > > > > other
> > > > > > > drivers need to change when we changing dma cells. Thanks.
> > > > > >
> > > > > > Do you have any other concerns about this patch set? If not, I think
> > > > > > Vinod can apply this patch set. Thanks.
> > > > >
> > > > > Sorry for the late reply. Yes, this makes sense since there are no
> > > > > existing users then. For the DT changes going through the dmaengine
> > > > > tree
> > > > >
> > > > > Acked-by: Arnd Bergmann 
> > > >
> > > > Thanks for your reviewing.
> > > >
> > > > >
> > > > > One more question, to make sure we don't need to edit it again:
> > > > > Why do you need both a 'channel id' and a 'slave id' here? Is this
> > > > > a strict hardware requirement for your DMA engine? In many
> > > > > other designs, only a DMA request line number needs to
> > > > > be described, and I think this would correspond to what you
> > > > > call the 'hardware slave id' in your documentation.
> > > >
> > > > I try to explain why we need the slave id.
> > > >
> > > > For our DMA engine driver, we have software request mode and hardware
> > > > request mode. For software request mode, the DMA engine driver need
> > > > trigger DMA to start transfer manually. But for hardware request mode,
> > > > we just set one unique slave id corresponding to the slave hardware to
> > > > the DMA engine, then the slave hardware can trigger DMA automatically.
> > > > And the slave id is not always same with the channel id according to
> > > > the SoC design, so we add one cell to specify the slave id.
> > >
> > > I did understand the need for a slave-id, I was instead wondering about
> > > the channel-id number. On many SoCs, all channels are equal, and you
> > > just have to pick one of those with the right capabilities for a 
> > > particular
> > > slave.
> >
> > Yes, all channels are equal. We just set a unique slave id for the
> > channel for a particular slave. For example, the SPI slave can use
> > channel 10 for tx transfer by setting slave id 11, or it also can use
> > channel 9 for tx transfer by setting same slave id 11.
>
> So the channel selection is software policy, not hardware description, and
> thus doesn't belong in DT?
>
> Can't the DMA engine driver allocate channels dynamically, removing the
> need to specify this in DT?

In theory we can do as you suggested. But we still want to
manage/assign the DMA channel resources manually for one SoC, we can
make sure some important DMA slaves (such as audio)  can request a DMA
channel at runtime firstly, another benefit is that it is easy to
debug since we can easily know which channel is assigned for this
slave.

-- 

Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-19 Thread Geert Uytterhoeven
Hi Baolin,

On Tue, Feb 19, 2019 at 4:15 AM Baolin Wang  wrote:
> On Mon, 18 Feb 2019 at 20:23, Arnd Bergmann  wrote:
> > On Mon, Feb 18, 2019 at 11:52 AM Baolin Wang  wrote:
> > > On Mon, 18 Feb 2019 at 18:31, Arnd Bergmann  wrote:
> > > >
> > > > On Tue, Feb 12, 2019 at 9:25 AM Baolin Wang  
> > > > wrote:
> > > > > On Fri, 1 Feb 2019 at 19:53, Baolin Wang  
> > > > > wrote:
> > > > > > On Thu, 31 Jan 2019 at 00:52, Arnd Bergmann  wrote:
> > > > > > > On Tue, Jan 22, 2019 at 2:21 PM Baolin Wang 
> > > > > > >  wrote:
> > > > > > > >
> > > > > > > >  Client:
> > > > > > > >  DMA clients connected to the Spreadtrum DMA controller must 
> > > > > > > > use the format
> > > > > > > > -described in the dma.txt file, using a two-cell specifier for 
> > > > > > > > each channel.
> > > > > > > > -The two cells in order are:
> > > > > > > > +described in the dma.txt file, using a three-cell specifier 
> > > > > > > > for each channel.
> > > > > > > > +The three cells in order are:
> > > > > > > >  1. A phandle pointing to the DMA controller.
> > > > > > > >  2. The channel id.
> > > > > > > > +3. The hardware slave id which is used for clients to trigger 
> > > > > > > > DMA engine
> > > > > > > > +automatically.
> > > > > > >
> > > > > > > I notice that this is an incompatible binding change. Is that 
> > > > > > > necessary?
> > > > > > > If the current code works, I'd suggest allowing both 
> > > > > > > #dma-cells=<2>
> > > > > > > and <3>, and then implementing both in the driver.
> > > > > >
> > > > > > Yes, this is necessary.
> > > > > >
> > > > > > Yes, current code can work, but the problem is that the DMA clients
> > > > > > must add one property (something like "sprd,slave-id") to specify 
> > > > > > the
> > > > > > slave id. So considering this, we want to change the dma-cells to 2,
> > > > > > including dma channel and dma slave id, which can avoid introducing
> > > > > > some similar properties for DMA clients.
> > > > > >
> > > > > > Now there are no DMA clients in mainline for Spreadtrum platform, 
> > > > > > and
> > > > > > we want to upstream our first DMA clients: SPI controller. So no 
> > > > > > other
> > > > > > drivers need to change when we changing dma cells. Thanks.
> > > > >
> > > > > Do you have any other concerns about this patch set? If not, I think
> > > > > Vinod can apply this patch set. Thanks.
> > > >
> > > > Sorry for the late reply. Yes, this makes sense since there are no
> > > > existing users then. For the DT changes going through the dmaengine
> > > > tree
> > > >
> > > > Acked-by: Arnd Bergmann 
> > >
> > > Thanks for your reviewing.
> > >
> > > >
> > > > One more question, to make sure we don't need to edit it again:
> > > > Why do you need both a 'channel id' and a 'slave id' here? Is this
> > > > a strict hardware requirement for your DMA engine? In many
> > > > other designs, only a DMA request line number needs to
> > > > be described, and I think this would correspond to what you
> > > > call the 'hardware slave id' in your documentation.
> > >
> > > I try to explain why we need the slave id.
> > >
> > > For our DMA engine driver, we have software request mode and hardware
> > > request mode. For software request mode, the DMA engine driver need
> > > trigger DMA to start transfer manually. But for hardware request mode,
> > > we just set one unique slave id corresponding to the slave hardware to
> > > the DMA engine, then the slave hardware can trigger DMA automatically.
> > > And the slave id is not always same with the channel id according to
> > > the SoC design, so we add one cell to specify the slave id.
> >
> > I did understand the need for a slave-id, I was instead wondering about
> > the channel-id number. On many SoCs, all channels are equal, and you
> > just have to pick one of those with the right capabilities for a particular
> > slave.
>
> Yes, all channels are equal. We just set a unique slave id for the
> channel for a particular slave. For example, the SPI slave can use
> channel 10 for tx transfer by setting slave id 11, or it also can use
> channel 9 for tx transfer by setting same slave id 11.

So the channel selection is software policy, not hardware description, and
thus doesn't belong in DT?

Can't the DMA engine driver allocate channels dynamically, removing the
need to specify this in DT?

Thanks!

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-18 Thread Baolin Wang
On Mon, 18 Feb 2019 at 20:23, Arnd Bergmann  wrote:
>
> On Mon, Feb 18, 2019 at 11:52 AM Baolin Wang  wrote:
> > On Mon, 18 Feb 2019 at 18:31, Arnd Bergmann  wrote:
> > >
> > > On Tue, Feb 12, 2019 at 9:25 AM Baolin Wang  
> > > wrote:
> > > > On Fri, 1 Feb 2019 at 19:53, Baolin Wang  wrote:
> > > > > On Thu, 31 Jan 2019 at 00:52, Arnd Bergmann  wrote:
> > > > > > On Tue, Jan 22, 2019 at 2:21 PM Baolin Wang 
> > > > > >  wrote:
> > > > > > >
> > > > > > >  Client:
> > > > > > >  DMA clients connected to the Spreadtrum DMA controller must use 
> > > > > > > the format
> > > > > > > -described in the dma.txt file, using a two-cell specifier for 
> > > > > > > each channel.
> > > > > > > -The two cells in order are:
> > > > > > > +described in the dma.txt file, using a three-cell specifier for 
> > > > > > > each channel.
> > > > > > > +The three cells in order are:
> > > > > > >  1. A phandle pointing to the DMA controller.
> > > > > > >  2. The channel id.
> > > > > > > +3. The hardware slave id which is used for clients to trigger 
> > > > > > > DMA engine
> > > > > > > +automatically.
> > > > > >
> > > > > > I notice that this is an incompatible binding change. Is that 
> > > > > > necessary?
> > > > > > If the current code works, I'd suggest allowing both #dma-cells=<2>
> > > > > > and <3>, and then implementing both in the driver.
> > > > >
> > > > > Yes, this is necessary.
> > > > >
> > > > > Yes, current code can work, but the problem is that the DMA clients
> > > > > must add one property (something like "sprd,slave-id") to specify the
> > > > > slave id. So considering this, we want to change the dma-cells to 2,
> > > > > including dma channel and dma slave id, which can avoid introducing
> > > > > some similar properties for DMA clients.
> > > > >
> > > > > Now there are no DMA clients in mainline for Spreadtrum platform, and
> > > > > we want to upstream our first DMA clients: SPI controller. So no other
> > > > > drivers need to change when we changing dma cells. Thanks.
> > > >
> > > > Do you have any other concerns about this patch set? If not, I think
> > > > Vinod can apply this patch set. Thanks.
> > >
> > > Sorry for the late reply. Yes, this makes sense since there are no
> > > existing users then. For the DT changes going through the dmaengine
> > > tree
> > >
> > > Acked-by: Arnd Bergmann 
> >
> > Thanks for your reviewing.
> >
> > >
> > > One more question, to make sure we don't need to edit it again:
> > > Why do you need both a 'channel id' and a 'slave id' here? Is this
> > > a strict hardware requirement for your DMA engine? In many
> > > other designs, only a DMA request line number needs to
> > > be described, and I think this would correspond to what you
> > > call the 'hardware slave id' in your documentation.
> >
> > I try to explain why we need the slave id.
> >
> > For our DMA engine driver, we have software request mode and hardware
> > request mode. For software request mode, the DMA engine driver need
> > trigger DMA to start transfer manually. But for hardware request mode,
> > we just set one unique slave id corresponding to the slave hardware to
> > the DMA engine, then the slave hardware can trigger DMA automatically.
> > And the slave id is not always same with the channel id according to
> > the SoC design, so we add one cell to specify the slave id.
>
> I did understand the need for a slave-id, I was instead wondering about
> the channel-id number. On many SoCs, all channels are equal, and you
> just have to pick one of those with the right capabilities for a particular
> slave.

Yes, all channels are equal. We just set a unique slave id for the
channel for a particular slave. For example, the SPI slave can use
channel 10 for tx transfer by setting slave id 11, or it also can use
channel 9 for tx transfer by setting same slave id 11.

-- 
Baolin Wang
Best Regards


Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-18 Thread Arnd Bergmann
On Mon, Feb 18, 2019 at 11:52 AM Baolin Wang  wrote:
> On Mon, 18 Feb 2019 at 18:31, Arnd Bergmann  wrote:
> >
> > On Tue, Feb 12, 2019 at 9:25 AM Baolin Wang  wrote:
> > > On Fri, 1 Feb 2019 at 19:53, Baolin Wang  wrote:
> > > > On Thu, 31 Jan 2019 at 00:52, Arnd Bergmann  wrote:
> > > > > On Tue, Jan 22, 2019 at 2:21 PM Baolin Wang  
> > > > > wrote:
> > > > > >
> > > > > >  Client:
> > > > > >  DMA clients connected to the Spreadtrum DMA controller must use 
> > > > > > the format
> > > > > > -described in the dma.txt file, using a two-cell specifier for each 
> > > > > > channel.
> > > > > > -The two cells in order are:
> > > > > > +described in the dma.txt file, using a three-cell specifier for 
> > > > > > each channel.
> > > > > > +The three cells in order are:
> > > > > >  1. A phandle pointing to the DMA controller.
> > > > > >  2. The channel id.
> > > > > > +3. The hardware slave id which is used for clients to trigger DMA 
> > > > > > engine
> > > > > > +automatically.
> > > > >
> > > > > I notice that this is an incompatible binding change. Is that 
> > > > > necessary?
> > > > > If the current code works, I'd suggest allowing both #dma-cells=<2>
> > > > > and <3>, and then implementing both in the driver.
> > > >
> > > > Yes, this is necessary.
> > > >
> > > > Yes, current code can work, but the problem is that the DMA clients
> > > > must add one property (something like "sprd,slave-id") to specify the
> > > > slave id. So considering this, we want to change the dma-cells to 2,
> > > > including dma channel and dma slave id, which can avoid introducing
> > > > some similar properties for DMA clients.
> > > >
> > > > Now there are no DMA clients in mainline for Spreadtrum platform, and
> > > > we want to upstream our first DMA clients: SPI controller. So no other
> > > > drivers need to change when we changing dma cells. Thanks.
> > >
> > > Do you have any other concerns about this patch set? If not, I think
> > > Vinod can apply this patch set. Thanks.
> >
> > Sorry for the late reply. Yes, this makes sense since there are no
> > existing users then. For the DT changes going through the dmaengine
> > tree
> >
> > Acked-by: Arnd Bergmann 
>
> Thanks for your reviewing.
>
> >
> > One more question, to make sure we don't need to edit it again:
> > Why do you need both a 'channel id' and a 'slave id' here? Is this
> > a strict hardware requirement for your DMA engine? In many
> > other designs, only a DMA request line number needs to
> > be described, and I think this would correspond to what you
> > call the 'hardware slave id' in your documentation.
>
> I try to explain why we need the slave id.
>
> For our DMA engine driver, we have software request mode and hardware
> request mode. For software request mode, the DMA engine driver need
> trigger DMA to start transfer manually. But for hardware request mode,
> we just set one unique slave id corresponding to the slave hardware to
> the DMA engine, then the slave hardware can trigger DMA automatically.
> And the slave id is not always same with the channel id according to
> the SoC design, so we add one cell to specify the slave id.

I did understand the need for a slave-id, I was instead wondering about
the channel-id number. On many SoCs, all channels are equal, and you
just have to pick one of those with the right capabilities for a particular
slave.

  Arnd


Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-18 Thread Baolin Wang
Hi Arnd,

On Mon, 18 Feb 2019 at 18:31, Arnd Bergmann  wrote:
>
> On Tue, Feb 12, 2019 at 9:25 AM Baolin Wang  wrote:
> > On Fri, 1 Feb 2019 at 19:53, Baolin Wang  wrote:
> > > On Thu, 31 Jan 2019 at 00:52, Arnd Bergmann  wrote:
> > > > On Tue, Jan 22, 2019 at 2:21 PM Baolin Wang  
> > > > wrote:
> > > > >
> > > > >  Client:
> > > > >  DMA clients connected to the Spreadtrum DMA controller must use the 
> > > > > format
> > > > > -described in the dma.txt file, using a two-cell specifier for each 
> > > > > channel.
> > > > > -The two cells in order are:
> > > > > +described in the dma.txt file, using a three-cell specifier for each 
> > > > > channel.
> > > > > +The three cells in order are:
> > > > >  1. A phandle pointing to the DMA controller.
> > > > >  2. The channel id.
> > > > > +3. The hardware slave id which is used for clients to trigger DMA 
> > > > > engine
> > > > > +automatically.
> > > >
> > > > I notice that this is an incompatible binding change. Is that necessary?
> > > > If the current code works, I'd suggest allowing both #dma-cells=<2>
> > > > and <3>, and then implementing both in the driver.
> > >
> > > Yes, this is necessary.
> > >
> > > Yes, current code can work, but the problem is that the DMA clients
> > > must add one property (something like "sprd,slave-id") to specify the
> > > slave id. So considering this, we want to change the dma-cells to 2,
> > > including dma channel and dma slave id, which can avoid introducing
> > > some similar properties for DMA clients.
> > >
> > > Now there are no DMA clients in mainline for Spreadtrum platform, and
> > > we want to upstream our first DMA clients: SPI controller. So no other
> > > drivers need to change when we changing dma cells. Thanks.
> >
> > Do you have any other concerns about this patch set? If not, I think
> > Vinod can apply this patch set. Thanks.
>
> Sorry for the late reply. Yes, this makes sense since there are no
> existing users then. For the DT changes going through the dmaengine
> tree
>
> Acked-by: Arnd Bergmann 

Thanks for your reviewing.

>
> One more question, to make sure we don't need to edit it again:
> Why do you need both a 'channel id' and a 'slave id' here? Is this
> a strict hardware requirement for your DMA engine? In many
> other designs, only a DMA request line number needs to
> be described, and I think this would correspond to what you
> call the 'hardware slave id' in your documentation.

I try to explain why we need the slave id.

For our DMA engine driver, we have software request mode and hardware
request mode. For software request mode, the DMA engine driver need
trigger DMA to start transfer manually. But for hardware request mode,
we just set one unique slave id corresponding to the slave hardware to
the DMA engine, then the slave hardware can trigger DMA automatically.
And the slave id is not always same with the channel id according to
the SoC design, so we add one cell to specify the slave id.

>
> Does each request line here correspond to a fixed channel
> id as well, or can a channel be shared between multiple

Yes, each request line corresponds to a fixed channel id.

> slave devices?
>
>   Arnd



-- 
Baolin Wang
Best Regards


Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-18 Thread Arnd Bergmann
On Tue, Feb 12, 2019 at 9:25 AM Baolin Wang  wrote:
> On Fri, 1 Feb 2019 at 19:53, Baolin Wang  wrote:
> > On Thu, 31 Jan 2019 at 00:52, Arnd Bergmann  wrote:
> > > On Tue, Jan 22, 2019 at 2:21 PM Baolin Wang  
> > > wrote:
> > > >
> > > >  Client:
> > > >  DMA clients connected to the Spreadtrum DMA controller must use the 
> > > > format
> > > > -described in the dma.txt file, using a two-cell specifier for each 
> > > > channel.
> > > > -The two cells in order are:
> > > > +described in the dma.txt file, using a three-cell specifier for each 
> > > > channel.
> > > > +The three cells in order are:
> > > >  1. A phandle pointing to the DMA controller.
> > > >  2. The channel id.
> > > > +3. The hardware slave id which is used for clients to trigger DMA 
> > > > engine
> > > > +automatically.
> > >
> > > I notice that this is an incompatible binding change. Is that necessary?
> > > If the current code works, I'd suggest allowing both #dma-cells=<2>
> > > and <3>, and then implementing both in the driver.
> >
> > Yes, this is necessary.
> >
> > Yes, current code can work, but the problem is that the DMA clients
> > must add one property (something like "sprd,slave-id") to specify the
> > slave id. So considering this, we want to change the dma-cells to 2,
> > including dma channel and dma slave id, which can avoid introducing
> > some similar properties for DMA clients.
> >
> > Now there are no DMA clients in mainline for Spreadtrum platform, and
> > we want to upstream our first DMA clients: SPI controller. So no other
> > drivers need to change when we changing dma cells. Thanks.
>
> Do you have any other concerns about this patch set? If not, I think
> Vinod can apply this patch set. Thanks.

Sorry for the late reply. Yes, this makes sense since there are no
existing users then. For the DT changes going through the dmaengine
tree

Acked-by: Arnd Bergmann 

One more question, to make sure we don't need to edit it again:
Why do you need both a 'channel id' and a 'slave id' here? Is this
a strict hardware requirement for your DMA engine? In many
other designs, only a DMA request line number needs to
be described, and I think this would correspond to what you
call the 'hardware slave id' in your documentation.

Does each request line here correspond to a fixed channel
id as well, or can a channel be shared between multiple
slave devices?

  Arnd


Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-12 Thread Baolin Wang
Hi Arnd,

On Fri, 1 Feb 2019 at 19:53, Baolin Wang  wrote:
>
> Hi Arnd,
> On Thu, 31 Jan 2019 at 00:52, Arnd Bergmann  wrote:
> >
> > On Tue, Jan 22, 2019 at 2:21 PM Baolin Wang  wrote:
> > >
> > > The DMA engine clients can trigger DMA engine automatically by setting
> > > the corresponding hardware slave id for the DMA engine. Thus add one
> > > cell to present the hardware slave id for DMA clients.
> > >
> > > Signed-off-by: Baolin Wang 
> > > ---
> > >  Documentation/devicetree/bindings/dma/sprd-dma.txt |   12 +++-
> > >  1 file changed, 7 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/Documentation/devicetree/bindings/dma/sprd-dma.txt 
> > > b/Documentation/devicetree/bindings/dma/sprd-dma.txt
> > > index 7a10fea..7812cf0 100644
> > > --- a/Documentation/devicetree/bindings/dma/sprd-dma.txt
> > > +++ b/Documentation/devicetree/bindings/dma/sprd-dma.txt
> > > @@ -6,8 +6,8 @@ Required properties:
> > >  - compatible: Should be "sprd,sc9860-dma".
> > >  - reg: Should contain DMA registers location and length.
> > >  - interrupts: Should contain one interrupt shared by all channel.
> > > -- #dma-cells: must be <1>. Used to represent the number of integer
> > > -   cells in the dmas property of client device.
> > > +- #dma-cells: must be <2>. Used to represent the channel id and slave id
> > > +   of integer cells in the dmas property of client device.
> > >  - #dma-channels : Number of DMA channels supported. Should be 32.
> > >  - clock-names: Should contain the clock of the DMA controller.
> > >  - clocks: Should contain a clock specifier for each entry in clock-names.
> > > @@ -28,14 +28,16 @@ apdma: dma-controller@2010 {
> > >
> > >  Client:
> > >  DMA clients connected to the Spreadtrum DMA controller must use the 
> > > format
> > > -described in the dma.txt file, using a two-cell specifier for each 
> > > channel.
> > > -The two cells in order are:
> > > +described in the dma.txt file, using a three-cell specifier for each 
> > > channel.
> > > +The three cells in order are:
> > >  1. A phandle pointing to the DMA controller.
> > >  2. The channel id.
> > > +3. The hardware slave id which is used for clients to trigger DMA engine
> > > +automatically.
> >
> > I notice that this is an incompatible binding change. Is that necessary?
> > If the current code works, I'd suggest allowing both #dma-cells=<2>
> > and <3>, and then implementing both in the driver.
>
> Yes, this is necessary.
>
> Yes, current code can work, but the problem is that the DMA clients
> must add one property (something like "sprd,slave-id") to specify the
> slave id. So considering this, we want to change the dma-cells to 2,
> including dma channel and dma slave id, which can avoid introducing
> some similar properties for DMA clients.
>
> Now there are no DMA clients in mainline for Spreadtrum platform, and
> we want to upstream our first DMA clients: SPI controller. So no other
> drivers need to change when we changing dma cells. Thanks.

Do you have any other concerns about this patch set? If not, I think
Vinod can apply this patch set. Thanks.

-- 
Baolin Wang
Best Regards


Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-02-01 Thread Baolin Wang
Hi Arnd,
On Thu, 31 Jan 2019 at 00:52, Arnd Bergmann  wrote:
>
> On Tue, Jan 22, 2019 at 2:21 PM Baolin Wang  wrote:
> >
> > The DMA engine clients can trigger DMA engine automatically by setting
> > the corresponding hardware slave id for the DMA engine. Thus add one
> > cell to present the hardware slave id for DMA clients.
> >
> > Signed-off-by: Baolin Wang 
> > ---
> >  Documentation/devicetree/bindings/dma/sprd-dma.txt |   12 +++-
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/dma/sprd-dma.txt 
> > b/Documentation/devicetree/bindings/dma/sprd-dma.txt
> > index 7a10fea..7812cf0 100644
> > --- a/Documentation/devicetree/bindings/dma/sprd-dma.txt
> > +++ b/Documentation/devicetree/bindings/dma/sprd-dma.txt
> > @@ -6,8 +6,8 @@ Required properties:
> >  - compatible: Should be "sprd,sc9860-dma".
> >  - reg: Should contain DMA registers location and length.
> >  - interrupts: Should contain one interrupt shared by all channel.
> > -- #dma-cells: must be <1>. Used to represent the number of integer
> > -   cells in the dmas property of client device.
> > +- #dma-cells: must be <2>. Used to represent the channel id and slave id
> > +   of integer cells in the dmas property of client device.
> >  - #dma-channels : Number of DMA channels supported. Should be 32.
> >  - clock-names: Should contain the clock of the DMA controller.
> >  - clocks: Should contain a clock specifier for each entry in clock-names.
> > @@ -28,14 +28,16 @@ apdma: dma-controller@2010 {
> >
> >  Client:
> >  DMA clients connected to the Spreadtrum DMA controller must use the format
> > -described in the dma.txt file, using a two-cell specifier for each channel.
> > -The two cells in order are:
> > +described in the dma.txt file, using a three-cell specifier for each 
> > channel.
> > +The three cells in order are:
> >  1. A phandle pointing to the DMA controller.
> >  2. The channel id.
> > +3. The hardware slave id which is used for clients to trigger DMA engine
> > +automatically.
>
> I notice that this is an incompatible binding change. Is that necessary?
> If the current code works, I'd suggest allowing both #dma-cells=<2>
> and <3>, and then implementing both in the driver.

Yes, this is necessary.

Yes, current code can work, but the problem is that the DMA clients
must add one property (something like "sprd,slave-id") to specify the
slave id. So considering this, we want to change the dma-cells to 2,
including dma channel and dma slave id, which can avoid introducing
some similar properties for DMA clients.

Now there are no DMA clients in mainline for Spreadtrum platform, and
we want to upstream our first DMA clients: SPI controller. So no other
drivers need to change when we changing dma cells. Thanks.

-- 
Baolin Wang
Best Regards


Re: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id

2019-01-30 Thread Arnd Bergmann
On Tue, Jan 22, 2019 at 2:21 PM Baolin Wang  wrote:
>
> The DMA engine clients can trigger DMA engine automatically by setting
> the corresponding hardware slave id for the DMA engine. Thus add one
> cell to present the hardware slave id for DMA clients.
>
> Signed-off-by: Baolin Wang 
> ---
>  Documentation/devicetree/bindings/dma/sprd-dma.txt |   12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/dma/sprd-dma.txt 
> b/Documentation/devicetree/bindings/dma/sprd-dma.txt
> index 7a10fea..7812cf0 100644
> --- a/Documentation/devicetree/bindings/dma/sprd-dma.txt
> +++ b/Documentation/devicetree/bindings/dma/sprd-dma.txt
> @@ -6,8 +6,8 @@ Required properties:
>  - compatible: Should be "sprd,sc9860-dma".
>  - reg: Should contain DMA registers location and length.
>  - interrupts: Should contain one interrupt shared by all channel.
> -- #dma-cells: must be <1>. Used to represent the number of integer
> -   cells in the dmas property of client device.
> +- #dma-cells: must be <2>. Used to represent the channel id and slave id
> +   of integer cells in the dmas property of client device.
>  - #dma-channels : Number of DMA channels supported. Should be 32.
>  - clock-names: Should contain the clock of the DMA controller.
>  - clocks: Should contain a clock specifier for each entry in clock-names.
> @@ -28,14 +28,16 @@ apdma: dma-controller@2010 {
>
>  Client:
>  DMA clients connected to the Spreadtrum DMA controller must use the format
> -described in the dma.txt file, using a two-cell specifier for each channel.
> -The two cells in order are:
> +described in the dma.txt file, using a three-cell specifier for each channel.
> +The three cells in order are:
>  1. A phandle pointing to the DMA controller.
>  2. The channel id.
> +3. The hardware slave id which is used for clients to trigger DMA engine
> +automatically.

I notice that this is an incompatible binding change. Is that necessary?
If the current code works, I'd suggest allowing both #dma-cells=<2>
and <3>, and then implementing both in the driver.

 Arnd