* Yegor Yefremov <yegorsli...@googlemail.com> [191002 06:57]:
> On Wed, Oct 2, 2019 at 12:03 AM Tony Lindgren <t...@atomide.com> wrote:
> > 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?
>
> The fix is working but on the first invocation, I get this output
> (minicom provokes the same output):
 
> # serialtest.py -c 2 /dev/ttyUSB0 /dev/ttyUSB0
...
> [  210.940612] [<c065fc94>] (__rpm_callback) from [<c065fd60>]
> (rpm_callback+0x20/0x80)
> [  210.948402] [<c065fd60>] (rpm_callback) from [<c065f7cc>]
> (rpm_resume+0x468/0x7a0)
> [  210.956018] [<c065f7cc>] (rpm_resume) from [<c065fb50>]
> (__pm_runtime_resume+0x4c/0x64)
> [  210.964086] [<c065fb50>] (__pm_runtime_resume) from [<bf020940>]
> (cppi41_dma_prep_slave_sg+0x20/0xfc [cppi41])

OK so that won't work, thanks for testing. Here's the alternative
patch to try along the lines described above that just wakes up
cppi41 and returns NULL so musb_ep_program() can continue with PIO
until cppi41 is awake.

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,22 @@ 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 dma_async_tx_descriptor *txd = NULL;
+       struct cppi41_dd *cdd = c->cdd;
        struct cppi41_desc *d;
        struct scatterlist *sg;
        unsigned int i;
+       int error;
+
+       error = pm_runtime_get(cdd->ddev.dev);
+       if (error < 0) {
+               pm_runtime_put_noidle(cdd->ddev.dev);
+
+               return NULL;
+       }
+
+       if (cdd->is_suspended)
+               goto err_out_not_ready;
 
        d = c->desc;
        for_each_sg(sgl, sg, sg_len, i) {
@@ -611,7 +624,13 @@ static struct dma_async_tx_descriptor 
*cppi41_dma_prep_slave_sg(
                d++;
        }
 
-       return &c->txd;
+       txd = &c->txd;
+
+err_out_not_ready:
+       pm_runtime_mark_last_busy(cdd->ddev.dev);
+       pm_runtime_put_autosuspend(cdd->ddev.dev);
+
+       return txd;
 }
 
 static void cppi41_compute_td_desc(struct cppi41_desc *d)
-- 
2.23.0

Reply via email to