diff mbox

[3/3] Documentation: dmaengine: Add DMA_CTRL_REUSE documentation

Message ID 1437676792-13465-3-git-send-email-vinod.koul@intel.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Vinod Koul July 23, 2015, 6:39 p.m. UTC
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
 Documentation/dmaengine/provider.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Robert Jarzmik July 23, 2015, 7:47 p.m. UTC | #1
Vinod Koul <vinod.koul@intel.com> writes:

> +  * DMA_CTRL_REUSE
> +    - If set, the descriptor can be reused after being completed. It should
> +      not be freed by provider if this flag is set.
> +    - The descriptor should be prepared for reuse by invoking
> +      dmaengine_desc_set_reuse() which will set DMA_CTRL_REUSE.
> +    - dmaengine_desc_set_reuse() will succeed only when channel support
> +      reusable descriptor as exhibited by capablities
> +    - As a consequence, if a device driver wants to skip the dma_map_sg() and
> +      dma_unmap_sg() in between 2 transfers, because the DMA'd data wasn't used,
> +      it can resubmit the transfer right after its completion.
> +    - Descriptor can be freed in few ways
> +	- Clearing DMA_CTRL_REUSE by invoking dmaengine_desc_clear_reuse()
> +	  and submitting for last txn
> +	- Explicitly invoking dmaengine_desc_free(), this can succeed only
> +	  when DMA_CTRL_REUSE is already set

> +	- Terminating the channel
Is this last condition mandatory, or can it be transformed into :
 - Clearing DMA_CTRL_REUSE and terminating the channel

The reason I'm asking this is for this kind of scenario :
 - 4 video buffers are prepared and submitted (ie. 4 txs)
 - 1st video buffer completes
 - 2nd video buffer starts, and an error occurs in this 2nd buffer
   => the driver will terminate the DMA channel to stop the transmission
 - the driver will wait for the next "start of frame" of the camera sensor
 - and then it will start 3rd video buffer
   => in this case, the 3rd video will be reused, even if the channel was
   terminated
   
Cheers.
Vinod Koul July 24, 2015, 5:36 a.m. UTC | #2
On Thu, Jul 23, 2015 at 09:47:22PM +0200, Robert Jarzmik wrote:
> Vinod Koul <vinod.koul@intel.com> writes:
> 
> > +  * DMA_CTRL_REUSE
> > +    - If set, the descriptor can be reused after being completed. It should
> > +      not be freed by provider if this flag is set.
> > +    - The descriptor should be prepared for reuse by invoking
> > +      dmaengine_desc_set_reuse() which will set DMA_CTRL_REUSE.
> > +    - dmaengine_desc_set_reuse() will succeed only when channel support
> > +      reusable descriptor as exhibited by capablities
> > +    - As a consequence, if a device driver wants to skip the dma_map_sg() and
> > +      dma_unmap_sg() in between 2 transfers, because the DMA'd data wasn't used,
> > +      it can resubmit the transfer right after its completion.
> > +    - Descriptor can be freed in few ways
> > +	- Clearing DMA_CTRL_REUSE by invoking dmaengine_desc_clear_reuse()
> > +	  and submitting for last txn
> > +	- Explicitly invoking dmaengine_desc_free(), this can succeed only
> > +	  when DMA_CTRL_REUSE is already set
> 
> > +	- Terminating the channel
> Is this last condition mandatory, or can it be transformed into :
>  - Clearing DMA_CTRL_REUSE and terminating the channel
> 
> The reason I'm asking this is for this kind of scenario :
>  - 4 video buffers are prepared and submitted (ie. 4 txs)
>  - 1st video buffer completes
>  - 2nd video buffer starts, and an error occurs in this 2nd buffer
>    => the driver will terminate the DMA channel to stop the transmission
>  - the driver will wait for the next "start of frame" of the camera sensor
>  - and then it will start 3rd video buffer
>    => in this case, the 3rd video will be reused, even if the channel was
>    terminated
Nope during terminate flow you are expected to clean up channel. Which mean
cleaning up all pending descriptors and throwing error. You are required to
prepare again

