On 03-03-20, 21:22, Laurent Pinchart wrote: > Hi Vinod, > > On Tue, Mar 03, 2020 at 10:02:54AM +0530, Vinod Koul wrote: > > On 02-03-20, 09:37, Laurent Pinchart wrote: > > > > > > I would be more comfortable in calling an API to do so :) > > > > The flow I am thinking is: > > > > > > > > - prep cyclic1 txn > > > > - submit cyclic1 txn > > > > - call issue_pending() (cyclic one starts) > > > > > > > > - prep cyclic2 txn > > > > - submit cyclic2 txn > > > > - signal_cyclic1_txn aka terminate_cookie() > > > > - cyclic1 completes, switch to cyclic2 (dmaengine driver) > > > > - get callback for cyclic1 (optional) > > > > > > > > To check if hw supports terminate_cookie() or not we can check if the > > > > callback support is implemented > > > > > > Two questions though: > > > > > > - Where is .issue_pending() called for cyclic2 in your above sequence ? > > > Surely it should be called somewhere, as the DMA engine API requires > > > .issue_pending() to be called for a transfer to be executed, otherwise > > > it stays in the submitted but not pending queue. > > > > Sorry missed that one, I would do that after submit cyclic2 txn step and > > then signal signal_cyclic1_txn termination > > OK, that matches my understanding, good :-) > > > > - With the introduction of a new .terminate_cookie() operation, we need > > > to specify that operation for all transfer types. What's its > > > > Correct > > > > > envisioned semantics for non-cyclic transfers ? And how do DMA engine > > > drivers report that they support .terminate_cookie() for cyclic > > > transfers but not for other transfer types (the counterpart of > > > reporting, in my proposition, that .issue_pending() isn't supported > > > replace the current cyclic transfer) ? > > > > Typically for dmaengine controller cyclic is *not* a special mode, only > > change is that a list provided to controller is circular. > > I don't agree with this. For cyclic transfers to be replaceable in a > clean way, the feature must be specifically implemented at the hardware > level. A DMA engine that supports chaining transfers with an explicit > way to override that chaining, and without the logic to report if the > inherent race was lost or not, really can't support this API. Well chaining is a typical feature in dmaengine and making last chain point to first makes it circular. I have seen couple of engines and this was the implementation in the hardware. There can exist special hardware for this purposes as well, but the point is that the cyclic can be treated as circular list. > Furthemore, for non-cyclic transfers, what would .terminate_cookie() do > ? I need it to be defined as terminating the current transfer when it > ends for the cyclic case, not terminating it immediately. All non-cyclic > transfers terminate by themselves when they end, so what would this new > operation do ? I would use it for two purposes, cancelling txn but at the end of current txn. I have couple of usages where this would be helpful. Second in error handling where some engines do not support aborting (unless we reset the whole controller) But yes the .terminate_cookie() semantics should indicate if the termination should be immediate or end of current txn. I see people using it for both. And with this I think it would make sense to also add this to capabilities :) > > So, the .terminate_cookie() should be a feature for all type of txn's. > > If for some reason (dont discount what hw designers can do) a controller > > supports this for some specific type(s), then they should return > > -ENOTSUPP for cookies that do not support and let the caller know. > > But then the caller can't know ahead of time, it will only find out when > it's too late, and can't decide not to use the DMA engine if it doesn't > support the feature. I don't think that's a very good option. Agreed so lets go with adding these in caps. -- ~Vinod