ksummit.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@linaro.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: ksummit-discuss@lists.linuxfoundation.org
Subject: Re: [Ksummit-discuss] [TECH TOPIC] PM dependencies
Date: Thu, 22 May 2014 17:39:05 -0700	[thread overview]
Message-ID: <7h61kxgwgm.fsf@paris.lan> (raw)
In-Reply-To: <31131010.huPvrnkcye@avalon> (Laurent Pinchart's message of "Fri, 23 May 2014 02:18:59 +0200")

Laurent Pinchart <laurent.pinchart@ideasonboard.com> writes:

> Hi Kevin,
>
> On Tuesday 20 May 2014 09:57:14 Kevin Hilman wrote:
>> Laurent Pinchart <laurent.pinchart@ideasonboard.com> writes:

[...]

I'll respond to the DMA/IOMMU part separately, as I need some time to
digest it.

>> > Furthermore, if the sensor is resumed first, it might try to access the
>> > device, which requires the clock output by the ISP to be available, and
>> > thus requires the ISP to be resumed. To solve this problem the ISP driver
>> > only restarts the clocks in its PM resume callback, and restarts the
>> > video stream (following the sequence described above) in its PM complete
>> > callback.
>>
>> For most devices, input clocks are modeled by the clock framework (or
>> managed by the SoC's runtime PM core), and therefore, a pm_runtime_get()
>> (or possibly an explict clk_enable()) is used to ensure the input clock
>> is running.  In this external device example, it sounds to me like the
>> sensor driver has no knowledge of its input clock so it has to rely on
>> some other layer to resume things in the right order for correct
>> functionality.
>> 
>> Maybe I'm wrong here (likely, since I haven't looked at the code, and am
>> admittedly very ignorant of the camera and display subsystems) but it
>> sounds to me like what's missing is the sensor driver having knowledge
>> of it's input clock and/or a way for it to request it's input clock to
>> be enabled (e.g. clk_get/clk_enable.)
>
> I'm glad that you point out likely being wrong yourself, as you are ;-) 

Touché.

It's good to have a low standard for oneself. ;)

> The sensor driver manages the sensor input clock explicitly through
> CCF (or at least it should, not all drivers do their homework
> properly, but that's just a matter of fixing them), so it can
> enable/disable the clock when needed. If the clock provider driver
> becomes runtime PM centric then part of the problem would be fixed.

Great, that simplifies things a bit, except...

>> Alternatively, what would proably be even better would be that the
>> sensor driver has a reference to the actual device that provides its
>> input clock (possibly via a DT phandle?) so that the sensor driver can
>> simply do a pm_runtime_get() on the device providing the clock.
>
> Isn't it better for the sensor DT node to reference its input clock through 
> the clocks property and enable/disable the clock on demand instead of 
> explicitly calling pm_runtime_(get|put) on the clock provider device ?

Possibly, but I suspect that's not going to be good enough.

As I mentioned in an earlier response to Geert, I don't think managing
clocks alone is enough.  I can imagine many platforms where a simple
clk_enable() of an input clock is not enough to bring the device
providing that clock out of a low power state.  For this to be generic
enough to handle those cases, I suspect runtime PM get/put is the right
way to go.

Of course, for many "simple" platforms, runtime PM get/put just ends up
doing a clk_enable/disable, but on the platforms where runtime PM is
slightly more... um, "interesting"... just doing a clk enable/disable
won't do what you hope.

>> > When adding more external devices to the mix the problem just becomes more
>> > complex, especially when the devices are chained (for instance sensor ->
>> > video processor -> ISP). The problem is similar on the display side,
>> > possibly with a different resume ordering (it should be noted that the
>> > external devices vs. internal device ordering might vary even inside the
>> > same class of devices - camera or display).
>> 
>> IMO, I still think that properly modeling the device dependenies
>> combined with a "runtime PM centric" view of suspend/resume should allow
>> the dependencies to be handled correctly for system suspend/resume and
>> runtime PM.
>
> I definitely need to give this a bit more thought. I agree that it would 
> likely solve part of the issue, but I'm not sure whether the rest is solvable 
> with the infrastructure we have now.

Not without some enhancments, but IMO ensuring the frameworks are
runtime PM centric, and possibly extending runtime PM slightly where
needed is a better route than creating something new.  Whatever that
"something new" would be would end up duplicating much of the use
counting already done by runtime PM anyways.

>> I think what complicates things here is not the PM specifics but
>> probably the fact that the device hierarchy (and dependencies) may be
>> dynamic depending on many factors like which sensors are in use,
>> post-processing, etc. etc.
>> 
>> Above, I suggested possibly using DT phandles to model these non
>> parent/child relationships.  That's all fine if the dependencies are not
>> changing, but if they are dynamic, we'll probably need something
>> different.
>
> They can be dynamic, yes. However, we already model the video data streams 
> dependencies using phandles in the V4L2 bindings, so the required information 
> is there. It would thus "just" be a matter of orchestrating all the involved 
> components. If we go the runtime PM way the problem might be simplified, but 
> as Ulf Hansson mentioned interactions between runtime PM and system 
> suspend/resume need to be taken care of.

I'm unfortunately all too familiar with the interactions between system
PM and runtime PM, but I believe we have a pretty good grip on that now,
and the infrastructure is in place to solve those problems.

Kevin

  reply	other threads:[~2014-05-23  0:39 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-12 17:43 Laurent Pinchart
2014-05-12 17:51 ` Shuah Khan
2014-05-18 15:42   ` Mauro Carvalho Chehab
2014-05-12 18:09 ` Tomasz Figa
2014-05-12 20:14 ` Mark Brown
2014-05-12 20:27   ` Laurent Pinchart
2014-05-12 20:31     ` Mark Brown
2014-05-12 21:16       ` Tomasz Figa
2014-05-12 22:07         ` Mark Brown
2014-05-13  7:43           ` Daniel Vetter
2014-05-13 10:31             ` Laurent Pinchart
2014-05-13 14:26               ` Shuah Khan
2014-05-15 23:43                 ` Laurent Pinchart
2014-05-19  1:00                   ` Shuah Khan
2014-05-19  7:30                     ` Geert Uytterhoeven
2014-05-13 22:27           ` Rafael J. Wysocki
2014-05-13 22:34             ` Rafael J. Wysocki
2014-05-14 12:59               ` Rafael J. Wysocki
2014-05-15 23:34               ` Laurent Pinchart
2014-05-20 16:57                 ` Kevin Hilman
2014-05-20 18:51                   ` Mark Brown
2014-05-21  9:26                   ` Ulf Hansson
2014-05-21 11:16                   ` Geert Uytterhoeven
2014-05-22  0:19                   ` Rafael J. Wysocki
2014-05-22 10:14                     ` Mark Brown
2014-05-23 23:15                       ` Rafael J. Wysocki
2014-05-24 10:53                         ` Mark Brown
2014-05-25 12:56                           ` Rafael J. Wysocki
2014-05-22 17:35                     ` Kevin Hilman
2014-05-23 23:26                       ` Rafael J. Wysocki
2014-05-23  0:18                   ` Laurent Pinchart
2014-05-23  0:39                     ` Kevin Hilman [this message]
2014-05-23  8:32                       ` Linus Walleij
2014-05-23 15:26                         ` Kevin Hilman
2014-05-24  0:13                           ` Rafael J. Wysocki
2014-05-24  0:08                         ` Rafael J. Wysocki
2014-05-26 14:30                         ` Peter De Schrijver
2014-05-23  8:25                     ` Linus Walleij
2014-05-23  9:10                       ` Ulf Hansson
2014-05-24  0:00                       ` Rafael J. Wysocki
2014-05-15 22:45             ` Laurent Pinchart
2014-05-14 21:08           ` Kevin Hilman
2014-05-14 12:11       ` Rafael J. Wysocki
2014-05-14 11:57         ` Mark Brown
2014-05-14 12:32           ` Rafael J. Wysocki
2014-05-14 15:14             ` Mark Brown
2014-05-14 15:26           ` Laurent Pinchart
2014-05-14 15:40             ` Mark Brown

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=7h61kxgwgm.fsf@paris.lan \
    --to=khilman@linaro.org \
    --cc=ksummit-discuss@lists.linuxfoundation.org \
    --cc=laurent.pinchart@ideasonboard.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