Here when adding, I though of giving few choice
- allowing folks to say, okay I have last txn, let me remove reuse and
  submit. That should be hint to driver to free it up
  The expecttaion would be that client supporting reuse check this for every
  submit, if the desc is being reused or not
- allowing cleanup anytime when we dont know where last txn is, or when user
  cancelled
- Or freeing gracefuly on already submitted desc
Robert Jarzmik July 24, 2015, 7:15 p.m. UTC | #3
Vinod Koul <vinod.koul@intel.com> writes:

>> > +	- Terminating the channel
>> Is this last condition mandatory, or can it be transformed into :
>>  - Clearing DMA_CTRL_REUSE and terminating the channel
>> 
>> The reason I'm asking this is for this kind of scenario :
>>  - 4 video buffers are prepared and submitted (ie. 4 txs)
>>  - 1st video buffer completes
>>  - 2nd video buffer starts, and an error occurs in this 2nd buffer
>>    => the driver will terminate the DMA channel to stop the transmission
>>  - the driver will wait for the next "start of frame" of the camera sensor
>>  - and then it will start 3rd video buffer
>>    => in this case, the 3rd video will be reused, even if the channel was
>>    terminated
> Nope during terminate flow you are expected to clean up channel. Which mean
> cleaning up all pending descriptors and throwing error. You are required to
> prepare again
Ok.

> Here when adding, I though of giving few choice
> - allowing folks to say, okay I have last txn, let me remove reuse and
>   submit. That should be hint to driver to free it up
>   The expecttaion would be that client supporting reuse check this for every
>   submit, if the desc is being reused or not
That one is great for drivers which know beforehand.

> - allowing cleanup anytime when we dont know where last txn is, or when user
>   cancelled
That one is great when it's the userspace which drives the decision to requeue
or not.

> - Or freeing gracefuly on already submitted desc
Ah I don't quite understand this one. I don't see the usecase in this one.

Cheers.
Lars-Peter Clausen July 27, 2015, 11:56 a.m. UTC | #4
On 07/24/2015 07:36 AM, Vinod Koul wrote:
> On Thu, Jul 23, 2015 at 09:47:22PM +0200, Robert Jarzmik wrote:
>> Vinod Koul <vinod.koul@intel.com> writes:
>>
>>> +  * DMA_CTRL_REUSE
>>> +    - If set, the descriptor can be reused after being completed. It should
>>> +      not be freed by provider if this flag is set.
>>> +    - The descriptor should be prepared for reuse by invoking
>>> +      dmaengine_desc_set_reuse() which will set DMA_CTRL_REUSE.
>>> +    - dmaengine_desc_set_reuse() will succeed only when channel support
>>> +      reusable descriptor as exhibited by capablities
>>> +    - As a consequence, if a device driver wants to skip the dma_map_sg() and
>>> +      dma_unmap_sg() in between 2 transfers, because the DMA'd data wasn't used,
>>> +      it can resubmit the transfer right after its completion.
>>> +    - Descriptor can be freed in few ways
>>> +	- Clearing DMA_CTRL_REUSE by invoking dmaengine_desc_clear_reuse()
>>> +	  and submitting for last txn
>>> +	- Explicitly invoking dmaengine_desc_free(), this can succeed only
>>> +	  when DMA_CTRL_REUSE is already set
>>
>>> +	- Terminating the channel
>> Is this last condition mandatory, or can it be transformed into :
>>   - Clearing DMA_CTRL_REUSE and terminating the channel
>>
>> The reason I'm asking this is for this kind of scenario :
>>   - 4 video buffers are prepared and submitted (ie. 4 txs)
>>   - 1st video buffer completes
>>   - 2nd video buffer starts, and an error occurs in this 2nd buffer
>>     => the driver will terminate the DMA channel to stop the transmission
>>   - the driver will wait for the next "start of frame" of the camera sensor
>>   - and then it will start 3rd video buffer
>>     => in this case, the 3rd video will be reused, even if the channel was
>>     terminated
> Nope during terminate flow you are expected to clean up channel. Which mean
> cleaning up all pending descriptors and throwing error. You are required to
> prepare again

