linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Peter Chen <hzpeterchen@gmail.com>
Cc: Peter Chen <peter.chen@nxp.com>,
	mark.rutland@arm.com, ulf.hansson@linaro.org, heiko@sntech.de,
	stephen.boyd@linaro.org, frank.li@nxp.com,
	linux-kernel@vger.kernel.org, gary.bisson@boundarydevices.com,
	festevam@gmail.com, stillcompiling@gmail.com, arnd@arndb.de,
	dbaryshkov@gmail.com, vaibhav.hiremath@linaro.org,
	krzk@kernel.org, mka@chromium.org, stern@rowland.harvard.edu,
	devicetree@vger.kernel.org, mail@maciej.szmigiero.name,
	pawel.moll@arm.com, linux-pm@vger.kernel.org,
	s.hauer@pengutronix.de, troy.kisky@boundarydevices.com,
	robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org,
	hverkuil@xs4all.nl, oscar@naiandei.net,
	gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	sre@kernel.org, broonie@kernel.org, p.zabel@pengutronix.de,
	shawnguo@kernel.org, jun.li@nxp.com
Subject: Re: [PATCH v16 2/7] power: add power sequence library
Date: Sat, 08 Jul 2017 14:14:56 +0200	[thread overview]
Message-ID: <10723509.cz5GGA4OTz@aspire.rjw.lan> (raw)
In-Reply-To: <20170708055115.GA25873@b29397-desktop>

