dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Tony Lindgren <tony@atomide.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
	Vinod Koul <vkoul@kernel.org>,
	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: Thu, 24 Oct 2019 11:52:02 +0300	[thread overview]
Message-ID: <4bcd75d8-b7c5-5006-d80f-c5bda0cdf011@ti.com> (raw)
In-Reply-To: <20191023201829.GR5610@atomide.com>



On 23/10/2019 23.18, Tony Lindgren wrote:
> * Peter Ujfalusi <peter.ujfalusi@ti.com> [191023 19:55]:
>> On 10/23/19 10:18 PM, Tony Lindgren wrote:
>>> We'd have to allow dma consumer driver call pm_runtime_get_sync()
>>> on the dma device. Something similar maybe to what we have
>>> for phy_pm_runtime_get_sync(). Or just get the device handle for
>>> dma so the consumer can call pm_runtime_get_sync() on it.
>>
>> How much a pm_runtime_get_sync(dmadev) is different when it is issued by
>> the client driver compared to when the dma driver issues it for it's own
>> device?
> 
> Well the consumer device could call pm_runtime_get_sync(dmadev)
> when the USB cable is connected for example, and then call
> pm_runtime_pu(dmadev) when let's say the USB cable is disconnected.

And the USB cable connect/disconnect is handled in interrupt -> you need
to call pm_runtime_get_sync(dmadev) from interrupt context and need to
mark the dmadev to pm_runtime_irq_safe()

> Without using pm_runtime_irq_safe() we currently don't have a
> clear path for doing this where the pm_runtime_get_sync(dmadev)
> may sleep.
> 
>> But I still fail to see the difference between the events before this
>> patch and with the case when there is a 100ms delay between prep_sg and
>> issue_pending.
>>
>> Before this patch:
>>
>> prep_sg()
>> issue_pending() <- runtime_get() /  put_autosuspend()
>> 		   _not_ starting transfer
>> runtime_resume() <- starts the transfer
>>
>> With this patch and than 100ms delay between prep_sg and issue_pending:
>>
>> prep_sg() <- runtime_get() /  put_autosuspend()
>> runtime_resume() <- not starting transfer
>> issue_pending() <- runtime_get() /  put_autosuspend()
>> 		   starts the transfer
>>
>> With this patch, but more than 100ms delay in between:
>>
>> prep_sg() <- runtime_get() /  put_autosuspend()
>> runtime_resume() <- not starting transfer
>>> 100ms delay
>> runtime_suspend()
>> issue_pending() <- runtime_get() /  put_autosuspend()
>> 		   _not_ starting transfer
>> runtime_resume() <- starts the transfer
>>
>> pm_runtime_get_sync() in issue_pending would be the solution to avoid
>> delayed execution, but the usb driver should not assume that DMA is
>> completed as soon as issue_pending returned.
> 
> Oh I see. Yes the consumer driver would need to check for
> the completed dma transfer in all cases. The delay issues
> should not currently happen in the musb_ep_program() problem
> case as it gets called from IRQ context.

the cppi41 driver solely relies on irq to check is the transfer is
completed (based on the cookie status).
So yeah, musb have no other choice than trust that the transfer is done
in a timely manner.

> And no, adding pm_runtime_get_sync() to issue_pending is not
> a solution. There may be clocks and regulators that need to
> be powered up, and we don't want to use pm_runtime_irq_safe()
> because of the permanent use count on the parent.

I think the only way to handle this is to keep the DMA enabled as long
as the USB cable is connected.
Either to introduce dma_pm_runtime_get_sync(struct dma_chan *c) and
dma_pm_runtime_put(struct dma_chan *c) or some better name.

It's use would be optional, but for USB you would call them for cable
connect the get_sync (from a work) and put it on disconnect.

The driver internally would not need to be changed, I think this patch
could be removed as well.

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  parent reply	other threads:[~2019-10-24  8:51 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
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 [this message]
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=4bcd75d8-b7c5-5006-d80f-c5bda0cdf011@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=vkoul@kernel.org \
    --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).