From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Cc: Toshi Kani <toshi.kani@hp.com>,
Bjorn Helgaas <bhelgaas@google.com>,
LKML <linux-kernel@vger.kernel.org>,
linux-pci@vger.kernel.org, Yinghai Lu <yinghai@kernel.org>,
Myron Stowe <myron.stowe@redhat.com>,
Yijing Wang <wangyijing0307@gmail.com>,
Jiang Liu <liuj97@gmail.com>
Subject: [PATCH 14/16] ACPI / PCI: Rework the setup and cleanup of device wakeup
Date: Thu, 20 Dec 2012 02:58:17 +0100 [thread overview]
Message-ID: <3181154.NDRBl366gp@vostro.rjw.lan> (raw)
In-Reply-To: <1855256.SyhOJGYMIh@vostro.rjw.lan>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Currently, the ACPI wakeup capability of PCI devices is set up
in two different places, partially in acpi_pci_bind() where
runtime wakeup is initialized and partially in
platform_pci_wakeup_init(), where system wakeup is initialized.
The cleanup is only done in acpi_pci_unbind() and it only covers
runtime wakeup.
Use the new .setup() and .cleanup() callbacks in struct acpi_bus_type
to consolidate that code and do the setup and the cleanup each in one
place.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/device_pm.c | 2 +-
drivers/acpi/pci_bind.c | 7 -------
drivers/pci/pci-acpi.c | 30 +++++++++++++++++++++++++++++-
drivers/pci/pci.c | 26 +-------------------------
drivers/pci/pci.h | 5 -----
drivers/pci/probe.c | 1 -
include/linux/acpi.h | 5 +++++
7 files changed, 36 insertions(+), 40 deletions(-)
Index: linux/drivers/acpi/pci_bind.c
===================================================================
--- linux.orig/drivers/acpi/pci_bind.c
+++ linux/drivers/acpi/pci_bind.c
@@ -43,9 +43,6 @@ static int acpi_pci_unbind(struct acpi_d
if (!dev)
goto out;
- device_set_run_wake(&dev->dev, false);
- pci_acpi_remove_pm_notifier(device);
-
if (!dev->subordinate)
goto out;
@@ -70,10 +67,6 @@ static int acpi_pci_bind(struct acpi_dev
if (!dev)
return 0;
- pci_acpi_add_pm_notifier(device, dev);
- if (device->wakeup.flags.run_wake)
- device_set_run_wake(&dev->dev, true);
-
/*
* Install the 'bind' function to facilitate callbacks for
* children of the P2P bridge.
Index: linux/drivers/pci/pci.h
===================================================================
--- linux.orig/drivers/pci/pci.h
+++ linux/drivers/pci/pci.h
@@ -44,9 +44,6 @@ int pci_probe_reset_function(struct pci_
* platform; to be used during system-wide transitions from a
* sleeping state to the working state and vice versa
*
- * @can_wakeup: returns 'true' if given device is capable of waking up the
- * system from a sleeping state
- *
* @sleep_wake: enables/disables the system wake up capability of given device
*
* @run_wake: enables/disables the platform to generate run-time wake-up events
@@ -60,7 +57,6 @@ struct pci_platform_pm_ops {
bool (*is_manageable)(struct pci_dev *dev);
int (*set_state)(struct pci_dev *dev, pci_power_t state);
pci_power_t (*choose_state)(struct pci_dev *dev);
- bool (*can_wakeup)(struct pci_dev *dev);
int (*sleep_wake)(struct pci_dev *dev, bool enable);
int (*run_wake)(struct pci_dev *dev, bool enable);
};
@@ -75,7 +71,6 @@ extern void pci_wakeup_bus(struct pci_bu
extern void pci_config_pm_runtime_get(struct pci_dev *dev);
extern void pci_config_pm_runtime_put(struct pci_dev *dev);
extern void pci_pm_init(struct pci_dev *dev);
-extern void platform_pci_wakeup_init(struct pci_dev *dev);
extern void pci_allocate_cap_save_buffers(struct pci_dev *dev);
void pci_free_cap_save_buffers(struct pci_dev *dev);
Index: linux/drivers/pci/probe.c
===================================================================
--- linux.orig/drivers/pci/probe.c
+++ linux/drivers/pci/probe.c
@@ -1276,7 +1276,6 @@ static void pci_init_capabilities(struct
/* Power Management */
pci_pm_init(dev);
- platform_pci_wakeup_init(dev);
/* Vital Product Data */
pci_vpd_pci22_init(dev);
Index: linux/drivers/pci/pci.c
===================================================================
--- linux.orig/drivers/pci/pci.c
+++ linux/drivers/pci/pci.c
@@ -450,7 +450,7 @@ static struct pci_platform_pm_ops *pci_p
int pci_set_platform_pm(struct pci_platform_pm_ops *ops)
{
if (!ops->is_manageable || !ops->set_state || !ops->choose_state
- || !ops->sleep_wake || !ops->can_wakeup)
+ || !ops->sleep_wake)
return -EINVAL;
pci_platform_pm = ops;
return 0;
@@ -473,11 +473,6 @@ static inline pci_power_t platform_pci_c
pci_platform_pm->choose_state(dev) : PCI_POWER_ERROR;
}
-static inline bool platform_pci_can_wakeup(struct pci_dev *dev)
-{
- return pci_platform_pm ? pci_platform_pm->can_wakeup(dev) : false;
-}
-
static inline int platform_pci_sleep_wake(struct pci_dev *dev, bool enable)
{
return pci_platform_pm ?
@@ -1960,25 +1955,6 @@ void pci_pm_init(struct pci_dev *dev)
}
}
-/**
- * platform_pci_wakeup_init - init platform wakeup if present
- * @dev: PCI device
- *
- * Some devices don't have PCI PM caps but can still generate wakeup
- * events through platform methods (like ACPI events). If @dev supports
- * platform wakeup events, set the device flag to indicate as much. This
- * may be redundant if the device also supports PCI PM caps, but double
- * initialization should be safe in that case.
- */
-void platform_pci_wakeup_init(struct pci_dev *dev)
-{
- if (!platform_pci_can_wakeup(dev))
- return;
-
- device_set_wakeup_capable(&dev->dev, true);
- platform_pci_sleep_wake(dev, false);
-}
-
static void pci_add_saved_cap(struct pci_dev *pci_dev,
struct pci_cap_saved_state *new_cap)
{
Index: linux/include/linux/acpi.h
===================================================================
--- linux.orig/include/linux/acpi.h
+++ linux/include/linux/acpi.h
@@ -510,9 +510,14 @@ static inline int acpi_subsys_resume_ear
#endif
#if defined(CONFIG_ACPI) && defined(CONFIG_PM)
+struct acpi_device *acpi_dev_pm_get_node(struct device *dev);
int acpi_dev_pm_attach(struct device *dev, bool power_on);
void acpi_dev_pm_detach(struct device *dev, bool power_off);
#else
+static struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
+{
+ return NULL;
+}
static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
{
return -ENODEV;
Index: linux/drivers/acpi/device_pm.c
===================================================================
--- linux.orig/drivers/acpi/device_pm.c
+++ linux/drivers/acpi/device_pm.c
@@ -634,7 +634,7 @@ int acpi_pm_device_sleep_wake(struct dev
* acpi_dev_pm_get_node - Get ACPI device node for the given physical device.
* @dev: Device to get the ACPI node for.
*/
-static struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
+struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
{
acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
struct acpi_device *adev;
Index: linux/drivers/pci/pci-acpi.c
===================================================================
--- linux.orig/drivers/pci/pci-acpi.c
+++ linux/drivers/pci/pci-acpi.c
@@ -283,7 +283,6 @@ static struct pci_platform_pm_ops acpi_p
.is_manageable = acpi_pci_power_manageable,
.set_state = acpi_pci_set_power_state,
.choose_state = acpi_pci_choose_state,
- .can_wakeup = acpi_pci_can_wakeup,
.sleep_wake = acpi_pci_sleep_wake,
.run_wake = acpi_pci_run_wake,
};
@@ -321,10 +320,39 @@ static int acpi_pci_find_root_bridge(str
return 0;
}
+static void acpi_pci_wakeup_setup(struct device *dev)
+{
+ struct acpi_device *adev = acpi_dev_pm_get_node(dev);
+ struct pci_dev *pci_dev = to_pci_dev(dev);
+
+ if (!adev || !adev->wakeup.flags.valid)
+ return;
+
+ device_set_wakeup_capable(dev, true);
+ acpi_pci_sleep_wake(pci_dev, false);
+
+ pci_acpi_add_pm_notifier(adev, pci_dev);
+ if (adev->wakeup.flags.run_wake)
+ device_set_run_wake(dev, true);
+}
+
+static void acpi_pci_wakeup_cleanup(struct device *dev)
+{
+ struct acpi_device *adev = acpi_dev_pm_get_node(dev);
+
+ if (adev && adev->wakeup.flags.valid) {
+ device_set_wakeup_capable(dev, false);
+ device_set_run_wake(dev, false);
+ pci_acpi_remove_pm_notifier(adev);
+ }
+}
+
static struct acpi_bus_type acpi_pci_bus = {
.bus = &pci_bus_type,
.find_device = acpi_pci_find_device,
.find_bridge = acpi_pci_find_root_bridge,
+ .setup = acpi_pci_wakeup_setup,
+ .cleanup = acpi_pci_wakeup_cleanup,
};
static int __init acpi_pci_init(void)
next prev parent reply other threads:[~2012-12-20 1:57 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-09 22:58 [PATCH 0/6] ACPI: Change the ACPI namespace scanning code ordering Rafael J. Wysocki
2012-12-09 23:00 ` [PATCH 1/6] ACPI: Separate adding ACPI device objects from probing ACPI drivers Rafael J. Wysocki
2012-12-12 15:50 ` Jiang Liu
2012-12-12 22:34 ` Rafael J. Wysocki
2012-12-12 16:38 ` Jiang Liu
2012-12-12 22:32 ` Rafael J. Wysocki
2012-12-12 23:43 ` [update][PATCH " Rafael J. Wysocki
2012-12-13 13:05 ` [PATCH " Jiang Liu
2012-12-13 19:40 ` Rafael J. Wysocki
2012-12-13 1:00 ` Bjorn Helgaas
2012-12-13 11:41 ` Rafael J. Wysocki
2012-12-09 23:00 ` [PATCH 2/6] ACPI: Change the ordering of PCI root bridge driver registrarion Rafael J. Wysocki
2012-12-13 1:00 ` Bjorn Helgaas
2012-12-13 12:19 ` Rafael J. Wysocki
2012-12-09 23:01 ` [PATCH 3/6] ACPI: Make acpi_bus_add() and acpi_bus_start() visibly different Rafael J. Wysocki
2012-12-13 0:11 ` [Update][PATCH " Rafael J. Wysocki
2012-12-09 23:02 ` [PATCH 4/6] ACPI: Reduce the usage of struct acpi_bus_ops Rafael J. Wysocki
2012-12-09 23:03 ` [PATCH 5/6] ACPI: Replace struct acpi_bus_ops with enum type Rafael J. Wysocki
2012-12-10 5:34 ` Yinghai Lu
2012-12-10 14:46 ` Rafael J. Wysocki
2012-12-10 17:07 ` Yinghai Lu
2012-12-10 22:47 ` Rafael J. Wysocki
2012-12-10 23:09 ` Rafael J. Wysocki
2012-12-10 23:14 ` Yinghai Lu
2012-12-11 1:02 ` Rafael J. Wysocki
2012-12-11 1:28 ` Rafael J. Wysocki
2012-12-11 2:26 ` Yinghai Lu
2012-12-11 12:45 ` Rafael J. Wysocki
2012-12-11 15:09 ` Jiang Liu
2012-12-11 18:30 ` Rafael J. Wysocki
2012-12-12 14:34 ` Yijing Wang
2012-12-12 15:05 ` Jiang Liu
2012-12-12 22:39 ` Rafael J. Wysocki
2012-12-10 23:22 ` Yinghai Lu
2012-12-11 0:48 ` Rafael J. Wysocki
2012-12-09 23:04 ` [PATCH 6/6] ACPI: Change the ordering of acpi_bus_check_add() Rafael J. Wysocki
2012-12-13 1:00 ` Bjorn Helgaas
2012-12-13 12:20 ` Rafael J. Wysocki
2012-12-13 11:45 ` [PATCH 0/6] ACPI: Change the ACPI namespace scanning code ordering Yijing Wang
2012-12-13 22:15 ` [PATCH rev.2 " Rafael J. Wysocki
2012-12-13 22:17 ` [PATCH rev.2 1/6] ACPI: Separate adding ACPI device objects from probing ACPI drivers Rafael J. Wysocki
2012-12-18 0:08 ` Toshi Kani
2012-12-18 1:48 ` Rafael J. Wysocki
2012-12-18 16:10 ` Toshi Kani
2012-12-18 18:59 ` Yinghai Lu
2012-12-18 20:48 ` Toshi Kani
2012-12-18 21:11 ` Yinghai Lu
2012-12-18 22:05 ` Rafael J. Wysocki
2012-12-19 1:57 ` Yinghai Lu
2012-12-18 21:57 ` Rafael J. Wysocki
2012-12-18 22:15 ` Toshi Kani
2012-12-18 23:00 ` Rafael J. Wysocki
2012-12-18 23:19 ` Bjorn Helgaas
2012-12-19 11:13 ` Rafael J. Wysocki
2012-12-20 1:45 ` [PATCH 0/16] ACPI: Rework ACPI namespace scanning for devices Rafael J. Wysocki
2012-12-20 1:47 ` [PATCH 1/16] ACPI: Separate adding ACPI device objects from probing ACPI drivers Rafael J. Wysocki
2013-01-11 20:00 ` Mika Westerberg
2013-01-11 20:31 ` Rafael J. Wysocki
2013-01-11 20:37 ` Mika Westerberg
2013-01-11 20:58 ` Rafael J. Wysocki
2013-01-11 20:59 ` Mika Westerberg
2012-12-20 1:48 ` [PATCH 2/16] ACPI: Change the ordering of PCI root bridge driver registrarion Rafael J. Wysocki
2012-12-20 1:49 ` [PATCH 3/16] ACPI: Make acpi_bus_add() and acpi_bus_start() visibly different Rafael J. Wysocki
2012-12-20 1:50 ` [PATCH 4/16] ACPI: Reduce the usage of struct acpi_bus_ops Rafael J. Wysocki
2012-12-20 1:50 ` [PATCH 5/16] ACPI: Replace struct acpi_bus_ops with enum type Rafael J. Wysocki
2012-12-20 1:51 ` [PATCH 6/16] ACPI: Change the ordering of acpi_bus_check_add() Rafael J. Wysocki
2012-12-20 1:52 ` [PATCH 7/16] ACPI / PCI: Fold acpi_pci_root_start() into acpi_pci_root_add() Rafael J. Wysocki
2012-12-20 1:53 ` [PATCH 8/16] ACPI: Remove acpi_start_single_object() and acpi_bus_start() Rafael J. Wysocki
2012-12-20 1:54 ` [PATCH 9/16] ACPI: Remove the arguments of acpi_bus_add() that are not used Rafael J. Wysocki
2012-12-20 1:54 ` [PATCH 10/16] ACPI: Drop the second argument of acpi_bus_scan() Rafael J. Wysocki
2012-12-20 1:55 ` [PATCH 11/16] ACPI: Replace ACPI device add_type field with a match_driver flag Rafael J. Wysocki
2012-12-20 1:56 ` [PATCH 12/16] ACPI: Make acpi_bus_scan() and acpi_bus_add() take only one argument Rafael J. Wysocki
2012-12-20 1:57 ` [PATCH 13/16] ACPI: Add .setup() and .cleanup() callbacks to struct acpi_bus_type Rafael J. Wysocki
2012-12-20 1:58 ` Rafael J. Wysocki [this message]
2012-12-20 1:59 ` [PATCH 15/16] ACPI / PCI: Move the _PRT setup and cleanup code to pci-acpi.c Rafael J. Wysocki
2012-12-20 2:00 ` [PATCH 16/16] ACPI: Drop ACPI device .bind() and .unbind() callbacks Rafael J. Wysocki
2013-01-13 14:16 ` [PATCH] ACPI: remove unused acpi_op_bind and acpi_op_unbind Jiang Liu
2013-01-14 13:03 ` Rafael J. Wysocki
2012-12-20 2:06 ` [PATCH 0/16] ACPI: Rework ACPI namespace scanning for devices Yinghai Lu
2012-12-21 0:09 ` Rafael J. Wysocki
2012-12-21 3:59 ` Yinghai Lu
2012-12-21 22:23 ` Rafael J. Wysocki
2012-12-20 21:07 ` Toshi Kani
2012-12-20 23:20 ` Rafael J. Wysocki
2012-12-13 22:18 ` [PATCH rev.2 2/6] ACPI: Change the ordering of PCI root bridge driver registrarion Rafael J. Wysocki
2012-12-13 22:21 ` [PATCH rev.2 3/6] ACPI: Make acpi_bus_add() and acpi_bus_start() visibly different Rafael J. Wysocki
2012-12-13 22:21 ` [PATCH rev.2 4/6] ACPI: Reduce the usage of struct acpi_bus_ops Rafael J. Wysocki
2012-12-13 22:22 ` [PATCH rev.2 5/6] ACPI: Replace struct acpi_bus_ops with enum type Rafael J. Wysocki
2012-12-13 22:23 ` [PATCH rev.2 6/6] ACPI: Change the ordering of acpi_bus_check_add() Rafael J. Wysocki
2012-12-14 9:56 ` [PATCH rev.2 0/6] ACPI: Change the ACPI namespace scanning code ordering Yijing Wang
2012-12-14 22:59 ` Rafael J. Wysocki
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=3181154.NDRBl366gp@vostro.rjw.lan \
--to=rjw@sisk.pl \
--cc=bhelgaas@google.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=liuj97@gmail.com \
--cc=myron.stowe@redhat.com \
--cc=toshi.kani@hp.com \
--cc=wangyijing0307@gmail.com \
--cc=yinghai@kernel.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
all inboxes | Powered by JetHome®