Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-acpi@vger.kernel.org, rajmohan.mani@intel.com,
	linux-media@vger.kernel.org,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: Re: [PATCH 1/5] ACPI: Enable driver and firmware hints to control power at probe time
Date: Fri, 31 May 2019 11:17:10 +0200
Message-ID: <9700088.HJ6KcFTmRF@kreacher> (raw)
In-Reply-To: <20190510100930.14641-2-sakari.ailus@linux.intel.com>

On Friday, May 10, 2019 12:09:26 PM CEST Sakari Ailus wrote:
> Allow drivers and firmware tell ACPI that there's no need to power on a
> device for probe. This requires both a hint from the firmware as well as
> an indication from a driver to leave the device off.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/acpi/device_pm.c | 9 +++++++--
>  include/linux/device.h   | 6 ++++++
>  2 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
> index b859d75eaf9f6..ca2409a30d26d 100644
> --- a/drivers/acpi/device_pm.c
> +++ b/drivers/acpi/device_pm.c
> @@ -1225,7 +1225,9 @@ static void acpi_dev_pm_detach(struct device *dev, bool power_off)
>  	if (adev && dev->pm_domain == &acpi_general_pm_domain) {
>  		dev_pm_domain_set(dev, NULL);
>  		acpi_remove_pm_notifier(adev);
> -		if (power_off) {
> +		if (power_off &&
> +		    !(dev->driver->probe_powered_off &&
> +		      device_property_present(dev, "avoid-power-probe"))) {
>  			/*
>  			 * If the device's PM QoS resume latency limit or flags
>  			 * have been exposed to user space, they have to be
> @@ -1273,7 +1275,10 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
>  
>  	acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func);
>  	dev_pm_domain_set(dev, &acpi_general_pm_domain);
> -	if (power_on) {
> +
> +	if (power_on &&
> +	    !(dev->driver->probe_powered_off &&
> +	      device_property_present(dev, "avoid-power-probe"))) {
>  		acpi_dev_pm_full_power(adev);
>  		acpi_device_wakeup_disable(adev);
>  	}
> diff --git a/include/linux/device.h b/include/linux/device.h
> index e85264fb66161..2a459fd5b954a 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -245,6 +245,11 @@ enum probe_type {
>   * @owner:	The module owner.
>   * @mod_name:	Used for built-in modules.
>   * @suppress_bind_attrs: Disables bind/unbind via sysfs.
> + * @probe_powered_off: The driver supports its probe function being called while
> + *		       the device is powered off, independently of the expected
> + *		       behaviour on combination of a given bus and firmware
> + *		       interface etc. The driver is responsible for powering the
> + *		       device on using runtime PM in such case.
>   * @probe_type:	Type of the probe (synchronous or asynchronous) to use.
>   * @of_match_table: The open firmware table.
>   * @acpi_match_table: The ACPI match table.
> @@ -282,6 +287,7 @@ struct device_driver {
>  	const char		*mod_name;	/* used for built-in modules */
>  
>  	bool suppress_bind_attrs;	/* disables bind/unbind via sysfs */
> +	bool probe_powered_off;

This is a bit of a misnomer IMO, because it is not just about devices that are completely off.
From the ACPI perspective that is about all devices not in D0, which may mean gated clocks
etc.

I would call it probe_low_power or similar and analogously in patch [2/5], and apart from this
I have no objections against this series, but I would suggest to CC the next iteration of it
to Greg K-H and the LKML as it touches the driver core.

>  	enum probe_type probe_type;
>  
>  	const struct of_device_id	*of_match_table;
> 





  reply index

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10 10:09 [PATCH 0/5] Support running driver's probe for a device powered off Sakari Ailus
2019-05-10 10:09 ` [PATCH 1/5] ACPI: Enable driver and firmware hints to control power at probe time Sakari Ailus
2019-05-31  9:17   ` Rafael J. Wysocki [this message]
2019-06-05 12:07     ` Sakari Ailus
2019-05-10 10:09 ` [PATCH 2/5] ACPI: Add a convenience function to tell a device is suspended in probe Sakari Ailus
2019-05-10 10:09 ` [PATCH 3/5] ov5670: Support probe whilst the device is off Sakari Ailus
2019-06-05  7:07   ` Tomasz Figa
2019-06-05 10:15     ` Sakari Ailus
2019-06-07  7:54       ` Tomasz Figa
2019-08-26  8:38         ` Sakari Ailus
2019-08-26  9:21           ` Tomasz Figa
2019-05-10 10:09 ` [PATCH 4/5] media: i2c: imx319: Support probe while " Sakari Ailus
2019-05-10 10:09 ` [PATCH 5/5] at24: Support probing while off Sakari Ailus

Reply instructions:

You may reply publically 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=9700088.HJ6KcFTmRF@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rajmohan.mani@intel.com \
    --cc=sakari.ailus@linux.intel.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

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org
	public-inbox-index linux-acpi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git