PCI run-time Power Management
Subsystems (5)
cover PCI run-time Power Management
Hi,
The following four patches implement some features needed for PCI run-time PM.
[1/4] adds a function for checking and clearing the PME status of a device
[2/4] adds support for PCIe native PME signaling mechanism
[3/4] adds support for ACPI-based PME signaling at run time
[4/4] adds prototype run-time PM callbacks for the PCI bus type
Patches [1/4] - [3/4] are rather complete, unless I missed something, but [4/4] still requires some work. For example, there should be some sort of synchronization between the run-time PM and system-wide sleep transitions which is missing at the moment. In addition, it would make sense to "autosuspend" PCI devices without drivers which has not been implemented yet.
Comments welcome.
Thanks,
Rafael
RFC PATCH 1/4 PCI PM: Add function for checking PME status of devices
From: Rafael J. Wysocki <[email protected]>
Add function pci_check_pme_status() that will check the PME status bit of given device and clear it along with the PME enable bit. It will be necessary for PCI run-time power management.
Based on a patch from Shaohua Li <[email protected]>
--- drivers/pci/pci.c | 35 +++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 1 + 2 files changed, 36 insertions(+)
drivers/pci/pci.h +1 -0
@@ -49,6 +49,7 @@ struct pci_platform_pm_ops {extern int pci_set_platform_pm (struct pci_platform_pm_ops *ops);extern void pci_update_current_state (struct pci_dev *dev,pci_power_t state);extern void pci_disable_enabled_device (struct pci_dev *dev); +extern bool pci_check_pme_status (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);
drivers/pci/pci.c +35 -0
@@ -1167,6 +1167,41 @@ int pci_set_pcie_reset_state(struct pci_ }/** +* pci_check_pme_status - Check if given device has generated PME. +* @dev: Device to check. +* +* Check the PME status of the device, clear PME status and PME enable. Return +* 'true' if PME has been generated by the device (and hasn't been spurious) or +* 'false' otherwise. +*/ +bool pci_check_pme_status (struct pci_dev *dev) +{ +int pmcsr_pos; +u16 pmcsr; +bool ret = false; + +if (!dev->pm_cap) +return false; + + pmcsr_pos = dev->pm_cap +PCI_PM_CTRL ; +/* clear PME status and disable PME to avoid interrupt flood */ +pci_read_config_word (dev, pmcsr_pos, &pmcsr); +if (!(pmcsr &PCI_PM_CTRL_PME_STATUS )) +return false; + + pmcsr |=PCI_PM_CTRL_PME_STATUS ; +/* Ignore spurious PME or clear PME enable if it's not spurious. */ +if (pmcsr &PCI_PM_CTRL_PME_ENABLE ) { + pmcsr &= ~PCI_PM_CTRL_PME_ENABLE ; + ret = true; + } + +pci_write_config_word (dev, pmcsr_pos, pmcsr); + +return ret; +} + +/** * pci_pme_capable - check the capability of PCI device to generate PME# * @dev: PCI device to handle. * @state: PCI state from which device will issue PME#.
Re: [RFC][PATCH 1/4] PCI PM: Add function for checking PME status of devices
Quoted 31 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Add function
pci_check_pme_status()that will check the PME status bit of given device and clear it along with the PME enable bit. It will be necessary for PCI run-time power management.Based on a patch from Shaohua Li <[email protected]>
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/pci/pci.c | 35 +++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 1 + 2 files changed, 36 insertions(+)Index:
linux-2.6/drivers/pci/pci.h
===================================================================drivers/pci/pci.h +1
-0@@ -49,6 +49,7 @@ struct pci_platform_pm_ops {extern int pci_set_platform_pm (struct pci_platform_pm_ops *ops);extern void pci_update_current_state (struct pci_dev *dev,pci_power_t state);extern void pci_disable_enabled_device (struct pci_dev *dev); +extern bool pci_check_pme_status (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);Index:
linux-2.6/drivers/pci/pci.c
===================================================================
drivers/pci/pci.c int pci_set_pcie_reset_state(struct pci_ · line 1175
Quoted 9 lines
drivers/pci/pci.c +6
-0@@ -1167,6 +1167,41 @@ int pci_set_pcie_reset_state(struct pci_ }/** +* pci_check_pme_status - Check if given device has generated PME. +* @dev: Device to check. +* +* Check the PME status of the device, clear PME status and PME enable. Return +* 'true' if PME has been generated by the device (and hasn't been spurious) or +* 'false' otherwise.
This comment confuses me because it implies that we always clear PME enable, but that's not what the code does. If PME_STATUS is not asserted, the code doesn't write anything.
Quoted 14 lines
drivers/pci/pci.c +14
-0+*/ +bool pci_check_pme_status (struct pci_dev *dev) +{ +int pmcsr_pos; +u16 pmcsr; +bool ret = false; + +if (!dev->pm_cap) +return false; + + pmcsr_pos = dev->pm_cap +PCI_PM_CTRL ; +/* clear PME status and disable PME to avoid interrupt flood */ +pci_read_config_word (dev, pmcsr_pos, &pmcsr); +if (!(pmcsr &PCI_PM_CTRL_PME_STATUS ))
drivers/pci/pci.c int pci_set_pcie_reset_state(struct pci_ · line 1199
Quoted 10 lines
drivers/pci/pci.c +10
-0+return false; + + pmcsr |=PCI_PM_CTRL_PME_STATUS ; +/* Ignore spurious PME or clear PME enable if it's not spurious. */ +if (pmcsr &PCI_PM_CTRL_PME_ENABLE ) { + pmcsr &= ~PCI_PM_CTRL_PME_ENABLE ; + ret = true; + } + +pci_write_config_word (dev, pmcsr_pos, pmcsr);
I can't tell whether the comment or the code is what was intended, but I think the following would be a clearer way to implement the comment:
pci_read_config_word(..., &pmcsr); pci_write_config_word(..., (pmcsr | STATUS) & ~ENABLE); if ((pmcsr & ENABLE) && (pmcsr & STATUS)) return true; return false;
Bjorn
Quoted 9 lines
drivers/pci/pci.c +5
-0+ +return ret; +} + +/** * pci_pme_capable - check the capability of PCI device to generate PME# * @dev: PCI device to handle. * @state: PCI state from which device will issue PME#.
Re: [RFC][PATCH 1/4] PCI PM: Add function for checking PME status of devices
Quoted 34 lines · Bjorn Helgaas
Quoted 33 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Add function
pci_check_pme_status()that will check the PME status bit of given device and clear it along with the PME enable bit. It will be necessary for PCI run-time power management.Based on a patch from Shaohua Li <[email protected]>
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/pci/pci.c | 35 +++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 1 + 2 files changed, 36 insertions(+)Index:
linux-2.6/drivers/pci/pci.h
===================================================================drivers/pci/pci.h +1
-0@@ -49,6 +49,7 @@ struct pci_platform_pm_ops {extern int pci_set_platform_pm (struct pci_platform_pm_ops *ops);extern void pci_update_current_state (struct pci_dev *dev,pci_power_t state);extern void pci_disable_enabled_device (struct pci_dev *dev); +extern bool pci_check_pme_status (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);Index:
linux-2.6/drivers/pci/pci.c
===================================================================drivers/pci/pci.c +0
-0@@ -1167,6 +1167,41 @@ int pci_set_pcie_reset_state(struct pci_ }
Quoted 11 lines
drivers/pci/pci.c int pci_set_pcie_reset_state(struct pci_ · line 1175
Quoted 7 lines
drivers/pci/pci.c +6
-0/** +* pci_check_pme_status - Check if given device has generated PME. +* @dev: Device to check. +* +* Check the PME status of the device, clear PME status and PME enable. Return +* 'true' if PME has been generated by the device (and hasn't been spurious) or +* 'false' otherwise. This comment confuses me because it implies that we always clear PME enable, but that's not what the code does. If
PME_STATUSis not asserted, the code doesn't write anything.
Well, that's a shortcut, perhaps going too far. It should say "clear PME status and PME enable, if the PME status was set". Will fix.
Quoted 18 lines
Quoted 18 lines
drivers/pci/pci.c +18
-0+*/ +bool pci_check_pme_status (struct pci_dev *dev) +{ +int pmcsr_pos; +u16 pmcsr; +bool ret = false; + +if (!dev->pm_cap) +return false; + + pmcsr_pos = dev->pm_cap +PCI_PM_CTRL ; +/* clear PME status and disable PME to avoid interrupt flood */ +pci_read_config_word (dev, pmcsr_pos, &pmcsr); +if (!(pmcsr &PCI_PM_CTRL_PME_STATUS )) +return false; + + pmcsr |=PCI_PM_CTRL_PME_STATUS ; +/* Ignore spurious PME or clear PME enable if it's not spurious. */
Quoted 8 lines
drivers/pci/pci.c int pci_set_pcie_reset_state(struct pci_ · line 1199
Quoted 6 lines
drivers/pci/pci.c +6
-0+if (pmcsr &PCI_PM_CTRL_PME_ENABLE ) { + pmcsr &= ~PCI_PM_CTRL_PME_ENABLE ; + ret = true; + } + +pci_write_config_word (dev, pmcsr_pos, pmcsr);I can't tell whether the comment or the code is what was intended,
The code. I'll fix the comment.
Quoted 9 lines
but I think the following would be a clearer way to implement the comment:
pci_read_config_word(..., &pmcsr); pci_write_config_word(..., (pmcsr | STATUS) & ~ENABLE); if ((pmcsr & ENABLE) && (pmcsr & STATUS)) return true; return false;
Thanks,
Rafael
RFC PATCH 1/4 PCI PM: Add function for checking PME status of devices
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Add function pci_check_pme_status() that will check the PME status bit of given device and clear it along with the PME enable bit. It will be necessary for PCI run-time power management.
Based on a patch from Shaohua Li <[email protected]>
--- drivers/pci/pci.c | 35 +++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 1 + 2 files changed, 36 insertions(+)
drivers/pci/pci.h +1 -0
@@ -49,6 +49,7 @@ struct pci_platform_pm_ops {extern int pci_set_platform_pm (struct pci_platform_pm_ops *ops);extern void pci_update_current_state (struct pci_dev *dev,pci_power_t state);extern void pci_disable_enabled_device (struct pci_dev *dev); +extern bool pci_check_pme_status (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);
drivers/pci/pci.c +35 -0
@@ -1167,6 +1167,41 @@ int pci_set_pcie_reset_state(struct pci_ }/** +* pci_check_pme_status - Check if given device has generated PME. +* @dev: Device to check. +* +* Check the PME status of the device, clear PME status and PME enable. Return +* 'true' if PME has been generated by the device (and hasn't been spurious) or +* 'false' otherwise. +*/ +bool pci_check_pme_status (struct pci_dev *dev) +{ +int pmcsr_pos; +u16 pmcsr; +bool ret = false; + +if (!dev->pm_cap) +return false; + + pmcsr_pos = dev->pm_cap +PCI_PM_CTRL ; +/* clear PME status and disable PME to avoid interrupt flood */ +pci_read_config_word (dev, pmcsr_pos, &pmcsr); +if (!(pmcsr &PCI_PM_CTRL_PME_STATUS )) +return false; + + pmcsr |=PCI_PM_CTRL_PME_STATUS ; +/* Ignore spurious PME or clear PME enable if it's not spurious. */ +if (pmcsr &PCI_PM_CTRL_PME_ENABLE ) { + pmcsr &= ~PCI_PM_CTRL_PME_ENABLE ; + ret = true; + } + +pci_write_config_word (dev, pmcsr_pos, pmcsr); + +return ret; +} + +/** * pci_pme_capable - check the capability of PCI device to generate PME# * @dev: PCI device to handle. * @state: PCI state from which device will issue PME#.
RFC PATCH 2/4 PCI PM: PCIe PME root port service driver (rev. 3)
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
PCIe native PME detection mechanism is based on interrupts generated by root ports or event collectors every time a PCIe device sends a PME message upstream.
Once a PME message has been sent by an endpoint device and received by its root port (or event collector in the case of root complex integrated endpoints), the Requester ID from the message header is registered in the root port's Root Status register. At the same time, the PME Status bit of the Root Status register is set to indicate that there's a PME to handle. If PCIe PME interrupt is enabled for the root port, it generates an interrupt once the PME Status has been set. After receiving the interrupt, the kernel can identify the PCIe device that generated the PME using the Requester ID from the root port's Root Status register. [For details, see PCI Express Base Specification, Rev. 2.0.]
Implement a driver for the PCIe PME root port service working in accordance with the above description.
Based on a patch from Shaohua Li <[email protected]>.
--- drivers/pci/pci-acpi.c | 4 drivers/pci/pcie/Kconfig | 4 drivers/pci/pcie/Makefile | 2 drivers/pci/pcie/pme/Makefile | 8 drivers/pci/pcie/pme/pcie_pme.c | 491 +++++++++++++++++++++++++++++++++++ drivers/pci/pcie/pme/pcie_pme.h | 28 + drivers/pci/pcie/pme/pcie_pme_acpi.c | 54 +++ include/linux/pci.h | 6 8 files changed, 595 insertions(+), 2 deletions(-)
drivers/pci/pcie/Kconfig +4 -0
@@ -46,3 +46,7 @@ config PCIEASPM_DEBUG help This enables PCI Express ASPM debug support. It will add per-device interface to control ASPM. + +config PCIE_PME + def_bool y + depends on PCIEPORTBUS && PM_RUNTIME && EXPERIMENTAL
drivers/pci/pcie/Makefile +2 -0
@@ -11,3 +11,5 @@ obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv # Build PCI Express AER if needed obj-$(CONFIG_PCIEAER) += aer/ + +obj-$(CONFIG_PCIE_PME) += pme/
drivers/pci/pcie/pme/pcie_pme.c new file +491 -0
491 lines not on this page · raw message
drivers/pci/pcie/pme/pcie_pme_acpi.c new file +54 -0
54 lines not on this page · raw message
drivers/pci/pcie/pme/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Makefile for PCI-Express Root Port PME signaling driver +# + +obj-$(CONFIG_PCIE_PME) += pmedriver.o + +pmedriver-objs := pcie_pme.o +pmedriver-$(CONFIG_ACPI) += pcie_pme_acpi.o
drivers/pci/pcie/pme/pcie_pme.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* drivers/pci/pcie/pme/pcie_pme.h +* +* PCI Express Root Port PME signaling support +* +* Copyright (C) 2009 Rafael J. Wysocki <[email protected]>, Novell Inc. +*/ + +#ifndef _PCIE_PME_H_ +#define _PCIE_PME_H_ + +struct pcie_device ; + +#ifdef CONFIG_ACPI +extern int pcie_pme_acpi_setup (struct pcie_device *srv); + +static inline int pcie_pme_platform_notify (struct pcie_device *srv) +{ +return pcie_pme_acpi_setup (srv); +} +#else /* !CONFIG_ACPI */ +static inline int pcie_pme_platform_notify (struct pcie_device *srv) +{ +return 0 ; +} +#endif /* !CONFIG_ACPI */ + +#endif
include/linux/pci.h +6 -0
@@ -911,6 +911,12 @@ extern void pcie_set_ecrc_checking(strucextern void pcie_ecrc_get_policy (char *str);#endif +#ifndef CONFIG_PCIE_PME +static inline bool pcie_pme_enabled (struct pci_dev *dev) {return false; } +#else +extern bool pcie_pme_enabled (struct pci_dev *dev); +#endif +#define pci_enable_msi (pdev) pci_enable_msi_block(pdev, 1)#ifdef CONFIG_HT_IRQ
drivers/pci/pci-acpi.c +2 -2
@@ -116,7 +116,7 @@ static void acpi_pci_propagate_wakeup_enint ret; ret =acpi_pm_device_sleep_wake (&bridge->dev, enable); -if (!ret || bridge->is_pcie) +if (!ret ||pcie_pme_enabled (bridge))return ; bus = bus->parent; }
@@ -131,7 +131,7 @@ static int acpi_pci_sleep_wake(struct pcif (acpi_pci_can_wakeup (dev))return acpi_pm_device_sleep_wake (&dev->dev, enable); -if (!dev->is_pcie) +if (!pcie_pme_enabled (dev))acpi_pci_propagate_wakeup_enable (dev->bus, enable);return 0 ;
RFC PATCH 2/4 PCI PM: PCIe PME root port service driver (rev. 3)
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
PCIe native PME detection mechanism is based on interrupts generated by root ports or event collectors every time a PCIe device sends a PME message upstream.
Once a PME message has been sent by an endpoint device and received by its root port (or event collector in the case of root complex integrated endpoints), the Requester ID from the message header is registered in the root port's Root Status register. At the same time, the PME Status bit of the Root Status register is set to indicate that there's a PME to handle. If PCIe PME interrupt is enabled for the root port, it generates an interrupt once the PME Status has been set. After receiving the interrupt, the kernel can identify the PCIe device that generated the PME using the Requester ID from the root port's Root Status register. [For details, see PCI Express Base Specification, Rev. 2.0.]
Implement a driver for the PCIe PME root port service working in accordance with the above description.
Based on a patch from Shaohua Li <[email protected]>.
--- drivers/pci/pci-acpi.c | 4 drivers/pci/pcie/Kconfig | 4 drivers/pci/pcie/Makefile | 2 drivers/pci/pcie/pme/Makefile | 8 drivers/pci/pcie/pme/pcie_pme.c | 491 +++++++++++++++++++++++++++++++++++ drivers/pci/pcie/pme/pcie_pme.h | 28 + drivers/pci/pcie/pme/pcie_pme_acpi.c | 54 +++ include/linux/pci.h | 6 8 files changed, 595 insertions(+), 2 deletions(-)
drivers/pci/pcie/Kconfig +4 -0
@@ -46,3 +46,7 @@ config PCIEASPM_DEBUG help This enables PCI Express ASPM debug support. It will add per-device interface to control ASPM. + +config PCIE_PME + def_bool y + depends on PCIEPORTBUS && PM_RUNTIME && EXPERIMENTAL
drivers/pci/pcie/Makefile +2 -0
@@ -11,3 +11,5 @@ obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv # Build PCI Express AER if needed obj-$(CONFIG_PCIEAER) += aer/ + +obj-$(CONFIG_PCIE_PME) += pme/
drivers/pci/pcie/pme/pcie_pme.c new file +491 -0
491 lines not on this page · raw message
drivers/pci/pcie/pme/pcie_pme_acpi.c new file +54 -0
54 lines not on this page · raw message
drivers/pci/pcie/pme/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Makefile for PCI-Express Root Port PME signaling driver +# + +obj-$(CONFIG_PCIE_PME) += pmedriver.o + +pmedriver-objs := pcie_pme.o +pmedriver-$(CONFIG_ACPI) += pcie_pme_acpi.o
drivers/pci/pcie/pme/pcie_pme.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* drivers/pci/pcie/pme/pcie_pme.h +* +* PCI Express Root Port PME signaling support +* +* Copyright (C) 2009 Rafael J. Wysocki <[email protected]>, Novell Inc. +*/ + +#ifndef _PCIE_PME_H_ +#define _PCIE_PME_H_ + +struct pcie_device ; + +#ifdef CONFIG_ACPI +extern int pcie_pme_acpi_setup (struct pcie_device *srv); + +static inline int pcie_pme_platform_notify (struct pcie_device *srv) +{ +return pcie_pme_acpi_setup (srv); +} +#else /* !CONFIG_ACPI */ +static inline int pcie_pme_platform_notify (struct pcie_device *srv) +{ +return 0 ; +} +#endif /* !CONFIG_ACPI */ + +#endif
include/linux/pci.h +6 -0
@@ -911,6 +911,12 @@ extern void pcie_set_ecrc_checking(strucextern void pcie_ecrc_get_policy (char *str);#endif +#ifndef CONFIG_PCIE_PME +static inline bool pcie_pme_enabled (struct pci_dev *dev) {return false; } +#else +extern bool pcie_pme_enabled (struct pci_dev *dev); +#endif +#define pci_enable_msi (pdev) pci_enable_msi_block(pdev, 1)#ifdef CONFIG_HT_IRQ
drivers/pci/pci-acpi.c +2 -2
@@ -116,7 +116,7 @@ static void acpi_pci_propagate_wakeup_enint ret; ret =acpi_pm_device_sleep_wake (&bridge->dev, enable); -if (!ret || bridge->is_pcie) +if (!ret ||pcie_pme_enabled (bridge))return ; bus = bus->parent; }
@@ -131,7 +131,7 @@ static int acpi_pci_sleep_wake(struct pcif (acpi_pci_can_wakeup (dev))return acpi_pm_device_sleep_wake (&dev->dev, enable); -if (!dev->is_pcie) +if (!pcie_pme_enabled (dev))acpi_pci_propagate_wakeup_enable (dev->bus, enable);return 0 ;
RFC PATCH 3/4 PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 2)
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Although the majority of PCI devices can generate PMEs that in principle may be used to wake up devices suspended at run time, platform support is generally necessary to convert PMEs into wake-up events that can be delivered to the kernel. If ACPI is used for this purpose, a PME generated by a PCI device will trigger the ACPI GPE associated with the device to generate an ACPI wake-up event that we can set up a handler for, provided that everything is configured correctly.
Unfortunately, the subset of PCI devices that have GPEs associated with them is quite limited and the other devices have to rely on the GPEs associated with their upstream bridges and, possibly, the root bridge to generate ACPI wake-up events in response to PMEs from them. Moreover, ACPI devices tend to share wake-up GPEs, in which cases it makes sense to install an ACPI notify handler for only one of them and "bind" the other devices to it. Furthermore, ACPI-based PCI hotplug also uses ACPI notify handlers that in general may conflict with the PM notify handlers, unless this issue is specifically taken care of.
Add ACPI platform support for PCI PME wake-up:
o Add a framework making is possible to use ACPI system notify handlers for both PM and hotplug at the same time and to take the wake-up GPE sharing into account.
o Add function acpi_device_run_wake() allowing us to enable or disable the GPE associated with given device to generate run-time wake-up events.
o Add a new PCI platform callback ->run_wake() to struct pci_platform_pm_ops allowing us to enable the platform to generate wake-up events for given device and implemet that callback for the ACPI platform.
o Define ACPI wake-up handlers for PCI devices and PCI buses and make the PCI-ACPI binding code register wake-up notifiers for devices associated with wake-up GPEs.
o Add function pci_platform_run_wake() that can be used to enable (or disable) the platform to generate wake-up events for given PCI device using the ->run_wake() platform callback.
Based on a patch from Matthew Garrett.
--- drivers/acpi/pci_bind.c | 19 drivers/acpi/pci_root.c | 5 drivers/acpi/sleep.c | 4 drivers/acpi/wakeup.c | 50 ++ drivers/pci/hotplug/acpiphp_glue.c | 23 - drivers/pci/pci-acpi.c | 706 +++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 32 + drivers/pci/pci.h | 19 include/acpi/acpi_bus.h | 20 - include/linux/pci-acpi.h | 14 kernel/power/Kconfig | 5 11 files changed, 874 insertions(+), 23 deletions(-)
drivers/pci/pci.h +16 -3
@@ -30,10 +30,14 @@ 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 +* @can_wakeup: returns 'true' if the plaform can generate wake-up events for +* given device. * -* @sleep_wake: enables/disables the system wake up capability of given device +* @sleep_wake: enables/disables the wake-up capability of given device +* +* @run_wake: enables/disables the platform to generate run-time wake-up events +* for given device (the device's wake-up capability has to be +* enabled by @sleep_wake for this feature to work) * * If given platform is generally capable of power managing PCI devices, all of * these callbacks are mandatory.
@@ -44,16 +48,25 @@ struct pci_platform_pm_ops {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); };extern int pci_set_platform_pm (struct pci_platform_pm_ops *ops); +extern int pci_platform_run_wake (struct pci_dev *dev,bool enable);extern void pci_update_current_state (struct pci_dev *dev,pci_power_t state);extern void pci_disable_enabled_device (struct pci_dev *dev);extern bool pci_check_pme_status (struct pci_dev *dev); +extern int __pci_pme_wakeup (struct pci_dev *dev,void *ign); +extern void pci_pme_wakeup_bus (struct pci_bus *bus);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); +static inline void pci_pme_wakeup (struct pci_dev *dev) +{ +__pci_pme_wakeup (dev,NULL ); +} +static inline bool pci_is_bridge (struct pci_dev *pci_dev) {return !!(pci_dev->subordinate);
drivers/pci/pci-acpi.c +706 -0
724 lines not on this page · raw message
drivers/pci/pci.c +32 -0
@@ -21,6 +21,7 @@#include <linux/interrupt.h> #include <asm/dma.h> /* isa_dma_bridge_buggy */ #include <linux/device.h> +#include <linux/pm_runtime.h> #include <asm/setup.h> #include "pci.h"
@@ -434,6 +435,12 @@ static inline int platform_pci_sleep_wak pci_platform_pm->sleep_wake(dev, enable) : -ENODEV; } +int pci_platform_run_wake (struct pci_dev *dev,bool enable) +{ +return pci_platform_pm ? + pci_platform_pm->run_wake (dev, enable) : -ENODEV ; +} +/** * pci_raw_set_power_state - Use PCI PM registers to set the power state of * given PCI device
@@ -1202,6 +1209,31 @@ bool pci_check_pme_status(struct pci_dev }/** +* pci_pme_wakeup - Wake up a PCI device if its PME Status bit is set. +* @dev: Device to handle. +* @ign: Ignored. +* +* Check if @dev has generated PME and queue a resume request for it in that +* case. +*/ +int __pci_pme_wakeup (struct pci_dev *dev,void *ign) +{ +if (pci_check_pme_status (dev)) +pm_request_resume (&dev->dev); +return 0 ; +} + +/** +* pci_pme_wakeup_bus - Walk given bus and wake up devices on it, if necessary. +* @bus: Top bus of the subtree to walk. +*/ +void pci_pme_wakeup_bus (struct pci_bus *bus) +{ +if (bus) +pci_walk_bus (bus, __pci_pme_wakeup,NULL ); +} + +/** * pci_pme_capable - check the capability of PCI device to generate PME# * @dev: PCI device to handle. * @state: PCI state from which device will issue PME#.
drivers/acpi/wakeup.c +50 -0
56 lines not on this page · raw message
include/acpi/acpi_bus.h +17 -3
@@ -386,21 +386,35 @@ acpi_handle acpi_get_pci_rootbridge_handstruct acpi_pci_root *acpi_pci_find_root (acpi_handle handle);#define DEVICE_ACPI_HANDLE (dev) ((acpi_handle)((dev)->archdata.acpi_handle)) -#ifdef CONFIG_PM_SLEEP +#ifdef CONFIG_PM_WAKEUP int acpi_pm_device_sleep_state (struct device *,int *);int acpi_pm_device_sleep_wake (struct device *,bool ); -#else /* !CONFIG_PM_SLEEP */ +int acpi_device_run_wake (struct acpi_device *,bool ); +bool acpi_wakeup_gpe_shared (struct acpi_device *,struct acpi_device *); +#else /* !CONFIG_PM_WAKEUP */ static inline int acpi_pm_device_sleep_state (struct device *d,int *p) {if (p) *p =ACPI_STATE_D0 ;return ACPI_STATE_D3 ; } +static inline int acpi_pm_device_sleep_wake (struct device *dev,bool enable) {return -ENODEV ; } -#endif /* !CONFIG_PM_SLEEP */ + +static inline int acpi_device_run_wake (struct device *dev,bool enable) +{ +return -ENODEV ; +} + +static inline bool acpi_wakeup_gpe_shared (struct acpi_device *a, +struct acpi_device *b) +{ +return false; +} +#endif /* !CONFIG_PM_WAKEUP */ #endif /* CONFIG_ACPI */
kernel/power/Kconfig +5 -0
@@ -236,3 +236,8 @@ config PM_RUNTIME and the bus type drivers of the buses the devices are on are responsible for the actual handling of the autosuspend requests and wake-up events. + +config PM_WAKEUP + bool + depends on SUSPEND || HIBERNATION || PM_RUNTIME + default y
drivers/acpi/sleep.c +2 -2
@@ -602,7 +602,7 @@ int acpi_suspend(u32 acpi_state)return -EINVAL ; } -#ifdef CONFIG_PM_SLEEP +#ifdef CONFIG_PM_WAKEUP /** * acpi_pm_device_sleep_state - return preferred power state of ACPI device * in the system sleep state given by %acpi_target_sleep_state
@@ -717,7 +717,7 @@ int acpi_pm_device_sleep_wake(struct dev return error; } -#endif +#endif /* CONFIG_PM_WAKEUP */ static void acpi_power_off_prepare (void ) {
drivers/acpi/pci_root.c +5 -0
@@ -577,6 +577,9 @@ static int __devinit acpi_pci_root_add(sif (flags != base_flags)acpi_pci_osc_support (root, flags); +if (device->wakeup.flags.valid) +pci_acpi_add_bus_pm_notifier (device, root->bus); +return 0 ; end:
@@ -598,6 +601,8 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device); +if (device->wakeup.flags.valid) +pci_acpi_remove_bus_pm_notifier (device, root->bus);kfree (root);return 0 ; }
include/linux/pci-acpi.h +14 -0
@@ -11,6 +11,20 @@#include <linux/acpi.h> #ifdef CONFIG_ACPI +extern acpi_status pci_acpi_add_hp_notifier (acpi_handle handle, +acpi_notify_handler handler, +void *context); +extern acpi_status pci_acpi_remove_hp_notifier (acpi_handle handle, +acpi_notify_handler handler); +extern acpi_status pci_acpi_add_device_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev); +extern acpi_status pci_acpi_remove_device_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev); +extern acpi_status pci_acpi_add_bus_pm_notifier (struct acpi_device *dev, +struct pci_bus *bus); +extern acpi_status pci_acpi_remove_bus_pm_notifier (struct acpi_device *dev, +struct pci_bus *bus); +static inline acpi_handle acpi_find_root_bridge_handle (struct pci_dev *pdev) {struct pci_bus *pbus = pdev->bus;
drivers/acpi/pci_bind.c +18 -1
@@ -26,6 +26,7 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/pci.h> +#include <linux/pci-acpi.h> #include <linux/acpi.h> #include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h>
@@ -38,7 +39,17 @@ static int acpi_pci_unbind(struct acpi_dstruct pci_dev *dev; dev =acpi_get_pci_dev (device->handle); -if (!dev || !dev->subordinate) +if (!dev) + goto out; + +if (device->wakeup.flags.valid) { +if (dev->subordinate) +pci_acpi_remove_bus_pm_notifier (device, + dev->subordinate); +pci_acpi_remove_device_pm_notifier (device, dev); + } + +if (!dev->subordinate) goto out;acpi_pci_irq_del_prt (dev->subordinate);
@@ -94,6 +105,12 @@ static int acpi_pci_bind(struct acpi_devacpi_pci_irq_add_prt (device->handle, bus); +if (device->wakeup.flags.valid) { +pci_acpi_add_device_pm_notifier (device, dev); +if (dev->subordinate) +pci_acpi_add_bus_pm_notifier (device, dev->subordinate); + } + out:pci_dev_put (dev);return 0 ;
drivers/pci/hotplug/acpiphp_glue.c +9 -14
@@ -238,8 +238,7 @@ register_slot(acpi_handle handle, u32 lv/* install notify handler */ if (!(newfunc->flags &FUNC_HAS_DCK )) { - status =acpi_install_notify_handler (handle, -ACPI_SYSTEM_NOTIFY , + status =pci_acpi_add_hp_notifier (handle, handle_hotplug_event_func, newfunc);
@@ -290,14 +289,12 @@ static void init_bridge_misc(struct acpi/* install notify handler */ if (bridge->type !=BRIDGE_TYPE_HOST ) {if ((bridge->flags &BRIDGE_HAS_EJ0 ) && bridge->func) { - status =acpi_remove_notify_handler (bridge->func->handle, -ACPI_SYSTEM_NOTIFY , + status =pci_acpi_remove_hp_notifier (bridge->func->handle, handle_hotplug_event_func);if (ACPI_FAILURE (status))err ("failed to remove notify handler\n" ); } - status =acpi_install_notify_handler (bridge->handle, -ACPI_SYSTEM_NOTIFY , + status =pci_acpi_add_hp_notifier (bridge->handle, handle_hotplug_event_bridge, bridge);
@@ -513,15 +510,14 @@ static void cleanup_bridge(struct acpiphacpi_status status;acpi_handle handle = bridge->handle; - status =acpi_remove_notify_handler (handle,ACPI_SYSTEM_NOTIFY , + status =pci_acpi_remove_hp_notifier (handle, handle_hotplug_event_bridge);if (ACPI_FAILURE (status))err ("failed to remove notify handler\n" );if ((bridge->type !=BRIDGE_TYPE_HOST ) && ((bridge->flags &BRIDGE_HAS_EJ0 ) && bridge->func)) { - status =acpi_install_notify_handler (bridge->func->handle, -ACPI_SYSTEM_NOTIFY , + status =pci_acpi_add_hp_notifier (bridge->func->handle, handle_hotplug_event_func, bridge->func);if (ACPI_FAILURE (status))
@@ -539,8 +535,7 @@ static void cleanup_bridge(struct acpiphunregister_dock_notifier (&func->nb); }if (!(func->flags &FUNC_HAS_DCK )) { - status =acpi_remove_notify_handler (func->handle, -ACPI_SYSTEM_NOTIFY , + status =pci_acpi_remove_hp_notifier (func->handle, handle_hotplug_event_func);if (ACPI_FAILURE (status))err ("failed to remove notify handler\n" );
@@ -602,7 +597,7 @@ static void remove_bridge(acpi_handle haif (bridge)cleanup_bridge (bridge);else -acpi_remove_notify_handler (handle,ACPI_SYSTEM_NOTIFY , +pci_acpi_remove_hp_notifier (handle, handle_hotplug_event_bridge); }
@@ -1492,8 +1487,8 @@ find_root_bridges(acpi_handle handle, u3int *count = (int *)context;if (acpi_is_root_bridge (handle)) { -acpi_install_notify_handler (handle,ACPI_SYSTEM_NOTIFY , - handle_hotplug_event_bridge,NULL ); +pci_acpi_add_hp_notifier (handle, + handle_hotplug_event_bridge,NULL ); (*count)++; }return AE_OK ;
Re: [RFC][PATCH 3/4] PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 2)
Quoted 10 lines · Rafael J. Wysocki
Unfortunately, the subset of PCI devices that have GPEs associated with them is quite limited and the other devices have to rely on the GPEs associated with their upstream bridges and, possibly, the root bridge to generate ACPI wake-up events in response to PMEs from them. Moreover, ACPI devices tend to share wake-up GPEs, in which cases it makes sense to install an ACPI notify handler for only one of them and "bind" the other devices to it. Furthermore, ACPI-based PCI hotplug also uses ACPI notify handlers that in general may conflict with the PM notify handlers, unless this issue is specifically taken care of.
I'm not sure this approach is correct - for instance, from a Dell system:
Method (_L0D, 0, NotSerialized)
{
Store (SMI (0xC6, 0x00), Local0)
If (And (Local0, 0x01))
{
Notify (\_SB.PCI0.AZAL, 0x02)
}
If (And (Local0, 0x02))
{
Notify (\_SB.PCI0.EHCI, 0x02)
}
If (And (Local0, 0x04))
{
Notify (\_SB.PCI0.EHC2, 0x02)
}
}All these devices share a GPE, but registering only one notify handler would result in us missing the notification in some cases. I also suspect that this should wait until the GPE rework is done.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [RFC][PATCH 3/4] PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 2)
Quoted 35 lines · Matthew Garrett
Quoted 10 lines · Rafael J. Wysocki
Unfortunately, the subset of PCI devices that have GPEs associated with them is quite limited and the other devices have to rely on the GPEs associated with their upstream bridges and, possibly, the root bridge to generate ACPI wake-up events in response to PMEs from them. Moreover, ACPI devices tend to share wake-up GPEs, in which cases it makes sense to install an ACPI notify handler for only one of them and "bind" the other devices to it. Furthermore, ACPI-based PCI hotplug also uses ACPI notify handlers that in general may conflict with the PM notify handlers, unless this issue is specifically taken care of.
I'm not sure this approach is correct - for instance, from a Dell system:
Method (_L0D, 0, NotSerialized) { Store (SMI (0xC6, 0x00), Local0) If (And (Local0, 0x01)) { Notify (\_SB.PCI0.AZAL, 0x02) } If (And (Local0, 0x02)) { Notify (\_SB.PCI0.EHCI, 0x02) } If (And (Local0, 0x04)) { Notify (\_SB.PCI0.EHC2, 0x02) } }
Quoted 2 lines
All these devices share a GPE, but registering only one notify handler would result in us missing the notification in some cases.
Ok, I see. The notification may be device-specific, although if we receive one, we'll need to check all devices sharing the GPE anyway.
I think that's not going to be difficult to take into account, but I won't be able to work on this until after the KS.
Quoted 1 line
I also suspect that this should wait until the GPE rework is done.
It certainly is better if the GPE rework is done first, although I'm not sure it's strictly necessary. At least I don't see why exactly at the moment.
Thanks,
Rafael
RFC PATCH 4/4 PCI PM: Run-time callbacks for PCI bus type
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Introduce run-time PM callbacks for the PCI bus type. Make the new callbacks work in analogy with the existing system sleep PM callbacks, so that the drivers already converted to struct dev_pm_ops can use their suspend and resume routines for run-time PM without modifications.
--- drivers/pci/pci-driver.c | 97 ++++++++++++++++++++++++++++++++++++++++++++--- kernel/power/Kconfig | 5 ++ 2 files changed, 97 insertions(+), 5 deletions(-)
kernel/power/Kconfig +5 -0
@@ -241,3 +241,8 @@ config PM_WAKEUP bool depends on SUSPEND || HIBERNATION || PM_RUNTIME default y + +config PM_OPS + bool + depends on PM_SLEEP || PM_RUNTIME + default y
drivers/pci/pci-driver.c +92 -5
140 lines not on this page · raw message
PATCH 1/1 pci: Updates to Rafael's runtime PCI PM patch set
In reply to Rafael J. WysockiThere's a few quirks with Rafael's PCI runtime PM code - this modifies them a little. The body of it is just porting it to my GPE rewrite, but it also moves the PCI binding earlier (otherwise acpi_pci_bind bails, since it's primarily intended for bridges), and also ensures that the pme bit gets set properly on hardware that requires it.
--- drivers/acpi/pci_bind.c | 12 ++++++------ drivers/acpi/wakeup.c | 36 ------------------------------------ drivers/pci/pci-acpi.c | 43 ++++++++++++++++--------------------------- drivers/pci/pci-driver.c | 6 ++++++ include/acpi/acpi_bus.h | 6 ------ 5 files changed, 28 insertions(+), 75 deletions(-)
drivers/acpi/pci_bind.c +6 -6
@@ -73,6 +73,12 @@ static int acpi_pci_bind(struct acpi_device *device)if (!dev)return 0 ; +if (device->wakeup.flags.valid) { +pci_acpi_add_device_pm_notifier (device, dev); +if (dev->subordinate) +pci_acpi_add_bus_pm_notifier (device, dev->subordinate); + } +/* * Install the 'bind' function to facilitate callbacks for * children of the P2P bridge.
@@ -105,12 +111,6 @@ static int acpi_pci_bind(struct acpi_device *device)acpi_pci_irq_add_prt (device->handle, bus); -if (device->wakeup.flags.valid) { -pci_acpi_add_device_pm_notifier (device, dev); -if (dev->subordinate) -pci_acpi_add_bus_pm_notifier (device, dev->subordinate); - } - out:pci_dev_put (dev);return 0 ;
drivers/acpi/wakeup.c +0 -36
@@ -98,42 +98,6 @@ void acpi_disable_wakeup_device(u8 sleep_state)#ifdef CONFIG_PM_WAKEUP /** -* acpi_device_run_wake - Enable/disable ACPI BIOS to generate wake-up events. -* @dev: Device to generate the wake-up events for. -* @enable: Desired action. -* -* If @enable is set, set up the GPE associated with @phys_dev to generate -* wake-up events at run time. If @enable is unset, disable the GPE associated -* with @phys_dev (unless it is marked as a run-wake device). -*/ -int acpi_device_run_wake (struct acpi_device *dev,bool enable) -{ -if (!dev || !dev->wakeup.flags.valid) -return -EINVAL ; - -if (enable) { -if (!dev->wakeup.state.enabled && !dev->wakeup.prepare_count) -return -EINVAL ; - -acpi_set_gpe_type (dev->wakeup.gpe_device, - dev->wakeup.gpe_number, -ACPI_GPE_TYPE_WAKE_RUN ); -acpi_enable_gpe (dev->wakeup.gpe_device, - dev->wakeup.gpe_number); - }else if (!dev->wakeup.flags.run_wake) { -acpi_set_gpe_type (dev->wakeup.gpe_device, - dev->wakeup.gpe_number, -ACPI_GPE_TYPE_WAKE ); -acpi_disable_gpe (dev->wakeup.gpe_device, - dev->wakeup.gpe_number); -acpi_clear_gpe (dev->wakeup.gpe_device, - dev->wakeup.gpe_number,ACPI_NOT_ISR ); - } - -return 0 ; -} - -/** * acpi_wakeup_gpes_shared - Check if given ACPI devices share a wake-up GPE. * @deva: First ACPI device to check. * @devb: Second ACPI device to check.
drivers/pci/pci-acpi.c +16 -27
95 lines not on this page · raw message
drivers/pci/pci-driver.c +6 -0
@@ -967,6 +967,9 @@ static int pci_pm_runtime_suspend(struct device *dev)pci_prepare_to_sleep (pci_dev); } +if (pci_pme_capable (pci_dev,pci_target_state (pci_dev))) +pci_pme_active (pci_dev, true); +pci_platform_run_wake (pci_dev, true);return 0 ;
@@ -980,6 +983,9 @@ static int pci_pm_runtime_resume(struct device *dev)if (!pm || !pm->runtime_resume)return -ENOSYS ; +if (pci_pme_capable (pci_dev,pci_target_state (pci_dev))) +pci_pme_active (pci_dev, false); +pci_platform_run_wake (pci_dev, false);pci_pm_default_resume_early (pci_dev);pci_pm_default_resume (pci_dev);
include/acpi/acpi_bus.h +0 -6
@@ -389,7 +389,6 @@ struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);#ifdef CONFIG_PM_WAKEUP int acpi_pm_device_sleep_state (struct device *,int *);int acpi_pm_device_sleep_wake (struct device *,bool ); -int acpi_device_run_wake (struct acpi_device *,bool );bool acpi_wakeup_gpe_shared (struct acpi_device *,struct acpi_device *);#else /* !CONFIG_PM_WAKEUP */ static inline int acpi_pm_device_sleep_state (struct device *d,int *p)
@@ -404,11 +403,6 @@ static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable)return -ENODEV ; } -static inline int acpi_device_run_wake (struct device *dev,bool enable) -{ -return -ENODEV ; -} -static inline bool acpi_wakeup_gpe_shared (struct acpi_device *a,struct acpi_device *b) {
Signature · 1 line
1.6.5.2
Re: [PATCH] pci: Updates to Rafael's runtime PCI PM patch set
Quoted 5 lines · Matthew Garrett
There's a few quirks with Rafael's PCI runtime PM code - this modifies them a little. The body of it is just porting it to my GPE rewrite, but it also moves the PCI binding earlier (otherwise
acpi_pci_bindbails, since it's primarily intended for bridges), and also ensures that the pme bit gets set properly on hardware that requires it.
Well, I thought more changes would be necessary. :-)
Looking good, a few comments below.
Quoted 9 lines
Signed-off-by Matthew Garrett <[email protected]>--- drivers/acpi/pci_bind.c | 12 ++++++------ drivers/acpi/wakeup.c | 36 ------------------------------------ drivers/pci/pci-acpi.c | 43 ++++++++++++++++--------------------------- drivers/pci/pci-driver.c | 6 ++++++ include/acpi/acpi_bus.h | 6 ------ 5 files changed, 28 insertions(+), 75 deletions(-)
...
drivers/pci/pci-driver.c static int pci_pm_runtime_suspend(struct device *dev) · line 972
Quoted 11 lines
drivers/pci/pci-driver.c +3
-0@@ -967,6 +967,9 @@ static int pci_pm_runtime_suspend(struct device *dev)pci_prepare_to_sleep (pci_dev); } +if (pci_pme_capable (pci_dev,pci_target_state (pci_dev))) +pci_pme_active (pci_dev, true); +
The PME was supposed to be turned on by pci_prepare_to_sleep(). I guess it wasn't in practice?
drivers/pci/pci-driver.c static int pci_pm_runtime_resume(struct device *dev) · line 988
Quoted 10 lines
drivers/pci/pci-driver.c +3
-0pci_platform_run_wake (pci_dev, true);return 0 ;@@ -980,6 +983,9 @@ static int pci_pm_runtime_resume(struct device *dev)if (!pm || !pm->runtime_resume)return -ENOSYS ; +if (pci_pme_capable (pci_dev,pci_target_state (pci_dev))) +pci_pme_active (pci_dev, false); +
Same here, pci_pm_default_resume_early() should cleare the PME theoretically, although not for bridges.
include/acpi/acpi_bus.h
Quoted 5 lines
drivers/pci/pci-driver.c +0
-0pci_platform_run_wake (pci_dev, false);pci_pm_default_resume_early (pci_dev);pci_pm_default_resume (pci_dev);include/acpi/acpi_bus.h +0
-0
Generally, some parts of it belong to the
"PCI PM: Run-time callbacks for PCI bus type" patch and the others belong to "PCI / ACPI PM: Platform support for PCI PME wake-up" patch. Should I fold the changes into them?
Rafael
Re: [PATCH] pci: Updates to Rafael's runtime PCI PM patch set
Quoted 2 lines · Rafael J. Wysocki
The PME was supposed to be turned on by
pci_prepare_to_sleep(). I guess it wasn't in practice?
Only if the device is set as a wakeup device, which seems messy. Though there may need to be a check there to avoid duplicate PME setup.
Quoted 4 lines
Generally, some parts of it belong to the
"PCI PM: Run-time callbacks for PCI bus type" patch and the others belong to "PCI / ACPI PM: Platform support for PCI PME wake-up" patch. Should I fold the changes into them?
Feel free!
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH] pci: Updates to Rafael's runtime PCI PM patch set
In reply to Rafael J. WysockiQuoted 2 lines · Rafael J. Wysocki
The PME was supposed to be turned on by
pci_prepare_to_sleep(). I guess it wasn't in practice?
Only if the device is set as a wakeup device, which seems messy. Though there may need to be a check there to avoid duplicate PME setup.
Quoted 4 lines
Generally, some parts of it belong to the
"PCI PM: Run-time callbacks for PCI bus type" patch and the others belong to "PCI / ACPI PM: Platform support for PCI PME wake-up" patch. Should I fold the changes into them?
Feel free!
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH] pci: Updates to Rafael's runtime PCI PM patch set
Quoted 6 lines · Matthew Garrett
Quoted 2 lines · Rafael J. Wysocki
The PME was supposed to be turned on by
pci_prepare_to_sleep(). I guess it wasn't in practice?Only if the device is set as a wakeup device, which seems messy.
Right. Plus there was an implicit assumption that devices which could wake up would also be able to generate PME at run time. It turns out that that need not be the case, though.
Quoted 1 line
Though there may need to be a check there to avoid duplicate PME setup.
Hmm, I need to think about that for a while.
Quoted 6 lines
Quoted 4 lines
Generally, some parts of it belong to the
"PCI PM: Run-time callbacks for PCI bus type" patch and the others belong to "PCI / ACPI PM: Platform support for PCI PME wake-up" patch. Should I fold the changes into them?Feel free!
OK, thanks!
Re: [PATCH] pci: Updates to Rafael's runtime PCI PM patch set
In reply to Matthew GarrettQuoted 6 lines · Matthew Garrett
Quoted 2 lines · Rafael J. Wysocki
The PME was supposed to be turned on by
pci_prepare_to_sleep(). I guess it wasn't in practice?Only if the device is set as a wakeup device, which seems messy.
Right. Plus there was an implicit assumption that devices which could wake up would also be able to generate PME at run time. It turns out that that need not be the case, though.
Quoted 1 line
Though there may need to be a check there to avoid duplicate PME setup.
Hmm, I need to think about that for a while.
Quoted 6 lines
Quoted 4 lines
Generally, some parts of it belong to the
"PCI PM: Run-time callbacks for PCI bus type" patch and the others belong to "PCI / ACPI PM: Platform support for PCI PME wake-up" patch. Should I fold the changes into them?Feel free!
OK, thanks!
Re: [PATCH] pci: Updates to Rafael's runtime PCI PM patch set
In reply to Matthew GarrettQuoted 5 lines · Matthew Garrett
There's a few quirks with Rafael's PCI runtime PM code - this modifies them a little. The body of it is just porting it to my GPE rewrite, but it also moves the PCI binding earlier (otherwise
acpi_pci_bindbails, since it's primarily intended for bridges), and also ensures that the pme bit gets set properly on hardware that requires it.
Well, I thought more changes would be necessary. :-)
Looking good, a few comments below.
Quoted 9 lines
Signed-off-by Matthew Garrett <[email protected]>--- drivers/acpi/pci_bind.c | 12 ++++++------ drivers/acpi/wakeup.c | 36 ------------------------------------ drivers/pci/pci-acpi.c | 43 ++++++++++++++++--------------------------- drivers/pci/pci-driver.c | 6 ++++++ include/acpi/acpi_bus.h | 6 ------ 5 files changed, 28 insertions(+), 75 deletions(-)
...
drivers/pci/pci-driver.c static int pci_pm_runtime_suspend(struct device *dev) · line 972
Quoted 11 lines
drivers/pci/pci-driver.c +3
-0@@ -967,6 +967,9 @@ static int pci_pm_runtime_suspend(struct device *dev)pci_prepare_to_sleep (pci_dev); } +if (pci_pme_capable (pci_dev,pci_target_state (pci_dev))) +pci_pme_active (pci_dev, true); +
The PME was supposed to be turned on by pci_prepare_to_sleep(). I guess it wasn't in practice?
drivers/pci/pci-driver.c static int pci_pm_runtime_resume(struct device *dev) · line 988
Quoted 10 lines
drivers/pci/pci-driver.c +3
-0pci_platform_run_wake (pci_dev, true);return 0 ;@@ -980,6 +983,9 @@ static int pci_pm_runtime_resume(struct device *dev)if (!pm || !pm->runtime_resume)return -ENOSYS ; +if (pci_pme_capable (pci_dev,pci_target_state (pci_dev))) +pci_pme_active (pci_dev, false); +
Same here, pci_pm_default_resume_early() should cleare the PME theoretically, although not for bridges.
include/acpi/acpi_bus.h
Quoted 5 lines
drivers/pci/pci-driver.c +0
-0pci_platform_run_wake (pci_dev, false);pci_pm_default_resume_early (pci_dev);pci_pm_default_resume (pci_dev);include/acpi/acpi_bus.h +0
-0
Generally, some parts of it belong to the
"PCI PM: Run-time callbacks for PCI bus type" patch and the others belong to "PCI / ACPI PM: Platform support for PCI PME wake-up" patch. Should I fold the changes into them?
Rafael