From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Tony Lindgren <tony@atomide.com>,
Dan Williams <dan.j.williams@intel.com>,
Vinod Koul <vinod.koul@intel.com>
Cc: Alexandre Bailon <abailon@baylibre.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Bin Liu <b-liu@ti.com>, Daniel Mack <zonque@gmail.com>,
Felipe Balbi <felipe.balbi@linux.intel.com>,
Grygorii Strashko <grygorii.strashko@ti.com>,
Johan Hovold <johan@kernel.org>, Sekhar Nori <nsekhar@ti.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
<dmaengine@vger.kernel.org>, <linux-usb@vger.kernel.org>,
<linux-omap@vger.kernel.org>,
<giulio.benetti@benettiengineering.com>,
Sebastian Reichel <sre@kernel.org>,
Skvortsov <andrej.skvortzov@gmail.com>,
Yegor Yefremov <yegorslists@googlemail.com>
Subject: Re: [PATCH] dmaengine: cppi41: Fix cppi41_dma_prep_slave_sg() when idle
Date: Wed, 23 Oct 2019 20:04:44 +0300 [thread overview]
Message-ID: <245e1e8f-7933-bae1-b779-239f33d4d449@ti.com> (raw)
In-Reply-To: <20191023153138.23442-1-tony@atomide.com>
Hi Tony,
On 10/23/19 6:31 PM, Tony Lindgren wrote:
> Yegor Yefremov <yegorslists@googlemail.com> reported that musb and ftdi
> uart can fail for the first open of the uart unless connected using
> a hub.
>
> This is because 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>
> ---
>
> Please consider adding Cc stable v4.9+ tag when committing
>
> ---
> 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 pm_runtime_get()
pm_runtime_mark_last_busy()+pm_runtime_put_autosuspend() around a code
which updates a descriptor in _memory_ helps then this best described as
works by luck ;)
I have a feeling that if you put enough delay between prepare_sg and
issue_pending in the usb driver then it will keep failing, no?
fwiw, in the cppi41_dma_issue_pending() the driver does:
error = pm_runtime_get(cdd->ddev.dev);
...
if (!cdd->is_suspended)
cppi41_run_queue(cdd);
...
pm_runtime_mark_last_busy(cdd->ddev.dev);
pm_runtime_put_autosuspend(cdd->ddev.dev);
Without waiting for the transfer to complete?
If issue_pending is not starting the transfer right away then the whole
pm handling is broken in there. imho.
runtime_get in prep_slave_sg and runtime_put when the transfer is finished?
> + 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)
>
- Peter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
next prev parent reply other threads:[~2019-10-23 17:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-23 15:31 [PATCH] dmaengine: cppi41: Fix cppi41_dma_prep_slave_sg() when idle Tony Lindgren
2019-10-23 15:52 ` Vinod Koul
2019-10-23 17:04 ` Peter Ujfalusi [this message]
2019-10-23 17:16 ` Tony Lindgren
2019-10-23 19:02 ` Peter Ujfalusi
2019-10-23 19:18 ` Tony Lindgren
2019-10-23 19:55 ` Peter Ujfalusi
2019-10-23 20:18 ` Tony Lindgren
2019-10-23 20:55 ` Grygorii Strashko
2019-10-23 21:27 ` Tony Lindgren
2019-10-23 21:43 ` Grygorii Strashko
2019-10-23 21:49 ` Tony Lindgren
2019-10-24 8:52 ` Peter Ujfalusi
2019-10-24 11:22 ` Andy Shevchenko
2019-10-24 14:00 ` Tony Lindgren
2019-10-23 18:55 ` Sergei Shtylyov
2019-10-23 18:58 ` Andy Shevchenko
2019-10-23 19:19 ` Sergei Shtylyov
2019-10-23 19:00 ` Tony Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=245e1e8f-7933-bae1-b779-239f33d4d449@ti.com \
--to=peter.ujfalusi@ti.com \
--cc=abailon@baylibre.com \
--cc=andrej.skvortzov@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=b-liu@ti.com \
--cc=bigeasy@linutronix.de \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=felipe.balbi@linux.intel.com \
--cc=giulio.benetti@benettiengineering.com \
--cc=grygorii.strashko@ti.com \
--cc=johan@kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nsekhar@ti.com \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=sre@kernel.org \
--cc=tony@atomide.com \
--cc=vinod.koul@intel.com \
--cc=yegorslists@googlemail.com \
--cc=zonque@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).