Hi,
* Tony Lindgren <[email protected]> [191001 16:52]:
> * Yegor Yefremov <[email protected]> [191001 09:20]:
> > I've tried to increase the autosuspend_delay_ms and to set control to
> > "on" but nothing changes. Below you can see the output of my testing
> > script [1] (Py2 only). As one can see, the first cycle i.e. after the
> > port is open for the first time, fails. But the subsequent cycle is
> > successful. If you invoke the script again, everything repeats.
> >
> > I've also made printk() in cppi41_run_queue() and it looks like this
> > routine will be called from cppi41_dma_issue_pending() only in the
> > beginning of the second test cycle.
>
> So sounds like for you intially cppi41_dma_issue_pending() has
> !cdd->is_suspended and just adds the request to the queue. And
> then cppi41_run_queue() never gets called if this happens while
> we have cppi41_runtime_resume() is still running?
I got it reproducable here by adding msleep(500) to the beginning
of cppi41_runtime_resume() :) Otherwise I'm only able to trigger
the issue maybe one out of 20 tries it seems.
Turns out the first dma call done by musb_ep_program() must wait
if cppi41 is PM runtime suspended. Otherwise musb_ep_program()
continues with other PIO packets before the DMA transfer is
started.
The patch below fixes it for me with a pm_runtime_get_sync()
in device_prep_slave_sg, so adding Peter and Vinod to Cc.
The other way to fix this would be to just wake up cpp41 in
cppi41_dma_prep_slave_sg() and return NULL so that we can
have musb_ep_program() continue with PIO while cppi41 is
asleep.
Anyways, care to try it out and see if it fixes your issue?
Regards,
Tony
8< ------------------
diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c
--- a/drivers/dma/ti/cppi41.c
+++ b/drivers/dma/ti/cppi41.c
@@ -586,9 +586,18 @@ static struct dma_async_tx_descriptor
*cppi41_dma_prep_slave_sg(
enum dma_transfer_direction dir, unsigned long tx_flags, void *context)
{
struct cppi41_channel *c = to_cpp41_chan(chan);
+ struct cppi41_dd *cdd = c->cdd;
struct cppi41_desc *d;
struct scatterlist *sg;
unsigned int i;
+ int error;
+
+ error = pm_runtime_get_sync(cdd->ddev.dev);
+ if (error < 0) {
+ pm_runtime_put_noidle(cdd->ddev.dev);
+
+ return NULL;
+ }
d = c->desc;
for_each_sg(sgl, sg, sg_len, i) {
@@ -611,6 +620,9 @@ static struct dma_async_tx_descriptor
*cppi41_dma_prep_slave_sg(
d++;
}
+ pm_runtime_mark_last_busy(cdd->ddev.dev);
+ pm_runtime_put_autosuspend(cdd->ddev.dev);
+
return &c->txd;
}
--
2.23.0