I don't see the necessity to free all descriptors when we call 
terminate_all(). What terminate_all() does is stop the current transfer and 
remove all pending transfers from the list. The ultimate cleanup point is 
when the channel is freed.

If we take audio or video as an example, you might choose to stop capture or 
playback and then later decide to restart it. There is no reason why we 
shouldn't be able to re-use the same descriptors over multiple of such 
iterations. The only point when the descriptor needs to be freed if the 
memory buffer it refers to is freed as well or the DMA channel is released.
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vinod Koul July 27, 2015, 4:19 p.m. UTC | #5
On Fri, Jul 24, 2015 at 09:15:23PM +0200, Robert Jarzmik wrote:
> > - Or freeing gracefuly on already submitted desc
> Ah I don't quite understand this one. I don't see the usecase in this one.
So you have submitted a descriptor as reusable and now no longer need it so
can call freeup for descriptor to free it up
Vinod Koul July 27, 2015, 4:20 p.m. UTC | #6
On Mon, Jul 27, 2015 at 01:56:06PM +0200, Lars-Peter Clausen wrote:
> On 07/24/2015 07:36 AM, Vinod Koul wrote:
> >Nope during terminate flow you are expected to clean up channel. Which mean
> >cleaning up all pending descriptors and throwing error. You are required to
> >prepare again
> 
> I don't see the necessity to free all descriptors when we call
> terminate_all(). What terminate_all() does is stop the current
> transfer and remove all pending transfers from the list. The
> ultimate cleanup point is when the channel is freed.
> 
> If we take audio or video as an example, you might choose to stop
> capture or playback and then later decide to restart it. There is no
> reason why we shouldn't be able to re-use the same descriptors over
> multiple of such iterations. The only point when the descriptor
> needs to be freed if the memory buffer it refers to is freed as well
> or the DMA channel is released.
Rethink about this and current behaviour I am okay to let go of this one.
Yes lets use channel free as ultimate cleanup

Thanks
Robert Jarzmik July 27, 2015, 4:41 p.m. UTC | #7
Vinod Koul <vinod.koul@intel.com> writes:

> On Fri, Jul 24, 2015 at 09:15:23PM +0200, Robert Jarzmik wrote:
>> > - Or freeing gracefuly on already submitted desc
>> Ah I don't quite understand this one. I don't see the usecase in this one.
> So you have submitted a descriptor as reusable and now no longer need it so
> can call freeup for descriptor to free it up
Thanks, I got it now. And that is definitely a usecase :)

Cheers.
diff mbox

Patch

diff --git a/Documentation/dmaengine/provider.txt b/Documentation/dmaengine/provider.txt
index 8b8eb7c57c1f..88f0b18c4ca1 100644
--- a/Documentation/dmaengine/provider.txt
+++ b/Documentation/dmaengine/provider.txt
@@ -351,6 +351,23 @@  where to put them)
     - This can be acked by invoking async_tx_ack()
     - If set, does not mean descriptor can be reused
 
+  * DMA_CTRL_REUSE
+    - If set, the descriptor can be reused after being completed. It should
+      not be freed by provider if this flag is set.
+    - The descriptor should be prepared for reuse by invoking
+      dmaengine_desc_set_reuse() which will set DMA_CTRL_REUSE.
+    - dmaengine_desc_set_reuse() will succeed only when channel support
+      reusable descriptor as exhibited by capablities
+    - As a consequence, if a device driver wants to skip the dma_map_sg() and
+      dma_unmap_sg() in between 2 transfers, because the DMA'd data wasn't used,
+      it can resubmit the transfer right after its completion.
+    - Descriptor can be freed in few ways
+	- Clearing DMA_CTRL_REUSE by invoking dmaengine_desc_clear_reuse()
+	  and submitting for last txn
+	- Explicitly invoking dmaengine_desc_free(), this can succeed only
+	  when DMA_CTRL_REUSE is already set
+	- Terminating the channel
+
 
 General Design Notes
 --------------------