mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Vinod Koul <vinod.koul@intel.com>,
	Lee Jones <lee.jones@linaro.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Jarkko Nikula <jarkko.nikula@linux.intel.com>,
	"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
	Mike Turquette <mturquette@linaro.org>
Subject: Re: [PATCH v3 2/8] ACPI / PM: Attach ACPI power domain only once
Date: Thu, 11 Jun 2015 01:41:57 +0200	[thread overview]
Message-ID: <2341229.OsnWD0GN2O@vostro.rjw.lan> (raw)
In-Reply-To: <1433170082-117462-3-git-send-email-andriy.shevchenko@linux.intel.com>

On Monday, June 01, 2015 05:47:56 PM Andy Shevchenko wrote:
> From: Mika Westerberg <mika.westerberg@linux.intel.com>
> 
> Some devices, like MFD subdevices, share a single ACPI companion device so
> that they are able to access their resources and children. However,
> currently all these subdevices are attached to the ACPI power domain and
> this might cause that the power methods for the companion device get called
> more than once.
> 
> In order to solve this we attach the ACPI power domain only to the first
> physical device that is bound to the ACPI companion device. In case of MFD
> devices, this is the parent MFD device itself.
> 
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  drivers/acpi/device_pm.c |  8 ++++++++
>  drivers/acpi/internal.h  |  2 ++
>  drivers/acpi/scan.c      | 46 ++++++++++++++++++++++++++++++----------------
>  3 files changed, 40 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
> index 735db11..7d0c7e9 100644
> --- a/drivers/acpi/device_pm.c
> +++ b/drivers/acpi/device_pm.c
> @@ -1103,6 +1103,14 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
>  	if (dev->pm_domain)
>  		return -EEXIST;
>  
> +	/*
> +	 * Only attach the power domain to the first device if the
> +	 * companion is shared by multiple. This is to prevent doing power
> +	 * management twice.
> +	 */
> +	if (!acpi_device_is_first_physical_node(adev, dev))
> +		return -EBUSY;
> +
>  	acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func);
>  	dev->pm_domain = &acpi_general_pm_domain;
>  	if (power_on) {
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index ba4a61e..c26a951 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -96,6 +96,8 @@ void acpi_device_add_finalize(struct acpi_device *device);
>  void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
>  bool acpi_device_is_present(struct acpi_device *adev);
>  bool acpi_device_is_battery(struct acpi_device *adev);
> +bool acpi_device_is_first_physical_node(struct acpi_device *adev,
> +					const struct device *dev);
>  
>  /* --------------------------------------------------------------------------
>                                    Power Resource
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index 03141aa..37f8f74 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -223,6 +223,35 @@ static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
>  	return len;
>  }
>  
> +/**
> + * acpi_device_is_first_physical_node - Is given dev first physical node
> + * @adev: ACPI companion device
> + * @dev: Physical device to check
> + *
> + * Function checks if given @dev is the first physical devices attached to
> + * the ACPI companion device. This distinction is needed in some cases
> + * where the same companion device is shared between many physical devices.
> + *
> + * Note that the caller have to provide valid @adev pointer.
> + */
> +bool acpi_device_is_first_physical_node(struct acpi_device *adev,
> +					const struct device *dev)
> +{
> +	bool ret = false;
> +
> +	mutex_lock(&adev->physical_node_lock);
> +	if (!list_empty(&adev->physical_node_list)) {
> +		const struct acpi_device_physical_node *node;
> +
> +		node = list_first_entry(&adev->physical_node_list,
> +					struct acpi_device_physical_node, node);
> +		ret = node->dev == dev;
> +	}
> +	mutex_unlock(&adev->physical_node_lock);
> +
> +	return ret;
> +}
> +
>  /*
>   * acpi_companion_match() - Can we match via ACPI companion device
>   * @dev: Device in question
> @@ -247,7 +276,6 @@ static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
>  static struct acpi_device *acpi_companion_match(const struct device *dev)
>  {
>  	struct acpi_device *adev;
> -	struct mutex *physical_node_lock;
>  
>  	adev = ACPI_COMPANION(dev);
>  	if (!adev)
> @@ -256,21 +284,7 @@ static struct acpi_device *acpi_companion_match(const struct device *dev)
>  	if (list_empty(&adev->pnp.ids))
>  		return NULL;
>  
> -	physical_node_lock = &adev->physical_node_lock;
> -	mutex_lock(physical_node_lock);
> -	if (list_empty(&adev->physical_node_list)) {
> -		adev = NULL;
> -	} else {
> -		const struct acpi_device_physical_node *node;
> -
> -		node = list_first_entry(&adev->physical_node_list,
> -					struct acpi_device_physical_node, node);
> -		if (node->dev != dev)
> -			adev = NULL;
> -	}
> -	mutex_unlock(physical_node_lock);
> -
> -	return adev;
> +	return acpi_device_is_first_physical_node(adev, dev) ? adev : NULL;
>  }
>  
>  static int __acpi_device_uevent_modalias(struct acpi_device *adev,
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

  reply	other threads:[~2015-06-10 23:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01 14:47 [PATCH v3 0/8] mfd: introduce a driver for LPSS devices on SPT Andy Shevchenko
2015-06-01 14:47 ` [PATCH v3 1/8] PM / QoS: Make it possible to expose device latency tolerance to userspace Andy Shevchenko
2015-06-10 23:41   ` Rafael J. Wysocki
2015-06-01 14:47 ` [PATCH v3 2/8] ACPI / PM: Attach ACPI power domain only once Andy Shevchenko
2015-06-10 23:41   ` Rafael J. Wysocki [this message]
2015-06-01 14:47 ` [PATCH v3 3/8] Driver core: wakeup the parent device before trying probe Andy Shevchenko
2015-06-08 23:42   ` Rafael J. Wysocki
2015-06-10  0:08     ` Rafael J. Wysocki
2015-06-10  9:43       ` Andy Shevchenko
2015-06-10 23:41         ` Rafael J. Wysocki
2015-06-10 14:02       ` Andy Shevchenko
2015-06-01 14:47 ` [PATCH v3 4/8] klist: implement klist_prev() Andy Shevchenko
2015-06-01 14:47 ` [PATCH v3 5/8] driver core: implement device_for_each_child_reverse() Andy Shevchenko
2015-06-01 14:48 ` [PATCH v3 6/8] mfd: make mfd_remove_devices() iterate in reverse order Andy Shevchenko
2015-06-01 14:48 ` [PATCH v3 7/8] dmaengine: add a driver for Intel integrated DMA 64-bit Andy Shevchenko
2015-06-01 14:48 ` [PATCH v3 8/8] mfd: Add support for Intel Sunrisepoint LPSS devices Andy Shevchenko
2015-06-02  9:44   ` Lee Jones

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=2341229.OsnWD0GN2O@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=mturquette@linaro.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=vinod.koul@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
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

all inboxes | Powered by JetHome®