PCI run-time PM support
Subsystems (8)
cover PCI run-time PM support
Hi,
The following series of patches provides run-time power management support through ACPI and the native PCIe PME.
[1/10] - Add flag for marking devices capable of generating wake-up events at run time
[2/10] - Add function for checking PME status of devices
[3/10] - Modify wake-up enable propagation so that it's done for PCIe devices too
[4/10] - PCIe PME root port service driver
[5/10] - ACPI GPE refcounting from Matthew
[6/10] - ACPI drivers support for GPE refcounting from Matthew
[7/10] - ACPI removal of the old GPE API from Matthew
[8/10] - ACPI add fields for handling run-wake devices
[9/10] - PCI ACPI platform support for run-time power management
[10/10] - Runtime PM callbacks for the PCI bus type
Comments welcome.
Best,
Rafael
RFC PATCH 1/10 PM: Add flag for devices capable of generating run-time wake-up events
From: Rafael J. Wysocki <[email protected]>
Apparently, there are devices that can wake up the system from sleep states and yet are incapable of generating wake-up events at run time. Thus, introduce a flag indicating if given device is capable of generating run-time wake-up events.
--- Documentation/power/runtime_pm.txt | 7 +++++-- include/linux/pm.h | 8 +++++--- include/linux/pm_runtime.h | 12 ++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-)
include/linux/pm.h +5 -3
@@ -179,9 +179,10 @@ typedef struct pm_message {* This need not mean that the device should be put into a low power state. * For example, if the device is behind a link which is about to be turned * off, the device may remain at full power. If the device does go to low -* power and if device_may_wakeup(dev) is true, remote wake-up (i.e., a -* hardware mechanism allowing the device to request a change of its power -* state, such as PCI PME) should be enabled for it. +* power and is capable of generating run-time wake-up events, remote +* wake-up (i.e., a hardware mechanism allowing the device to request a +* change of its power state via a wake-up event, such as PCI PME) should +* be enabled for it. * * @runtime_resume: Put the device into the fully active state in response to a * wake-up event generated by hardware or at the request of software. If
@@ -434,6 +435,7 @@ struct dev_pm_info { unsigned int idle_notification:1; unsigned int request_pending:1; unsigned int deferred_resume:1; + unsigned int run_wake:1;enum rpm_request request;enum rpm_status runtime_status;int runtime_error;
Documentation/power/runtime_pm.txt +5 -2
@@ -71,9 +71,9 @@ what to do to handle the device). purpose). In particular, if the driver requires remote wakeup capability for proper -functioning and device_may_wakeup() returns 'false' for the device, then +functioning and device_run_wake() returns 'false' for the device, then ->runtime_suspend() should return -EBUSY. On the other hand, if -device_may_wakeup() returns 'true' for the device and the device is put +device_run_wake() returns 'true' for the device and the device is put into a low power state during the execution of its bus type's ->runtime_suspend(), it is expected that remote wake-up (i.e. hardware mechanism allowing the device to request a change of its power state, such as PCI PME)
@@ -214,6 +214,9 @@ defined in include/linux/pm.h: being executed for that device and it is not practical to wait for the suspend to complete; means "start a resume as soon as you've suspended" + unsigned int run_wake; + - set if the device is capable of generating run-time wake-up events + enum rpm_status runtime_status; - the run-time PM status of the device; this field's initial value is RPM_SUSPENDED, which means that each device is initially regarded by the
include/linux/pm_runtime.h +12 -0
@@ -50,6 +50,16 @@ static inline void pm_runtime_put_noidle atomic_add_unless(&dev->power.usage_count, -1, 0); } +static inline bool device_run_wake (struct device *dev) +{ +return dev->power.run_wake; +} + +static inline void device_set_run_wake (struct device *dev,bool enable) +{ + dev->power.run_wake = enable; +} +#else /* !CONFIG_PM_RUNTIME */ static inline int pm_runtime_idle (struct device *dev) {return -ENOSYS ; }
@@ -73,6 +83,8 @@ static inline bool pm_children_suspendedstatic inline void pm_suspend_ignore_children (struct device *dev,bool en) {}static inline void pm_runtime_get_noresume (struct device *dev) {}static inline void pm_runtime_put_noidle (struct device *dev) {} +static inline bool device_run_wake (struct device *dev) {return false; } +static inline void device_set_run_wake (struct device *dev,bool enable) {}#endif /* !CONFIG_PM_RUNTIME */
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
Quoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Apparently, there are devices that can wake up the system from sleep states and yet are incapable of generating wake-up events at run time. Thus, introduce a flag indicating if given device is capable of generating run-time wake-up events.
This raises the question: Who is responsible for setting the new flag? The code that registers the device?
What if the kernel can't tell whether or not the device can generate runtime wake-up events?
What if the user wants to override the kernel's setting? Should there be a sysfs attribute controlling the flag?
Alan Stern
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
Quoted 11 lines · Alan Stern
Quoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Apparently, there are devices that can wake up the system from sleep states and yet are incapable of generating wake-up events at run time. Thus, introduce a flag indicating if given device is capable of generating run-time wake-up events.
This raises the question: Who is responsible for setting the new flag? The code that registers the device?
Yes, in general. The platform.
Actually, I needed it for PCI, but I thought it would be better to put it at the core level.
Quoted 2 lines
What if the kernel can't tell whether or not the device can generate runtime wake-up events?
Do you have any specific examples in mind?
Quoted 2 lines
What if the user wants to override the kernel's setting? Should there be a sysfs attribute controlling the flag?
I have no plans for adding anything like that.
Rafael
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · Alan Stern
Quoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Apparently, there are devices that can wake up the system from sleep states and yet are incapable of generating wake-up events at run time. Thus, introduce a flag indicating if given device is capable of generating run-time wake-up events.
Quoted 4 lines
Quoted 2 lines
This raises the question: Who is responsible for setting the new flag? The code that registers the device?
Yes, in general. The platform.
And for non-platform devices (hot-pluggable, for example)? Presumably you would want the driver that detects and registers the device to set this flag.
Quoted 7 lines
Actually, I needed it for PCI, but I thought it would be better to put it at the core level.
Quoted 2 lines
What if the kernel can't tell whether or not the device can generate runtime wake-up events?
Do you have any specific examples in mind?
What about Matthew's example of an ACPI GPE which might or might not cause a runtime wake-up event, depending on the AML code in the BIOS?
Quoted 4 lines
Quoted 2 lines
What if the user wants to override the kernel's setting? Should there be a sysfs attribute controlling the flag?
I have no plans for adding anything like that.
So if the kernel makes a mistake here, the user won't be able to correct it.
Alan Stern
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
Quoted 6 lines · Alan Stern
Quoted 1 line · Rafael J. Wysocki
Yes, in general. The platform.
And for non-platform devices (hot-pluggable, for example)? Presumably you would want the driver that detects and registers the device to set this flag.
Are there any cases where the bus code won't know this?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
What if the kernel can't tell whether or not the device can generate runtime wake-up events?
Do you have any specific examples in mind?
What about Matthew's example of an ACPI GPE which might or might not cause a runtime wake-up event, depending on the AML code in the BIOS?
The platform knows whether or not that's the case.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
Quoted 9 lines · Matthew Garrett
Quoted 6 lines · Alan Stern
Quoted 1 line · Rafael J. Wysocki
Yes, in general. The platform.
And for non-platform devices (hot-pluggable, for example)? Presumably you would want the driver that detects and registers the device to set this flag.
Are there any cases where the bus code won't know this?
None that I'm aware of. I merely wanted to clarify where the flag was supposed to get set.
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
What if the kernel can't tell whether or not the device can generate runtime wake-up events?
Do you have any specific examples in mind?
What about Matthew's example of an ACPI GPE which might or might not cause a runtime wake-up event, depending on the AML code in the BIOS?
The platform knows whether or not that's the case.
Okay, then it isn't a problem. Except perhaps in the case of buggy devices which _should_ generate these events but don't.
Alan Stern
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
In reply to Matthew GarrettQuoted 9 lines · Matthew Garrett
Quoted 6 lines · Alan Stern
Quoted 1 line · Rafael J. Wysocki
Yes, in general. The platform.
And for non-platform devices (hot-pluggable, for example)? Presumably you would want the driver that detects and registers the device to set this flag.
Are there any cases where the bus code won't know this?
None that I'm aware of. I merely wanted to clarify where the flag was supposed to get set.
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
What if the kernel can't tell whether or not the device can generate runtime wake-up events?
Do you have any specific examples in mind?
What about Matthew's example of an ACPI GPE which might or might not cause a runtime wake-up event, depending on the AML code in the BIOS?
The platform knows whether or not that's the case.
Okay, then it isn't a problem. Except perhaps in the case of buggy devices which _should_ generate these events but don't.
Alan Stern
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
In reply to Alan SternQuoted 6 lines · Alan Stern
Quoted 1 line · Rafael J. Wysocki
Yes, in general. The platform.
And for non-platform devices (hot-pluggable, for example)? Presumably you would want the driver that detects and registers the device to set this flag.
Are there any cases where the bus code won't know this?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
What if the kernel can't tell whether or not the device can generate runtime wake-up events?
Do you have any specific examples in mind?
What about Matthew's example of an ACPI GPE which might or might not cause a runtime wake-up event, depending on the AML code in the BIOS?
The platform knows whether or not that's the case.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
In reply to Alan SternAm Montag, 16. November 2009 22:00:49 schrieb Alan Stern:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
What if the user wants to override the kernel's setting? Should there be a sysfs attribute controlling the flag?
I have no plans for adding anything like that.
So if the kernel makes a mistake here, the user won't be able to correct it.
If the kernel cannot tell whether a device can generate a request for remote wakeup, how would it know the enable such requests? Now we might come to a device that has a flatly wrong firmware, but has that really been encountered in the wild?
Regards
Oliver
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
In reply to Alan SternAm Montag, 16. November 2009 22:00:49 schrieb Alan Stern:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
What if the user wants to override the kernel's setting? Should there be a sysfs attribute controlling the flag?
I have no plans for adding anything like that.
So if the kernel makes a mistake here, the user won't be able to correct it.
If the kernel cannot tell whether a device can generate a request for remote wakeup, how would it know the enable such requests? Now we might come to a device that has a flatly wrong firmware, but has that really been encountered in the wild?
Regards
Oliver
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
In reply to Rafael J. WysockiQuoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · Alan Stern
Quoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Apparently, there are devices that can wake up the system from sleep states and yet are incapable of generating wake-up events at run time. Thus, introduce a flag indicating if given device is capable of generating run-time wake-up events.
Quoted 4 lines
Quoted 2 lines
This raises the question: Who is responsible for setting the new flag? The code that registers the device?
Yes, in general. The platform.
And for non-platform devices (hot-pluggable, for example)? Presumably you would want the driver that detects and registers the device to set this flag.
Quoted 7 lines
Actually, I needed it for PCI, but I thought it would be better to put it at the core level.
Quoted 2 lines
What if the kernel can't tell whether or not the device can generate runtime wake-up events?
Do you have any specific examples in mind?
What about Matthew's example of an ACPI GPE which might or might not cause a runtime wake-up event, depending on the AML code in the BIOS?
Quoted 4 lines
Quoted 2 lines
What if the user wants to override the kernel's setting? Should there be a sysfs attribute controlling the flag?
I have no plans for adding anything like that.
So if the kernel makes a mistake here, the user won't be able to correct it.
Alan Stern
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
In reply to Alan SternQuoted 11 lines · Alan Stern
Quoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Apparently, there are devices that can wake up the system from sleep states and yet are incapable of generating wake-up events at run time. Thus, introduce a flag indicating if given device is capable of generating run-time wake-up events.
This raises the question: Who is responsible for setting the new flag? The code that registers the device?
Yes, in general. The platform.
Actually, I needed it for PCI, but I thought it would be better to put it at the core level.
Quoted 2 lines
What if the kernel can't tell whether or not the device can generate runtime wake-up events?
Do you have any specific examples in mind?
Quoted 2 lines
What if the user wants to override the kernel's setting? Should there be a sysfs attribute controlling the flag?
I have no plans for adding anything like that.
Rafael
Re: [RFC][PATCH 1/10] PM: Add flag for devices capable of generating run-time wake-up events
In reply to Rafael J. WysockiQuoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Apparently, there are devices that can wake up the system from sleep states and yet are incapable of generating wake-up events at run time. Thus, introduce a flag indicating if given device is capable of generating run-time wake-up events.
This raises the question: Who is responsible for setting the new flag? The code that registers the device?
What if the kernel can't tell whether or not the device can generate runtime wake-up events?
What if the user wants to override the kernel's setting? Should there be a sysfs attribute controlling the flag?
Alan Stern
RFC PATCH 2/10 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 used 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 and if set, clear it and clear PME enable +* (if set). Return 'true' if PME status and PME enable were both set 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 ; +pci_read_config_word (dev, pmcsr_pos, &pmcsr); +if (!(pmcsr &PCI_PM_CTRL_PME_STATUS )) +return false; + +/* Clear PME status. */ + pmcsr |=PCI_PM_CTRL_PME_STATUS ; +if (pmcsr &PCI_PM_CTRL_PME_ENABLE ) { +/* Disable PME to avoid interrupt flood. */ + 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 3/10 PCI / PM: Propagate wake-up enable for PCIe devices too
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Having read the PM part of the PCIe 2.0 specification more carefully I think that it was a mistake to restrict the wake-up enable propagation to non-PCIe devices, because if we do not request control of the root ports' PME registers via OSC, PCIe PME is supposed to be handled by the platform, just like the non-PCIe PME. Even if we do that, the wake-up propagation is done to allow the devices to wake up the system from sleep states which involves the platform anyway, so it won't hurt.
--- drivers/pci/pci-acpi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/pci/pci-acpi.c +2 -8
@@ -112,11 +112,7 @@ static bool acpi_pci_can_wakeup(struct pstatic void acpi_pci_propagate_wakeup_enable (struct pci_bus *bus,bool enable) {while (bus->parent) { -struct pci_dev *bridge = bus->self; -int ret; - - ret =acpi_pm_device_sleep_wake (&bridge->dev, enable); -if (!ret || bridge->is_pcie) +if (!acpi_pm_device_sleep_wake (&bus->self->dev, enable))return ; bus = bus->parent; }
@@ -131,9 +127,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) -acpi_pci_propagate_wakeup_enable (dev->bus, enable); - +acpi_pci_propagate_wakeup_enable (dev->bus, enable);return 0 ; }
RFC PATCH 3/10 PCI / PM: Propagate wake-up enable for PCIe devices too
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Having read the PM part of the PCIe 2.0 specification more carefully I think that it was a mistake to restrict the wake-up enable propagation to non-PCIe devices, because if we do not request control of the root ports' PME registers via OSC, PCIe PME is supposed to be handled by the platform, just like the non-PCIe PME. Even if we do that, the wake-up propagation is done to allow the devices to wake up the system from sleep states which involves the platform anyway, so it won't hurt.
--- drivers/pci/pci-acpi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/pci/pci-acpi.c +2 -8
@@ -112,11 +112,7 @@ static bool acpi_pci_can_wakeup(struct pstatic void acpi_pci_propagate_wakeup_enable (struct pci_bus *bus,bool enable) {while (bus->parent) { -struct pci_dev *bridge = bus->self; -int ret; - - ret =acpi_pm_device_sleep_wake (&bridge->dev, enable); -if (!ret || bridge->is_pcie) +if (!acpi_pm_device_sleep_wake (&bus->self->dev, enable))return ; bus = bus->parent; }
@@ -131,9 +127,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) -acpi_pci_propagate_wakeup_enable (dev->bus, enable); - +acpi_pci_propagate_wakeup_enable (dev->bus, enable);return 0 ; }
RFC PATCH 4/10 PCI PM: PCIe PME root port service driver (rev. 4)
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/pcie/Kconfig | 4 drivers/pci/pcie/Makefile | 2 drivers/pci/pcie/pme/Makefile | 8 drivers/pci/pcie/pme/pcie_pme.c | 479 +++++++++++++++++++++++++++++++++++ drivers/pci/pcie/pme/pcie_pme.h | 28 ++ drivers/pci/pcie/pme/pcie_pme_acpi.c | 54 +++ include/linux/pci.h | 1 7 files changed, 576 insertions(+)
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 +479 -0
479 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 +1 -0
@@ -238,6 +238,7 @@ struct pci_dev {configuration space */ unsigned int pme_support:5; /* Bitmask of states from which PME#can be generated */ + unsigned int pme_interrupt:1; unsigned int d1_support:1; /* Low power state D1 is supported */ unsigned int d2_support:1; /* Low power state D2 is supported */ unsigned int no_d1d2:1; /* Only allow D0 and D3 */
RFC PATCH 4/10 PCI PM: PCIe PME root port service driver (rev. 4)
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/pcie/Kconfig | 4 drivers/pci/pcie/Makefile | 2 drivers/pci/pcie/pme/Makefile | 8 drivers/pci/pcie/pme/pcie_pme.c | 479 +++++++++++++++++++++++++++++++++++ drivers/pci/pcie/pme/pcie_pme.h | 28 ++ drivers/pci/pcie/pme/pcie_pme_acpi.c | 54 +++ include/linux/pci.h | 1 7 files changed, 576 insertions(+)
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 +479 -0
479 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 +1 -0
@@ -238,6 +238,7 @@ struct pci_dev {configuration space */ unsigned int pme_support:5; /* Bitmask of states from which PME#can be generated */ + unsigned int pme_interrupt:1; unsigned int d1_support:1; /* Low power state D1 is supported */ unsigned int d2_support:1; /* Low power state D2 is supported */ unsigned int no_d1d2:1; /* Only allow D0 and D3 */
RFC PATCH 5/10 ACPI: Add infrastructure for refcounting GPE consumers
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
ACPI GPEs may map to multiple devices. The current GPE interface only provides a mechanism for enabling and disabling GPEs, making it difficult to change the state of GPEs at runtime without extensive cooperation between devices. Add an API to allow devices to indicate whether or not they want their device's GPE to be enabled for both runtime and wakeup events.
---drivers/acpi/acpica/aclocal.h | 2 +
drivers/acpi/acpica/aclocal.h | 2 drivers/acpi/acpica/evxfevnt.c | 161 +++++++++++++++++++++++++++++++++++++++++ include/acpi/acpixf.h | 8 ++ 3 files changed, 171 insertions(+)
drivers/acpi/acpica/aclocal.h +2 -0
@@ -426,6 +426,8 @@ struct acpi_gpe_event_info {struct acpi_gpe_register_info *register_info;/* Backpointer to register info */ u8 flags;/* Misc info about this GPE */ u8 gpe_number;/* This GPE */ +u8 runtime_count; +u8 wakeup_count; };/* Information about a GPE register pair, one per each status/enable pair in an array */
drivers/acpi/acpica/evxfevnt.c +161 -0
167 lines not on this page · raw message
include/acpi/acpixf.h +8 -0
@@ -282,6 +282,14 @@ acpi_status acpi_get_event_status(u32 ev*/ acpi_status acpi_set_gpe_type (acpi_handle gpe_device,u32 gpe_number,u8 type); +acpi_status acpi_ref_runtime_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_unref_runtime_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_ref_wakeup_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_unref_wakeup_gpe (acpi_handle gpe_device,u32 gpe_number); +acpi_status acpi_enable_gpe (acpi_handle gpe_device,u32 gpe_number);acpi_status acpi_disable_gpe (acpi_handle gpe_device,u32 gpe_number);
RFC PATCH 5/10 ACPI: Add infrastructure for refcounting GPE consumers
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
ACPI GPEs may map to multiple devices. The current GPE interface only provides a mechanism for enabling and disabling GPEs, making it difficult to change the state of GPEs at runtime without extensive cooperation between devices. Add an API to allow devices to indicate whether or not they want their device's GPE to be enabled for both runtime and wakeup events.
---drivers/acpi/acpica/aclocal.h | 2 +
drivers/acpi/acpica/aclocal.h | 2 drivers/acpi/acpica/evxfevnt.c | 161 +++++++++++++++++++++++++++++++++++++++++ include/acpi/acpixf.h | 8 ++ 3 files changed, 171 insertions(+)
drivers/acpi/acpica/aclocal.h +2 -0
@@ -426,6 +426,8 @@ struct acpi_gpe_event_info {struct acpi_gpe_register_info *register_info;/* Backpointer to register info */ u8 flags;/* Misc info about this GPE */ u8 gpe_number;/* This GPE */ +u8 runtime_count; +u8 wakeup_count; };/* Information about a GPE register pair, one per each status/enable pair in an array */
drivers/acpi/acpica/evxfevnt.c +161 -0
167 lines not on this page · raw message
include/acpi/acpixf.h +8 -0
@@ -282,6 +282,14 @@ acpi_status acpi_get_event_status(u32 ev*/ acpi_status acpi_set_gpe_type (acpi_handle gpe_device,u32 gpe_number,u8 type); +acpi_status acpi_ref_runtime_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_unref_runtime_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_ref_wakeup_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_unref_wakeup_gpe (acpi_handle gpe_device,u32 gpe_number); +acpi_status acpi_enable_gpe (acpi_handle gpe_device,u32 gpe_number);acpi_status acpi_disable_gpe (acpi_handle gpe_device,u32 gpe_number);
RFC PATCH 6/10 ACPI: Add support for new refcounted GPE API to drivers
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
Add GPE refcounting support to ACPI drivers that need it. This will currently do little until the core is changed over to use the new behaviour.
Signed-off-by; Rafael J. Wysocki <[email protected]>
---drivers/acpi/button.c | 12 ++++++++++++
drivers/acpi/button.c | 12 ++++++++++++ drivers/acpi/ec.c | 4 +++- drivers/acpi/wakeup.c | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/acpi/button.c +12 -0
@@ -420,6 +420,10 @@ static int acpi_button_add(struct acpi_d ACPI_GPE_TYPE_WAKE_RUN);acpi_enable_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); +acpi_ref_runtime_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); +acpi_ref_wakeup_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); device->wakeup.state.enabled =1 ; }
@@ -439,6 +443,14 @@ static int acpi_button_remove(struct acp {struct acpi_button *button =acpi_driver_data (device); +if (device->wakeup.flags.valid) { +acpi_unref_runtime_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); +acpi_unref_wakeup_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); + device->wakeup.state.enabled =0 ; + } +acpi_button_remove_fs (device);input_unregister_device (button->input);kfree (button);
drivers/acpi/ec.c +3 -1
@@ -755,7 +755,7 @@ static int ec_install_handlers(struct acif (ACPI_FAILURE (status))return -ENODEV ;acpi_set_gpe_type (NULL , ec->gpe,ACPI_GPE_TYPE_RUNTIME ); -acpi_enable_gpe (NULL , ec->gpe); +acpi_ref_runtime_gpe (NULL , ec->gpe); status = acpi_install_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
@@ -772,6 +772,7 @@ static int ec_install_handlers(struct ac }else {acpi_remove_gpe_handler (NULL , ec->gpe, &acpi_ec_gpe_handler); +acpi_unref_runtime_gpe (NULL , ec->gpe);return -ENODEV ; } }
@@ -782,6 +783,7 @@ static int ec_install_handlers(struct acstatic void ec_remove_handlers (struct acpi_ec *ec) { +acpi_unref_runtime_gpe (NULL , ec->gpe);if (ACPI_FAILURE (acpi_remove_address_space_handler (ec->handle,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler)))pr_err (PREFIX "failed to remove space handler\n" );
drivers/acpi/wakeup.c +6 -0
@@ -81,6 +81,8 @@ void acpi_enable_wakeup_device(u8 sleep_if (!dev->wakeup.flags.run_wake)acpi_enable_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number); +acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } }
@@ -121,6 +123,8 @@ void acpi_disable_wakeup_device(u8 sleepacpi_clear_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number,ACPI_NOT_ISR ); } +acpi_unref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } }
@@ -141,6 +145,8 @@ int __init acpi_wakeup_device_init(void) ACPI_GPE_TYPE_WAKE_RUN);acpi_enable_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number); +acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); dev->wakeup.state.enabled =1 ; }mutex_unlock (&acpi_device_lock);
RFC PATCH 6/10 ACPI: Add support for new refcounted GPE API to drivers
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
Add GPE refcounting support to ACPI drivers that need it. This will currently do little until the core is changed over to use the new behaviour.
Signed-off-by; Rafael J. Wysocki <[email protected]>
---drivers/acpi/button.c | 12 ++++++++++++
drivers/acpi/button.c | 12 ++++++++++++ drivers/acpi/ec.c | 4 +++- drivers/acpi/wakeup.c | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/acpi/button.c +12 -0
@@ -420,6 +420,10 @@ static int acpi_button_add(struct acpi_d ACPI_GPE_TYPE_WAKE_RUN);acpi_enable_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); +acpi_ref_runtime_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); +acpi_ref_wakeup_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); device->wakeup.state.enabled =1 ; }
@@ -439,6 +443,14 @@ static int acpi_button_remove(struct acp {struct acpi_button *button =acpi_driver_data (device); +if (device->wakeup.flags.valid) { +acpi_unref_runtime_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); +acpi_unref_wakeup_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); + device->wakeup.state.enabled =0 ; + } +acpi_button_remove_fs (device);input_unregister_device (button->input);kfree (button);
drivers/acpi/ec.c +3 -1
@@ -755,7 +755,7 @@ static int ec_install_handlers(struct acif (ACPI_FAILURE (status))return -ENODEV ;acpi_set_gpe_type (NULL , ec->gpe,ACPI_GPE_TYPE_RUNTIME ); -acpi_enable_gpe (NULL , ec->gpe); +acpi_ref_runtime_gpe (NULL , ec->gpe); status = acpi_install_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
@@ -772,6 +772,7 @@ static int ec_install_handlers(struct ac }else {acpi_remove_gpe_handler (NULL , ec->gpe, &acpi_ec_gpe_handler); +acpi_unref_runtime_gpe (NULL , ec->gpe);return -ENODEV ; } }
@@ -782,6 +783,7 @@ static int ec_install_handlers(struct acstatic void ec_remove_handlers (struct acpi_ec *ec) { +acpi_unref_runtime_gpe (NULL , ec->gpe);if (ACPI_FAILURE (acpi_remove_address_space_handler (ec->handle,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler)))pr_err (PREFIX "failed to remove space handler\n" );
drivers/acpi/wakeup.c +6 -0
@@ -81,6 +81,8 @@ void acpi_enable_wakeup_device(u8 sleep_if (!dev->wakeup.flags.run_wake)acpi_enable_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number); +acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } }
@@ -121,6 +123,8 @@ void acpi_disable_wakeup_device(u8 sleepacpi_clear_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number,ACPI_NOT_ISR ); } +acpi_unref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } }
@@ -141,6 +145,8 @@ int __init acpi_wakeup_device_init(void) ACPI_GPE_TYPE_WAKE_RUN);acpi_enable_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number); +acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); dev->wakeup.state.enabled =1 ; }mutex_unlock (&acpi_device_lock);
RFC PATCH 7/10 ACPI: Remove old GPE API and transition code entirely to new one
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
Remove the old GPE type handling entirely, which gets rid of various quirks like the implicit disabling with GPE type setting. This requires a small amount of rework in order to ensure that non-wake GPEs are enabled by default to preserve existing behaviour.
---drivers/acpi/acpica/acevents.h | 6 +--
drivers/acpi/acpica/acevents.h | 6 - drivers/acpi/acpica/evgpe.c | 147 +++-------------------------------------- drivers/acpi/acpica/evgpeblk.c | 69 ++++++------------- drivers/acpi/acpica/evxface.c | 14 --- drivers/acpi/acpica/evxfevnt.c | 48 ------------- drivers/acpi/button.c | 5 - drivers/acpi/ec.c | 2 drivers/acpi/wakeup.c | 55 ++------------- include/acpi/actypes.h | 32 ++------ 9 files changed, 59 insertions(+), 319 deletions(-)
drivers/acpi/acpica/acevents.h +1 -5
@@ -76,8 +76,7 @@ acpi_ev_queue_notify_request(struct acpi* evgpe - GPE handling and dispatch */ acpi_status -acpi_ev_update_gpe_enable_masks (struct acpi_gpe_event_info *gpe_event_info, -u8 type); +acpi_ev_update_gpe_enable_masks (struct acpi_gpe_event_info *gpe_event_info); acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
@@ -122,9 +121,6 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_eveu32 acpi_ev_gpe_detect (struct acpi_gpe_xrupt_info *gpe_xrupt_list);acpi_status -acpi_ev_set_gpe_type (struct acpi_gpe_event_info *gpe_event_info,u8 type); - -acpi_status acpi_ev_check_for_wake_only_gpe (struct acpi_gpe_event_info *gpe_event_info);acpi_status acpi_ev_gpe_initialize (void );
drivers/acpi/acpica/evgpe.c +14 -133
194 lines not on this page · raw message
drivers/acpi/acpica/evgpeblk.c +22 -47
112 lines not on this page · raw message
drivers/acpi/acpica/evxface.c +0 -14
@@ -617,13 +617,6 @@ acpi_install_gpe_handler(acpi_handle gpe handler->context = context; handler->method_node = gpe_event_info->dispatch.method_node; -/* Disable the GPE before installing the handler */ - - status =acpi_ev_disable_gpe (gpe_event_info); -if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } -/* Install the handler */ flags =acpi_os_acquire_lock (acpi_gbl_gpe_lock);
@@ -707,13 +700,6 @@ acpi_remove_gpe_handler(acpi_handle gpe_ goto unlock_and_exit; } -/* Disable the GPE before removing the handler */ - - status =acpi_ev_disable_gpe (gpe_event_info); -if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } -/* Make sure all deferred tasks are completed */ (void )acpi_ut_release_mutex (ACPI_MTX_EVENTS );
drivers/acpi/acpica/evxfevnt.c +2 -46
66 lines not on this page · raw message
drivers/acpi/button.c +0 -5
@@ -415,11 +415,6 @@ static int acpi_button_add(struct acpi_dif (device->wakeup.flags.valid) {/* Button's GPE is run-wake GPE */ -acpi_set_gpe_type (device->wakeup.gpe_device, - device->wakeup.gpe_number, -ACPI_GPE_TYPE_WAKE_RUN ); -acpi_enable_gpe (device->wakeup.gpe_device, - device->wakeup.gpe_number);acpi_ref_runtime_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); acpi_ref_wakeup_gpe(device->wakeup.gpe_device,
drivers/acpi/ec.c +1 -1
@@ -754,7 +754,7 @@ static int ec_install_handlers(struct ac &acpi_ec_gpe_handler, ec);if (ACPI_FAILURE (status))return -ENODEV ; -acpi_set_gpe_type (NULL , ec->gpe,ACPI_GPE_TYPE_RUNTIME ); +acpi_ref_runtime_gpe (NULL , ec->gpe); status = acpi_install_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC,
drivers/acpi/wakeup.c +9 -46
77 lines not on this page · raw message
include/acpi/actypes.h +10 -22
@@ -668,41 +668,29 @@ typedef u32 acpi_event_status;/* * GPE info flags - Per GPE -* +-+-+-+---+---+-+ -* |7|6|5|4:3|2:1|0| -* +-+-+-+---+---+-+ -* | | | | | | -* | | | | | +--- Interrupt type: Edge or Level Triggered -* | | | | +--- Type: Wake-only, Runtime-only, or wake/runtime +* +-+-+-+---+-+-+-+ +* |7|6|5|4:3|2|1|0| +* +-+-+-+---+-+-+-+ +* | | | | | | | +* | | | | | | +--- Interrupt type: Edge or Level Triggered +* | | | | | +--- GPE can wake the system +* | | | | +--- Unused * | | | +--- Type of dispatch -- to method, handler, or none -* | | +--- Enabled for runtime? -* | +--- Enabled for wake? +* | | +--- Unused +* | +--- Unused * +--- Unused */ #define ACPI_GPE_XRUPT_TYPE_MASK (u8) 0x01#define ACPI_GPE_LEVEL_TRIGGERED (u8) 0x01#define ACPI_GPE_EDGE_TRIGGERED (u8) 0x00 -#define ACPI_GPE_TYPE_MASK (u8) 0x06 -#define ACPI_GPE_TYPE_WAKE_RUN (u8) 0x06 -#define ACPI_GPE_TYPE_WAKE (u8) 0x02 -#define ACPI_GPE_TYPE_RUNTIME (u8) 0x04/* Default */ +#define ACPI_GPE_CAN_WAKE (u8) 0x02#define ACPI_GPE_DISPATCH_MASK (u8) 0x18#define ACPI_GPE_DISPATCH_HANDLER (u8) 0x08#define ACPI_GPE_DISPATCH_METHOD (u8) 0x10#define ACPI_GPE_DISPATCH_NOT_USED (u8) 0x00/* Default */ -#define ACPI_GPE_RUN_ENABLE_MASK (u8) 0x20 -#define ACPI_GPE_RUN_ENABLED (u8) 0x20 -#define ACPI_GPE_RUN_DISABLED (u8) 0x00/* Default */ - -#define ACPI_GPE_WAKE_ENABLE_MASK (u8) 0x40 -#define ACPI_GPE_WAKE_ENABLED (u8) 0x40 -#define ACPI_GPE_WAKE_DISABLED (u8) 0x00/* Default */ - -#define ACPI_GPE_ENABLE_MASK (u8) 0x60/* Both run/wake */ -/* * Flags for GPE and Lock interfaces */
RFC PATCH 7/10 ACPI: Remove old GPE API and transition code entirely to new one
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
Remove the old GPE type handling entirely, which gets rid of various quirks like the implicit disabling with GPE type setting. This requires a small amount of rework in order to ensure that non-wake GPEs are enabled by default to preserve existing behaviour.
---drivers/acpi/acpica/acevents.h | 6 +--
drivers/acpi/acpica/acevents.h | 6 - drivers/acpi/acpica/evgpe.c | 147 +++-------------------------------------- drivers/acpi/acpica/evgpeblk.c | 69 ++++++------------- drivers/acpi/acpica/evxface.c | 14 --- drivers/acpi/acpica/evxfevnt.c | 48 ------------- drivers/acpi/button.c | 5 - drivers/acpi/ec.c | 2 drivers/acpi/wakeup.c | 55 ++------------- include/acpi/actypes.h | 32 ++------ 9 files changed, 59 insertions(+), 319 deletions(-)
drivers/acpi/acpica/acevents.h +1 -5
@@ -76,8 +76,7 @@ acpi_ev_queue_notify_request(struct acpi* evgpe - GPE handling and dispatch */ acpi_status -acpi_ev_update_gpe_enable_masks (struct acpi_gpe_event_info *gpe_event_info, -u8 type); +acpi_ev_update_gpe_enable_masks (struct acpi_gpe_event_info *gpe_event_info); acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
@@ -122,9 +121,6 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_eveu32 acpi_ev_gpe_detect (struct acpi_gpe_xrupt_info *gpe_xrupt_list);acpi_status -acpi_ev_set_gpe_type (struct acpi_gpe_event_info *gpe_event_info,u8 type); - -acpi_status acpi_ev_check_for_wake_only_gpe (struct acpi_gpe_event_info *gpe_event_info);acpi_status acpi_ev_gpe_initialize (void );
drivers/acpi/acpica/evgpe.c +14 -133
194 lines not on this page · raw message
drivers/acpi/acpica/evgpeblk.c +22 -47
112 lines not on this page · raw message
drivers/acpi/acpica/evxface.c +0 -14
@@ -617,13 +617,6 @@ acpi_install_gpe_handler(acpi_handle gpe handler->context = context; handler->method_node = gpe_event_info->dispatch.method_node; -/* Disable the GPE before installing the handler */ - - status =acpi_ev_disable_gpe (gpe_event_info); -if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } -/* Install the handler */ flags =acpi_os_acquire_lock (acpi_gbl_gpe_lock);
@@ -707,13 +700,6 @@ acpi_remove_gpe_handler(acpi_handle gpe_ goto unlock_and_exit; } -/* Disable the GPE before removing the handler */ - - status =acpi_ev_disable_gpe (gpe_event_info); -if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } -/* Make sure all deferred tasks are completed */ (void )acpi_ut_release_mutex (ACPI_MTX_EVENTS );
drivers/acpi/acpica/evxfevnt.c +2 -46
66 lines not on this page · raw message
drivers/acpi/button.c +0 -5
@@ -415,11 +415,6 @@ static int acpi_button_add(struct acpi_dif (device->wakeup.flags.valid) {/* Button's GPE is run-wake GPE */ -acpi_set_gpe_type (device->wakeup.gpe_device, - device->wakeup.gpe_number, -ACPI_GPE_TYPE_WAKE_RUN ); -acpi_enable_gpe (device->wakeup.gpe_device, - device->wakeup.gpe_number);acpi_ref_runtime_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); acpi_ref_wakeup_gpe(device->wakeup.gpe_device,
drivers/acpi/ec.c +1 -1
@@ -754,7 +754,7 @@ static int ec_install_handlers(struct ac &acpi_ec_gpe_handler, ec);if (ACPI_FAILURE (status))return -ENODEV ; -acpi_set_gpe_type (NULL , ec->gpe,ACPI_GPE_TYPE_RUNTIME ); +acpi_ref_runtime_gpe (NULL , ec->gpe); status = acpi_install_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC,
drivers/acpi/wakeup.c +9 -46
77 lines not on this page · raw message
include/acpi/actypes.h +10 -22
@@ -668,41 +668,29 @@ typedef u32 acpi_event_status;/* * GPE info flags - Per GPE -* +-+-+-+---+---+-+ -* |7|6|5|4:3|2:1|0| -* +-+-+-+---+---+-+ -* | | | | | | -* | | | | | +--- Interrupt type: Edge or Level Triggered -* | | | | +--- Type: Wake-only, Runtime-only, or wake/runtime +* +-+-+-+---+-+-+-+ +* |7|6|5|4:3|2|1|0| +* +-+-+-+---+-+-+-+ +* | | | | | | | +* | | | | | | +--- Interrupt type: Edge or Level Triggered +* | | | | | +--- GPE can wake the system +* | | | | +--- Unused * | | | +--- Type of dispatch -- to method, handler, or none -* | | +--- Enabled for runtime? -* | +--- Enabled for wake? +* | | +--- Unused +* | +--- Unused * +--- Unused */ #define ACPI_GPE_XRUPT_TYPE_MASK (u8) 0x01#define ACPI_GPE_LEVEL_TRIGGERED (u8) 0x01#define ACPI_GPE_EDGE_TRIGGERED (u8) 0x00 -#define ACPI_GPE_TYPE_MASK (u8) 0x06 -#define ACPI_GPE_TYPE_WAKE_RUN (u8) 0x06 -#define ACPI_GPE_TYPE_WAKE (u8) 0x02 -#define ACPI_GPE_TYPE_RUNTIME (u8) 0x04/* Default */ +#define ACPI_GPE_CAN_WAKE (u8) 0x02#define ACPI_GPE_DISPATCH_MASK (u8) 0x18#define ACPI_GPE_DISPATCH_HANDLER (u8) 0x08#define ACPI_GPE_DISPATCH_METHOD (u8) 0x10#define ACPI_GPE_DISPATCH_NOT_USED (u8) 0x00/* Default */ -#define ACPI_GPE_RUN_ENABLE_MASK (u8) 0x20 -#define ACPI_GPE_RUN_ENABLED (u8) 0x20 -#define ACPI_GPE_RUN_DISABLED (u8) 0x00/* Default */ - -#define ACPI_GPE_WAKE_ENABLE_MASK (u8) 0x40 -#define ACPI_GPE_WAKE_ENABLED (u8) 0x40 -#define ACPI_GPE_WAKE_DISABLED (u8) 0x00/* Default */ - -#define ACPI_GPE_ENABLE_MASK (u8) 0x60/* Both run/wake */ -/* * Flags for GPE and Lock interfaces */
RFC PATCH 8/10 ACPI / PM: Add more run-time wake-up fields
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Use the run_wake flag to mark all devices for which run-time wake-up events may be generated by the platform. Introduce a new wake-up flag, special, for marking devices that should be permanently enabled to generate run-time events. Also, introduce a reference counter for run-wake devices and a function that will initialize all of the run-time wake-up fields for given device.
--- drivers/acpi/button.c | 2 ++ drivers/acpi/scan.c | 37 +++++++++++++++++++++++++++---------- drivers/acpi/wakeup.c | 2 +- include/acpi/acpi_bus.h | 2 ++ 4 files changed, 32 insertions(+), 11 deletions(-)
drivers/acpi/wakeup.c +1 -1
@@ -106,7 +106,7 @@ int __init acpi_wakeup_device_init(void) struct acpi_device, wakeup_list);/* In case user doesn't load button driver */ -if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled) +if (!dev->wakeup.flags.special || dev->wakeup.state.enabled)continue ;acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number);
include/acpi/acpi_bus.h +2 -0
@@ -242,6 +242,7 @@ struct acpi_device_perf {struct acpi_device_wakeup_flags {u8 valid:1 ;/* Can successfully enable wakeup? */ u8 run_wake:1 ;/* Run-Wake GPE devices */ +u8 special:1 ;/* Run-wake devices that are always enabled */ };struct acpi_device_wakeup_state {
@@ -256,6 +257,7 @@ struct acpi_device_wakeup {struct acpi_device_wakeup_state state;struct acpi_device_wakeup_flags flags;int prepare_count; +int run_wake_count; };/* Device */
drivers/acpi/button.c +2 -0
@@ -419,6 +419,7 @@ static int acpi_button_add(struct acpi_d device->wakeup.gpe_number);acpi_ref_wakeup_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); + device->wakeup.run_wake_count++; device->wakeup.state.enabled =1 ; }
@@ -443,6 +444,7 @@ static int acpi_button_remove(struct acp device->wakeup.gpe_number);acpi_unref_wakeup_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); + device->wakeup.run_wake_count--; device->wakeup.state.enabled =0 ; }
drivers/acpi/scan.c +27 -10
@@ -742,19 +742,39 @@ acpi_bus_extract_wakeup_device_power_pacreturn AE_OK ; } -static int acpi_bus_get_wakeup_device_flags (struct acpi_device *device) +static void acpi_bus_set_run_wake_flags (struct acpi_device *device) { -acpi_status status =0 ; -struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; -union acpi_object *package =NULL ; -int psw_error; -struct acpi_device_id button_device_ids[] = { {"PNP0C0D" ,0 }, {"PNP0C0C" ,0 }, {"PNP0C0E" ,0 }, {"" ,0 }, }; +acpi_status status; +acpi_event_status event_status; + + device->wakeup.run_wake_count =0 ; + +/* Power button, Lid switch always enable wakeup */ +if (!acpi_match_device_ids (device, button_device_ids)) { + device->wakeup.flags.run_wake =1 ; + device->wakeup.flags.special =1 ; +return ; + } + + status =acpi_get_gpe_status (NULL , device->wakeup.gpe_number, +ACPI_NOT_ISR , &event_status); +if (status ==AE_OK ) + device->wakeup.flags.run_wake = + !!(event_status &ACPI_EVENT_FLAG_HANDLE ); +} + +static int acpi_bus_get_wakeup_device_flags (struct acpi_device *device) +{ +acpi_status status =0 ; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *package =NULL ; +int psw_error;/* _PRW */ status =acpi_evaluate_object (device->handle,"_PRW" ,NULL , &buffer);
@@ -774,6 +794,7 @@ static int acpi_bus_get_wakeup_device_fl device->wakeup.flags.valid =1 ; device->wakeup.prepare_count =0 ; +acpi_bus_set_run_wake_flags (device);/* Call _PSW/_DSW object to disable its ability to wake the sleeping * system for the ACPI device with the _PRW object. * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
@@ -785,10 +806,6 @@ static int acpi_bus_get_wakeup_device_flACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"error in _DSW or _PSW evaluation\n" )); -/* Power button, Lid switch always enable wakeup */ -if (!acpi_match_device_ids (device, button_device_ids)) - device->wakeup.flags.run_wake =1 ; - end:if (ACPI_FAILURE (status)) device->flags.wake_capable =0 ;
RFC PATCH 8/10 ACPI / PM: Add more run-time wake-up fields
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Use the run_wake flag to mark all devices for which run-time wake-up events may be generated by the platform. Introduce a new wake-up flag, special, for marking devices that should be permanently enabled to generate run-time events. Also, introduce a reference counter for run-wake devices and a function that will initialize all of the run-time wake-up fields for given device.
--- drivers/acpi/button.c | 2 ++ drivers/acpi/scan.c | 37 +++++++++++++++++++++++++++---------- drivers/acpi/wakeup.c | 2 +- include/acpi/acpi_bus.h | 2 ++ 4 files changed, 32 insertions(+), 11 deletions(-)
drivers/acpi/wakeup.c +1 -1
@@ -106,7 +106,7 @@ int __init acpi_wakeup_device_init(void) struct acpi_device, wakeup_list);/* In case user doesn't load button driver */ -if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled) +if (!dev->wakeup.flags.special || dev->wakeup.state.enabled)continue ;acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number);
include/acpi/acpi_bus.h +2 -0
@@ -242,6 +242,7 @@ struct acpi_device_perf {struct acpi_device_wakeup_flags {u8 valid:1 ;/* Can successfully enable wakeup? */ u8 run_wake:1 ;/* Run-Wake GPE devices */ +u8 special:1 ;/* Run-wake devices that are always enabled */ };struct acpi_device_wakeup_state {
@@ -256,6 +257,7 @@ struct acpi_device_wakeup {struct acpi_device_wakeup_state state;struct acpi_device_wakeup_flags flags;int prepare_count; +int run_wake_count; };/* Device */
drivers/acpi/button.c +2 -0
@@ -419,6 +419,7 @@ static int acpi_button_add(struct acpi_d device->wakeup.gpe_number);acpi_ref_wakeup_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); + device->wakeup.run_wake_count++; device->wakeup.state.enabled =1 ; }
@@ -443,6 +444,7 @@ static int acpi_button_remove(struct acp device->wakeup.gpe_number);acpi_unref_wakeup_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); + device->wakeup.run_wake_count--; device->wakeup.state.enabled =0 ; }
drivers/acpi/scan.c +27 -10
@@ -742,19 +742,39 @@ acpi_bus_extract_wakeup_device_power_pacreturn AE_OK ; } -static int acpi_bus_get_wakeup_device_flags (struct acpi_device *device) +static void acpi_bus_set_run_wake_flags (struct acpi_device *device) { -acpi_status status =0 ; -struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; -union acpi_object *package =NULL ; -int psw_error; -struct acpi_device_id button_device_ids[] = { {"PNP0C0D" ,0 }, {"PNP0C0C" ,0 }, {"PNP0C0E" ,0 }, {"" ,0 }, }; +acpi_status status; +acpi_event_status event_status; + + device->wakeup.run_wake_count =0 ; + +/* Power button, Lid switch always enable wakeup */ +if (!acpi_match_device_ids (device, button_device_ids)) { + device->wakeup.flags.run_wake =1 ; + device->wakeup.flags.special =1 ; +return ; + } + + status =acpi_get_gpe_status (NULL , device->wakeup.gpe_number, +ACPI_NOT_ISR , &event_status); +if (status ==AE_OK ) + device->wakeup.flags.run_wake = + !!(event_status &ACPI_EVENT_FLAG_HANDLE ); +} + +static int acpi_bus_get_wakeup_device_flags (struct acpi_device *device) +{ +acpi_status status =0 ; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *package =NULL ; +int psw_error;/* _PRW */ status =acpi_evaluate_object (device->handle,"_PRW" ,NULL , &buffer);
@@ -774,6 +794,7 @@ static int acpi_bus_get_wakeup_device_fl device->wakeup.flags.valid =1 ; device->wakeup.prepare_count =0 ; +acpi_bus_set_run_wake_flags (device);/* Call _PSW/_DSW object to disable its ability to wake the sleeping * system for the ACPI device with the _PRW object. * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
@@ -785,10 +806,6 @@ static int acpi_bus_get_wakeup_device_flACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"error in _DSW or _PSW evaluation\n" )); -/* Power button, Lid switch always enable wakeup */ -if (!acpi_match_device_ids (device, button_device_ids)) - device->wakeup.flags.run_wake =1 ; - end:if (ACPI_FAILURE (status)) device->flags.wake_capable =0 ;
RFC PATCH 9/10 PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 3)
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-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 new PCI platform callback ->test_run_wake() and ->run_wake() to struct pci_platform_pm_ops allowing us, respectively, to check if if the platform can generate run-time wake-up events for given device and to enable/disable the platform to do that. Implemet these callbacks 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_dev_run_wake() which can be used by PCI drivers to check if given device is capable of generating wake-up events at run time.
Developed in cooperation with Matthew Garrett <[email protected]>.
--- drivers/acpi/pci_bind.c | 13 + drivers/acpi/pci_root.c | 7 drivers/acpi/sleep.c | 22 +- drivers/pci/hotplug/acpiphp_glue.c | 23 -- drivers/pci/pci-acpi.c | 399 +++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 50 ++++ drivers/pci/pci.h | 12 + include/acpi/acpi_bus.h | 11 - include/linux/pci-acpi.h | 24 ++ include/linux/pci.h | 1 kernel/power/Kconfig | 5 11 files changed, 543 insertions(+), 24 deletions(-)
drivers/pci/pci.h +12 -0
@@ -35,6 +35,10 @@ int pci_probe_reset_function(struct pci_* * @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 +* 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,24 @@ 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 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 +399 -0
420 lines not on this page · raw message
drivers/pci/pci.c +50 -0
74 lines not on this page · raw message
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 +16 -6
@@ -626,7 +626,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
@@ -712,6 +712,18 @@ int acpi_pm_device_sleep_state(struct de }/** +* acpi_pm_wake_up_power - Enable/disable device wake-up power. +* @dev: ACPI device to handle. +* @enable: Whether to enable or disable the wake-up power of the device. +*/ +int acpi_pm_wake_up_power (struct acpi_device *dev,bool enable) +{ +return enable ? +acpi_enable_wakeup_device_power (dev, acpi_target_sleep_state) : +acpi_disable_wakeup_device_power (dev); +} + +/** * acpi_pm_device_sleep_wake - enable or disable the system wake-up * capability of given device * @dev: device to handle
@@ -732,16 +744,14 @@ int acpi_pm_device_sleep_wake(struct dev return -ENODEV; } - error = enable ? -acpi_enable_wakeup_device_power (adev, acpi_target_sleep_state) : -acpi_disable_wakeup_device_power (adev); + error =acpi_pm_wake_up_power (adev, enable);if (!error) -dev_info (dev,"wake-up capability %s by ACPI\n" , +dev_info (dev,"wake-up power %s by ACPI\n" , enable ?"enabled" :"disabled" );return error; } -#endif +#endif /* CONFIG_PM_WAKEUP */ static void acpi_power_off_prepare (void ) {
drivers/acpi/pci_root.c +7 -0
@@ -30,6 +30,7 @@#include <linux/proc_fs.h> #include <linux/spinlock.h> #include <linux/pm.h> +#include <linux/pm_runtime.h> #include <linux/pci.h> #include <linux/pci-acpi.h> #include <linux/acpi.h>
@@ -576,6 +577,9 @@ static int __devinit acpi_pci_root_add(sif (flags != base_flags)acpi_pci_osc_support (root, flags); +if (!pci_acpi_add_bus_pm_notifier (device, root->bus)) +device_set_run_wake (root->bus->bridge, true); +return 0 ; end:
@@ -597,6 +601,9 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device); +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (root->bus->bridge, false); +kfree (root);return 0 ; }
include/linux/pci-acpi.h +24 -0
@@ -11,6 +11,30 @@#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_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev, +struct pci_bus *pci_bus); +extern acpi_status pci_acpi_remove_pm_notifier (struct acpi_device *dev); + +static inline +acpi_status pci_acpi_add_device_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev) +{ +return pci_acpi_add_pm_notifier (dev, pci_dev, pci_dev->subordinate); +} + +static inline +acpi_status pci_acpi_add_bus_pm_notifier (struct acpi_device *dev, +struct pci_bus *pci_bus) +{ +return pci_acpi_add_pm_notifier (dev,NULL , pci_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 +12 -1
@@ -26,7 +26,9 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/pci.h> +#include <linux/pci-acpi.h> #include <linux/acpi.h> +#include <linux/pm_runtime.h> #include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h>
@@ -38,7 +40,13 @@ 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; + +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (&dev->dev, false); + +if (!dev->subordinate) goto out;acpi_pci_irq_del_prt (dev->subordinate);
@@ -62,6 +70,9 @@ static int acpi_pci_bind(struct acpi_devif (!dev)return 0 ; +if (!pci_acpi_add_device_pm_notifier (device, dev)) +device_set_run_wake (&dev->dev, true); +/* * Install the 'bind' function to facilitate callbacks for * children of the P2P bridge.
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 ;
include/linux/pci.h +1 -0
@@ -743,6 +743,7 @@ int pci_wake_from_d3(struct pci_dev *devpci_power_t pci_target_state (struct pci_dev *dev);int pci_prepare_to_sleep (struct pci_dev *dev);int pci_back_from_sleep (struct pci_dev *dev); +bool pci_dev_run_wake (struct pci_dev *dev);/* Functions for PCI Hotplug drivers to use */ int pci_bus_find_capability (struct pci_bus *bus,unsigned int devfn,int cap);
include/acpi/acpi_bus.h +8 -3
@@ -388,21 +388,26 @@ 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_wake_up_power (struct acpi_device *,bool );int acpi_pm_device_sleep_wake (struct device *,bool ); -#else /* !CONFIG_PM_SLEEP */ +#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_wake_up_power (struct acpi_device *dev,bool enable) +{ +return -ENODEV ; +}static inline int acpi_pm_device_sleep_wake (struct device *dev,bool enable) {return -ENODEV ; } -#endif /* !CONFIG_PM_SLEEP */ +#endif /* !CONFIG_PM_WAKEUP */ #endif /* CONFIG_ACPI */
Re: [RFC][PATCH 9/10] PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 3)
Quoted 37 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
drivers/pci/pci-acpi.c +36
-0+/** +* pci_acpi_add_pm_notifier - Register PM notifier for given device. +* @dev: ACPI device to add the notifier for. +* @pci_dev: PCI device to check for the PME status if an event is signaled. +* @pci_bus: PCI bus to walk (checking PME status) if an event is signaled. +* +* Check if there is a notifier object for @dev and if that is the case, add +* @pci_dev to it as the device whose PME status should be checked if a PM +* event is signaled for @dev. Also, add @pci_bus to it as the bus to walk +* checking the PME status of all devices on it if a PM event is signaled for +* @dev. Otherwise, create a new notifier object for @dev and add both +* @pci_dev and @pci_bus to it. +*/ +acpi_status pci_acpi_add_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev, +struct pci_bus *pci_bus) +{ +struct pci_acpi_notifier_block *nb; +acpi_status status =AE_OK ; + +if (!dev->wakeup.flags.run_wake) +return AE_BAD_PARAMETER ; + +mutex_lock (&pci_acpi_notifier_mtx); + +list_for_each_entry (nb, &pci_acpi_runtime_notifiers, entry) +if (nb->dev == dev) { +if (nb->pci_dev || nb->pci_bus) + goto out; +else + goto add; + } + + nb =new_notifier (dev); +if (!nb) { + status =AE_NO_MEMORY ;
drivers/pci/pci-acpi.c line 259
Quoted 10 lines
drivers/pci/pci-acpi.c +10
-0+ goto out; + } +list_add_tail (&nb->entry, &pci_acpi_runtime_notifiers); + + status =acpi_install_notify_handler (dev->handle,ACPI_SYSTEM_NOTIFY , + pci_acpi_event_fn, nb); +if (ACPI_FAILURE (status)) { +list_del (&nb->entry); +kfree (nb); + }
I think when nb is freed, it should be go to "out:".
Quoted 17 lines
drivers/pci/pci-acpi.c +17
-0+ + add: + nb->pci_dev = pci_dev; + nb->pci_bus = pci_bus; + + out: +mutex_unlock (&pci_acpi_notifier_mtx); +return status; +} + +/** +* pci_acpi_remove_pm_notifier - Unregister PM notifier for given device. +* @dev: ACPI device to remove the notifier from. +* +* Find the notifier object for @dev and clear its @pci_dev and @pci_bus fields. +* If the notifier object is not necessary any more after that, remove it too. +*/
Re: [RFC][PATCH 9/10] PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 3)
In reply to Rafael J. WysockiQuoted 37 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
drivers/pci/pci-acpi.c +36
-0+/** +* pci_acpi_add_pm_notifier - Register PM notifier for given device. +* @dev: ACPI device to add the notifier for. +* @pci_dev: PCI device to check for the PME status if an event is signaled. +* @pci_bus: PCI bus to walk (checking PME status) if an event is signaled. +* +* Check if there is a notifier object for @dev and if that is the case, add +* @pci_dev to it as the device whose PME status should be checked if a PM +* event is signaled for @dev. Also, add @pci_bus to it as the bus to walk +* checking the PME status of all devices on it if a PM event is signaled for +* @dev. Otherwise, create a new notifier object for @dev and add both +* @pci_dev and @pci_bus to it. +*/ +acpi_status pci_acpi_add_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev, +struct pci_bus *pci_bus) +{ +struct pci_acpi_notifier_block *nb; +acpi_status status =AE_OK ; + +if (!dev->wakeup.flags.run_wake) +return AE_BAD_PARAMETER ; + +mutex_lock (&pci_acpi_notifier_mtx); + +list_for_each_entry (nb, &pci_acpi_runtime_notifiers, entry) +if (nb->dev == dev) { +if (nb->pci_dev || nb->pci_bus) + goto out; +else + goto add; + } + + nb =new_notifier (dev); +if (!nb) { + status =AE_NO_MEMORY ;
drivers/pci/pci-acpi.c line 259
Quoted 10 lines
drivers/pci/pci-acpi.c +10
-0+ goto out; + } +list_add_tail (&nb->entry, &pci_acpi_runtime_notifiers); + + status =acpi_install_notify_handler (dev->handle,ACPI_SYSTEM_NOTIFY , + pci_acpi_event_fn, nb); +if (ACPI_FAILURE (status)) { +list_del (&nb->entry); +kfree (nb); + }
I think when nb is freed, it should be go to "out:".
Quoted 17 lines
drivers/pci/pci-acpi.c +17
-0+ + add: + nb->pci_dev = pci_dev; + nb->pci_bus = pci_bus; + + out: +mutex_unlock (&pci_acpi_notifier_mtx); +return status; +} + +/** +* pci_acpi_remove_pm_notifier - Unregister PM notifier for given device. +* @dev: ACPI device to remove the notifier from. +* +* Find the notifier object for @dev and clear its @pci_dev and @pci_bus fields. +* If the notifier object is not necessary any more after that, remove it too. +*/
Re: [RFC][PATCH 9/10] PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 3)
Quoted 42 lines · Jin Dongming
Quoted 41 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
drivers/pci/pci-acpi.c +40
-0+/** +* pci_acpi_add_pm_notifier - Register PM notifier for given device. +* @dev: ACPI device to add the notifier for. +* @pci_dev: PCI device to check for the PME status if an event is signaled. +* @pci_bus: PCI bus to walk (checking PME status) if an event is signaled. +* +* Check if there is a notifier object for @dev and if that is the case, add +* @pci_dev to it as the device whose PME status should be checked if a PM +* event is signaled for @dev. Also, add @pci_bus to it as the bus to walk +* checking the PME status of all devices on it if a PM event is signaled for +* @dev. Otherwise, create a new notifier object for @dev and add both +* @pci_dev and @pci_bus to it. +*/ +acpi_status pci_acpi_add_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev, +struct pci_bus *pci_bus) +{ +struct pci_acpi_notifier_block *nb; +acpi_status status =AE_OK ; + +if (!dev->wakeup.flags.run_wake) +return AE_BAD_PARAMETER ; + +mutex_lock (&pci_acpi_notifier_mtx); + +list_for_each_entry (nb, &pci_acpi_runtime_notifiers, entry) +if (nb->dev == dev) { +if (nb->pci_dev || nb->pci_bus) + goto out; +else + goto add; + } + + nb =new_notifier (dev); +if (!nb) { + status =AE_NO_MEMORY ; + goto out; + } +list_add_tail (&nb->entry, &pci_acpi_runtime_notifiers); +
Quoted 8 lines
drivers/pci/pci-acpi.c line 259
Quoted 6 lines
drivers/pci/pci-acpi.c +6
-0+ status =acpi_install_notify_handler (dev->handle,ACPI_SYSTEM_NOTIFY , + pci_acpi_event_fn, nb); +if (ACPI_FAILURE (status)) { +list_del (&nb->entry); +kfree (nb); + }I think when nb is freed, it should be go to "out:".
You're absolutely right, thanks for catching this bug.
I'll fix it in the next version of the patch.
Quoted 9 lines
Quoted 9 lines
drivers/pci/pci-acpi.c +9
-0+ + add: + nb->pci_dev = pci_dev; + nb->pci_bus = pci_bus; + + out: +mutex_unlock (&pci_acpi_notifier_mtx); +return status; +}
Quoted 8 lines
drivers/pci/pci-acpi.c line 276
Quoted 8 lines
drivers/pci/pci-acpi.c +8
-0+ +/** +* pci_acpi_remove_pm_notifier - Unregister PM notifier for given device. +* @dev: ACPI device to remove the notifier from. +* +* Find the notifier object for @dev and clear its @pci_dev and @pci_bus fields. +* If the notifier object is not necessary any more after that, remove it too. +*/
Best,
Rafael
Re: [RFC][PATCH 9/10] PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 3)
In reply to Jin DongmingQuoted 42 lines · Jin Dongming
Quoted 41 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
drivers/pci/pci-acpi.c +40
-0+/** +* pci_acpi_add_pm_notifier - Register PM notifier for given device. +* @dev: ACPI device to add the notifier for. +* @pci_dev: PCI device to check for the PME status if an event is signaled. +* @pci_bus: PCI bus to walk (checking PME status) if an event is signaled. +* +* Check if there is a notifier object for @dev and if that is the case, add +* @pci_dev to it as the device whose PME status should be checked if a PM +* event is signaled for @dev. Also, add @pci_bus to it as the bus to walk +* checking the PME status of all devices on it if a PM event is signaled for +* @dev. Otherwise, create a new notifier object for @dev and add both +* @pci_dev and @pci_bus to it. +*/ +acpi_status pci_acpi_add_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev, +struct pci_bus *pci_bus) +{ +struct pci_acpi_notifier_block *nb; +acpi_status status =AE_OK ; + +if (!dev->wakeup.flags.run_wake) +return AE_BAD_PARAMETER ; + +mutex_lock (&pci_acpi_notifier_mtx); + +list_for_each_entry (nb, &pci_acpi_runtime_notifiers, entry) +if (nb->dev == dev) { +if (nb->pci_dev || nb->pci_bus) + goto out; +else + goto add; + } + + nb =new_notifier (dev); +if (!nb) { + status =AE_NO_MEMORY ; + goto out; + } +list_add_tail (&nb->entry, &pci_acpi_runtime_notifiers); +
Quoted 8 lines
drivers/pci/pci-acpi.c line 259
Quoted 6 lines
drivers/pci/pci-acpi.c +6
-0+ status =acpi_install_notify_handler (dev->handle,ACPI_SYSTEM_NOTIFY , + pci_acpi_event_fn, nb); +if (ACPI_FAILURE (status)) { +list_del (&nb->entry); +kfree (nb); + }I think when nb is freed, it should be go to "out:".
You're absolutely right, thanks for catching this bug.
I'll fix it in the next version of the patch.
Quoted 9 lines
Quoted 9 lines
drivers/pci/pci-acpi.c +9
-0+ + add: + nb->pci_dev = pci_dev; + nb->pci_bus = pci_bus; + + out: +mutex_unlock (&pci_acpi_notifier_mtx); +return status; +}
Quoted 8 lines
drivers/pci/pci-acpi.c line 276
Quoted 8 lines
drivers/pci/pci-acpi.c +8
-0+ +/** +* pci_acpi_remove_pm_notifier - Unregister PM notifier for given device. +* @dev: ACPI device to remove the notifier from. +* +* Find the notifier object for @dev and clear its @pci_dev and @pci_bus fields. +* If the notifier object is not necessary any more after that, remove it too. +*/
Best,
Rafael
RFC PATCH 9/10 PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 3)
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-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 new PCI platform callback ->test_run_wake() and ->run_wake() to struct pci_platform_pm_ops allowing us, respectively, to check if if the platform can generate run-time wake-up events for given device and to enable/disable the platform to do that. Implemet these callbacks 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_dev_run_wake() which can be used by PCI drivers to check if given device is capable of generating wake-up events at run time.
Developed in cooperation with Matthew Garrett <[email protected]>.
--- drivers/acpi/pci_bind.c | 13 + drivers/acpi/pci_root.c | 7 drivers/acpi/sleep.c | 22 +- drivers/pci/hotplug/acpiphp_glue.c | 23 -- drivers/pci/pci-acpi.c | 399 +++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 50 ++++ drivers/pci/pci.h | 12 + include/acpi/acpi_bus.h | 11 - include/linux/pci-acpi.h | 24 ++ include/linux/pci.h | 1 kernel/power/Kconfig | 5 11 files changed, 543 insertions(+), 24 deletions(-)
drivers/pci/pci.h +12 -0
@@ -35,6 +35,10 @@ int pci_probe_reset_function(struct pci_* * @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 +* 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,24 @@ 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 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 +399 -0
420 lines not on this page · raw message
drivers/pci/pci.c +50 -0
74 lines not on this page · raw message
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 +16 -6
@@ -626,7 +626,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
@@ -712,6 +712,18 @@ int acpi_pm_device_sleep_state(struct de }/** +* acpi_pm_wake_up_power - Enable/disable device wake-up power. +* @dev: ACPI device to handle. +* @enable: Whether to enable or disable the wake-up power of the device. +*/ +int acpi_pm_wake_up_power (struct acpi_device *dev,bool enable) +{ +return enable ? +acpi_enable_wakeup_device_power (dev, acpi_target_sleep_state) : +acpi_disable_wakeup_device_power (dev); +} + +/** * acpi_pm_device_sleep_wake - enable or disable the system wake-up * capability of given device * @dev: device to handle
@@ -732,16 +744,14 @@ int acpi_pm_device_sleep_wake(struct dev return -ENODEV; } - error = enable ? -acpi_enable_wakeup_device_power (adev, acpi_target_sleep_state) : -acpi_disable_wakeup_device_power (adev); + error =acpi_pm_wake_up_power (adev, enable);if (!error) -dev_info (dev,"wake-up capability %s by ACPI\n" , +dev_info (dev,"wake-up power %s by ACPI\n" , enable ?"enabled" :"disabled" );return error; } -#endif +#endif /* CONFIG_PM_WAKEUP */ static void acpi_power_off_prepare (void ) {
drivers/acpi/pci_root.c +7 -0
@@ -30,6 +30,7 @@#include <linux/proc_fs.h> #include <linux/spinlock.h> #include <linux/pm.h> +#include <linux/pm_runtime.h> #include <linux/pci.h> #include <linux/pci-acpi.h> #include <linux/acpi.h>
@@ -576,6 +577,9 @@ static int __devinit acpi_pci_root_add(sif (flags != base_flags)acpi_pci_osc_support (root, flags); +if (!pci_acpi_add_bus_pm_notifier (device, root->bus)) +device_set_run_wake (root->bus->bridge, true); +return 0 ; end:
@@ -597,6 +601,9 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device); +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (root->bus->bridge, false); +kfree (root);return 0 ; }
include/linux/pci-acpi.h +24 -0
@@ -11,6 +11,30 @@#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_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev, +struct pci_bus *pci_bus); +extern acpi_status pci_acpi_remove_pm_notifier (struct acpi_device *dev); + +static inline +acpi_status pci_acpi_add_device_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev) +{ +return pci_acpi_add_pm_notifier (dev, pci_dev, pci_dev->subordinate); +} + +static inline +acpi_status pci_acpi_add_bus_pm_notifier (struct acpi_device *dev, +struct pci_bus *pci_bus) +{ +return pci_acpi_add_pm_notifier (dev,NULL , pci_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 +12 -1
@@ -26,7 +26,9 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/pci.h> +#include <linux/pci-acpi.h> #include <linux/acpi.h> +#include <linux/pm_runtime.h> #include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h>
@@ -38,7 +40,13 @@ 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; + +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (&dev->dev, false); + +if (!dev->subordinate) goto out;acpi_pci_irq_del_prt (dev->subordinate);
@@ -62,6 +70,9 @@ static int acpi_pci_bind(struct acpi_devif (!dev)return 0 ; +if (!pci_acpi_add_device_pm_notifier (device, dev)) +device_set_run_wake (&dev->dev, true); +/* * Install the 'bind' function to facilitate callbacks for * children of the P2P bridge.
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 ;
include/linux/pci.h +1 -0
@@ -743,6 +743,7 @@ int pci_wake_from_d3(struct pci_dev *devpci_power_t pci_target_state (struct pci_dev *dev);int pci_prepare_to_sleep (struct pci_dev *dev);int pci_back_from_sleep (struct pci_dev *dev); +bool pci_dev_run_wake (struct pci_dev *dev);/* Functions for PCI Hotplug drivers to use */ int pci_bus_find_capability (struct pci_bus *bus,unsigned int devfn,int cap);
include/acpi/acpi_bus.h +8 -3
@@ -388,21 +388,26 @@ 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_wake_up_power (struct acpi_device *,bool );int acpi_pm_device_sleep_wake (struct device *,bool ); -#else /* !CONFIG_PM_SLEEP */ +#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_wake_up_power (struct acpi_device *dev,bool enable) +{ +return -ENODEV ; +}static inline int acpi_pm_device_sleep_wake (struct device *dev,bool enable) {return -ENODEV ; } -#endif /* !CONFIG_PM_SLEEP */ +#endif /* !CONFIG_PM_WAKEUP */ #endif /* CONFIG_ACPI */
RFC PATCH 10/10 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 | 94 ++++++++++++++++++++++++++++++++++++++++++++--- drivers/pci/pci.c | 43 ++++++++++++++++++--- drivers/pci/pci.h | 1 include/linux/pci.h | 9 ++++ kernel/power/Kconfig | 5 ++ 5 files changed, 140 insertions(+), 12 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 +89 -5
137 lines not on this page · raw message
drivers/pci/pci.c +37 -6
89 lines not on this page · raw message
include/linux/pci.h +8 -1
@@ -738,13 +738,20 @@ int pci_set_power_state(struct pci_dev *pci_power_t pci_choose_state (struct pci_dev *dev,pm_message_t state);bool pci_pme_capable (struct pci_dev *dev,pci_power_t state);void pci_pme_active (struct pci_dev *dev,bool enable); -int pci_enable_wake (struct pci_dev *dev,pci_power_t state,bool enable); +int __pci_enable_wake (struct pci_dev *dev,pci_power_t state, +bool runtime,bool enable);int pci_wake_from_d3 (struct pci_dev *dev,bool enable);pci_power_t pci_target_state (struct pci_dev *dev);int pci_prepare_to_sleep (struct pci_dev *dev);int pci_back_from_sleep (struct pci_dev *dev);bool pci_dev_run_wake (struct pci_dev *dev); +static inline int pci_enable_wake (struct pci_dev *dev,pci_power_t state, +bool enable) +{ +return __pci_enable_wake (dev, state, false, enable); +} +/* Functions for PCI Hotplug drivers to use */ int pci_bus_find_capability (struct pci_bus *bus,unsigned int devfn,int cap);#ifdef CONFIG_HOTPLUG
drivers/pci/pci.h +1 -0
@@ -55,6 +55,7 @@ extern int pci_set_platform_pm(struct pcextern 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_finish_runtime_suspend (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);
RFC PATCH 10/10 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 | 94 ++++++++++++++++++++++++++++++++++++++++++++--- drivers/pci/pci.c | 43 ++++++++++++++++++--- drivers/pci/pci.h | 1 include/linux/pci.h | 9 ++++ kernel/power/Kconfig | 5 ++ 5 files changed, 140 insertions(+), 12 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 +89 -5
137 lines not on this page · raw message
drivers/pci/pci.c +37 -6
89 lines not on this page · raw message
include/linux/pci.h +8 -1
@@ -738,13 +738,20 @@ int pci_set_power_state(struct pci_dev *pci_power_t pci_choose_state (struct pci_dev *dev,pm_message_t state);bool pci_pme_capable (struct pci_dev *dev,pci_power_t state);void pci_pme_active (struct pci_dev *dev,bool enable); -int pci_enable_wake (struct pci_dev *dev,pci_power_t state,bool enable); +int __pci_enable_wake (struct pci_dev *dev,pci_power_t state, +bool runtime,bool enable);int pci_wake_from_d3 (struct pci_dev *dev,bool enable);pci_power_t pci_target_state (struct pci_dev *dev);int pci_prepare_to_sleep (struct pci_dev *dev);int pci_back_from_sleep (struct pci_dev *dev);bool pci_dev_run_wake (struct pci_dev *dev); +static inline int pci_enable_wake (struct pci_dev *dev,pci_power_t state, +bool enable) +{ +return __pci_enable_wake (dev, state, false, enable); +} +/* Functions for PCI Hotplug drivers to use */ int pci_bus_find_capability (struct pci_bus *bus,unsigned int devfn,int cap);#ifdef CONFIG_HOTPLUG
drivers/pci/pci.h +1 -0
@@ -55,6 +55,7 @@ extern int pci_set_platform_pm(struct pcextern 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_finish_runtime_suspend (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);
cover PCI run-time PM support (updated)
In reply to Rafael J. WysockiHi,
The following (updated) series of patches provides preliminary run-time power management support for PCI devices through ACPI and/or the native PCIe PME.
Some patches have been modified since the previous iteration and two new patches have been added. Also, I've tested this patchset with the native PCIe PME mechanism using the r8169 driver on the MSI Wind U-100 (see the last patch for details).
[1/12] - Add flag for marking devices capable of generating wake-up events at run time
[2/12] - Add function for checking PME status of devices
[3/12] - Modify wake-up enable propagation so that it's done for PCIe devices too
[4/12] - PCIe PME root port service driver
[5/12][New] - "Don't use MSIs for PME signaling" switch for PCIe
[6/12] - ACPI GPE refcounting, from Matthew
[7/12] - ACPI drivers support for GPE refcounting, from Matthew
[8/12] - ACPI removal of the old GPE API, from Matthew
[9/12] - ACPI add fields for handling run-wake devices
[10/12] - PCI ACPI platform support for run-time power management
[11/12] - Runtime PM callbacks for the PCI bus type
[12/12] - Runtime PM support for r8169 (experimental)
If there are no objections, I think the patches [1-11/12] are ready for merging at this point.
Thanks,
Rafael
RFC PATCH 1/12 PM: Add flag for devices capable of generating run-time wake-up events
From: Rafael J. Wysocki <[email protected]>
Apparently, there are devices that can wake up the system from sleep states and yet are incapable of generating wake-up events at run time. Thus, introduce a flag indicating if given device is capable of generating run-time wake-up events.
--- Documentation/power/runtime_pm.txt | 7 +++++-- include/linux/pm.h | 8 +++++--- include/linux/pm_runtime.h | 12 ++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-)
include/linux/pm.h +5 -3
@@ -179,9 +179,10 @@ typedef struct pm_message {* This need not mean that the device should be put into a low power state. * For example, if the device is behind a link which is about to be turned * off, the device may remain at full power. If the device does go to low -* power and if device_may_wakeup(dev) is true, remote wake-up (i.e., a -* hardware mechanism allowing the device to request a change of its power -* state, such as PCI PME) should be enabled for it. +* power and is capable of generating run-time wake-up events, remote +* wake-up (i.e., a hardware mechanism allowing the device to request a +* change of its power state via a wake-up event, such as PCI PME) should +* be enabled for it. * * @runtime_resume: Put the device into the fully active state in response to a * wake-up event generated by hardware or at the request of software. If
@@ -434,6 +435,7 @@ struct dev_pm_info { unsigned int idle_notification:1; unsigned int request_pending:1; unsigned int deferred_resume:1; + unsigned int run_wake:1;enum rpm_request request;enum rpm_status runtime_status;int runtime_error;
Documentation/power/runtime_pm.txt +5 -2
@@ -71,9 +71,9 @@ what to do to handle the device). purpose). In particular, if the driver requires remote wakeup capability for proper -functioning and device_may_wakeup() returns 'false' for the device, then +functioning and device_run_wake() returns 'false' for the device, then ->runtime_suspend() should return -EBUSY. On the other hand, if -device_may_wakeup() returns 'true' for the device and the device is put +device_run_wake() returns 'true' for the device and the device is put into a low power state during the execution of its bus type's ->runtime_suspend(), it is expected that remote wake-up (i.e. hardware mechanism allowing the device to request a change of its power state, such as PCI PME)
@@ -214,6 +214,9 @@ defined in include/linux/pm.h: being executed for that device and it is not practical to wait for the suspend to complete; means "start a resume as soon as you've suspended" + unsigned int run_wake; + - set if the device is capable of generating run-time wake-up events + enum rpm_status runtime_status; - the run-time PM status of the device; this field's initial value is RPM_SUSPENDED, which means that each device is initially regarded by the
include/linux/pm_runtime.h +12 -0
@@ -50,6 +50,16 @@ static inline void pm_runtime_put_noidle atomic_add_unless(&dev->power.usage_count, -1, 0); } +static inline bool device_run_wake (struct device *dev) +{ +return dev->power.run_wake; +} + +static inline void device_set_run_wake (struct device *dev,bool enable) +{ + dev->power.run_wake = enable; +} +#else /* !CONFIG_PM_RUNTIME */ static inline int pm_runtime_idle (struct device *dev) {return -ENOSYS ; }
@@ -73,6 +83,8 @@ static inline bool pm_children_suspendedstatic inline void pm_suspend_ignore_children (struct device *dev,bool en) {}static inline void pm_runtime_get_noresume (struct device *dev) {}static inline void pm_runtime_put_noidle (struct device *dev) {} +static inline bool device_run_wake (struct device *dev) {return false; } +static inline void device_set_run_wake (struct device *dev,bool enable) {}#endif /* !CONFIG_PM_RUNTIME */
RFC PATCH 1/12 PM: Add flag for devices capable of generating run-time wake-up events
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Apparently, there are devices that can wake up the system from sleep states and yet are incapable of generating wake-up events at run time. Thus, introduce a flag indicating if given device is capable of generating run-time wake-up events.
--- Documentation/power/runtime_pm.txt | 7 +++++-- include/linux/pm.h | 8 +++++--- include/linux/pm_runtime.h | 12 ++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-)
include/linux/pm.h +5 -3
@@ -179,9 +179,10 @@ typedef struct pm_message {* This need not mean that the device should be put into a low power state. * For example, if the device is behind a link which is about to be turned * off, the device may remain at full power. If the device does go to low -* power and if device_may_wakeup(dev) is true, remote wake-up (i.e., a -* hardware mechanism allowing the device to request a change of its power -* state, such as PCI PME) should be enabled for it. +* power and is capable of generating run-time wake-up events, remote +* wake-up (i.e., a hardware mechanism allowing the device to request a +* change of its power state via a wake-up event, such as PCI PME) should +* be enabled for it. * * @runtime_resume: Put the device into the fully active state in response to a * wake-up event generated by hardware or at the request of software. If
@@ -434,6 +435,7 @@ struct dev_pm_info { unsigned int idle_notification:1; unsigned int request_pending:1; unsigned int deferred_resume:1; + unsigned int run_wake:1;enum rpm_request request;enum rpm_status runtime_status;int runtime_error;
Documentation/power/runtime_pm.txt +5 -2
@@ -71,9 +71,9 @@ what to do to handle the device). purpose). In particular, if the driver requires remote wakeup capability for proper -functioning and device_may_wakeup() returns 'false' for the device, then +functioning and device_run_wake() returns 'false' for the device, then ->runtime_suspend() should return -EBUSY. On the other hand, if -device_may_wakeup() returns 'true' for the device and the device is put +device_run_wake() returns 'true' for the device and the device is put into a low power state during the execution of its bus type's ->runtime_suspend(), it is expected that remote wake-up (i.e. hardware mechanism allowing the device to request a change of its power state, such as PCI PME)
@@ -214,6 +214,9 @@ defined in include/linux/pm.h: being executed for that device and it is not practical to wait for the suspend to complete; means "start a resume as soon as you've suspended" + unsigned int run_wake; + - set if the device is capable of generating run-time wake-up events + enum rpm_status runtime_status; - the run-time PM status of the device; this field's initial value is RPM_SUSPENDED, which means that each device is initially regarded by the
include/linux/pm_runtime.h +12 -0
@@ -50,6 +50,16 @@ static inline void pm_runtime_put_noidle atomic_add_unless(&dev->power.usage_count, -1, 0); } +static inline bool device_run_wake (struct device *dev) +{ +return dev->power.run_wake; +} + +static inline void device_set_run_wake (struct device *dev,bool enable) +{ + dev->power.run_wake = enable; +} +#else /* !CONFIG_PM_RUNTIME */ static inline int pm_runtime_idle (struct device *dev) {return -ENOSYS ; }
@@ -73,6 +83,8 @@ static inline bool pm_children_suspendedstatic inline void pm_suspend_ignore_children (struct device *dev,bool en) {}static inline void pm_runtime_get_noresume (struct device *dev) {}static inline void pm_runtime_put_noidle (struct device *dev) {} +static inline bool device_run_wake (struct device *dev) {return false; } +static inline void device_set_run_wake (struct device *dev,bool enable) {}#endif /* !CONFIG_PM_RUNTIME */
RFC PATCH 2/12 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 and if set, clear it and clear PME enable +* (if set). Return 'true' if PME status and PME enable were both set 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 ; +pci_read_config_word (dev, pmcsr_pos, &pmcsr); +if (!(pmcsr &PCI_PM_CTRL_PME_STATUS )) +return false; + +/* Clear PME status. */ + pmcsr |=PCI_PM_CTRL_PME_STATUS ; +if (pmcsr &PCI_PM_CTRL_PME_ENABLE ) { +/* Disable PME to avoid interrupt flood. */ + 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/12 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 and if set, clear it and clear PME enable +* (if set). Return 'true' if PME status and PME enable were both set 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 ; +pci_read_config_word (dev, pmcsr_pos, &pmcsr); +if (!(pmcsr &PCI_PM_CTRL_PME_STATUS )) +return false; + +/* Clear PME status. */ + pmcsr |=PCI_PM_CTRL_PME_STATUS ; +if (pmcsr &PCI_PM_CTRL_PME_ENABLE ) { +/* Disable PME to avoid interrupt flood. */ + 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 3/12 PCI / PM: Propagate wake-up enable for PCIe devices too
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Having read the PM part of the PCIe 2.0 specification more carefully I think that it was a mistake to restrict the wake-up enable propagation to non-PCIe devices, because if we do not request control of the root ports' PME registers via OSC, PCIe PME is supposed to be handled by the platform, just like the non-PCIe PME. Even if we do that, the wake-up propagation is done to allow the devices to wake up the system from sleep states which involves the platform anyway, so it won't hurt.
--- drivers/pci/pci-acpi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/pci/pci-acpi.c +2 -8
@@ -112,11 +112,7 @@ static bool acpi_pci_can_wakeup(struct pstatic void acpi_pci_propagate_wakeup_enable (struct pci_bus *bus,bool enable) {while (bus->parent) { -struct pci_dev *bridge = bus->self; -int ret; - - ret =acpi_pm_device_sleep_wake (&bridge->dev, enable); -if (!ret || bridge->is_pcie) +if (!acpi_pm_device_sleep_wake (&bus->self->dev, enable))return ; bus = bus->parent; }
@@ -131,9 +127,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) -acpi_pci_propagate_wakeup_enable (dev->bus, enable); - +acpi_pci_propagate_wakeup_enable (dev->bus, enable);return 0 ; }
Re: [RFC][PATCH 3/12] PCI / PM: Propagate wake-up enable for PCIe devices too
Quoted 11 lines · On Sun, 29 Nov 2009 16:35:54 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
From: Rafael J. Wysocki <[email protected]>
Having read the PM part of the PCIe 2.0 specification more carefully I think that it was a mistake to restrict the wake-up enable propagation to non-PCIe devices, because if we do not request control of the root ports' PME registers via OSC, PCIe PME is supposed to be handled by the platform, just like the non-PCIe PME. Even if we do that, the wake-up propagation is done to allow the devices to wake up the system from sleep states which involves the platform anyway, so it won't hurt.
Quoted 4 lines
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/pci/pci-acpi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
Applied after fixing up conflicts related to dev->is_pcie.
Thanks,
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Re: [RFC][PATCH 3/12] PCI / PM: Propagate wake-up enable for PCIe devices too
Quoted 14 lines · Jesse Barnes
Quoted 11 lines · On Sun, 29 Nov 2009 16:35:54 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
From: Rafael J. Wysocki <[email protected]>
Having read the PM part of the PCIe 2.0 specification more carefully I think that it was a mistake to restrict the wake-up enable propagation to non-PCIe devices, because if we do not request control of the root ports' PME registers via OSC, PCIe PME is supposed to be handled by the platform, just like the non-PCIe PME. Even if we do that, the wake-up propagation is done to allow the devices to wake up the system from sleep states which involves the platform anyway, so it won't hurt.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/pci/pci-acpi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)Applied after fixing up conflicts related to
dev->is_pcie.
Thanks!
Re: [RFC][PATCH 3/12] PCI / PM: Propagate wake-up enable for PCIe devices too
In reply to Jesse BarnesQuoted 14 lines · Jesse Barnes
Quoted 11 lines · On Sun, 29 Nov 2009 16:35:54 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
From: Rafael J. Wysocki <[email protected]>
Having read the PM part of the PCIe 2.0 specification more carefully I think that it was a mistake to restrict the wake-up enable propagation to non-PCIe devices, because if we do not request control of the root ports' PME registers via OSC, PCIe PME is supposed to be handled by the platform, just like the non-PCIe PME. Even if we do that, the wake-up propagation is done to allow the devices to wake up the system from sleep states which involves the platform anyway, so it won't hurt.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/pci/pci-acpi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)Applied after fixing up conflicts related to
dev->is_pcie.
Thanks!
Re: [RFC][PATCH 3/12] PCI / PM: Propagate wake-up enable for PCIe devices too
In reply to Rafael J. WysockiQuoted 11 lines · On Sun, 29 Nov 2009 16:35:54 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
From: Rafael J. Wysocki <[email protected]>
Having read the PM part of the PCIe 2.0 specification more carefully I think that it was a mistake to restrict the wake-up enable propagation to non-PCIe devices, because if we do not request control of the root ports' PME registers via OSC, PCIe PME is supposed to be handled by the platform, just like the non-PCIe PME. Even if we do that, the wake-up propagation is done to allow the devices to wake up the system from sleep states which involves the platform anyway, so it won't hurt.
Quoted 4 lines
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/pci/pci-acpi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
Applied after fixing up conflicts related to dev->is_pcie.
Thanks,
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
RFC PATCH 4/12 PCI PM: PCIe PME root port service driver (rev. 5)
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]>.
--- Documentation/kernel-parameters.txt | 6 drivers/pci/pcie/Kconfig | 4 drivers/pci/pcie/Makefile | 2 drivers/pci/pcie/pme/Makefile | 8 drivers/pci/pcie/pme/pcie_pme.c | 495 +++++++++++++++++++++++++++++++++++ drivers/pci/pcie/pme/pcie_pme.h | 28 + drivers/pci/pcie/pme/pcie_pme_acpi.c | 54 +++ include/linux/pci.h | 1 8 files changed, 598 insertions(+)
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 +495 -0
495 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 +1 -0
@@ -238,6 +238,7 @@ struct pci_dev {configuration space */ unsigned int pme_support:5; /* Bitmask of states from which PME#can be generated */ + unsigned int pme_interrupt:1; unsigned int d1_support:1; /* Low power state D1 is supported */ unsigned int d2_support:1; /* Low power state D2 is supported */ unsigned int no_d1d2:1; /* Only allow D0 and D3 */
Documentation/kernel-parameters.txt +6 -0
@@ -1966,6 +1966,12 @@ and is between 256 and 4096 characters. force Enable ASPM even on devices that claim not to support it. WARNING: Forcing ASPM on may cause system lockups. + pcie_pme= [PCIE,PM] Native PCIe PME signaling options: + off Do not use native PCIe PME signaling. + force Use native PCIe PME signaling even if the BIOS refuses + to allow the kernel to control the relevant PCIe config + registers. + pcmv= [HW,PCMCIA] BadgePAD 4 pd. [PARIDE]
RFC PATCH 4/12 PCI PM: PCIe PME root port service driver (rev. 5) (updated)
Quoted 20 lines · Rafael J. Wysocki
From: 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.
...
Review
Quoted 5 lines
(quoted diff) +5
-0+/** + * pcie_pme_remove - Prepare PCIe PME service device for removal. + * @srv - PCIe service device to resume. + */ +static int pcie_pme_remove(struct pcie_device *srv)
This should be a void function. Fixed patch is appended.
Review
Quoted 7 lines
(quoted diff) +7
-0+{ + pcie_pme_suspend(srv); + free_irq(srv->irq, srv); + kfree(get_service_data(srv)); + + return 0; +}
---
From: Rafael J. Wysocki <[email protected]>
Subject: PCI PM: PCIe PME root port service driver (rev. 5)
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]>.
--- Documentation/kernel-parameters.txt | 6 drivers/pci/pcie/Kconfig | 4 drivers/pci/pcie/Makefile | 2 drivers/pci/pcie/pme/Makefile | 8 drivers/pci/pcie/pme/pcie_pme.c | 493 +++++++++++++++++++++++++++++++++++ drivers/pci/pcie/pme/pcie_pme.h | 28 + drivers/pci/pcie/pme/pcie_pme_acpi.c | 54 +++ include/linux/pci.h | 1 8 files changed, 596 insertions(+)
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 +493 -0
493 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 +1 -0
@@ -238,6 +238,7 @@ struct pci_dev {configuration space */ unsigned int pme_support:5; /* Bitmask of states from which PME#can be generated */ + unsigned int pme_interrupt:1; unsigned int d1_support:1; /* Low power state D1 is supported */ unsigned int d2_support:1; /* Low power state D2 is supported */ unsigned int no_d1d2:1; /* Only allow D0 and D3 */
Documentation/kernel-parameters.txt +6 -0
@@ -1966,6 +1966,12 @@ and is between 256 and 4096 characters. force Enable ASPM even on devices that claim not to support it. WARNING: Forcing ASPM on may cause system lockups. + pcie_pme= [PCIE,PM] Native PCIe PME signaling options: + off Do not use native PCIe PME signaling. + force Use native PCIe PME signaling even if the BIOS refuses + to allow the kernel to control the relevant PCIe config + registers. + pcmv= [HW,PCMCIA] BadgePAD 4 pd. [PARIDE]
RFC PATCH 4/12 PCI PM: PCIe PME root port service driver (rev. 5) (updated)
In reply to Rafael J. WysockiQuoted 20 lines · Rafael J. Wysocki
From: 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.
...
Review
Quoted 5 lines
(quoted diff) +5
-0+/** + * pcie_pme_remove - Prepare PCIe PME service device for removal. + * @srv - PCIe service device to resume. + */ +static int pcie_pme_remove(struct pcie_device *srv)
This should be a void function. Fixed patch is appended.
Review
Quoted 7 lines
(quoted diff) +7
-0+{ + pcie_pme_suspend(srv); + free_irq(srv->irq, srv); + kfree(get_service_data(srv)); + + return 0; +}
---
From: Rafael J. Wysocki <[email protected]>
Subject: PCI PM: PCIe PME root port service driver (rev. 5)
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]>.
--- Documentation/kernel-parameters.txt | 6 drivers/pci/pcie/Kconfig | 4 drivers/pci/pcie/Makefile | 2 drivers/pci/pcie/pme/Makefile | 8 drivers/pci/pcie/pme/pcie_pme.c | 493 +++++++++++++++++++++++++++++++++++ drivers/pci/pcie/pme/pcie_pme.h | 28 + drivers/pci/pcie/pme/pcie_pme_acpi.c | 54 +++ include/linux/pci.h | 1 8 files changed, 596 insertions(+)
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 +493 -0
493 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 +1 -0
@@ -238,6 +238,7 @@ struct pci_dev {configuration space */ unsigned int pme_support:5; /* Bitmask of states from which PME#can be generated */ + unsigned int pme_interrupt:1; unsigned int d1_support:1; /* Low power state D1 is supported */ unsigned int d2_support:1; /* Low power state D2 is supported */ unsigned int no_d1d2:1; /* Only allow D0 and D3 */
Documentation/kernel-parameters.txt +6 -0
@@ -1966,6 +1966,12 @@ and is between 256 and 4096 characters. force Enable ASPM even on devices that claim not to support it. WARNING: Forcing ASPM on may cause system lockups. + pcie_pme= [PCIE,PM] Native PCIe PME signaling options: + off Do not use native PCIe PME signaling. + force Use native PCIe PME signaling even if the BIOS refuses + to allow the kernel to control the relevant PCIe config + registers. + pcmv= [HW,PCMCIA] BadgePAD 4 pd. [PARIDE]
RFC PATCH 4/12 PCI PM: PCIe PME root port service driver (rev. 5)
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]>.
--- Documentation/kernel-parameters.txt | 6 drivers/pci/pcie/Kconfig | 4 drivers/pci/pcie/Makefile | 2 drivers/pci/pcie/pme/Makefile | 8 drivers/pci/pcie/pme/pcie_pme.c | 495 +++++++++++++++++++++++++++++++++++ drivers/pci/pcie/pme/pcie_pme.h | 28 + drivers/pci/pcie/pme/pcie_pme_acpi.c | 54 +++ include/linux/pci.h | 1 8 files changed, 598 insertions(+)
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 +495 -0
495 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 +1 -0
@@ -238,6 +238,7 @@ struct pci_dev {configuration space */ unsigned int pme_support:5; /* Bitmask of states from which PME#can be generated */ + unsigned int pme_interrupt:1; unsigned int d1_support:1; /* Low power state D1 is supported */ unsigned int d2_support:1; /* Low power state D2 is supported */ unsigned int no_d1d2:1; /* Only allow D0 and D3 */
Documentation/kernel-parameters.txt +6 -0
@@ -1966,6 +1966,12 @@ and is between 256 and 4096 characters. force Enable ASPM even on devices that claim not to support it. WARNING: Forcing ASPM on may cause system lockups. + pcie_pme= [PCIE,PM] Native PCIe PME signaling options: + off Do not use native PCIe PME signaling. + force Use native PCIe PME signaling even if the BIOS refuses + to allow the kernel to control the relevant PCIe config + registers. + pcmv= [HW,PCMCIA] BadgePAD 4 pd. [PARIDE]
RFC PATCH 5/12 PCI PM: Make it possible to force using INTx for PCIe PME signaling
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Apparently, some machines may have problems with PCI run-time power management if MSIs are used for the hative PCIe PME signaling. In particular, on the MSI Wind U-100 PCIe PME interrupts are not generated by a PCIe root port after a resume from suspend to RAM, if the system wake-up was triggered by a PME from the device attached to this port. [It doesn't help to free the interrupt on suspend and request it back on resume, even if that is done along with disabling the MSI and re-enabling it, respectively.] However, if INTx interrupts are used for this purpose on the same machine, everything works just fine.
For this reason, add a kernel command line switch allowing one to request that MSIs be not used for the native PCIe PME signaling, introduce a DMI table allowing us to blacklist machines that need this switch to be set by default and put the MSI Wind U-100 into this table.
--- Documentation/kernel-parameters.txt | 2 ++ drivers/pci/pcie/pme/pcie_pme.c | 14 +++++++++++++- drivers/pci/pcie/portdrv.h | 17 +++++++++++++++++ drivers/pci/pcie/portdrv_core.c | 5 +++++ drivers/pci/pcie/portdrv_pci.c | 26 ++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 1 deletion(-)
drivers/pci/pcie/pme/pcie_pme.c +13 -1
@@ -53,12 +53,22 @@ static bool pcie_pme_disabled;*/ static bool pcie_pme_force_enable; +/* +* If this switch is set, MSI will not be used for PCIe PME signaling. This +* causes the PCIe port driver to use INTx interrupts only, but it turns out +* that using MSI for PCIe PME signaling doesn't play well with PCIe PME-based +* wake-up from system sleep states. +*/ +bool pcie_pme_msi_disabled; +static int __init pcie_pme_setup (char *str) {if (!strcmp (str,"off" )) pcie_pme_disabled = true;else if (!strcmp (str,"force" )) pcie_pme_force_enable = true; +else if (!strcmp (str,"nomsi" )) + pcie_pme_msi_disabled = true;return 1 ; }__setup ("pcie_pme=" , pcie_pme_setup);
@@ -73,7 +83,9 @@ __setup("pcie_pme=", pcie_pme_setup);*/ static bool pcie_pme_platform_setup (struct pcie_device *srv) { -return !pcie_pme_platform_notify (srv) || pcie_pme_force_enable; +if (!pcie_pme_platform_notify (srv)) +return true; +return pcie_pme_force_enable; }struct pcie_pme_service_data {
drivers/pci/pcie/portdrv_core.c +5 -0
@@ -190,6 +190,10 @@ static int assign_interrupt_mode(structint irq, interrupt_mode =PCIE_PORT_NO_IRQ ;int i; +/* We have to use INTx if MSI cannot be used for PCIe PME. */ +if ((mask &PCIE_PORT_SERVICE_PME ) &&pcie_pme_no_msi ()) + goto no_msi; +/* Try to use MSI-X if supported */ if (!pcie_port_enable_msix (dev, vectors, mask))return PCIE_PORT_MSIX_MODE ;
@@ -198,6 +202,7 @@ static int assign_interrupt_mode(structif (!pci_enable_msi (dev)) interrupt_mode =PCIE_PORT_MSI_MODE ; + no_msi:if (interrupt_mode ==PCIE_PORT_NO_IRQ && dev->pin) interrupt_mode = PCIE_PORT_INTx_MODE;
drivers/pci/pcie/portdrv_pci.c +26 -0
@@ -15,6 +15,7 @@#include <linux/slab.h> #include <linux/pcieport_if.h> #include <linux/aer.h> +#include <linux/dmi.h> #include "portdrv.h" #include "aer/aerdrv.h"
@@ -272,10 +273,35 @@ static struct pci_driver pcie_portdriver .driver.pm = PCIE_PORTDRV_PM_OPS, }; +static int __init dmi_pcie_pme_disable_msi (const struct dmi_system_id *d) +{ +pr_notice ("%s detected: will not use MSI for PCIe PME signaling\n" , + d->ident); +pcie_pme_disable_msi (); +return 0 ; +} + +static struct dmi_system_id __initdata pcie_portdrv_dmi_table[] = { +/* +* Boxes that should not use MSI for PCIe PME signaling. +*/ + { + .callback = dmi_pcie_pme_disable_msi, + .ident ="MSI Wind U-100" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR , +"MICRO-STAR INTERNATIONAL CO., LTD" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"U-100" ), + }, + }, +}; +static int __init pcie_portdrv_init (void ) {int retval; +dmi_check_system (pcie_portdrv_dmi_table); + retval =pcie_port_bus_register ();if (retval) {printk (KERN_WARNING "PCIE: bus_register error: %d\n" , retval);
drivers/pci/pcie/portdrv.h +17 -0
@@ -45,4 +45,21 @@ extern void pcie_port_device_remove(struextern int __must_check pcie_port_bus_register (void );extern void pcie_port_bus_unregister (void ); +#ifdef CONFIG_PCIE_PME +extern bool pcie_pme_msi_disabled; + +static inline void pcie_pme_disable_msi (void ) +{ + pcie_pme_msi_disabled = true; +} + +static inline bool pcie_pme_no_msi (void ) +{ +return pcie_pme_msi_disabled; +} +#else /* !CONFIG_PCIE_PME */ +static inline void pcie_pme_disable_msi (void ) {} +static inline bool pcie_pme_no_msi (void ) {return false; } +#endif /* !CONFIG_PCIE_PME */ +#endif /* _PORTDRV_H_ */
Documentation/kernel-parameters.txt +2 -0
@@ -1971,6 +1971,8 @@ and is between 256 and 4096 characters. force Use native PCIe PME signaling even if the BIOS refuses to allow the kernel to control the relevant PCIe config registers. + nomsi Do not use MSI for native PCIe PME signaling (this makes + all PCIe root ports use INTx for everything). pcmv= [HW,PCMCIA] BadgePAD 4
RFC PATCH 5/12 PCI PM: Make it possible to force using INTx for PCIe PME signaling (updated)
Quoted 13 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Apparently, some machines may have problems with PCI run-time power management if MSIs are used for the hative PCIe PME signaling. In particular, on the MSI Wind U-100 PCIe PME interrupts are not generated by a PCIe root port after a resume from suspend to RAM, if the system wake-up was triggered by a PME from the device attached to this port. [It doesn't help to free the interrupt on suspend and request it back on resume, even if that is done along with disabling the MSI and re-enabling it, respectively.] However, if INTx interrupts are used for this purpose on the same machine, everything works just fine.
Quoted 5 lines
For this reason, add a kernel command line switch allowing one to request that MSIs be not used for the native PCIe PME signaling, introduce a DMI table allowing us to blacklist machines that need this switch to be set by default and put the MSI Wind U-100 into this table.
The DMI table has to be terminated appropriately. Fixed version is appended.
---
From: Rafael J. Wysocki <[email protected]>
Subject: PCI PM: Make it possible to force using INTx for PCIe PME signaling
Apparently, some machines may have problems with PCI run-time power management if MSIs are used for the hative PCIe PME signaling. In particular, on the MSI Wind U-100 PCIe PME interrupts are not generated by a PCIe root port after a resume from suspend to RAM, if the system wake-up was triggered by a PME from the device attached to this port. [It doesn't help to free the interrupt on suspend and request it back on resume, even if that is done along with disabling the MSI and re-enabling it, respectively.] However, if INTx interrupts are used for this purpose on the same machine, everything works just fine.
For this reason, add a kernel command line switch allowing one to request that MSIs be not used for the native PCIe PME signaling, introduce a DMI table allowing us to blacklist machines that need this switch to be set by default and put the MSI Wind U-100 into this table.
--- Documentation/kernel-parameters.txt | 2 ++ drivers/pci/pcie/pme/pcie_pme.c | 14 +++++++++++++- drivers/pci/pcie/portdrv.h | 17 +++++++++++++++++ drivers/pci/pcie/portdrv_core.c | 5 +++++ drivers/pci/pcie/portdrv_pci.c | 27 +++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 1 deletion(-)
drivers/pci/pcie/pme/pcie_pme.c +13 -1
@@ -53,12 +53,22 @@ static bool pcie_pme_disabled;*/ static bool pcie_pme_force_enable; +/* +* If this switch is set, MSI will not be used for PCIe PME signaling. This +* causes the PCIe port driver to use INTx interrupts only, but it turns out +* that using MSI for PCIe PME signaling doesn't play well with PCIe PME-based +* wake-up from system sleep states. +*/ +bool pcie_pme_msi_disabled; +static int __init pcie_pme_setup (char *str) {if (!strcmp (str,"off" )) pcie_pme_disabled = true;else if (!strcmp (str,"force" )) pcie_pme_force_enable = true; +else if (!strcmp (str,"nomsi" )) + pcie_pme_msi_disabled = true;return 1 ; }__setup ("pcie_pme=" , pcie_pme_setup);
@@ -73,7 +83,9 @@ __setup("pcie_pme=", pcie_pme_setup);*/ static bool pcie_pme_platform_setup (struct pcie_device *srv) { -return !pcie_pme_platform_notify (srv) || pcie_pme_force_enable; +if (!pcie_pme_platform_notify (srv)) +return true; +return pcie_pme_force_enable; }struct pcie_pme_service_data {
drivers/pci/pcie/portdrv_core.c +5 -0
@@ -190,6 +190,10 @@ static int assign_interrupt_mode(structint irq, interrupt_mode =PCIE_PORT_NO_IRQ ;int i; +/* We have to use INTx if MSI cannot be used for PCIe PME. */ +if ((mask &PCIE_PORT_SERVICE_PME ) &&pcie_pme_no_msi ()) + goto no_msi; +/* Try to use MSI-X if supported */ if (!pcie_port_enable_msix (dev, vectors, mask))return PCIE_PORT_MSIX_MODE ;
@@ -198,6 +202,7 @@ static int assign_interrupt_mode(structif (!pci_enable_msi (dev)) interrupt_mode =PCIE_PORT_MSI_MODE ; + no_msi:if (interrupt_mode ==PCIE_PORT_NO_IRQ && dev->pin) interrupt_mode = PCIE_PORT_INTx_MODE;
drivers/pci/pcie/portdrv_pci.c +27 -0
@@ -15,6 +15,7 @@#include <linux/slab.h> #include <linux/pcieport_if.h> #include <linux/aer.h> +#include <linux/dmi.h> #include "portdrv.h" #include "aer/aerdrv.h"
@@ -272,10 +273,36 @@ static struct pci_driver pcie_portdriver .driver.pm = PCIE_PORTDRV_PM_OPS, }; +static int __init dmi_pcie_pme_disable_msi (const struct dmi_system_id *d) +{ +pr_notice ("%s detected: will not use MSI for PCIe PME signaling\n" , + d->ident); +pcie_pme_disable_msi (); +return 0 ; +} + +static struct dmi_system_id __initdata pcie_portdrv_dmi_table[] = { +/* +* Boxes that should not use MSI for PCIe PME signaling. +*/ + { + .callback = dmi_pcie_pme_disable_msi, + .ident ="MSI Wind U-100" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR , +"MICRO-STAR INTERNATIONAL CO., LTD" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"U-100" ), + }, + }, + {} +}; +static int __init pcie_portdrv_init (void ) {int retval; +dmi_check_system (pcie_portdrv_dmi_table); + retval =pcie_port_bus_register ();if (retval) {printk (KERN_WARNING "PCIE: bus_register error: %d\n" , retval);
drivers/pci/pcie/portdrv.h +17 -0
@@ -45,4 +45,21 @@ extern void pcie_port_device_remove(struextern int __must_check pcie_port_bus_register (void );extern void pcie_port_bus_unregister (void ); +#ifdef CONFIG_PCIE_PME +extern bool pcie_pme_msi_disabled; + +static inline void pcie_pme_disable_msi (void ) +{ + pcie_pme_msi_disabled = true; +} + +static inline bool pcie_pme_no_msi (void ) +{ +return pcie_pme_msi_disabled; +} +#else /* !CONFIG_PCIE_PME */ +static inline void pcie_pme_disable_msi (void ) {} +static inline bool pcie_pme_no_msi (void ) {return false; } +#endif /* !CONFIG_PCIE_PME */ +#endif /* _PORTDRV_H_ */
Documentation/kernel-parameters.txt +2 -0
@@ -1971,6 +1971,8 @@ and is between 256 and 4096 characters. force Use native PCIe PME signaling even if the BIOS refuses to allow the kernel to control the relevant PCIe config registers. + nomsi Do not use MSI for native PCIe PME signaling (this makes + all PCIe root ports use INTx for everything). pcmv= [HW,PCMCIA] BadgePAD 4
RFC PATCH 5/12 PCI PM: Make it possible to force using INTx for PCIe PME signaling (updated)
In reply to Rafael J. WysockiQuoted 13 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Apparently, some machines may have problems with PCI run-time power management if MSIs are used for the hative PCIe PME signaling. In particular, on the MSI Wind U-100 PCIe PME interrupts are not generated by a PCIe root port after a resume from suspend to RAM, if the system wake-up was triggered by a PME from the device attached to this port. [It doesn't help to free the interrupt on suspend and request it back on resume, even if that is done along with disabling the MSI and re-enabling it, respectively.] However, if INTx interrupts are used for this purpose on the same machine, everything works just fine.
Quoted 5 lines
For this reason, add a kernel command line switch allowing one to request that MSIs be not used for the native PCIe PME signaling, introduce a DMI table allowing us to blacklist machines that need this switch to be set by default and put the MSI Wind U-100 into this table.
The DMI table has to be terminated appropriately. Fixed version is appended.
---
From: Rafael J. Wysocki <[email protected]>
Subject: PCI PM: Make it possible to force using INTx for PCIe PME signaling
Apparently, some machines may have problems with PCI run-time power management if MSIs are used for the hative PCIe PME signaling. In particular, on the MSI Wind U-100 PCIe PME interrupts are not generated by a PCIe root port after a resume from suspend to RAM, if the system wake-up was triggered by a PME from the device attached to this port. [It doesn't help to free the interrupt on suspend and request it back on resume, even if that is done along with disabling the MSI and re-enabling it, respectively.] However, if INTx interrupts are used for this purpose on the same machine, everything works just fine.
For this reason, add a kernel command line switch allowing one to request that MSIs be not used for the native PCIe PME signaling, introduce a DMI table allowing us to blacklist machines that need this switch to be set by default and put the MSI Wind U-100 into this table.
--- Documentation/kernel-parameters.txt | 2 ++ drivers/pci/pcie/pme/pcie_pme.c | 14 +++++++++++++- drivers/pci/pcie/portdrv.h | 17 +++++++++++++++++ drivers/pci/pcie/portdrv_core.c | 5 +++++ drivers/pci/pcie/portdrv_pci.c | 27 +++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 1 deletion(-)
drivers/pci/pcie/pme/pcie_pme.c +13 -1
@@ -53,12 +53,22 @@ static bool pcie_pme_disabled;*/ static bool pcie_pme_force_enable; +/* +* If this switch is set, MSI will not be used for PCIe PME signaling. This +* causes the PCIe port driver to use INTx interrupts only, but it turns out +* that using MSI for PCIe PME signaling doesn't play well with PCIe PME-based +* wake-up from system sleep states. +*/ +bool pcie_pme_msi_disabled; +static int __init pcie_pme_setup (char *str) {if (!strcmp (str,"off" )) pcie_pme_disabled = true;else if (!strcmp (str,"force" )) pcie_pme_force_enable = true; +else if (!strcmp (str,"nomsi" )) + pcie_pme_msi_disabled = true;return 1 ; }__setup ("pcie_pme=" , pcie_pme_setup);
@@ -73,7 +83,9 @@ __setup("pcie_pme=", pcie_pme_setup);*/ static bool pcie_pme_platform_setup (struct pcie_device *srv) { -return !pcie_pme_platform_notify (srv) || pcie_pme_force_enable; +if (!pcie_pme_platform_notify (srv)) +return true; +return pcie_pme_force_enable; }struct pcie_pme_service_data {
drivers/pci/pcie/portdrv_core.c +5 -0
@@ -190,6 +190,10 @@ static int assign_interrupt_mode(structint irq, interrupt_mode =PCIE_PORT_NO_IRQ ;int i; +/* We have to use INTx if MSI cannot be used for PCIe PME. */ +if ((mask &PCIE_PORT_SERVICE_PME ) &&pcie_pme_no_msi ()) + goto no_msi; +/* Try to use MSI-X if supported */ if (!pcie_port_enable_msix (dev, vectors, mask))return PCIE_PORT_MSIX_MODE ;
@@ -198,6 +202,7 @@ static int assign_interrupt_mode(structif (!pci_enable_msi (dev)) interrupt_mode =PCIE_PORT_MSI_MODE ; + no_msi:if (interrupt_mode ==PCIE_PORT_NO_IRQ && dev->pin) interrupt_mode = PCIE_PORT_INTx_MODE;
drivers/pci/pcie/portdrv_pci.c +27 -0
@@ -15,6 +15,7 @@#include <linux/slab.h> #include <linux/pcieport_if.h> #include <linux/aer.h> +#include <linux/dmi.h> #include "portdrv.h" #include "aer/aerdrv.h"
@@ -272,10 +273,36 @@ static struct pci_driver pcie_portdriver .driver.pm = PCIE_PORTDRV_PM_OPS, }; +static int __init dmi_pcie_pme_disable_msi (const struct dmi_system_id *d) +{ +pr_notice ("%s detected: will not use MSI for PCIe PME signaling\n" , + d->ident); +pcie_pme_disable_msi (); +return 0 ; +} + +static struct dmi_system_id __initdata pcie_portdrv_dmi_table[] = { +/* +* Boxes that should not use MSI for PCIe PME signaling. +*/ + { + .callback = dmi_pcie_pme_disable_msi, + .ident ="MSI Wind U-100" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR , +"MICRO-STAR INTERNATIONAL CO., LTD" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"U-100" ), + }, + }, + {} +}; +static int __init pcie_portdrv_init (void ) {int retval; +dmi_check_system (pcie_portdrv_dmi_table); + retval =pcie_port_bus_register ();if (retval) {printk (KERN_WARNING "PCIE: bus_register error: %d\n" , retval);
drivers/pci/pcie/portdrv.h +17 -0
@@ -45,4 +45,21 @@ extern void pcie_port_device_remove(struextern int __must_check pcie_port_bus_register (void );extern void pcie_port_bus_unregister (void ); +#ifdef CONFIG_PCIE_PME +extern bool pcie_pme_msi_disabled; + +static inline void pcie_pme_disable_msi (void ) +{ + pcie_pme_msi_disabled = true; +} + +static inline bool pcie_pme_no_msi (void ) +{ +return pcie_pme_msi_disabled; +} +#else /* !CONFIG_PCIE_PME */ +static inline void pcie_pme_disable_msi (void ) {} +static inline bool pcie_pme_no_msi (void ) {return false; } +#endif /* !CONFIG_PCIE_PME */ +#endif /* _PORTDRV_H_ */
Documentation/kernel-parameters.txt +2 -0
@@ -1971,6 +1971,8 @@ and is between 256 and 4096 characters. force Use native PCIe PME signaling even if the BIOS refuses to allow the kernel to control the relevant PCIe config registers. + nomsi Do not use MSI for native PCIe PME signaling (this makes + all PCIe root ports use INTx for everything). pcmv= [HW,PCMCIA] BadgePAD 4
RFC PATCH 5/12 PCI PM: Make it possible to force using INTx for PCIe PME signaling
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Apparently, some machines may have problems with PCI run-time power management if MSIs are used for the hative PCIe PME signaling. In particular, on the MSI Wind U-100 PCIe PME interrupts are not generated by a PCIe root port after a resume from suspend to RAM, if the system wake-up was triggered by a PME from the device attached to this port. [It doesn't help to free the interrupt on suspend and request it back on resume, even if that is done along with disabling the MSI and re-enabling it, respectively.] However, if INTx interrupts are used for this purpose on the same machine, everything works just fine.
For this reason, add a kernel command line switch allowing one to request that MSIs be not used for the native PCIe PME signaling, introduce a DMI table allowing us to blacklist machines that need this switch to be set by default and put the MSI Wind U-100 into this table.
--- Documentation/kernel-parameters.txt | 2 ++ drivers/pci/pcie/pme/pcie_pme.c | 14 +++++++++++++- drivers/pci/pcie/portdrv.h | 17 +++++++++++++++++ drivers/pci/pcie/portdrv_core.c | 5 +++++ drivers/pci/pcie/portdrv_pci.c | 26 ++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 1 deletion(-)
drivers/pci/pcie/pme/pcie_pme.c +13 -1
@@ -53,12 +53,22 @@ static bool pcie_pme_disabled;*/ static bool pcie_pme_force_enable; +/* +* If this switch is set, MSI will not be used for PCIe PME signaling. This +* causes the PCIe port driver to use INTx interrupts only, but it turns out +* that using MSI for PCIe PME signaling doesn't play well with PCIe PME-based +* wake-up from system sleep states. +*/ +bool pcie_pme_msi_disabled; +static int __init pcie_pme_setup (char *str) {if (!strcmp (str,"off" )) pcie_pme_disabled = true;else if (!strcmp (str,"force" )) pcie_pme_force_enable = true; +else if (!strcmp (str,"nomsi" )) + pcie_pme_msi_disabled = true;return 1 ; }__setup ("pcie_pme=" , pcie_pme_setup);
@@ -73,7 +83,9 @@ __setup("pcie_pme=", pcie_pme_setup);*/ static bool pcie_pme_platform_setup (struct pcie_device *srv) { -return !pcie_pme_platform_notify (srv) || pcie_pme_force_enable; +if (!pcie_pme_platform_notify (srv)) +return true; +return pcie_pme_force_enable; }struct pcie_pme_service_data {
drivers/pci/pcie/portdrv_core.c +5 -0
@@ -190,6 +190,10 @@ static int assign_interrupt_mode(structint irq, interrupt_mode =PCIE_PORT_NO_IRQ ;int i; +/* We have to use INTx if MSI cannot be used for PCIe PME. */ +if ((mask &PCIE_PORT_SERVICE_PME ) &&pcie_pme_no_msi ()) + goto no_msi; +/* Try to use MSI-X if supported */ if (!pcie_port_enable_msix (dev, vectors, mask))return PCIE_PORT_MSIX_MODE ;
@@ -198,6 +202,7 @@ static int assign_interrupt_mode(structif (!pci_enable_msi (dev)) interrupt_mode =PCIE_PORT_MSI_MODE ; + no_msi:if (interrupt_mode ==PCIE_PORT_NO_IRQ && dev->pin) interrupt_mode = PCIE_PORT_INTx_MODE;
drivers/pci/pcie/portdrv_pci.c +26 -0
@@ -15,6 +15,7 @@#include <linux/slab.h> #include <linux/pcieport_if.h> #include <linux/aer.h> +#include <linux/dmi.h> #include "portdrv.h" #include "aer/aerdrv.h"
@@ -272,10 +273,35 @@ static struct pci_driver pcie_portdriver .driver.pm = PCIE_PORTDRV_PM_OPS, }; +static int __init dmi_pcie_pme_disable_msi (const struct dmi_system_id *d) +{ +pr_notice ("%s detected: will not use MSI for PCIe PME signaling\n" , + d->ident); +pcie_pme_disable_msi (); +return 0 ; +} + +static struct dmi_system_id __initdata pcie_portdrv_dmi_table[] = { +/* +* Boxes that should not use MSI for PCIe PME signaling. +*/ + { + .callback = dmi_pcie_pme_disable_msi, + .ident ="MSI Wind U-100" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR , +"MICRO-STAR INTERNATIONAL CO., LTD" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"U-100" ), + }, + }, +}; +static int __init pcie_portdrv_init (void ) {int retval; +dmi_check_system (pcie_portdrv_dmi_table); + retval =pcie_port_bus_register ();if (retval) {printk (KERN_WARNING "PCIE: bus_register error: %d\n" , retval);
drivers/pci/pcie/portdrv.h +17 -0
@@ -45,4 +45,21 @@ extern void pcie_port_device_remove(struextern int __must_check pcie_port_bus_register (void );extern void pcie_port_bus_unregister (void ); +#ifdef CONFIG_PCIE_PME +extern bool pcie_pme_msi_disabled; + +static inline void pcie_pme_disable_msi (void ) +{ + pcie_pme_msi_disabled = true; +} + +static inline bool pcie_pme_no_msi (void ) +{ +return pcie_pme_msi_disabled; +} +#else /* !CONFIG_PCIE_PME */ +static inline void pcie_pme_disable_msi (void ) {} +static inline bool pcie_pme_no_msi (void ) {return false; } +#endif /* !CONFIG_PCIE_PME */ +#endif /* _PORTDRV_H_ */
Documentation/kernel-parameters.txt +2 -0
@@ -1971,6 +1971,8 @@ and is between 256 and 4096 characters. force Use native PCIe PME signaling even if the BIOS refuses to allow the kernel to control the relevant PCIe config registers. + nomsi Do not use MSI for native PCIe PME signaling (this makes + all PCIe root ports use INTx for everything). pcmv= [HW,PCMCIA] BadgePAD 4
RFC PATCH 6/12 ACPI: Add infrastructure for refcounting GPE consumers
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
ACPI GPEs may map to multiple devices. The current GPE interface only provides a mechanism for enabling and disabling GPEs, making it difficult to change the state of GPEs at runtime without extensive cooperation between devices. Add an API to allow devices to indicate whether or not they want their device's GPE to be enabled for both runtime and wakeup events.
---drivers/acpi/acpica/aclocal.h | 2 +
drivers/acpi/acpica/aclocal.h | 2 drivers/acpi/acpica/evxfevnt.c | 161 +++++++++++++++++++++++++++++++++++++++++ include/acpi/acpixf.h | 8 ++ 3 files changed, 171 insertions(+)
drivers/acpi/acpica/aclocal.h +2 -0
@@ -426,6 +426,8 @@ struct acpi_gpe_event_info {struct acpi_gpe_register_info *register_info;/* Backpointer to register info */ u8 flags;/* Misc info about this GPE */ u8 gpe_number;/* This GPE */ +u8 runtime_count; +u8 wakeup_count; };/* Information about a GPE register pair, one per each status/enable pair in an array */
drivers/acpi/acpica/evxfevnt.c +161 -0
167 lines not on this page · raw message
include/acpi/acpixf.h +8 -0
@@ -282,6 +282,14 @@ acpi_status acpi_get_event_status(u32 ev*/ acpi_status acpi_set_gpe_type (acpi_handle gpe_device,u32 gpe_number,u8 type); +acpi_status acpi_ref_runtime_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_unref_runtime_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_ref_wakeup_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_unref_wakeup_gpe (acpi_handle gpe_device,u32 gpe_number); +acpi_status acpi_enable_gpe (acpi_handle gpe_device,u32 gpe_number);acpi_status acpi_disable_gpe (acpi_handle gpe_device,u32 gpe_number);
RFC PATCH 6/12 ACPI: Add infrastructure for refcounting GPE consumers
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
ACPI GPEs may map to multiple devices. The current GPE interface only provides a mechanism for enabling and disabling GPEs, making it difficult to change the state of GPEs at runtime without extensive cooperation between devices. Add an API to allow devices to indicate whether or not they want their device's GPE to be enabled for both runtime and wakeup events.
---drivers/acpi/acpica/aclocal.h | 2 +
drivers/acpi/acpica/aclocal.h | 2 drivers/acpi/acpica/evxfevnt.c | 161 +++++++++++++++++++++++++++++++++++++++++ include/acpi/acpixf.h | 8 ++ 3 files changed, 171 insertions(+)
drivers/acpi/acpica/aclocal.h +2 -0
@@ -426,6 +426,8 @@ struct acpi_gpe_event_info {struct acpi_gpe_register_info *register_info;/* Backpointer to register info */ u8 flags;/* Misc info about this GPE */ u8 gpe_number;/* This GPE */ +u8 runtime_count; +u8 wakeup_count; };/* Information about a GPE register pair, one per each status/enable pair in an array */
drivers/acpi/acpica/evxfevnt.c +161 -0
167 lines not on this page · raw message
include/acpi/acpixf.h +8 -0
@@ -282,6 +282,14 @@ acpi_status acpi_get_event_status(u32 ev*/ acpi_status acpi_set_gpe_type (acpi_handle gpe_device,u32 gpe_number,u8 type); +acpi_status acpi_ref_runtime_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_unref_runtime_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_ref_wakeup_gpe (acpi_handle gpe_device,u32 gpe_number); + +acpi_status acpi_unref_wakeup_gpe (acpi_handle gpe_device,u32 gpe_number); +acpi_status acpi_enable_gpe (acpi_handle gpe_device,u32 gpe_number);acpi_status acpi_disable_gpe (acpi_handle gpe_device,u32 gpe_number);
RFC PATCH 7/12 ACPI: Add support for new refcounted GPE API to drivers
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
Add GPE refcounting support to ACPI drivers that need it. This will currently do little until the core is changed over to use the new behaviour.
Signed-off-by; Rafael J. Wysocki <[email protected]>
---drivers/acpi/button.c | 12 ++++++++++++
drivers/acpi/button.c | 12 ++++++++++++ drivers/acpi/ec.c | 4 +++- drivers/acpi/wakeup.c | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/acpi/button.c +12 -0
@@ -420,6 +420,10 @@ static int acpi_button_add(struct acpi_d ACPI_GPE_TYPE_WAKE_RUN);acpi_enable_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); +acpi_ref_runtime_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); +acpi_ref_wakeup_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); device->wakeup.state.enabled =1 ; }
@@ -439,6 +443,14 @@ static int acpi_button_remove(struct acp {struct acpi_button *button =acpi_driver_data (device); +if (device->wakeup.flags.valid) { +acpi_unref_runtime_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); +acpi_unref_wakeup_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); + device->wakeup.state.enabled =0 ; + } +acpi_button_remove_fs (device);input_unregister_device (button->input);kfree (button);
drivers/acpi/ec.c +3 -1
@@ -755,7 +755,7 @@ static int ec_install_handlers(struct acif (ACPI_FAILURE (status))return -ENODEV ;acpi_set_gpe_type (NULL , ec->gpe,ACPI_GPE_TYPE_RUNTIME ); -acpi_enable_gpe (NULL , ec->gpe); +acpi_ref_runtime_gpe (NULL , ec->gpe); status = acpi_install_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
@@ -772,6 +772,7 @@ static int ec_install_handlers(struct ac }else {acpi_remove_gpe_handler (NULL , ec->gpe, &acpi_ec_gpe_handler); +acpi_unref_runtime_gpe (NULL , ec->gpe);return -ENODEV ; } }
@@ -782,6 +783,7 @@ static int ec_install_handlers(struct acstatic void ec_remove_handlers (struct acpi_ec *ec) { +acpi_unref_runtime_gpe (NULL , ec->gpe);if (ACPI_FAILURE (acpi_remove_address_space_handler (ec->handle,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler)))pr_err (PREFIX "failed to remove space handler\n" );
drivers/acpi/wakeup.c +6 -0
@@ -81,6 +81,8 @@ void acpi_enable_wakeup_device(u8 sleep_if (!dev->wakeup.flags.run_wake)acpi_enable_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number); +acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } }
@@ -121,6 +123,8 @@ void acpi_disable_wakeup_device(u8 sleepacpi_clear_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number,ACPI_NOT_ISR ); } +acpi_unref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } }
@@ -141,6 +145,8 @@ int __init acpi_wakeup_device_init(void) ACPI_GPE_TYPE_WAKE_RUN);acpi_enable_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number); +acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); dev->wakeup.state.enabled =1 ; }mutex_unlock (&acpi_device_lock);
RFC PATCH 7/12 ACPI: Add support for new refcounted GPE API to drivers
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
Add GPE refcounting support to ACPI drivers that need it. This will currently do little until the core is changed over to use the new behaviour.
Signed-off-by; Rafael J. Wysocki <[email protected]>
---drivers/acpi/button.c | 12 ++++++++++++
drivers/acpi/button.c | 12 ++++++++++++ drivers/acpi/ec.c | 4 +++- drivers/acpi/wakeup.c | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/acpi/button.c +12 -0
@@ -420,6 +420,10 @@ static int acpi_button_add(struct acpi_d ACPI_GPE_TYPE_WAKE_RUN);acpi_enable_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); +acpi_ref_runtime_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); +acpi_ref_wakeup_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); device->wakeup.state.enabled =1 ; }
@@ -439,6 +443,14 @@ static int acpi_button_remove(struct acp {struct acpi_button *button =acpi_driver_data (device); +if (device->wakeup.flags.valid) { +acpi_unref_runtime_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); +acpi_unref_wakeup_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); + device->wakeup.state.enabled =0 ; + } +acpi_button_remove_fs (device);input_unregister_device (button->input);kfree (button);
drivers/acpi/ec.c +3 -1
@@ -755,7 +755,7 @@ static int ec_install_handlers(struct acif (ACPI_FAILURE (status))return -ENODEV ;acpi_set_gpe_type (NULL , ec->gpe,ACPI_GPE_TYPE_RUNTIME ); -acpi_enable_gpe (NULL , ec->gpe); +acpi_ref_runtime_gpe (NULL , ec->gpe); status = acpi_install_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
@@ -772,6 +772,7 @@ static int ec_install_handlers(struct ac }else {acpi_remove_gpe_handler (NULL , ec->gpe, &acpi_ec_gpe_handler); +acpi_unref_runtime_gpe (NULL , ec->gpe);return -ENODEV ; } }
@@ -782,6 +783,7 @@ static int ec_install_handlers(struct acstatic void ec_remove_handlers (struct acpi_ec *ec) { +acpi_unref_runtime_gpe (NULL , ec->gpe);if (ACPI_FAILURE (acpi_remove_address_space_handler (ec->handle,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler)))pr_err (PREFIX "failed to remove space handler\n" );
drivers/acpi/wakeup.c +6 -0
@@ -81,6 +81,8 @@ void acpi_enable_wakeup_device(u8 sleep_if (!dev->wakeup.flags.run_wake)acpi_enable_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number); +acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } }
@@ -121,6 +123,8 @@ void acpi_disable_wakeup_device(u8 sleepacpi_clear_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number,ACPI_NOT_ISR ); } +acpi_unref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } }
@@ -141,6 +145,8 @@ int __init acpi_wakeup_device_init(void) ACPI_GPE_TYPE_WAKE_RUN);acpi_enable_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number); +acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, + dev->wakeup.gpe_number); dev->wakeup.state.enabled =1 ; }mutex_unlock (&acpi_device_lock);
RFC PATCH 8/12 ACPI: Remove old GPE API and transition code entirely to new one
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
Remove the old GPE type handling entirely, which gets rid of various quirks like the implicit disabling with GPE type setting. This requires a small amount of rework in order to ensure that non-wake GPEs are enabled by default to preserve existing behaviour.
---drivers/acpi/acpica/acevents.h | 6 +--
drivers/acpi/acpica/acevents.h | 6 - drivers/acpi/acpica/evgpe.c | 147 +++-------------------------------------- drivers/acpi/acpica/evgpeblk.c | 69 ++++++------------- drivers/acpi/acpica/evxface.c | 14 --- drivers/acpi/acpica/evxfevnt.c | 48 ------------- drivers/acpi/button.c | 5 - drivers/acpi/ec.c | 2 drivers/acpi/wakeup.c | 55 ++------------- include/acpi/actypes.h | 32 ++------ 9 files changed, 59 insertions(+), 319 deletions(-)
drivers/acpi/acpica/acevents.h +1 -5
@@ -76,8 +76,7 @@ acpi_ev_queue_notify_request(struct acpi* evgpe - GPE handling and dispatch */ acpi_status -acpi_ev_update_gpe_enable_masks (struct acpi_gpe_event_info *gpe_event_info, -u8 type); +acpi_ev_update_gpe_enable_masks (struct acpi_gpe_event_info *gpe_event_info); acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
@@ -122,9 +121,6 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_eveu32 acpi_ev_gpe_detect (struct acpi_gpe_xrupt_info *gpe_xrupt_list);acpi_status -acpi_ev_set_gpe_type (struct acpi_gpe_event_info *gpe_event_info,u8 type); - -acpi_status acpi_ev_check_for_wake_only_gpe (struct acpi_gpe_event_info *gpe_event_info);acpi_status acpi_ev_gpe_initialize (void );
drivers/acpi/acpica/evgpe.c +14 -133
194 lines not on this page · raw message
drivers/acpi/acpica/evgpeblk.c +22 -47
112 lines not on this page · raw message
drivers/acpi/acpica/evxface.c +0 -14
@@ -617,13 +617,6 @@ acpi_install_gpe_handler(acpi_handle gpe handler->context = context; handler->method_node = gpe_event_info->dispatch.method_node; -/* Disable the GPE before installing the handler */ - - status =acpi_ev_disable_gpe (gpe_event_info); -if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } -/* Install the handler */ flags =acpi_os_acquire_lock (acpi_gbl_gpe_lock);
@@ -707,13 +700,6 @@ acpi_remove_gpe_handler(acpi_handle gpe_ goto unlock_and_exit; } -/* Disable the GPE before removing the handler */ - - status =acpi_ev_disable_gpe (gpe_event_info); -if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } -/* Make sure all deferred tasks are completed */ (void )acpi_ut_release_mutex (ACPI_MTX_EVENTS );
drivers/acpi/acpica/evxfevnt.c +2 -46
66 lines not on this page · raw message
drivers/acpi/button.c +0 -5
@@ -415,11 +415,6 @@ static int acpi_button_add(struct acpi_dif (device->wakeup.flags.valid) {/* Button's GPE is run-wake GPE */ -acpi_set_gpe_type (device->wakeup.gpe_device, - device->wakeup.gpe_number, -ACPI_GPE_TYPE_WAKE_RUN ); -acpi_enable_gpe (device->wakeup.gpe_device, - device->wakeup.gpe_number);acpi_ref_runtime_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); acpi_ref_wakeup_gpe(device->wakeup.gpe_device,
drivers/acpi/ec.c +1 -1
@@ -754,7 +754,7 @@ static int ec_install_handlers(struct ac &acpi_ec_gpe_handler, ec);if (ACPI_FAILURE (status))return -ENODEV ; -acpi_set_gpe_type (NULL , ec->gpe,ACPI_GPE_TYPE_RUNTIME ); +acpi_ref_runtime_gpe (NULL , ec->gpe); status = acpi_install_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC,
drivers/acpi/wakeup.c +9 -46
77 lines not on this page · raw message
include/acpi/actypes.h +10 -22
@@ -668,41 +668,29 @@ typedef u32 acpi_event_status;/* * GPE info flags - Per GPE -* +-+-+-+---+---+-+ -* |7|6|5|4:3|2:1|0| -* +-+-+-+---+---+-+ -* | | | | | | -* | | | | | +--- Interrupt type: Edge or Level Triggered -* | | | | +--- Type: Wake-only, Runtime-only, or wake/runtime +* +-+-+-+---+-+-+-+ +* |7|6|5|4:3|2|1|0| +* +-+-+-+---+-+-+-+ +* | | | | | | | +* | | | | | | +--- Interrupt type: Edge or Level Triggered +* | | | | | +--- GPE can wake the system +* | | | | +--- Unused * | | | +--- Type of dispatch -- to method, handler, or none -* | | +--- Enabled for runtime? -* | +--- Enabled for wake? +* | | +--- Unused +* | +--- Unused * +--- Unused */ #define ACPI_GPE_XRUPT_TYPE_MASK (u8) 0x01#define ACPI_GPE_LEVEL_TRIGGERED (u8) 0x01#define ACPI_GPE_EDGE_TRIGGERED (u8) 0x00 -#define ACPI_GPE_TYPE_MASK (u8) 0x06 -#define ACPI_GPE_TYPE_WAKE_RUN (u8) 0x06 -#define ACPI_GPE_TYPE_WAKE (u8) 0x02 -#define ACPI_GPE_TYPE_RUNTIME (u8) 0x04/* Default */ +#define ACPI_GPE_CAN_WAKE (u8) 0x02#define ACPI_GPE_DISPATCH_MASK (u8) 0x18#define ACPI_GPE_DISPATCH_HANDLER (u8) 0x08#define ACPI_GPE_DISPATCH_METHOD (u8) 0x10#define ACPI_GPE_DISPATCH_NOT_USED (u8) 0x00/* Default */ -#define ACPI_GPE_RUN_ENABLE_MASK (u8) 0x20 -#define ACPI_GPE_RUN_ENABLED (u8) 0x20 -#define ACPI_GPE_RUN_DISABLED (u8) 0x00/* Default */ - -#define ACPI_GPE_WAKE_ENABLE_MASK (u8) 0x40 -#define ACPI_GPE_WAKE_ENABLED (u8) 0x40 -#define ACPI_GPE_WAKE_DISABLED (u8) 0x00/* Default */ - -#define ACPI_GPE_ENABLE_MASK (u8) 0x60/* Both run/wake */ -/* * Flags for GPE and Lock interfaces */
RFC PATCH 8/12 ACPI: Remove old GPE API and transition code entirely to new one
In reply to Rafael J. WysockiFrom: Matthew Garrett <[email protected]>
Remove the old GPE type handling entirely, which gets rid of various quirks like the implicit disabling with GPE type setting. This requires a small amount of rework in order to ensure that non-wake GPEs are enabled by default to preserve existing behaviour.
---drivers/acpi/acpica/acevents.h | 6 +--
drivers/acpi/acpica/acevents.h | 6 - drivers/acpi/acpica/evgpe.c | 147 +++-------------------------------------- drivers/acpi/acpica/evgpeblk.c | 69 ++++++------------- drivers/acpi/acpica/evxface.c | 14 --- drivers/acpi/acpica/evxfevnt.c | 48 ------------- drivers/acpi/button.c | 5 - drivers/acpi/ec.c | 2 drivers/acpi/wakeup.c | 55 ++------------- include/acpi/actypes.h | 32 ++------ 9 files changed, 59 insertions(+), 319 deletions(-)
drivers/acpi/acpica/acevents.h +1 -5
@@ -76,8 +76,7 @@ acpi_ev_queue_notify_request(struct acpi* evgpe - GPE handling and dispatch */ acpi_status -acpi_ev_update_gpe_enable_masks (struct acpi_gpe_event_info *gpe_event_info, -u8 type); +acpi_ev_update_gpe_enable_masks (struct acpi_gpe_event_info *gpe_event_info); acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
@@ -122,9 +121,6 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_eveu32 acpi_ev_gpe_detect (struct acpi_gpe_xrupt_info *gpe_xrupt_list);acpi_status -acpi_ev_set_gpe_type (struct acpi_gpe_event_info *gpe_event_info,u8 type); - -acpi_status acpi_ev_check_for_wake_only_gpe (struct acpi_gpe_event_info *gpe_event_info);acpi_status acpi_ev_gpe_initialize (void );
drivers/acpi/acpica/evgpe.c +14 -133
194 lines not on this page · raw message
drivers/acpi/acpica/evgpeblk.c +22 -47
112 lines not on this page · raw message
drivers/acpi/acpica/evxface.c +0 -14
@@ -617,13 +617,6 @@ acpi_install_gpe_handler(acpi_handle gpe handler->context = context; handler->method_node = gpe_event_info->dispatch.method_node; -/* Disable the GPE before installing the handler */ - - status =acpi_ev_disable_gpe (gpe_event_info); -if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } -/* Install the handler */ flags =acpi_os_acquire_lock (acpi_gbl_gpe_lock);
@@ -707,13 +700,6 @@ acpi_remove_gpe_handler(acpi_handle gpe_ goto unlock_and_exit; } -/* Disable the GPE before removing the handler */ - - status =acpi_ev_disable_gpe (gpe_event_info); -if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } -/* Make sure all deferred tasks are completed */ (void )acpi_ut_release_mutex (ACPI_MTX_EVENTS );
drivers/acpi/acpica/evxfevnt.c +2 -46
66 lines not on this page · raw message
drivers/acpi/button.c +0 -5
@@ -415,11 +415,6 @@ static int acpi_button_add(struct acpi_dif (device->wakeup.flags.valid) {/* Button's GPE is run-wake GPE */ -acpi_set_gpe_type (device->wakeup.gpe_device, - device->wakeup.gpe_number, -ACPI_GPE_TYPE_WAKE_RUN ); -acpi_enable_gpe (device->wakeup.gpe_device, - device->wakeup.gpe_number);acpi_ref_runtime_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); acpi_ref_wakeup_gpe(device->wakeup.gpe_device,
drivers/acpi/ec.c +1 -1
@@ -754,7 +754,7 @@ static int ec_install_handlers(struct ac &acpi_ec_gpe_handler, ec);if (ACPI_FAILURE (status))return -ENODEV ; -acpi_set_gpe_type (NULL , ec->gpe,ACPI_GPE_TYPE_RUNTIME ); +acpi_ref_runtime_gpe (NULL , ec->gpe); status = acpi_install_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC,
drivers/acpi/wakeup.c +9 -46
77 lines not on this page · raw message
include/acpi/actypes.h +10 -22
@@ -668,41 +668,29 @@ typedef u32 acpi_event_status;/* * GPE info flags - Per GPE -* +-+-+-+---+---+-+ -* |7|6|5|4:3|2:1|0| -* +-+-+-+---+---+-+ -* | | | | | | -* | | | | | +--- Interrupt type: Edge or Level Triggered -* | | | | +--- Type: Wake-only, Runtime-only, or wake/runtime +* +-+-+-+---+-+-+-+ +* |7|6|5|4:3|2|1|0| +* +-+-+-+---+-+-+-+ +* | | | | | | | +* | | | | | | +--- Interrupt type: Edge or Level Triggered +* | | | | | +--- GPE can wake the system +* | | | | +--- Unused * | | | +--- Type of dispatch -- to method, handler, or none -* | | +--- Enabled for runtime? -* | +--- Enabled for wake? +* | | +--- Unused +* | +--- Unused * +--- Unused */ #define ACPI_GPE_XRUPT_TYPE_MASK (u8) 0x01#define ACPI_GPE_LEVEL_TRIGGERED (u8) 0x01#define ACPI_GPE_EDGE_TRIGGERED (u8) 0x00 -#define ACPI_GPE_TYPE_MASK (u8) 0x06 -#define ACPI_GPE_TYPE_WAKE_RUN (u8) 0x06 -#define ACPI_GPE_TYPE_WAKE (u8) 0x02 -#define ACPI_GPE_TYPE_RUNTIME (u8) 0x04/* Default */ +#define ACPI_GPE_CAN_WAKE (u8) 0x02#define ACPI_GPE_DISPATCH_MASK (u8) 0x18#define ACPI_GPE_DISPATCH_HANDLER (u8) 0x08#define ACPI_GPE_DISPATCH_METHOD (u8) 0x10#define ACPI_GPE_DISPATCH_NOT_USED (u8) 0x00/* Default */ -#define ACPI_GPE_RUN_ENABLE_MASK (u8) 0x20 -#define ACPI_GPE_RUN_ENABLED (u8) 0x20 -#define ACPI_GPE_RUN_DISABLED (u8) 0x00/* Default */ - -#define ACPI_GPE_WAKE_ENABLE_MASK (u8) 0x40 -#define ACPI_GPE_WAKE_ENABLED (u8) 0x40 -#define ACPI_GPE_WAKE_DISABLED (u8) 0x00/* Default */ - -#define ACPI_GPE_ENABLE_MASK (u8) 0x60/* Both run/wake */ -/* * Flags for GPE and Lock interfaces */
RFC PATCH 9/12 ACPI / PM: Add more run-time wake-up fields
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Use the run_wake flag to mark all devices for which run-time wake-up events may be generated by the platform. Introduce a new wake-up flag, special, for marking devices that should be permanently enabled to generate run-time events. Also, introduce a reference counter for run-wake devices and a function that will initialize all of the run-time wake-up fields for given device.
--- drivers/acpi/button.c | 2 ++ drivers/acpi/scan.c | 37 +++++++++++++++++++++++++++---------- drivers/acpi/wakeup.c | 2 +- include/acpi/acpi_bus.h | 2 ++ 4 files changed, 32 insertions(+), 11 deletions(-)
drivers/acpi/wakeup.c +1 -1
@@ -106,7 +106,7 @@ int __init acpi_wakeup_device_init(void) struct acpi_device, wakeup_list);/* In case user doesn't load button driver */ -if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled) +if (!dev->wakeup.flags.special || dev->wakeup.state.enabled)continue ;acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number);
include/acpi/acpi_bus.h +2 -0
@@ -242,6 +242,7 @@ struct acpi_device_perf {struct acpi_device_wakeup_flags {u8 valid:1 ;/* Can successfully enable wakeup? */ u8 run_wake:1 ;/* Run-Wake GPE devices */ +u8 special:1 ;/* Run-wake devices that are always enabled */ };struct acpi_device_wakeup_state {
@@ -256,6 +257,7 @@ struct acpi_device_wakeup {struct acpi_device_wakeup_state state;struct acpi_device_wakeup_flags flags;int prepare_count; +int run_wake_count; };/* Device */
drivers/acpi/button.c +2 -0
@@ -419,6 +419,7 @@ static int acpi_button_add(struct acpi_d device->wakeup.gpe_number);acpi_ref_wakeup_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); + device->wakeup.run_wake_count++; device->wakeup.state.enabled =1 ; }
@@ -443,6 +444,7 @@ static int acpi_button_remove(struct acp device->wakeup.gpe_number);acpi_unref_wakeup_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); + device->wakeup.run_wake_count--; device->wakeup.state.enabled =0 ; }
drivers/acpi/scan.c +27 -10
@@ -742,19 +742,39 @@ acpi_bus_extract_wakeup_device_power_pacreturn AE_OK ; } -static int acpi_bus_get_wakeup_device_flags (struct acpi_device *device) +static void acpi_bus_set_run_wake_flags (struct acpi_device *device) { -acpi_status status =0 ; -struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; -union acpi_object *package =NULL ; -int psw_error; -struct acpi_device_id button_device_ids[] = { {"PNP0C0D" ,0 }, {"PNP0C0C" ,0 }, {"PNP0C0E" ,0 }, {"" ,0 }, }; +acpi_status status; +acpi_event_status event_status; + + device->wakeup.run_wake_count =0 ; + +/* Power button, Lid switch always enable wakeup */ +if (!acpi_match_device_ids (device, button_device_ids)) { + device->wakeup.flags.run_wake =1 ; + device->wakeup.flags.special =1 ; +return ; + } + + status =acpi_get_gpe_status (NULL , device->wakeup.gpe_number, +ACPI_NOT_ISR , &event_status); +if (status ==AE_OK ) + device->wakeup.flags.run_wake = + !!(event_status &ACPI_EVENT_FLAG_HANDLE ); +} + +static int acpi_bus_get_wakeup_device_flags (struct acpi_device *device) +{ +acpi_status status =0 ; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *package =NULL ; +int psw_error;/* _PRW */ status =acpi_evaluate_object (device->handle,"_PRW" ,NULL , &buffer);
@@ -774,6 +794,7 @@ static int acpi_bus_get_wakeup_device_fl device->wakeup.flags.valid =1 ; device->wakeup.prepare_count =0 ; +acpi_bus_set_run_wake_flags (device);/* Call _PSW/_DSW object to disable its ability to wake the sleeping * system for the ACPI device with the _PRW object. * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
@@ -785,10 +806,6 @@ static int acpi_bus_get_wakeup_device_flACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"error in _DSW or _PSW evaluation\n" )); -/* Power button, Lid switch always enable wakeup */ -if (!acpi_match_device_ids (device, button_device_ids)) - device->wakeup.flags.run_wake =1 ; - end:if (ACPI_FAILURE (status)) device->flags.wake_capable =0 ;
RFC PATCH 9/12 ACPI / PM: Add more run-time wake-up fields
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Use the run_wake flag to mark all devices for which run-time wake-up events may be generated by the platform. Introduce a new wake-up flag, special, for marking devices that should be permanently enabled to generate run-time events. Also, introduce a reference counter for run-wake devices and a function that will initialize all of the run-time wake-up fields for given device.
--- drivers/acpi/button.c | 2 ++ drivers/acpi/scan.c | 37 +++++++++++++++++++++++++++---------- drivers/acpi/wakeup.c | 2 +- include/acpi/acpi_bus.h | 2 ++ 4 files changed, 32 insertions(+), 11 deletions(-)
drivers/acpi/wakeup.c +1 -1
@@ -106,7 +106,7 @@ int __init acpi_wakeup_device_init(void) struct acpi_device, wakeup_list);/* In case user doesn't load button driver */ -if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled) +if (!dev->wakeup.flags.special || dev->wakeup.state.enabled)continue ;acpi_ref_wakeup_gpe (dev->wakeup.gpe_device, dev->wakeup.gpe_number);
include/acpi/acpi_bus.h +2 -0
@@ -242,6 +242,7 @@ struct acpi_device_perf {struct acpi_device_wakeup_flags {u8 valid:1 ;/* Can successfully enable wakeup? */ u8 run_wake:1 ;/* Run-Wake GPE devices */ +u8 special:1 ;/* Run-wake devices that are always enabled */ };struct acpi_device_wakeup_state {
@@ -256,6 +257,7 @@ struct acpi_device_wakeup {struct acpi_device_wakeup_state state;struct acpi_device_wakeup_flags flags;int prepare_count; +int run_wake_count; };/* Device */
drivers/acpi/button.c +2 -0
@@ -419,6 +419,7 @@ static int acpi_button_add(struct acpi_d device->wakeup.gpe_number);acpi_ref_wakeup_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); + device->wakeup.run_wake_count++; device->wakeup.state.enabled =1 ; }
@@ -443,6 +444,7 @@ static int acpi_button_remove(struct acp device->wakeup.gpe_number);acpi_unref_wakeup_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); + device->wakeup.run_wake_count--; device->wakeup.state.enabled =0 ; }
drivers/acpi/scan.c +27 -10
@@ -742,19 +742,39 @@ acpi_bus_extract_wakeup_device_power_pacreturn AE_OK ; } -static int acpi_bus_get_wakeup_device_flags (struct acpi_device *device) +static void acpi_bus_set_run_wake_flags (struct acpi_device *device) { -acpi_status status =0 ; -struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; -union acpi_object *package =NULL ; -int psw_error; -struct acpi_device_id button_device_ids[] = { {"PNP0C0D" ,0 }, {"PNP0C0C" ,0 }, {"PNP0C0E" ,0 }, {"" ,0 }, }; +acpi_status status; +acpi_event_status event_status; + + device->wakeup.run_wake_count =0 ; + +/* Power button, Lid switch always enable wakeup */ +if (!acpi_match_device_ids (device, button_device_ids)) { + device->wakeup.flags.run_wake =1 ; + device->wakeup.flags.special =1 ; +return ; + } + + status =acpi_get_gpe_status (NULL , device->wakeup.gpe_number, +ACPI_NOT_ISR , &event_status); +if (status ==AE_OK ) + device->wakeup.flags.run_wake = + !!(event_status &ACPI_EVENT_FLAG_HANDLE ); +} + +static int acpi_bus_get_wakeup_device_flags (struct acpi_device *device) +{ +acpi_status status =0 ; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *package =NULL ; +int psw_error;/* _PRW */ status =acpi_evaluate_object (device->handle,"_PRW" ,NULL , &buffer);
@@ -774,6 +794,7 @@ static int acpi_bus_get_wakeup_device_fl device->wakeup.flags.valid =1 ; device->wakeup.prepare_count =0 ; +acpi_bus_set_run_wake_flags (device);/* Call _PSW/_DSW object to disable its ability to wake the sleeping * system for the ACPI device with the _PRW object. * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
@@ -785,10 +806,6 @@ static int acpi_bus_get_wakeup_device_flACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"error in _DSW or _PSW evaluation\n" )); -/* Power button, Lid switch always enable wakeup */ -if (!acpi_match_device_ids (device, button_device_ids)) - device->wakeup.flags.run_wake =1 ; - end:if (ACPI_FAILURE (status)) device->flags.wake_capable =0 ;
RFC PATCH 10/12 PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 4)
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-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 new PCI platform callback ->test_run_wake() and ->run_wake() to struct pci_platform_pm_ops allowing us, respectively, to check if if the platform can generate run-time wake-up events for given device and to enable/disable the platform to do that. Implemet these callbacks 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_dev_run_wake() which can be used by PCI drivers to check if given device is capable of generating wake-up events at run time.
Developed in cooperation with Matthew Garrett <[email protected]>.
--- drivers/acpi/pci_bind.c | 13 + drivers/acpi/pci_root.c | 7 drivers/acpi/sleep.c | 22 +- drivers/pci/hotplug/acpiphp_glue.c | 23 -- drivers/pci/pci-acpi.c | 397 +++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 67 ++++++ drivers/pci/pci.h | 12 + include/acpi/acpi_bus.h | 11 - include/linux/pci-acpi.h | 24 ++ include/linux/pci.h | 1 kernel/power/Kconfig | 5 11 files changed, 558 insertions(+), 24 deletions(-)
drivers/pci/pci.h +12 -0
@@ -35,6 +35,10 @@ int pci_probe_reset_function(struct pci_* * @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 +* 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,24 @@ 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 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 +397 -0
418 lines not on this page · raw message
drivers/pci/pci.c +67 -0
91 lines not on this page · raw message
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 +16 -6
@@ -626,7 +626,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
@@ -712,6 +712,18 @@ int acpi_pm_device_sleep_state(struct de }/** +* acpi_pm_wake_up_power - Enable/disable device wake-up power. +* @dev: ACPI device to handle. +* @enable: Whether to enable or disable the wake-up power of the device. +*/ +int acpi_pm_wake_up_power (struct acpi_device *dev,bool enable) +{ +return enable ? +acpi_enable_wakeup_device_power (dev, acpi_target_sleep_state) : +acpi_disable_wakeup_device_power (dev); +} + +/** * acpi_pm_device_sleep_wake - enable or disable the system wake-up * capability of given device * @dev: device to handle
@@ -732,16 +744,14 @@ int acpi_pm_device_sleep_wake(struct dev return -ENODEV; } - error = enable ? -acpi_enable_wakeup_device_power (adev, acpi_target_sleep_state) : -acpi_disable_wakeup_device_power (adev); + error =acpi_pm_wake_up_power (adev, enable);if (!error) -dev_info (dev,"wake-up capability %s by ACPI\n" , +dev_info (dev,"wake-up power %s by ACPI\n" , enable ?"enabled" :"disabled" );return error; } -#endif +#endif /* CONFIG_PM_WAKEUP */ static void acpi_power_off_prepare (void ) {
drivers/acpi/pci_root.c +7 -0
@@ -30,6 +30,7 @@#include <linux/proc_fs.h> #include <linux/spinlock.h> #include <linux/pm.h> +#include <linux/pm_runtime.h> #include <linux/pci.h> #include <linux/pci-acpi.h> #include <linux/acpi.h>
@@ -576,6 +577,9 @@ static int __devinit acpi_pci_root_add(sif (flags != base_flags)acpi_pci_osc_support (root, flags); +if (!pci_acpi_add_bus_pm_notifier (device, root->bus)) +device_set_run_wake (root->bus->bridge, true); +return 0 ; end:
@@ -597,6 +601,9 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device); +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (root->bus->bridge, false); +kfree (root);return 0 ; }
include/linux/pci-acpi.h +24 -0
@@ -11,6 +11,30 @@#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_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev, +struct pci_bus *pci_bus); +extern acpi_status pci_acpi_remove_pm_notifier (struct acpi_device *dev); + +static inline +acpi_status pci_acpi_add_device_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev) +{ +return pci_acpi_add_pm_notifier (dev, pci_dev, pci_dev->subordinate); +} + +static inline +acpi_status pci_acpi_add_bus_pm_notifier (struct acpi_device *dev, +struct pci_bus *pci_bus) +{ +return pci_acpi_add_pm_notifier (dev,NULL , pci_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 +12 -1
@@ -26,7 +26,9 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/pci.h> +#include <linux/pci-acpi.h> #include <linux/acpi.h> +#include <linux/pm_runtime.h> #include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h>
@@ -38,7 +40,13 @@ 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; + +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (&dev->dev, false); + +if (!dev->subordinate) goto out;acpi_pci_irq_del_prt (dev->subordinate);
@@ -62,6 +70,9 @@ static int acpi_pci_bind(struct acpi_devif (!dev)return 0 ; +if (!pci_acpi_add_device_pm_notifier (device, dev)) +device_set_run_wake (&dev->dev, true); +/* * Install the 'bind' function to facilitate callbacks for * children of the P2P bridge.
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 ;
include/linux/pci.h +1 -0
@@ -743,6 +743,7 @@ int pci_wake_from_d3(struct pci_dev *devpci_power_t pci_target_state (struct pci_dev *dev);int pci_prepare_to_sleep (struct pci_dev *dev);int pci_back_from_sleep (struct pci_dev *dev); +bool pci_dev_run_wake (struct pci_dev *dev);/* Functions for PCI Hotplug drivers to use */ int pci_bus_find_capability (struct pci_bus *bus,unsigned int devfn,int cap);
include/acpi/acpi_bus.h +8 -3
@@ -388,21 +388,26 @@ 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_wake_up_power (struct acpi_device *,bool );int acpi_pm_device_sleep_wake (struct device *,bool ); -#else /* !CONFIG_PM_SLEEP */ +#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_wake_up_power (struct acpi_device *dev,bool enable) +{ +return -ENODEV ; +}static inline int acpi_pm_device_sleep_wake (struct device *dev,bool enable) {return -ENODEV ; } -#endif /* !CONFIG_PM_SLEEP */ +#endif /* !CONFIG_PM_WAKEUP */ #endif /* CONFIG_ACPI */
RFC PATCH 10/12 PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 4)
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-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 new PCI platform callback ->test_run_wake() and ->run_wake() to struct pci_platform_pm_ops allowing us, respectively, to check if if the platform can generate run-time wake-up events for given device and to enable/disable the platform to do that. Implemet these callbacks 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_dev_run_wake() which can be used by PCI drivers to check if given device is capable of generating wake-up events at run time.
Developed in cooperation with Matthew Garrett <[email protected]>.
--- drivers/acpi/pci_bind.c | 13 + drivers/acpi/pci_root.c | 7 drivers/acpi/sleep.c | 22 +- drivers/pci/hotplug/acpiphp_glue.c | 23 -- drivers/pci/pci-acpi.c | 397 +++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 67 ++++++ drivers/pci/pci.h | 12 + include/acpi/acpi_bus.h | 11 - include/linux/pci-acpi.h | 24 ++ include/linux/pci.h | 1 kernel/power/Kconfig | 5 11 files changed, 558 insertions(+), 24 deletions(-)
drivers/pci/pci.h +12 -0
@@ -35,6 +35,10 @@ int pci_probe_reset_function(struct pci_* * @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 +* 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,24 @@ 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 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 +397 -0
418 lines not on this page · raw message
drivers/pci/pci.c +67 -0
91 lines not on this page · raw message
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 +16 -6
@@ -626,7 +626,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
@@ -712,6 +712,18 @@ int acpi_pm_device_sleep_state(struct de }/** +* acpi_pm_wake_up_power - Enable/disable device wake-up power. +* @dev: ACPI device to handle. +* @enable: Whether to enable or disable the wake-up power of the device. +*/ +int acpi_pm_wake_up_power (struct acpi_device *dev,bool enable) +{ +return enable ? +acpi_enable_wakeup_device_power (dev, acpi_target_sleep_state) : +acpi_disable_wakeup_device_power (dev); +} + +/** * acpi_pm_device_sleep_wake - enable or disable the system wake-up * capability of given device * @dev: device to handle
@@ -732,16 +744,14 @@ int acpi_pm_device_sleep_wake(struct dev return -ENODEV; } - error = enable ? -acpi_enable_wakeup_device_power (adev, acpi_target_sleep_state) : -acpi_disable_wakeup_device_power (adev); + error =acpi_pm_wake_up_power (adev, enable);if (!error) -dev_info (dev,"wake-up capability %s by ACPI\n" , +dev_info (dev,"wake-up power %s by ACPI\n" , enable ?"enabled" :"disabled" );return error; } -#endif +#endif /* CONFIG_PM_WAKEUP */ static void acpi_power_off_prepare (void ) {
drivers/acpi/pci_root.c +7 -0
@@ -30,6 +30,7 @@#include <linux/proc_fs.h> #include <linux/spinlock.h> #include <linux/pm.h> +#include <linux/pm_runtime.h> #include <linux/pci.h> #include <linux/pci-acpi.h> #include <linux/acpi.h>
@@ -576,6 +577,9 @@ static int __devinit acpi_pci_root_add(sif (flags != base_flags)acpi_pci_osc_support (root, flags); +if (!pci_acpi_add_bus_pm_notifier (device, root->bus)) +device_set_run_wake (root->bus->bridge, true); +return 0 ; end:
@@ -597,6 +601,9 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device); +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (root->bus->bridge, false); +kfree (root);return 0 ; }
include/linux/pci-acpi.h +24 -0
@@ -11,6 +11,30 @@#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_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev, +struct pci_bus *pci_bus); +extern acpi_status pci_acpi_remove_pm_notifier (struct acpi_device *dev); + +static inline +acpi_status pci_acpi_add_device_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev) +{ +return pci_acpi_add_pm_notifier (dev, pci_dev, pci_dev->subordinate); +} + +static inline +acpi_status pci_acpi_add_bus_pm_notifier (struct acpi_device *dev, +struct pci_bus *pci_bus) +{ +return pci_acpi_add_pm_notifier (dev,NULL , pci_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 +12 -1
@@ -26,7 +26,9 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/pci.h> +#include <linux/pci-acpi.h> #include <linux/acpi.h> +#include <linux/pm_runtime.h> #include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h>
@@ -38,7 +40,13 @@ 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; + +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (&dev->dev, false); + +if (!dev->subordinate) goto out;acpi_pci_irq_del_prt (dev->subordinate);
@@ -62,6 +70,9 @@ static int acpi_pci_bind(struct acpi_devif (!dev)return 0 ; +if (!pci_acpi_add_device_pm_notifier (device, dev)) +device_set_run_wake (&dev->dev, true); +/* * Install the 'bind' function to facilitate callbacks for * children of the P2P bridge.
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 ;
include/linux/pci.h +1 -0
@@ -743,6 +743,7 @@ int pci_wake_from_d3(struct pci_dev *devpci_power_t pci_target_state (struct pci_dev *dev);int pci_prepare_to_sleep (struct pci_dev *dev);int pci_back_from_sleep (struct pci_dev *dev); +bool pci_dev_run_wake (struct pci_dev *dev);/* Functions for PCI Hotplug drivers to use */ int pci_bus_find_capability (struct pci_bus *bus,unsigned int devfn,int cap);
include/acpi/acpi_bus.h +8 -3
@@ -388,21 +388,26 @@ 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_wake_up_power (struct acpi_device *,bool );int acpi_pm_device_sleep_wake (struct device *,bool ); -#else /* !CONFIG_PM_SLEEP */ +#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_wake_up_power (struct acpi_device *dev,bool enable) +{ +return -ENODEV ; +}static inline int acpi_pm_device_sleep_wake (struct device *dev,bool enable) {return -ENODEV ; } -#endif /* !CONFIG_PM_SLEEP */ +#endif /* !CONFIG_PM_WAKEUP */ #endif /* CONFIG_ACPI */
Re: [RFC][PATCH 10/12] PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 4)
drivers/pci/pci-acpi.c line 81
Quoted 6 lines · Rafael J. Wysocki
drivers/pci/pci-acpi.c +6
-0+if (event ==ACPI_NOTIFY_DEVICE_WAKE ) { +if (nb->dev->wakeup.run_wake_count >0 ) { +if (nb->pci_bus) +pci_pme_wakeup_bus (nb->pci_bus); +if (nb->pci_dev) +pci_pme_wakeup (nb->pci_dev);
We may receive wakeup events on devices that aren't PME capable, which is the case for uhci on my test box. In that case we probably want to wake them up unconditionally.
+ if (nb->pci_dev) {
+ if (nb->pci_dev->pm_cap)
+ pci_pme_wakeup(nb->pci_dev);
+ else
+ pm_request_resume(&nb->pci_dev->dev);
seems to work, though possibly we should assume that the firmware knows best and always schedule a wake in respose to a resume request?
Signature · 1 line
Matthew Garrett | [email protected]
Re: [RFC][PATCH 10/12] PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 4)
Quoted 19 lines · Matthew Garrett
drivers/pci/pci-acpi.c line 81
Quoted 6 lines · Rafael J. Wysocki
drivers/pci/pci-acpi.c +6
-0+if (event ==ACPI_NOTIFY_DEVICE_WAKE ) { +if (nb->dev->wakeup.run_wake_count >0 ) { +if (nb->pci_bus) +pci_pme_wakeup_bus (nb->pci_bus); +if (nb->pci_dev) +pci_pme_wakeup (nb->pci_dev);We may receive wakeup events on devices that aren't PME capable, which is the case for uhci on my test box. In that case we probably want to wake them up unconditionally.
(quoted diff) +5
-0+ if (nb->pci_dev) { + if (nb->pci_dev->pm_cap) + pci_pme_wakeup(nb->pci_dev); + else + pm_request_resume(&nb->pci_dev->dev);
Quoted 2 lines
seems to work, though possibly we should assume that the firmware knows best and always schedule a wake in respose to a resume request?
I think we can simply do:
+ if (nb->pci_dev) {
+ pci_pme_wakeup(nb->pci_dev);
+ pm_request_resume(&nb->pci_dev->dev);
+ }
If the pci_pme_wakeup() spawns a resume request, the other call will just return.
Thanks,
Rafael
RFC PATCH 10/12 PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 5)
Quoted 30 lines · Rafael J. Wysocki
Quoted 19 lines · Matthew Garrett
Review
Quoted 6 lines · Rafael J. Wysocki
(quoted diff) +6
-0+ if (event == ACPI_NOTIFY_DEVICE_WAKE) { + if (nb->dev->wakeup.run_wake_count > 0) { + if (nb->pci_bus) + pci_pme_wakeup_bus(nb->pci_bus); + if (nb->pci_dev) + pci_pme_wakeup(nb->pci_dev);We may receive wakeup events on devices that aren't PME capable, which is the case for uhci on my test box. In that case we probably want to wake them up unconditionally.
(quoted diff) +5
-0+ if (nb->pci_dev) { + if (nb->pci_dev->pm_cap) + pci_pme_wakeup(nb->pci_dev); + else + pm_request_resume(&nb->pci_dev->dev);Quoted 2 lines
seems to work, though possibly we should assume that the firmware knows best and always schedule a wake in respose to a resume request?
I think we can simply do:
(quoted diff) +4
-0+ if (nb->pci_dev) { + pci_pme_wakeup(nb->pci_dev); + pm_request_resume(&nb->pci_dev->dev); + }
Quoted 2 lines
If the
pci_pme_wakeup()spawns a resume request, the other call will just return.
Or better, make it
pci_check_pme_status(nb->pci_dev);pm_request_resume(&nb->pci_dev->dev);
which avoids calling pm_request_resume() twice and allows us to make pci_pme_wakeup a static function.
Rev. 5 of the patch implementing this is appended.
---
From: Rafael J. Wysocki <[email protected]>
Subject: PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 5)
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-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 new PCI platform callback ->test_run_wake() and ->run_wake() to struct pci_platform_pm_ops allowing us, respectively, to check if if the platform can generate run-time wake-up events for given device and to enable/disable the platform to do that. Implemet these callbacks 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_dev_run_wake() which can be used by PCI drivers to check if given device is capable of generating wake-up events at run time.
Developed in cooperation with Matthew Garrett <[email protected]>.
--- drivers/acpi/pci_bind.c | 13 + drivers/acpi/pci_root.c | 7 drivers/acpi/sleep.c | 22 +- drivers/pci/hotplug/acpiphp_glue.c | 23 -- drivers/pci/pci-acpi.c | 399 +++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 67 ++++++ drivers/pci/pci.h | 7 include/acpi/acpi_bus.h | 11 - include/linux/pci-acpi.h | 24 ++ include/linux/pci.h | 1 kernel/power/Kconfig | 5 11 files changed, 555 insertions(+), 24 deletions(-)
drivers/pci/pci.h +7 -0
@@ -35,6 +35,10 @@ int pci_probe_reset_function(struct pci_* * @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 +* 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,12 +48,15 @@ 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 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);
drivers/pci/pci-acpi.c +399 -0
420 lines not on this page · raw message
drivers/pci/pci.c +67 -0
91 lines not on this page · raw message
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 +16 -6
@@ -634,7 +634,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
@@ -720,6 +720,18 @@ int acpi_pm_device_sleep_state(struct de }/** +* acpi_pm_wake_up_power - Enable/disable device wake-up power. +* @dev: ACPI device to handle. +* @enable: Whether to enable or disable the wake-up power of the device. +*/ +int acpi_pm_wake_up_power (struct acpi_device *dev,bool enable) +{ +return enable ? +acpi_enable_wakeup_device_power (dev, acpi_target_sleep_state) : +acpi_disable_wakeup_device_power (dev); +} + +/** * acpi_pm_device_sleep_wake - enable or disable the system wake-up * capability of given device * @dev: device to handle
@@ -740,16 +752,14 @@ int acpi_pm_device_sleep_wake(struct dev return -ENODEV; } - error = enable ? -acpi_enable_wakeup_device_power (adev, acpi_target_sleep_state) : -acpi_disable_wakeup_device_power (adev); + error =acpi_pm_wake_up_power (adev, enable);if (!error) -dev_info (dev,"wake-up capability %s by ACPI\n" , +dev_info (dev,"wake-up power %s by ACPI\n" , enable ?"enabled" :"disabled" );return error; } -#endif +#endif /* CONFIG_PM_WAKEUP */ static void acpi_power_off_prepare (void ) {
drivers/acpi/pci_root.c +7 -0
@@ -30,6 +30,7 @@#include <linux/proc_fs.h> #include <linux/spinlock.h> #include <linux/pm.h> +#include <linux/pm_runtime.h> #include <linux/pci.h> #include <linux/pci-acpi.h> #include <linux/acpi.h>
@@ -576,6 +577,9 @@ static int __devinit acpi_pci_root_add(sif (flags != base_flags)acpi_pci_osc_support (root, flags); +if (!pci_acpi_add_bus_pm_notifier (device, root->bus)) +device_set_run_wake (root->bus->bridge, true); +return 0 ; end:
@@ -597,6 +601,9 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device); +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (root->bus->bridge, false); +kfree (root);return 0 ; }
include/linux/pci-acpi.h +24 -0
@@ -11,6 +11,30 @@#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_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev, +struct pci_bus *pci_bus); +extern acpi_status pci_acpi_remove_pm_notifier (struct acpi_device *dev); + +static inline +acpi_status pci_acpi_add_device_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev) +{ +return pci_acpi_add_pm_notifier (dev, pci_dev, pci_dev->subordinate); +} + +static inline +acpi_status pci_acpi_add_bus_pm_notifier (struct acpi_device *dev, +struct pci_bus *pci_bus) +{ +return pci_acpi_add_pm_notifier (dev,NULL , pci_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 +12 -1
@@ -26,7 +26,9 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/pci.h> +#include <linux/pci-acpi.h> #include <linux/acpi.h> +#include <linux/pm_runtime.h> #include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h>
@@ -38,7 +40,13 @@ 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; + +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (&dev->dev, false); + +if (!dev->subordinate) goto out;acpi_pci_irq_del_prt (dev->subordinate);
@@ -62,6 +70,9 @@ static int acpi_pci_bind(struct acpi_devif (!dev)return 0 ; +if (!pci_acpi_add_device_pm_notifier (device, dev)) +device_set_run_wake (&dev->dev, true); +/* * Install the 'bind' function to facilitate callbacks for * children of the P2P bridge.
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 ;
include/linux/pci.h +1 -0
@@ -743,6 +743,7 @@ int pci_wake_from_d3(struct pci_dev *devpci_power_t pci_target_state (struct pci_dev *dev);int pci_prepare_to_sleep (struct pci_dev *dev);int pci_back_from_sleep (struct pci_dev *dev); +bool pci_dev_run_wake (struct pci_dev *dev);/* Functions for PCI Hotplug drivers to use */ int pci_bus_find_capability (struct pci_bus *bus,unsigned int devfn,int cap);
include/acpi/acpi_bus.h +8 -3
@@ -388,21 +388,26 @@ 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_wake_up_power (struct acpi_device *,bool );int acpi_pm_device_sleep_wake (struct device *,bool ); -#else /* !CONFIG_PM_SLEEP */ +#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_wake_up_power (struct acpi_device *dev,bool enable) +{ +return -ENODEV ; +}static inline int acpi_pm_device_sleep_wake (struct device *dev,bool enable) {return -ENODEV ; } -#endif /* !CONFIG_PM_SLEEP */ +#endif /* !CONFIG_PM_WAKEUP */ #endif /* CONFIG_ACPI */
RFC PATCH 10/12 PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 5)
In reply to Rafael J. WysockiQuoted 30 lines · Rafael J. Wysocki
Quoted 19 lines · Matthew Garrett
Review
Quoted 6 lines · Rafael J. Wysocki
(quoted diff) +6
-0+ if (event == ACPI_NOTIFY_DEVICE_WAKE) { + if (nb->dev->wakeup.run_wake_count > 0) { + if (nb->pci_bus) + pci_pme_wakeup_bus(nb->pci_bus); + if (nb->pci_dev) + pci_pme_wakeup(nb->pci_dev);We may receive wakeup events on devices that aren't PME capable, which is the case for uhci on my test box. In that case we probably want to wake them up unconditionally.
(quoted diff) +5
-0+ if (nb->pci_dev) { + if (nb->pci_dev->pm_cap) + pci_pme_wakeup(nb->pci_dev); + else + pm_request_resume(&nb->pci_dev->dev);Quoted 2 lines
seems to work, though possibly we should assume that the firmware knows best and always schedule a wake in respose to a resume request?
I think we can simply do:
(quoted diff) +4
-0+ if (nb->pci_dev) { + pci_pme_wakeup(nb->pci_dev); + pm_request_resume(&nb->pci_dev->dev); + }
Quoted 2 lines
If the
pci_pme_wakeup()spawns a resume request, the other call will just return.
Or better, make it
pci_check_pme_status(nb->pci_dev);pm_request_resume(&nb->pci_dev->dev);
which avoids calling pm_request_resume() twice and allows us to make pci_pme_wakeup a static function.
Rev. 5 of the patch implementing this is appended.
---
From: Rafael J. Wysocki <[email protected]>
Subject: PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 5)
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-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 new PCI platform callback ->test_run_wake() and ->run_wake() to struct pci_platform_pm_ops allowing us, respectively, to check if if the platform can generate run-time wake-up events for given device and to enable/disable the platform to do that. Implemet these callbacks 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_dev_run_wake() which can be used by PCI drivers to check if given device is capable of generating wake-up events at run time.
Developed in cooperation with Matthew Garrett <[email protected]>.
--- drivers/acpi/pci_bind.c | 13 + drivers/acpi/pci_root.c | 7 drivers/acpi/sleep.c | 22 +- drivers/pci/hotplug/acpiphp_glue.c | 23 -- drivers/pci/pci-acpi.c | 399 +++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 67 ++++++ drivers/pci/pci.h | 7 include/acpi/acpi_bus.h | 11 - include/linux/pci-acpi.h | 24 ++ include/linux/pci.h | 1 kernel/power/Kconfig | 5 11 files changed, 555 insertions(+), 24 deletions(-)
drivers/pci/pci.h +7 -0
@@ -35,6 +35,10 @@ int pci_probe_reset_function(struct pci_* * @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 +* 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,12 +48,15 @@ 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 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);
drivers/pci/pci-acpi.c +399 -0
420 lines not on this page · raw message
drivers/pci/pci.c +67 -0
91 lines not on this page · raw message
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 +16 -6
@@ -634,7 +634,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
@@ -720,6 +720,18 @@ int acpi_pm_device_sleep_state(struct de }/** +* acpi_pm_wake_up_power - Enable/disable device wake-up power. +* @dev: ACPI device to handle. +* @enable: Whether to enable or disable the wake-up power of the device. +*/ +int acpi_pm_wake_up_power (struct acpi_device *dev,bool enable) +{ +return enable ? +acpi_enable_wakeup_device_power (dev, acpi_target_sleep_state) : +acpi_disable_wakeup_device_power (dev); +} + +/** * acpi_pm_device_sleep_wake - enable or disable the system wake-up * capability of given device * @dev: device to handle
@@ -740,16 +752,14 @@ int acpi_pm_device_sleep_wake(struct dev return -ENODEV; } - error = enable ? -acpi_enable_wakeup_device_power (adev, acpi_target_sleep_state) : -acpi_disable_wakeup_device_power (adev); + error =acpi_pm_wake_up_power (adev, enable);if (!error) -dev_info (dev,"wake-up capability %s by ACPI\n" , +dev_info (dev,"wake-up power %s by ACPI\n" , enable ?"enabled" :"disabled" );return error; } -#endif +#endif /* CONFIG_PM_WAKEUP */ static void acpi_power_off_prepare (void ) {
drivers/acpi/pci_root.c +7 -0
@@ -30,6 +30,7 @@#include <linux/proc_fs.h> #include <linux/spinlock.h> #include <linux/pm.h> +#include <linux/pm_runtime.h> #include <linux/pci.h> #include <linux/pci-acpi.h> #include <linux/acpi.h>
@@ -576,6 +577,9 @@ static int __devinit acpi_pci_root_add(sif (flags != base_flags)acpi_pci_osc_support (root, flags); +if (!pci_acpi_add_bus_pm_notifier (device, root->bus)) +device_set_run_wake (root->bus->bridge, true); +return 0 ; end:
@@ -597,6 +601,9 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device); +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (root->bus->bridge, false); +kfree (root);return 0 ; }
include/linux/pci-acpi.h +24 -0
@@ -11,6 +11,30 @@#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_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev, +struct pci_bus *pci_bus); +extern acpi_status pci_acpi_remove_pm_notifier (struct acpi_device *dev); + +static inline +acpi_status pci_acpi_add_device_pm_notifier (struct acpi_device *dev, +struct pci_dev *pci_dev) +{ +return pci_acpi_add_pm_notifier (dev, pci_dev, pci_dev->subordinate); +} + +static inline +acpi_status pci_acpi_add_bus_pm_notifier (struct acpi_device *dev, +struct pci_bus *pci_bus) +{ +return pci_acpi_add_pm_notifier (dev,NULL , pci_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 +12 -1
@@ -26,7 +26,9 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/pci.h> +#include <linux/pci-acpi.h> #include <linux/acpi.h> +#include <linux/pm_runtime.h> #include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h>
@@ -38,7 +40,13 @@ 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; + +pci_acpi_remove_pm_notifier (device); +device_set_run_wake (&dev->dev, false); + +if (!dev->subordinate) goto out;acpi_pci_irq_del_prt (dev->subordinate);
@@ -62,6 +70,9 @@ static int acpi_pci_bind(struct acpi_devif (!dev)return 0 ; +if (!pci_acpi_add_device_pm_notifier (device, dev)) +device_set_run_wake (&dev->dev, true); +/* * Install the 'bind' function to facilitate callbacks for * children of the P2P bridge.
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 ;
include/linux/pci.h +1 -0
@@ -743,6 +743,7 @@ int pci_wake_from_d3(struct pci_dev *devpci_power_t pci_target_state (struct pci_dev *dev);int pci_prepare_to_sleep (struct pci_dev *dev);int pci_back_from_sleep (struct pci_dev *dev); +bool pci_dev_run_wake (struct pci_dev *dev);/* Functions for PCI Hotplug drivers to use */ int pci_bus_find_capability (struct pci_bus *bus,unsigned int devfn,int cap);
include/acpi/acpi_bus.h +8 -3
@@ -388,21 +388,26 @@ 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_wake_up_power (struct acpi_device *,bool );int acpi_pm_device_sleep_wake (struct device *,bool ); -#else /* !CONFIG_PM_SLEEP */ +#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_wake_up_power (struct acpi_device *dev,bool enable) +{ +return -ENODEV ; +}static inline int acpi_pm_device_sleep_wake (struct device *dev,bool enable) {return -ENODEV ; } -#endif /* !CONFIG_PM_SLEEP */ +#endif /* !CONFIG_PM_WAKEUP */ #endif /* CONFIG_ACPI */
Re: [RFC][PATCH 10/12] PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 4)
In reply to Matthew GarrettQuoted 19 lines · Matthew Garrett
drivers/pci/pci-acpi.c line 81
Quoted 6 lines · Rafael J. Wysocki
drivers/pci/pci-acpi.c +6
-0+if (event ==ACPI_NOTIFY_DEVICE_WAKE ) { +if (nb->dev->wakeup.run_wake_count >0 ) { +if (nb->pci_bus) +pci_pme_wakeup_bus (nb->pci_bus); +if (nb->pci_dev) +pci_pme_wakeup (nb->pci_dev);We may receive wakeup events on devices that aren't PME capable, which is the case for uhci on my test box. In that case we probably want to wake them up unconditionally.
(quoted diff) +5
-0+ if (nb->pci_dev) { + if (nb->pci_dev->pm_cap) + pci_pme_wakeup(nb->pci_dev); + else + pm_request_resume(&nb->pci_dev->dev);
Quoted 2 lines
seems to work, though possibly we should assume that the firmware knows best and always schedule a wake in respose to a resume request?
I think we can simply do:
+ if (nb->pci_dev) {
+ pci_pme_wakeup(nb->pci_dev);
+ pm_request_resume(&nb->pci_dev->dev);
+ }
If the pci_pme_wakeup() spawns a resume request, the other call will just return.
Thanks,
Rafael
Re: [RFC][PATCH 10/12] PCI / ACPI PM: Platform support for PCI PME wake-up (rev. 4)
In reply to Rafael J. Wysockidrivers/pci/pci-acpi.c line 81
Quoted 6 lines · Rafael J. Wysocki
drivers/pci/pci-acpi.c +6
-0+if (event ==ACPI_NOTIFY_DEVICE_WAKE ) { +if (nb->dev->wakeup.run_wake_count >0 ) { +if (nb->pci_bus) +pci_pme_wakeup_bus (nb->pci_bus); +if (nb->pci_dev) +pci_pme_wakeup (nb->pci_dev);
We may receive wakeup events on devices that aren't PME capable, which is the case for uhci on my test box. In that case we probably want to wake them up unconditionally.
+ if (nb->pci_dev) {
+ if (nb->pci_dev->pm_cap)
+ pci_pme_wakeup(nb->pci_dev);
+ else
+ pm_request_resume(&nb->pci_dev->dev);
seems to work, though possibly we should assume that the firmware knows best and always schedule a wake in respose to a resume request?
Signature · 1 line
Matthew Garrett | [email protected]
RFC PATCH 11/12 PCI PM: Run-time callbacks for PCI bus type (rev. 2)
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 | 105 ++++++++++++++++++++++++++++++++++++++++++++--- drivers/pci/pci.c | 43 ++++++++++++++++--- drivers/pci/pci.h | 1 include/linux/pci.h | 9 +++- kernel/power/Kconfig | 5 ++ 5 files changed, 151 insertions(+), 12 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 +100 -5
154 lines not on this page · raw message
drivers/pci/pci.c +37 -6
89 lines not on this page · raw message
include/linux/pci.h +8 -1
@@ -738,13 +738,20 @@ int pci_set_power_state(struct pci_dev *pci_power_t pci_choose_state (struct pci_dev *dev,pm_message_t state);bool pci_pme_capable (struct pci_dev *dev,pci_power_t state);void pci_pme_active (struct pci_dev *dev,bool enable); -int pci_enable_wake (struct pci_dev *dev,pci_power_t state,bool enable); +int __pci_enable_wake (struct pci_dev *dev,pci_power_t state, +bool runtime,bool enable);int pci_wake_from_d3 (struct pci_dev *dev,bool enable);pci_power_t pci_target_state (struct pci_dev *dev);int pci_prepare_to_sleep (struct pci_dev *dev);int pci_back_from_sleep (struct pci_dev *dev);bool pci_dev_run_wake (struct pci_dev *dev); +static inline int pci_enable_wake (struct pci_dev *dev,pci_power_t state, +bool enable) +{ +return __pci_enable_wake (dev, state, false, enable); +} +/* Functions for PCI Hotplug drivers to use */ int pci_bus_find_capability (struct pci_bus *bus,unsigned int devfn,int cap);#ifdef CONFIG_HOTPLUG
drivers/pci/pci.h +1 -0
@@ -55,6 +55,7 @@ extern int pci_set_platform_pm(struct pcextern 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_finish_runtime_suspend (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);
RFC PATCH 11/12 PCI PM: Run-time callbacks for PCI bus type (rev. 2)
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 | 105 ++++++++++++++++++++++++++++++++++++++++++++--- drivers/pci/pci.c | 43 ++++++++++++++++--- drivers/pci/pci.h | 1 include/linux/pci.h | 9 +++- kernel/power/Kconfig | 5 ++ 5 files changed, 151 insertions(+), 12 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 +100 -5
154 lines not on this page · raw message
drivers/pci/pci.c +37 -6
89 lines not on this page · raw message
include/linux/pci.h +8 -1
@@ -738,13 +738,20 @@ int pci_set_power_state(struct pci_dev *pci_power_t pci_choose_state (struct pci_dev *dev,pm_message_t state);bool pci_pme_capable (struct pci_dev *dev,pci_power_t state);void pci_pme_active (struct pci_dev *dev,bool enable); -int pci_enable_wake (struct pci_dev *dev,pci_power_t state,bool enable); +int __pci_enable_wake (struct pci_dev *dev,pci_power_t state, +bool runtime,bool enable);int pci_wake_from_d3 (struct pci_dev *dev,bool enable);pci_power_t pci_target_state (struct pci_dev *dev);int pci_prepare_to_sleep (struct pci_dev *dev);int pci_back_from_sleep (struct pci_dev *dev);bool pci_dev_run_wake (struct pci_dev *dev); +static inline int pci_enable_wake (struct pci_dev *dev,pci_power_t state, +bool enable) +{ +return __pci_enable_wake (dev, state, false, enable); +} +/* Functions for PCI Hotplug drivers to use */ int pci_bus_find_capability (struct pci_bus *bus,unsigned int devfn,int cap);#ifdef CONFIG_HOTPLUG
drivers/pci/pci.h +1 -0
@@ -55,6 +55,7 @@ extern int pci_set_platform_pm(struct pcextern 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_finish_runtime_suspend (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);
Re: [RFC][PATCH 11/12] PCI PM: Run-time callbacks for PCI bus type (rev. 2)
drivers/pci/pci.c void pci_pme_active(struct pci_dev *dev, · line 1301
Quoted 2 lines · Rafael J. Wysocki
drivers/pci/pci.c +1
-1-if (enable && !device_may_wakeup (&dev->dev)) +if (enable && runtime && !device_may_wakeup (&dev->dev))
Should this be !runtime? We only care about device_may_wakeup() in the system suspend case.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [RFC][PATCH 11/12] PCI PM: Run-time callbacks for PCI bus type (rev. 2)
Quoted 7 lines · Matthew Garrett
drivers/pci/pci.c void pci_pme_active(struct pci_dev *dev, · line 1301
Quoted 2 lines · Rafael J. Wysocki
drivers/pci/pci.c +1
-1-if (enable && !device_may_wakeup (&dev->dev)) +if (enable && runtime && !device_may_wakeup (&dev->dev))Should this be !runtime? We only care about
device_may_wakeup()in the system suspend case.
Yes, it should, thanks!
Re: [RFC][PATCH 11/12] PCI PM: Run-time callbacks for PCI bus type (rev. 2)
In reply to Matthew GarrettQuoted 7 lines · Matthew Garrett
drivers/pci/pci.c void pci_pme_active(struct pci_dev *dev, · line 1301
Quoted 2 lines · Rafael J. Wysocki
drivers/pci/pci.c +1
-1-if (enable && !device_may_wakeup (&dev->dev)) +if (enable && runtime && !device_may_wakeup (&dev->dev))Should this be !runtime? We only care about
device_may_wakeup()in the system suspend case.
Yes, it should, thanks!
Re: [RFC][PATCH 11/12] PCI PM: Run-time callbacks for PCI bus type (rev. 2)
In reply to Rafael J. Wysockidrivers/pci/pci.c void pci_pme_active(struct pci_dev *dev, · line 1301
Quoted 2 lines · Rafael J. Wysocki
drivers/pci/pci.c +1
-1-if (enable && !device_may_wakeup (&dev->dev)) +if (enable && runtime && !device_may_wakeup (&dev->dev))
Should this be !runtime? We only care about device_may_wakeup() in the system suspend case.
Signature · 1 line
Matthew Garrett | [email protected]
RFC PATCH 12/12 PM / r8169: Add simplified run-time PM support
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Use the PCI run-time power management framework to add simplified run-time PM support to the r8169 driver. Namely, make the driver suspend the device when the link is off and set it up for generating wake-up event after the link has been detected again.
--- drivers/net/r8169.c | 133 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 106 insertions(+), 27 deletions(-)
drivers/net/r8169.c +106 -27
@@ -23,6 +23,7 @@#include <linux/tcp.h> #include <linux/init.h> #include <linux/dma-mapping.h> +#include <linux/pm_runtime.h> #include <asm/system.h> #include <asm/io.h>
@@ -504,6 +505,8 @@ struct rtl8169_private {struct mii_if_info mii;struct rtl8169_counters counters; +u32 saved_wolopts; +bool exiting; };MODULE_AUTHOR ("Realtek and the Linux r8169 crew <[email protected]>" );
@@ -750,48 +753,54 @@ static void rtl8169_check_link_status(stif (netif_msg_ifdown (tp)) printk(KERN_INFO PFX "%s: link down\n", dev->name);netif_carrier_off (dev); +pm_schedule_suspend (&tp->pci_dev->dev,100 ); }spin_unlock_irqrestore (&tp->lock, flags); } -static void rtl8169_get_wol (struct net_device *dev,struct ethtool_wolinfo *wol) +#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST) + +static u32 __rtl8169_get_wol (struct rtl8169_private *tp) { -struct rtl8169_private *tp =netdev_priv (dev);void __iomem *ioaddr = tp->mmio_addr;u8 options; - - wol->wolopts =0 ; - -#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST) - wol->supported =WAKE_ANY ; - -spin_lock_irq (&tp->lock); +u32 wolopts =0 ; options =RTL_R8 (Config1);if (!(options & PMEnable)) - goto out_unlock; +return 0 ; options =RTL_R8 (Config3);if (options & LinkUp) - wol->wolopts |=WAKE_PHY ; + wolopts |=WAKE_PHY ;if (options & MagicPacket) - wol->wolopts |=WAKE_MAGIC ; + wolopts |=WAKE_MAGIC ; options =RTL_R8 (Config5);if (options &UWF ) - wol->wolopts |=WAKE_UCAST ; + wolopts |=WAKE_UCAST ;if (options &BWF ) - wol->wolopts |=WAKE_BCAST ; + wolopts |=WAKE_BCAST ;if (options &MWF ) - wol->wolopts |=WAKE_MCAST ; + wolopts |=WAKE_MCAST ; -out_unlock: -spin_unlock_irq (&tp->lock); +return wolopts; } -static int rtl8169_set_wol (struct net_device *dev,struct ethtool_wolinfo *wol) +static void rtl8169_get_wol (struct net_device *dev,struct ethtool_wolinfo *wol) {struct rtl8169_private *tp =netdev_priv (dev); + +spin_lock_irq (&tp->lock); + + wol->supported =WAKE_ANY ; + wol->wolopts =__rtl8169_get_wol (tp); + +spin_unlock_irq (&tp->lock); +} + +static void __rtl8169_set_wol (struct rtl8169_private *tp,u32 wolopts) +{void __iomem *ioaddr = tp->mmio_addr;unsigned int i; static struct {
@@ -808,23 +817,29 @@ static int rtl8169_set_wol(struct net_de { WAKE_ANY, Config5, LanWake } }; -spin_lock_irq (&tp->lock); -RTL_W8 (Cfg9346, Cfg9346_Unlock);for (i =0 ; i <ARRAY_SIZE (cfg); i++) {u8 options =RTL_R8 (cfg[i].reg) & ~cfg[i].mask; -if (wol->wolopts & cfg[i].opt) +if (wolopts & cfg[i].opt) options |= cfg[i].mask;RTL_W8 (cfg[i].reg, options); }RTL_W8 (Cfg9346, Cfg9346_Lock); +} + +static int rtl8169_set_wol (struct net_device *dev,struct ethtool_wolinfo *wol) +{ +struct rtl8169_private *tp =netdev_priv (dev); + +spin_lock_irq (&tp->lock);if (wol->wolopts) tp->features |=RTL_FEATURE_WOL ;else tp->features &= ~RTL_FEATURE_WOL ; +__rtl8169_set_wol (tp, wol->wolopts);device_set_wakeup_enable (&tp->pci_dev->dev, wol->wolopts);spin_unlock_irq (&tp->lock);
@@ -3000,6 +3015,7 @@ rtl8169_init_one(struct pci_dev *pdev, c tp->dev = dev; tp->pci_dev = pdev; tp->msg_enable =netif_msg_init (debug.msg_enable,R8169_MSG_DEFAULT ); + tp->exiting = false; mii = &tp->mii; mii->dev = dev;
@@ -3232,6 +3248,8 @@ static void __devexit rtl8169_remove_onestruct net_device *dev =pci_get_drvdata (pdev);struct rtl8169_private *tp =netdev_priv (dev); + tp->exiting = true; +flush_scheduled_work ();unregister_netdev (dev);
@@ -3254,7 +3272,6 @@ static int rtl8169_open(struct net_devicstruct pci_dev *pdev = tp->pci_dev;int retval = -ENOMEM ; -rtl8169_set_rxbufsize (tp, dev);/*
@@ -3291,6 +3308,13 @@ static int rtl8169_open(struct net_devicrtl8169_request_timer (dev); + tp->saved_wolopts =0 ; + +if (pci_dev_run_wake (pdev)) { +pm_runtime_set_active (&pdev->dev); +pm_runtime_enable (&pdev->dev); + } +rtl8169_check_link_status (dev, tp, tp->mmio_addr); out:return retval;
@@ -4724,6 +4748,14 @@ static int rtl8169_close(struct net_devistruct rtl8169_private *tp =netdev_priv (dev);struct pci_dev *pdev = tp->pci_dev; +if (pci_dev_run_wake (pdev)) { +pm_runtime_get_noresume (&pdev->dev); +pm_runtime_resume (&pdev->dev); +pm_runtime_disable (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); + } +/* update counters before going down */ rtl8169_update_counters (dev);
@@ -4841,21 +4873,65 @@ static int rtl8169_suspend(struct devicereturn 0 ; } +static void __rtl8169_resume (struct net_device *dev) +{ +netif_device_attach (dev); +rtl8169_schedule_work (dev, rtl8169_reset_task); +} +static int rtl8169_resume (struct device *device) {struct pci_dev *pdev =to_pci_dev (device);struct net_device *dev =pci_get_drvdata (pdev); -if (!netif_running (dev)) - goto out; +if (netif_running (dev)) +__rtl8169_resume (dev); -netif_device_attach (dev); +return 0 ; +} + +static int rtl8169_runtime_suspend (struct device *device) +{ +struct pci_dev *pdev =to_pci_dev (device); +struct net_device *dev =pci_get_drvdata (pdev); +struct rtl8169_private *tp =netdev_priv (dev); + +dev_dbg (&pdev->dev,"suspending\n" ); + +spin_lock_irq (&tp->lock); + tp->saved_wolopts =__rtl8169_get_wol (tp); +__rtl8169_set_wol (tp,WAKE_ANY ); +spin_unlock_irq (&tp->lock); + +rtl8169_net_suspend (dev); + +return 0 ; +} + +static int rtl8169_runtime_resume (struct device *device) +{ +struct pci_dev *pdev =to_pci_dev (device); +struct net_device *dev =pci_get_drvdata (pdev); +struct rtl8169_private *tp =netdev_priv (dev); + +dev_dbg (&pdev->dev,"resuming\n" ); + +spin_lock_irq (&tp->lock); +__rtl8169_set_wol (tp, tp->saved_wolopts); + tp->saved_wolopts =0 ; +spin_unlock_irq (&tp->lock); + +if (!tp->exiting) +__rtl8169_resume (dev); -rtl8169_schedule_work (dev, rtl8169_reset_task); -out:return 0 ; } +static int rtl8169_runtime_idle (struct device *device) +{ +return -EBUSY ; +} +static struct dev_pm_ops rtl8169_pm_ops = { .suspend = rtl8169_suspend, .resume = rtl8169_resume,
@@ -4863,6 +4939,9 @@ static struct dev_pm_ops rtl8169_pm_ops .thaw = rtl8169_resume, .poweroff = rtl8169_suspend, .restore = rtl8169_resume, + .runtime_suspend = rtl8169_runtime_suspend, + .runtime_resume = rtl8169_runtime_resume, + .runtime_idle = rtl8169_runtime_idle, };#define RTL8169_PM_OPS (&rtl8169_pm_ops)
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
Hi!
Quoted 4 lines
Use the PCI run-time power management framework to add simplified run-time PM support to the r8169 driver. Namely, make the driver suspend the device when the link is off and set it up for generating wake-up event after the link has been detected again.
Nice!
Do you have any idea how much power it saves?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
In reply to Rafael J. WysockiHi!
Quoted 4 lines
Use the PCI run-time power management framework to add simplified run-time PM support to the r8169 driver. Namely, make the driver suspend the device when the link is off and set it up for generating wake-up event after the link has been detected again.
Nice!
Do you have any idea how much power it saves?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
Quoted 10 lines · Pavel Machek
Hi!
Quoted 4 lines
Use the PCI run-time power management framework to add simplified run-time PM support to the r8169 driver. Namely, make the driver suspend the device when the link is off and set it up for generating wake-up event after the link has been detected again.
Nice!
Do you have any idea how much power it saves?
No, but there should be a power meter somewhere here ...
I'll let you know if I can find it.
Rafael
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines · Pavel Machek
Hi!
Quoted 4 lines
Use the PCI run-time power management framework to add simplified run-time PM support to the r8169 driver. Namely, make the driver suspend the device when the link is off and set it up for generating wake-up event after the link has been detected again.
Quoted 7 lines
Quoted 3 lines
Nice!
Do you have any idea how much power it saves?
No, but there should be a power meter somewhere here ...
I'll let you know if I can find it.
On notebooks, you can often use
pavel@amd:/data/l/linux-msm/arch/arm/mach-msm$ cat /proc/acpi/battery/BAT0/state present: yes capacity state: ok charging state: charged present rate: 0 mW remaining capacity: 71830 mWh present voltage: 16277 mV
...present rate is often usable-enough.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
Quoted 9 lines · Pavel Machek
Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines · Pavel Machek
Hi!
Quoted 4 lines
Use the PCI run-time power management framework to add simplified run-time PM support to the r8169 driver. Namely, make the driver suspend the device when the link is off and set it up for generating wake-up event after the link has been detected again.
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Nice!
Do you have any idea how much power it saves?
No, but there should be a power meter somewhere here ...
I'll let you know if I can find it.
Well, I found it, but it has a watt resolution and measures energy in kWh, so it's not very useful in this case (the box draws 14 - 20 W total at full power).
Quoted 11 lines
On notebooks, you can often use
pavel@amd:/data/l/linux-msm/arch/arm/mach-msm$ cat /proc/acpi/battery/BAT0/state present: yes capacity state: ok charging state: charged present rate: 0 mW remaining capacity: 71830 mWh present voltage: 16277 mV
Quoted 1 line
...present rate is often usable-enough.
Using /proc/acpi/battery/BAT1/state I measured the energy drawn in 10 minutes both with the network adapter in D0 and D3hot. The results were that with the network adapter in D0 the box drew 2476 mWh, while with the network adapter in D3hot it drew 2361 mWh. The difference is 115 mWh, or about 5% on this particular box.
This means about 0.1 Wh in 10 minutes, so we can save about 0.6 Wh per hour.
Rafael
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
Quoted 14 lines
Quoted 12 lines
On notebooks, you can often use
pavel@amd:/data/l/linux-msm/arch/arm/mach-msm$ cat /proc/acpi/battery/BAT0/state present: yes capacity state: ok charging state: charged present rate: 0 mW remaining capacity: 71830 mWh present voltage: 16277 mVQuoted 1 line
...present rate is often usable-enough.
Quoted 7 lines
Using
/proc/acpi/battery/BAT1/stateI measured the energy drawn in 10 minutes both with the network adapter in D0 and D3hot. The results were that with the network adapter in D0 the box drew 2476 mWh, while with the network adapter in D3hot it drew 2361 mWh. The difference is 115 mWh, or about 5% on this particular box.This means about 0.1 Wh in 10 minutes, so we can save about 0.6 Wh per hour.
Which means it saves 0.6W :-). Measuring power in Wh/h is "interesting". Ok, that's consistent with my experiments, ethernet transciever was around 1W... Thanks.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
In reply to Rafael J. WysockiQuoted 14 lines
Quoted 12 lines
On notebooks, you can often use
pavel@amd:/data/l/linux-msm/arch/arm/mach-msm$ cat /proc/acpi/battery/BAT0/state present: yes capacity state: ok charging state: charged present rate: 0 mW remaining capacity: 71830 mWh present voltage: 16277 mVQuoted 1 line
...present rate is often usable-enough.
Quoted 7 lines
Using
/proc/acpi/battery/BAT1/stateI measured the energy drawn in 10 minutes both with the network adapter in D0 and D3hot. The results were that with the network adapter in D0 the box drew 2476 mWh, while with the network adapter in D3hot it drew 2361 mWh. The difference is 115 mWh, or about 5% on this particular box.This means about 0.1 Wh in 10 minutes, so we can save about 0.6 Wh per hour.
Which means it saves 0.6W :-). Measuring power in Wh/h is "interesting". Ok, that's consistent with my experiments, ethernet transciever was around 1W... Thanks.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
Quoted 20 lines · Pavel Machek
Quoted 20 lines
Quoted 12 lines
On notebooks, you can often use
pavel@amd:/data/l/linux-msm/arch/arm/mach-msm$ cat /proc/acpi/battery/BAT0/state present: yes capacity state: ok charging state: charged present rate: 0 mW remaining capacity: 71830 mWh present voltage: 16277 mVQuoted 1 line
...present rate is often usable-enough.
Using
/proc/acpi/battery/BAT1/stateI measured the energy drawn in 10 minutes both with the network adapter in D0 and D3hot. The results were that with the network adapter in D0 the box drew 2476 mWh, while with the network adapter in D3hot it drew 2361 mWh. The difference is 115 mWh, or about 5% on this particular box.
Quoted 3 lines
Quoted 1 line
This means about 0.1 Wh in 10 minutes, so we can save about 0.6 Wh per hour.
Which means it saves 0.6W :-). Measuring power in Wh/h is "interesting".
You can't save power, you can only save energy. Wh is just an energy unit.
Quoted 1 line
Ok, that's consistent with my experiments, ethernet transciever was around 1W... Thanks.
No big deal.
Rafael
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Using
/proc/acpi/battery/BAT1/stateI measured the energy drawn in 10 minutes both with the network adapter in D0 and D3hot. The results were that with the network adapter in D0 the box drew 2476 mWh, while with the network adapter in D3hot it drew 2361 mWh. The difference is 115 mWh, or about 5% on this particular box.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
This means about 0.1 Wh in 10 minutes, so we can save about 0.6 Wh per hour.
Which means it saves 0.6W :-). Measuring power in Wh/h is "interesting".
You can't save power, you can only save energy. Wh is just an energy unit.
Of course we can save power, you just did :-).
(And in some cases -- data centers, limited cooling -- you are limited by power, not energy. You are right that on notebooks, energy is more important.)
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
Am Montag, 4. Januar 2010 09:31:08 schrieb Pavel Machek:
Quoted 7 lines
Quoted 1 line
You can't save power, you can only save energy. Wh is just an energy unit.
Of course we can save power, you just did :-).
(And in some cases -- data centers, limited cooling -- you are limited by power, not energy. You are right that on notebooks, energy is more important.)
If possible less power is better on a laptop, fans are loud and take energy to run.
Regards
Oliver
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
In reply to Pavel MachekAm Montag, 4. Januar 2010 09:31:08 schrieb Pavel Machek:
Quoted 7 lines
Quoted 1 line
You can't save power, you can only save energy. Wh is just an energy unit.
Of course we can save power, you just did :-).
(And in some cases -- data centers, limited cooling -- you are limited by power, not energy. You are right that on notebooks, energy is more important.)
If possible less power is better on a laptop, fans are loud and take energy to run.
Regards
Oliver
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
In reply to Pavel MachekQuoted 9 lines · Pavel Machek
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Using
/proc/acpi/battery/BAT1/stateI measured the energy drawn in 10 minutes both with the network adapter in D0 and D3hot. The results were that with the network adapter in D0 the box drew 2476 mWh, while with the network adapter in D3hot it drew 2361 mWh. The difference is 115 mWh, or about 5% on this particular box.This means about 0.1 Wh in 10 minutes, so we can save about 0.6 Wh per hour.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Which means it saves 0.6W :-). Measuring power in Wh/h is "interesting".
You can't save power, you can only save energy. Wh is just an energy unit.
Of course we can save power, you just did :-).
(And in some cases -- data centers, limited cooling -- you are limited by power, not energy.
But still energy is what you pay for, isn't it?
Quoted 1 line
You are right that on notebooks, energy is more important.)
You may require less power to run, so if that's what you mean by "saving", then I agree. :-)
Rafael
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
Quoted 10 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Which means it saves 0.6W :-). Measuring power in Wh/h is "interesting".
You can't save power, you can only save energy. Wh is just an energy unit.
Of course we can save power, you just did :-).
(And in some cases -- data centers, limited cooling -- you are limited by power, not energy.
But still energy is what you pay for, isn't it?
Energy is what you pay for, but if you eat too much power, data centre overheats and goes down.
Quoted 4 lines
Quoted 1 line
You are right that on notebooks, energy is more important.)
You may require less power to run, so if that's what you mean by "saving", then I agree. :-)
Yes, that's what I meant by saving :-), and yes, they are very related.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
In reply to Rafael J. WysockiQuoted 10 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Which means it saves 0.6W :-). Measuring power in Wh/h is "interesting".
You can't save power, you can only save energy. Wh is just an energy unit.
Of course we can save power, you just did :-).
(And in some cases -- data centers, limited cooling -- you are limited by power, not energy.
But still energy is what you pay for, isn't it?
Energy is what you pay for, but if you eat too much power, data centre overheats and goes down.
Quoted 4 lines
Quoted 1 line
You are right that on notebooks, energy is more important.)
You may require less power to run, so if that's what you mean by "saving", then I agree. :-)
Yes, that's what I meant by saving :-), and yes, they are very related.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
In reply to Pavel MachekQuoted 9 lines · Pavel Machek
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Using
/proc/acpi/battery/BAT1/stateI measured the energy drawn in 10 minutes both with the network adapter in D0 and D3hot. The results were that with the network adapter in D0 the box drew 2476 mWh, while with the network adapter in D3hot it drew 2361 mWh. The difference is 115 mWh, or about 5% on this particular box.This means about 0.1 Wh in 10 minutes, so we can save about 0.6 Wh per hour.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Which means it saves 0.6W :-). Measuring power in Wh/h is "interesting".
You can't save power, you can only save energy. Wh is just an energy unit.
Of course we can save power, you just did :-).
(And in some cases -- data centers, limited cooling -- you are limited by power, not energy.
But still energy is what you pay for, isn't it?
Quoted 1 line
You are right that on notebooks, energy is more important.)
You may require less power to run, so if that's what you mean by "saving", then I agree. :-)
Rafael
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
In reply to Rafael J. WysockiQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Using
/proc/acpi/battery/BAT1/stateI measured the energy drawn in 10 minutes both with the network adapter in D0 and D3hot. The results were that with the network adapter in D0 the box drew 2476 mWh, while with the network adapter in D3hot it drew 2361 mWh. The difference is 115 mWh, or about 5% on this particular box.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
This means about 0.1 Wh in 10 minutes, so we can save about 0.6 Wh per hour.
Which means it saves 0.6W :-). Measuring power in Wh/h is "interesting".
You can't save power, you can only save energy. Wh is just an energy unit.
Of course we can save power, you just did :-).
(And in some cases -- data centers, limited cooling -- you are limited by power, not energy. You are right that on notebooks, energy is more important.)
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
In reply to Pavel MachekQuoted 20 lines · Pavel Machek
Quoted 20 lines
Quoted 12 lines
On notebooks, you can often use
pavel@amd:/data/l/linux-msm/arch/arm/mach-msm$ cat /proc/acpi/battery/BAT0/state present: yes capacity state: ok charging state: charged present rate: 0 mW remaining capacity: 71830 mWh present voltage: 16277 mVQuoted 1 line
...present rate is often usable-enough.
Using
/proc/acpi/battery/BAT1/stateI measured the energy drawn in 10 minutes both with the network adapter in D0 and D3hot. The results were that with the network adapter in D0 the box drew 2476 mWh, while with the network adapter in D3hot it drew 2361 mWh. The difference is 115 mWh, or about 5% on this particular box.
Quoted 3 lines
Quoted 1 line
This means about 0.1 Wh in 10 minutes, so we can save about 0.6 Wh per hour.
Which means it saves 0.6W :-). Measuring power in Wh/h is "interesting".
You can't save power, you can only save energy. Wh is just an energy unit.
Quoted 1 line
Ok, that's consistent with my experiments, ethernet transciever was around 1W... Thanks.
No big deal.
Rafael
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
In reply to Pavel MachekQuoted 9 lines · Pavel Machek
Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines · Pavel Machek
Hi!
Quoted 4 lines
Use the PCI run-time power management framework to add simplified run-time PM support to the r8169 driver. Namely, make the driver suspend the device when the link is off and set it up for generating wake-up event after the link has been detected again.
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Nice!
Do you have any idea how much power it saves?
No, but there should be a power meter somewhere here ...
I'll let you know if I can find it.
Well, I found it, but it has a watt resolution and measures energy in kWh, so it's not very useful in this case (the box draws 14 - 20 W total at full power).
Quoted 11 lines
On notebooks, you can often use
pavel@amd:/data/l/linux-msm/arch/arm/mach-msm$ cat /proc/acpi/battery/BAT0/state present: yes capacity state: ok charging state: charged present rate: 0 mW remaining capacity: 71830 mWh present voltage: 16277 mV
Quoted 1 line
...present rate is often usable-enough.
Using /proc/acpi/battery/BAT1/state I measured the energy drawn in 10 minutes both with the network adapter in D0 and D3hot. The results were that with the network adapter in D0 the box drew 2476 mWh, while with the network adapter in D3hot it drew 2361 mWh. The difference is 115 mWh, or about 5% on this particular box.
This means about 0.1 Wh in 10 minutes, so we can save about 0.6 Wh per hour.
Rafael
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
In reply to Rafael J. WysockiQuoted 8 lines · Rafael J. Wysocki
Quoted 7 lines · Pavel Machek
Hi!
Quoted 4 lines
Use the PCI run-time power management framework to add simplified run-time PM support to the r8169 driver. Namely, make the driver suspend the device when the link is off and set it up for generating wake-up event after the link has been detected again.
Quoted 7 lines
Quoted 3 lines
Nice!
Do you have any idea how much power it saves?
No, but there should be a power meter somewhere here ...
I'll let you know if I can find it.
On notebooks, you can often use
pavel@amd:/data/l/linux-msm/arch/arm/mach-msm$ cat /proc/acpi/battery/BAT0/state present: yes capacity state: ok charging state: charged present rate: 0 mW remaining capacity: 71830 mWh present voltage: 16277 mV
...present rate is often usable-enough.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC][PATCH 12/12] PM / r8169: Add simplified run-time PM support
In reply to Pavel MachekQuoted 10 lines · Pavel Machek
Hi!
Quoted 4 lines
Use the PCI run-time power management framework to add simplified run-time PM support to the r8169 driver. Namely, make the driver suspend the device when the link is off and set it up for generating wake-up event after the link has been detected again.
Nice!
Do you have any idea how much power it saves?
No, but there should be a power meter somewhere here ...
I'll let you know if I can find it.
Rafael
RFC PATCH 12/12 PM / r8169: Add simplified run-time PM support
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Use the PCI run-time power management framework to add simplified run-time PM support to the r8169 driver. Namely, make the driver suspend the device when the link is off and set it up for generating wake-up event after the link has been detected again.
--- drivers/net/r8169.c | 133 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 106 insertions(+), 27 deletions(-)
drivers/net/r8169.c +106 -27
@@ -23,6 +23,7 @@#include <linux/tcp.h> #include <linux/init.h> #include <linux/dma-mapping.h> +#include <linux/pm_runtime.h> #include <asm/system.h> #include <asm/io.h>
@@ -504,6 +505,8 @@ struct rtl8169_private {struct mii_if_info mii;struct rtl8169_counters counters; +u32 saved_wolopts; +bool exiting; };MODULE_AUTHOR ("Realtek and the Linux r8169 crew <[email protected]>" );
@@ -750,48 +753,54 @@ static void rtl8169_check_link_status(stif (netif_msg_ifdown (tp)) printk(KERN_INFO PFX "%s: link down\n", dev->name);netif_carrier_off (dev); +pm_schedule_suspend (&tp->pci_dev->dev,100 ); }spin_unlock_irqrestore (&tp->lock, flags); } -static void rtl8169_get_wol (struct net_device *dev,struct ethtool_wolinfo *wol) +#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST) + +static u32 __rtl8169_get_wol (struct rtl8169_private *tp) { -struct rtl8169_private *tp =netdev_priv (dev);void __iomem *ioaddr = tp->mmio_addr;u8 options; - - wol->wolopts =0 ; - -#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST) - wol->supported =WAKE_ANY ; - -spin_lock_irq (&tp->lock); +u32 wolopts =0 ; options =RTL_R8 (Config1);if (!(options & PMEnable)) - goto out_unlock; +return 0 ; options =RTL_R8 (Config3);if (options & LinkUp) - wol->wolopts |=WAKE_PHY ; + wolopts |=WAKE_PHY ;if (options & MagicPacket) - wol->wolopts |=WAKE_MAGIC ; + wolopts |=WAKE_MAGIC ; options =RTL_R8 (Config5);if (options &UWF ) - wol->wolopts |=WAKE_UCAST ; + wolopts |=WAKE_UCAST ;if (options &BWF ) - wol->wolopts |=WAKE_BCAST ; + wolopts |=WAKE_BCAST ;if (options &MWF ) - wol->wolopts |=WAKE_MCAST ; + wolopts |=WAKE_MCAST ; -out_unlock: -spin_unlock_irq (&tp->lock); +return wolopts; } -static int rtl8169_set_wol (struct net_device *dev,struct ethtool_wolinfo *wol) +static void rtl8169_get_wol (struct net_device *dev,struct ethtool_wolinfo *wol) {struct rtl8169_private *tp =netdev_priv (dev); + +spin_lock_irq (&tp->lock); + + wol->supported =WAKE_ANY ; + wol->wolopts =__rtl8169_get_wol (tp); + +spin_unlock_irq (&tp->lock); +} + +static void __rtl8169_set_wol (struct rtl8169_private *tp,u32 wolopts) +{void __iomem *ioaddr = tp->mmio_addr;unsigned int i; static struct {
@@ -808,23 +817,29 @@ static int rtl8169_set_wol(struct net_de { WAKE_ANY, Config5, LanWake } }; -spin_lock_irq (&tp->lock); -RTL_W8 (Cfg9346, Cfg9346_Unlock);for (i =0 ; i <ARRAY_SIZE (cfg); i++) {u8 options =RTL_R8 (cfg[i].reg) & ~cfg[i].mask; -if (wol->wolopts & cfg[i].opt) +if (wolopts & cfg[i].opt) options |= cfg[i].mask;RTL_W8 (cfg[i].reg, options); }RTL_W8 (Cfg9346, Cfg9346_Lock); +} + +static int rtl8169_set_wol (struct net_device *dev,struct ethtool_wolinfo *wol) +{ +struct rtl8169_private *tp =netdev_priv (dev); + +spin_lock_irq (&tp->lock);if (wol->wolopts) tp->features |=RTL_FEATURE_WOL ;else tp->features &= ~RTL_FEATURE_WOL ; +__rtl8169_set_wol (tp, wol->wolopts);device_set_wakeup_enable (&tp->pci_dev->dev, wol->wolopts);spin_unlock_irq (&tp->lock);
@@ -3000,6 +3015,7 @@ rtl8169_init_one(struct pci_dev *pdev, c tp->dev = dev; tp->pci_dev = pdev; tp->msg_enable =netif_msg_init (debug.msg_enable,R8169_MSG_DEFAULT ); + tp->exiting = false; mii = &tp->mii; mii->dev = dev;
@@ -3232,6 +3248,8 @@ static void __devexit rtl8169_remove_onestruct net_device *dev =pci_get_drvdata (pdev);struct rtl8169_private *tp =netdev_priv (dev); + tp->exiting = true; +flush_scheduled_work ();unregister_netdev (dev);
@@ -3254,7 +3272,6 @@ static int rtl8169_open(struct net_devicstruct pci_dev *pdev = tp->pci_dev;int retval = -ENOMEM ; -rtl8169_set_rxbufsize (tp, dev);/*
@@ -3291,6 +3308,13 @@ static int rtl8169_open(struct net_devicrtl8169_request_timer (dev); + tp->saved_wolopts =0 ; + +if (pci_dev_run_wake (pdev)) { +pm_runtime_set_active (&pdev->dev); +pm_runtime_enable (&pdev->dev); + } +rtl8169_check_link_status (dev, tp, tp->mmio_addr); out:return retval;
@@ -4724,6 +4748,14 @@ static int rtl8169_close(struct net_devistruct rtl8169_private *tp =netdev_priv (dev);struct pci_dev *pdev = tp->pci_dev; +if (pci_dev_run_wake (pdev)) { +pm_runtime_get_noresume (&pdev->dev); +pm_runtime_resume (&pdev->dev); +pm_runtime_disable (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); + } +/* update counters before going down */ rtl8169_update_counters (dev);
@@ -4841,21 +4873,65 @@ static int rtl8169_suspend(struct devicereturn 0 ; } +static void __rtl8169_resume (struct net_device *dev) +{ +netif_device_attach (dev); +rtl8169_schedule_work (dev, rtl8169_reset_task); +} +static int rtl8169_resume (struct device *device) {struct pci_dev *pdev =to_pci_dev (device);struct net_device *dev =pci_get_drvdata (pdev); -if (!netif_running (dev)) - goto out; +if (netif_running (dev)) +__rtl8169_resume (dev); -netif_device_attach (dev); +return 0 ; +} + +static int rtl8169_runtime_suspend (struct device *device) +{ +struct pci_dev *pdev =to_pci_dev (device); +struct net_device *dev =pci_get_drvdata (pdev); +struct rtl8169_private *tp =netdev_priv (dev); + +dev_dbg (&pdev->dev,"suspending\n" ); + +spin_lock_irq (&tp->lock); + tp->saved_wolopts =__rtl8169_get_wol (tp); +__rtl8169_set_wol (tp,WAKE_ANY ); +spin_unlock_irq (&tp->lock); + +rtl8169_net_suspend (dev); + +return 0 ; +} + +static int rtl8169_runtime_resume (struct device *device) +{ +struct pci_dev *pdev =to_pci_dev (device); +struct net_device *dev =pci_get_drvdata (pdev); +struct rtl8169_private *tp =netdev_priv (dev); + +dev_dbg (&pdev->dev,"resuming\n" ); + +spin_lock_irq (&tp->lock); +__rtl8169_set_wol (tp, tp->saved_wolopts); + tp->saved_wolopts =0 ; +spin_unlock_irq (&tp->lock); + +if (!tp->exiting) +__rtl8169_resume (dev); -rtl8169_schedule_work (dev, rtl8169_reset_task); -out:return 0 ; } +static int rtl8169_runtime_idle (struct device *device) +{ +return -EBUSY ; +} +static struct dev_pm_ops rtl8169_pm_ops = { .suspend = rtl8169_suspend, .resume = rtl8169_resume,
@@ -4863,6 +4939,9 @@ static struct dev_pm_ops rtl8169_pm_ops .thaw = rtl8169_resume, .poweroff = rtl8169_suspend, .restore = rtl8169_resume, + .runtime_suspend = rtl8169_runtime_suspend, + .runtime_resume = rtl8169_runtime_resume, + .runtime_idle = rtl8169_runtime_idle, };#define RTL8169_PM_OPS (&rtl8169_pm_ops)
Re: [RFC][PATCH 0/12] PCI run-time PM support (updated)
In reply to Rafael J. WysockiQuoted 29 lines · On Sun, 29 Nov 2009 16:32:44 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Hi,
The following (updated) series of patches provides preliminary run-time power management support for PCI devices through ACPI and/or the native PCIe PME.
Some patches have been modified since the previous iteration and two new patches have been added. Also, I've tested this patchset with the native PCIe PME mechanism using the r8169 driver on the MSI Wind U-100 (see the last patch for details).
[1/12] - Add flag for marking devices capable of generating wake-up events at run time
[2/12] - Add function for checking PME status of devices[3/12] - Modify wake-up enable propagation so that it's done for PCIe devices too
[4/12] - PCIe PME root port service driver[5/12][New] - "Don't use MSIs for PME signaling" switch for PCIe
[6/12] - ACPI GPE refcounting, from Matthew
[7/12] - ACPI drivers support for GPE refcounting, from Matthew
[8/12] - ACPI removal of the old GPE API, from Matthew
[9/12] - ACPI add fields for handling run-wake devices
Quoted 8 lines
[10/12] - PCI ACPI platform support for run-time power management
[11/12] - Runtime PM callbacks for the PCI bus type
[12/12] - Runtime PM support for r8169 (experimental)
If there are no objections, I think the patches [1-11/12] are ready for merging at this point.
Len, it sounds like this patchset is settling down. Have you or one of the ACPI folks had a chance to check out the ACPI GPE changes? I can take it all through my PCI tree if you're ok with it.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Re: [RFC][PATCH 0/12] PCI run-time PM support (updated)
In reply to Rafael J. WysockiQuoted 29 lines · On Sun, 29 Nov 2009 16:32:44 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Hi,
The following (updated) series of patches provides preliminary run-time power management support for PCI devices through ACPI and/or the native PCIe PME.
Some patches have been modified since the previous iteration and two new patches have been added. Also, I've tested this patchset with the native PCIe PME mechanism using the r8169 driver on the MSI Wind U-100 (see the last patch for details).
[1/12] - Add flag for marking devices capable of generating wake-up events at run time
[2/12] - Add function for checking PME status of devices[3/12] - Modify wake-up enable propagation so that it's done for PCIe devices too
[4/12] - PCIe PME root port service driver[5/12][New] - "Don't use MSIs for PME signaling" switch for PCIe
[6/12] - ACPI GPE refcounting, from Matthew
[7/12] - ACPI drivers support for GPE refcounting, from Matthew
[8/12] - ACPI removal of the old GPE API, from Matthew
[9/12] - ACPI add fields for handling run-wake devices
Quoted 8 lines
[10/12] - PCI ACPI platform support for run-time power management
[11/12] - Runtime PM callbacks for the PCI bus type
[12/12] - Runtime PM support for r8169 (experimental)
If there are no objections, I think the patches [1-11/12] are ready for merging at this point.
Len, it sounds like this patchset is settling down. Have you or one of the ACPI folks had a chance to check out the ACPI GPE changes? I can take it all through my PCI tree if you're ok with it.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
cover PCI run-time PM support (updated)
In reply to Rafael J. WysockiHi,
The following (updated) series of patches provides preliminary run-time power management support for PCI devices through ACPI and/or the native PCIe PME.
Some patches have been modified since the previous iteration and two new patches have been added. Also, I've tested this patchset with the native PCIe PME mechanism using the r8169 driver on the MSI Wind U-100 (see the last patch for details).
[1/12] - Add flag for marking devices capable of generating wake-up events at run time
[2/12] - Add function for checking PME status of devices
[3/12] - Modify wake-up enable propagation so that it's done for PCIe devices too
[4/12] - PCIe PME root port service driver
[5/12][New] - "Don't use MSIs for PME signaling" switch for PCIe
[6/12] - ACPI GPE refcounting, from Matthew
[7/12] - ACPI drivers support for GPE refcounting, from Matthew
[8/12] - ACPI removal of the old GPE API, from Matthew
[9/12] - ACPI add fields for handling run-wake devices
[10/12] - PCI ACPI platform support for run-time power management
[11/12] - Runtime PM callbacks for the PCI bus type
[12/12] - Runtime PM support for r8169 (experimental)
If there are no objections, I think the patches [1-11/12] are ready for merging at this point.
Thanks,
Rafael