* [PATCH] dmaengine: cppi41: Fix issue with musb and ftdi uart
@ 2019-10-22 14:55 Tony Lindgren
2019-10-23 4:53 ` Vinod Koul
0 siblings, 1 reply; 3+ messages in thread
From: Tony Lindgren @ 2019-10-22 14:55 UTC (permalink / raw)
To: Dan Williams, Vinod Koul
Cc: Alexandre Bailon, Andy Shevchenko, Bin Liu, Daniel Mack,
Felipe Balbi, George Cherian, Grygorii Strashko, Johan Hovold,
Peter Ujfalusi, Sekhar Nori, Sebastian Andrzej Siewior,
Sergei Shtylyov, dmaengine, linux-usb, linux-omap,
giulio.benetti, Sebastian Reichel, Skvortsov, Yegor Yefremov
The first dma call done by musb_ep_program() must wait if cppi41 is PM
runtime suspended. Otherwise musb_ep_program() continues with other
non-dma packets before the DMA transfer is started causing at least ftdi
uarts to fail to receive data.
Let's fix the issue by waking up cppi41 with PM runtime calls added to
cppi41_dma_prep_slave_sg() and return NULL if still idled. This way we
have musb_ep_program() continue with PIO until cppi41 is awake.
Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support")
Cc: Bin Liu <b-liu@ti.com>
Cc: giulio.benetti@benettiengineering.com
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Skvortsov <andrej.skvortzov@gmail.com>
Reported-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/dma/ti/cppi41.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: cppi41: Fix issue with musb and ftdi uart
2019-10-22 14:55 [PATCH] dmaengine: cppi41: Fix issue with musb and ftdi uart Tony Lindgren
@ 2019-10-23 4:53 ` Vinod Koul
2019-10-23 15:27 ` Tony Lindgren
0 siblings, 1 reply; 3+ messages in thread
From: Vinod Koul @ 2019-10-23 4:53 UTC (permalink / raw)
To: Tony Lindgren
Cc: Dan Williams, Vinod Koul, Alexandre Bailon, Andy Shevchenko,
Bin Liu, Daniel Mack, Felipe Balbi, George Cherian,
Grygorii Strashko, Johan Hovold, Peter Ujfalusi, Sekhar Nori,
Sebastian Andrzej Siewior, Sergei Shtylyov, dmaengine, linux-usb,
linux-omap, giulio.benetti, Sebastian Reichel, Skvortsov,
Yegor Yefremov
Hi Tony,
On 22-10-19, 07:55, Tony Lindgren wrote:
Patch subject should reflect the patch changes not the fix. The patch
title here is not telling me anything about the change below. Pls
consider updating the title.
> The first dma call done by musb_ep_program() must wait if cppi41 is PM
> runtime suspended. Otherwise musb_ep_program() continues with other
> non-dma packets before the DMA transfer is started causing at least ftdi
> uarts to fail to receive data.
>
> Let's fix the issue by waking up cppi41 with PM runtime calls added to
> cppi41_dma_prep_slave_sg() and return NULL if still idled. This way we
> have musb_ep_program() continue with PIO until cppi41 is awake.
>
> Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support")
Cc stable?
> Cc: Bin Liu <b-liu@ti.com>
> Cc: giulio.benetti@benettiengineering.com
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Cc: Sebastian Reichel <sre@kernel.org>
> Cc: Skvortsov <andrej.skvortzov@gmail.com>
> Reported-by: Yegor Yefremov <yegorslists@googlemail.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
> drivers/dma/ti/cppi41.c | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
>
> 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
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: cppi41: Fix issue with musb and ftdi uart
2019-10-23 4:53 ` Vinod Koul
@ 2019-10-23 15:27 ` Tony Lindgren
0 siblings, 0 replies; 3+ messages in thread
From: Tony Lindgren @ 2019-10-23 15:27 UTC (permalink / raw)
To: Vinod Koul
Cc: Dan Williams, Vinod Koul, Alexandre Bailon, Andy Shevchenko,
Bin Liu, Daniel Mack, Felipe Balbi, George Cherian,
Grygorii Strashko, Johan Hovold, Peter Ujfalusi, Sekhar Nori,
Sebastian Andrzej Siewior, Sergei Shtylyov, dmaengine, linux-usb,
linux-omap, giulio.benetti, Sebastian Reichel, Skvortsov,
Yegor Yefremov
* Vinod Koul <vkoul@kernel.org> [191023 04:54]:
> Hi Tony,
>
> On 22-10-19, 07:55, Tony Lindgren wrote:
>
> Patch subject should reflect the patch changes not the fix. The patch
> title here is not telling me anything about the change below. Pls
> consider updating the title.
Sure, I'll resend with updated description using:
dmaengine: cppi41: Fix cppi41_dma_prep_slave_sg() when idle
> > The first dma call done by musb_ep_program() must wait if cppi41 is PM
> > runtime suspended. Otherwise musb_ep_program() continues with other
> > non-dma packets before the DMA transfer is started causing at least ftdi
> > uarts to fail to receive data.
> >
> > Let's fix the issue by waking up cppi41 with PM runtime calls added to
> > cppi41_dma_prep_slave_sg() and return NULL if still idled. This way we
> > have musb_ep_program() continue with PIO until cppi41 is awake.
> >
> > Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support")
>
> Cc stable?
Yes please.
Regards,
Tony
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-23 15:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-22 14:55 [PATCH] dmaengine: cppi41: Fix issue with musb and ftdi uart Tony Lindgren
2019-10-23 4:53 ` Vinod Koul
2019-10-23 15:27 ` Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).