On Saturday, July 08, 2017 01:51:15 PM Peter Chen wrote:
> On Fri, Jul 07, 2017 at 03:03:06PM +0200, Rafael J. Wysocki wrote:
> > On Friday, July 07, 2017 04:01:07 PM Peter Chen wrote:
> > > On Fri, Jul 07, 2017 at 03:13:48AM +0200, Rafael J. Wysocki wrote:
> > > > > 
> > > > > - Can I write new code for it or I need to depend on something?
> > > > 
> > > > There is nothing this code needs to depend on AFAICS, but there are existing
> > > > solutions in this problem space (ACPI power management, genpd), so it needs to
> > > > be careful enough about possible overlaps etc.
> > > > 
> > > > > I find there is already "power state" concept at documentation.
> > > > > Documentation/ABI/testing/sysfs-devices-power_state
> > > > 
> > > > This is ACPI-specific and only in sysfs directories representing ACPI device
> > > > objects (which aren't physical devices).
> > > > 
> > > > Anyway, since ACPI covers the problem space you are working in already,
> > > > your code has to be mutually exclusive with it.
> > > > 
> > > > > - If I can write the new code for it, except the problems I want
> > > > > to fix, are there any other use cases I need to consider?
> > > > 
> > > > I would start simple and focus on the particular problem at hand, that is
> > > > devices with two power states ("on" and "off") where the "on" state
> > > > depends on a number of clocks and/or GPIOs.  Still, I'd also avoid making
> > > > design choices that might prevent it from being extended in the future
> > > > if need be.
> > > > 
> > > > One major problem I can see is how to "attach" the power states framework
> > > > to a particular device (once we have discovered that it should be used with
> > > > that device).
> > > > 
> > > > For bus types that don't do power management of their own you could follow
> > > > ACPI (and genpd) and provide a PM domain for this purpose, but bus types
> > > > doing their own PM (like USB) will probably need to be treated differently.
> > > > In those cases the bus type code will have to know that it should call some
> > > > helpers to switch power states of devices.
> > > > 
> > > 
> > > After thinking more, using a power state framework is seems too heavy
> > > for this use case. This use case is just do some clock and gpio
> > > operations before device is created, and do some put operations
> > > after device is deleted. We just need some helpers in one structure
> > > (called "power sequence" or "power state") for this purpose.
> > > 
> > > For the use case, the clock and gpio operation can be done after device
> > > is created, the power domain is more suitable.
> > 
> > There is a problem with PM domains that they only provide hooks for runtime PM
> > and system suspend/resume (including hibernation) and not for generic
> > "power up" and "power down" operations that may need to be carried out at
> > probe time before the runtime PM framework can be used (and analogously
> > at remove time).
> > 
> > I would consider starting with the patch below or similar.
> > 
> > Then you can define something like POWER_STATE_SEQUENCE type for your
> > case and basically use almost what you have already with it, except that
> > struct pwrsec_generic will now become struct power_state_sequence and
> > struct power_state_info will be embedded in it instead of struct pwrsec.
> > 
> > The major comceptual difference is that ->power_up and ->power_down are
> > now available at the level of the device that needs the power sequence and
> > pm_device_power_up/down() can be used wherever necessary (in the code,
> > in a bus type, in a controller driver or even in the driver for this particular
> > device).
> 
> Rafeal, thanks for your patch.
> 
> The biggest problem for my use case is the device is still not created.
> How can I call pm_device_power_up(dev)?

Can you please elaborate on that a bit?

You surely need a device object before probing the device and why would the
device be accessed before that point?

I guess you have a bus with devices that are discoverable in principle, but
they cannot be discovered before being powered up, so you need the information
on which devices to power up in a DT, right?

Thanks,
Rafael

  reply	other threads:[~2017-07-08 12:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21  6:42 [PATCH v16 0/7] power: add power sequence library Peter Chen
2017-06-21  6:42 ` [PATCH v16 1/7] binding-doc: power: pwrseq-generic: add binding doc for generic " Peter Chen
2017-06-21  6:42 ` [PATCH v16 2/7] power: add " Peter Chen
2017-07-05  0:44   ` Rafael J. Wysocki
2017-07-05 11:54     ` Peter Chen
2017-07-07  1:13       ` Rafael J. Wysocki
2017-07-07  8:01         ` Peter Chen
2017-07-07 13:03           ` Rafael J. Wysocki
2017-07-08  5:51             ` Peter Chen
2017-07-08 12:14               ` Rafael J. Wysocki [this message]
2017-07-10  2:28                 ` Peter Chen
2017-07-17 13:39                   ` Rafael J. Wysocki
2017-07-18  4:29                     ` Peter Chen
2017-07-18 17:06                       ` Rafael J. Wysocki
2017-07-19  2:56                         ` Peter Chen
2017-07-19 11:34                           ` Rafael J. Wysocki
2017-07-20  9:35                             ` Peter Chen
2017-06-21  6:42 ` [PATCH v16 3/7] binding-doc: usb: usb-device: add optional properties for power sequence Peter Chen
2017-06-21  6:42 ` [PATCH v16 4/7] usb: core: add power sequence handling for USB devices Peter Chen
2017-06-21  6:42 ` [PATCH v16 5/7] ARM: dts: imx6qdl: Enable usb node children with <reg> Peter Chen
2017-06-21  6:42 ` [PATCH v16 6/7] ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property Peter Chen
2017-06-21  6:42 ` [PATCH v16 7/7] ARM: dts: imx6q-evi: Fix onboard hub reset line Peter Chen

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=10723509.cz5GGA4OTz@aspire.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=dbaryshkov@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=frank.li@nxp.com \
    --cc=gary.bisson@boundarydevices.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=hverkuil@xs4all.nl \
    --cc=hzpeterchen@gmail.com \
    --cc=jun.li@nxp.com \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mail@maciej.szmigiero.name \
    --cc=mark.rutland@arm.com \
    --cc=mka@chromium.org \
    --cc=oscar@naiandei.net \
    --cc=p.zabel@pengutronix.de \
    --cc=pawel.moll@arm.com \
    --cc=peter.chen@nxp.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=sre@kernel.org \
    --cc=stephen.boyd@linaro.org \
    --cc=stern@rowland.harvard.edu \
    --cc=stillcompiling@gmail.com \
    --cc=troy.kisky@boundarydevices.com \
    --cc=ulf.hansson@linaro.org \
    --cc=vaibhav.hiremath@linaro.org \
    /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).