PCI: PM: ACPI: Drop unnecessary acpi_pci_power_manageable() calls
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): 8003272.NyiUUSuA9g@kreacher
PATCH 1/5 PCI: PM: x86: Drop Intel MID PCI PM support
From: Rafael J. Wysocki <[email protected]>
Support for Intel MID platforms has mostly gone away with the SFI support removal in commit 4590d98f5a4f ("sfi: Remove framework for deprecated firmware"), but there are some pieces of it still in the tree. One of them is the MID PCI PM support code which gets in the way of subsequent PCI PM simplifications and trying to update it is rather pointless, so get rid of it completely along with the arch code pieces that are only used by it.
---
I am going to post patches removing the rest of MID support from arch/x86/ and elsewhere, but that is still quite a bit of stuff and I don't want this simple PCI PM series to depend on that work.
--- arch/x86/include/asm/intel-mid.h | 3 arch/x86/platform/intel-mid/pwr.c | 150 -------------------------------------- drivers/pci/Makefile | 1 drivers/pci/pci-mid.c | 77 ------------------- 4 files changed, 231 deletions(-)
drivers/pci/Makefile +0 -1
@@ -22,7 +22,6 @@ obj-$(CONFIG_PCI_ATS) += ats.o obj-$(CONFIG_PCI_IOV) += iov.o obj-$(CONFIG_PCI_BRIDGE_EMUL) += pci-bridge-emul.o obj-$(CONFIG_PCI_LABEL) += pci-label.o -obj-$(CONFIG_X86_INTEL_MID) += pci-mid.o obj-$(CONFIG_PCI_SYSCALL) += syscall.o obj-$(CONFIG_PCI_STUB) += pci-stub.o obj-$(CONFIG_PCI_PF_STUB) += pci-pf-stub.o
drivers/pci/pci-mid.c deleted +0 -77
77 lines not on this page · raw message
arch/x86/platform/intel-mid/pwr.c +0 -150
174 lines not on this page · raw message
arch/x86/include/asm/intel-mid.h +0 -3
@@ -10,9 +10,6 @@#include <linux/pci.h> extern int intel_mid_pci_init (void ); -extern int intel_mid_pci_set_power_state (struct pci_dev *pdev,pci_power_t state); -extern pci_power_t intel_mid_pci_get_power_state (struct pci_dev *pdev); -extern void intel_mid_pwr_power_off (void );#define INTEL_MID_PWR_LSS_OFFSET 4
Re: [PATCH v1 1/5] PCI: PM: x86: Drop Intel MID PCI PM support
Quoted 11 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Support for Intel MID platforms has mostly gone away with the SFI support removal in commit
4590d98f5a4f("sfi: Remove framework for deprecated firmware"), but there are some pieces of it still in the tree. One of them is the MID PCI PM support code which gets in the way of subsequent PCI PM simplifications and trying to update it is rather pointless, so get rid of it completely along with the arch code pieces that are only used by it.
Quoted 6 lines
Signed-off-by Rafael J. Wysocki <[email protected]>---
I am going to post patches removing the rest of MID support from
arch/x86/and elsewhere, but that is still quite a bit of stuff and I don't want this simple PCI PM series to depend on that work.
This is still being used by MID with ACPI assisted (*) support. Hence, not ack.
*) ACPI layer is provided by U-Boot and can't fulfill all possible features that ACPI may use in the Linux kernel.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Rafael J. Wysocki
maintainerRe: [PATCH v1 1/5] PCI: PM: x86: Drop Intel MID PCI PM support
Quoted 20 lines · Andy Shevchenko
Quoted 11 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Support for Intel MID platforms has mostly gone away with the SFI support removal in commit
4590d98f5a4f("sfi: Remove framework for deprecated firmware"), but there are some pieces of it still in the tree. One of them is the MID PCI PM support code which gets in the way of subsequent PCI PM simplifications and trying to update it is rather pointless, so get rid of it completely along with the arch code pieces that are only used by it.Quoted 6 lines
Signed-off-by Rafael J. Wysocki <[email protected]>---
I am going to post patches removing the rest of MID support from
arch/x86/and elsewhere, but that is still quite a bit of stuff and I don't want this simple PCI PM series to depend on that work.
Quoted 5 lines
This is still being used by MID with ACPI assisted (*) support. Hence, not ack.
*) ACPI layer is provided by U-Boot and can't fulfill all possible features that ACPI may use in the Linux kernel.
OK, good to know.
I'm not sure how this PCI PM stuff works with ACPI. It looks like this relies on a specific ordering of arch_initcall() calls for correctness which is sort of fragile.
Re: [PATCH v1 1/5] PCI: PM: x86: Drop Intel MID PCI PM support
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Andy Shevchenko
On Sun, Sep 19, 2021 at 9:01 AM Rafael J. Wysocki <[email protected]> wrote:
...
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
I am going to post patches removing the rest of MID support from
arch/x86/and elsewhere, but that is still quite a bit of stuff and I don't want this simple PCI PM series to depend on that work.This is still being used by MID with ACPI assisted (*) support. Hence, not ack.
Quoted 6 lines
Quoted 2 lines
*) ACPI layer is provided by U-Boot and can't fulfill all possible features that ACPI may use in the Linux kernel.
OK, good to know.
I'm not sure how this PCI PM stuff works with ACPI.
It doesn't that is the point. The PCI is very interesting there and what I meant is that the ACPI implementation I have provided via U-Boot does not cover these. If you have any hints/ideas how it may be handled, I am all ears!
Quoted 3 lines
It looks like
this relies on a specific ordering ofarch_initcall()calls for correctness which is sort of fragile.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Rafael J. Wysocki
maintainerRe: [PATCH v1 1/5] PCI: PM: x86: Drop Intel MID PCI PM support
Quoted 18 lines · Andy Shevchenko
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Andy Shevchenko
On Sun, Sep 19, 2021 at 9:01 AM Rafael J. Wysocki <[email protected]> wrote:
...
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
I am going to post patches removing the rest of MID support from
arch/x86/and elsewhere, but that is still quite a bit of stuff and I don't want this simple PCI PM series to depend on that work.This is still being used by MID with ACPI assisted (*) support. Hence, not ack.
*) ACPI layer is provided by U-Boot and can't fulfill all possible features that ACPI may use in the Linux kernel.
Quoted 7 lines
Quoted 3 lines
OK, good to know.
I'm not sure how this PCI PM stuff works with ACPI.
It doesn't that is the point. The PCI is very interesting there and what I meant is that the ACPI implementation I have provided via U-Boot does not cover these.
That's OK. It just means that these devices are not power-manageable via ACPI on the platforms in question, but the MID PCI PM code is present in the kernel, so we don't need analogous code in AML in the ACPI tables.
My point is that something like the v2 of this patch series
(https://lore.kernel.org/linux-acpi/1800633.tdWV9SEqCh@kreacher/T/#m1ec249724a5ad5ad358b0ed8e149e3926934955d)
is needed to prevent ACPI from overtaking the PM for the PCI devices on the platform once we've decided to use the MID PM for them.
Now, if it is necessary to use ACPI PM for some devices and the MID PM for other devices on the same platform, the latter needs to grow a meaningful "power manageable" function that needs to be used in the code as appropriate.
Quoted 1 line
If you have any hints/ideas how it may be handled, I am all ears!
Re: [PATCH v1 1/5] PCI: PM: x86: Drop Intel MID PCI PM support
In reply to Rafael J. WysockiHi,
Op 18-09-2021 om 15:21 schreef Rafael J. Wysocki:
Quoted 9 lines
From: Rafael J. Wysocki <[email protected]>
Support for Intel MID platforms has mostly gone away with the SFI support removal in commit
4590d98f5a4f("sfi: Remove framework for deprecated firmware"), but there are some pieces of it still in the tree. One of them is the MID PCI PM support code which gets in the way of subsequent PCI PM simplifications and trying to update it is rather pointless, so get rid of it completely along with the arch code pieces that are only used by it.
Removing PM support for MID will break (among others) Intel Edison, which is currently in use and running up to date vanilla kernel (v5.14) and user space.
I would happily test updates PM when they appear.
Quoted 307 lines
Signed-off-by Rafael J. Wysocki <[email protected]>---
I am going to post patches removing the rest of MID support from
arch/x86/and elsewhere, but that is still quite a bit of stuff and I don't want this simple PCI PM series to depend on that work.--- arch/x86/include/asm/intel-mid.h | 3 arch/x86/platform/intel-mid/pwr.c | 150 -------------------------------------- drivers/pci/Makefile | 1 drivers/pci/pci-mid.c | 77 ------------------- 4 files changed, 231 deletions(-)Index: linux-pm/drivers/pci/Makefile
===================================================================drivers/pci/Makefile +0
-1@@ -22,7 +22,6 @@ obj-$(CONFIG_PCI_ATS) += ats.o obj-$(CONFIG_PCI_IOV) += iov.o obj-$(CONFIG_PCI_BRIDGE_EMUL) += pci-bridge-emul.o obj-$(CONFIG_PCI_LABEL) += pci-label.o -obj-$(CONFIG_X86_INTEL_MID) += pci-mid.o obj-$(CONFIG_PCI_SYSCALL) += syscall.o obj-$(CONFIG_PCI_STUB) += pci-stub.o obj-$(CONFIG_PCI_PF_STUB) += pci-pf-stub.oIndex:
linux-pm/drivers/pci/pci-mid.c
===================================================================drivers/pci/pci-mid.c deleted +0
-77@@ -1,77 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* -* Intel MID platform PM support -* -* Copyright (C) 2016, Intel Corporation -* -* Author: Andy Shevchenko <[email protected]> -*/ - -#include <linux/init.h> -#include <linux/pci.h> - -#include <asm/cpu_device_id.h> -#include <asm/intel-family.h> -#include <asm/intel-mid.h> - -#include "pci.h" - -static bool mid_pci_power_manageable (struct pci_dev *dev) -{ -return true; -} - -static int mid_pci_set_power_state (struct pci_dev *pdev,pci_power_t state) -{ -return intel_mid_pci_set_power_state (pdev, state); -} - -static pci_power_t mid_pci_get_power_state (struct pci_dev *pdev) -{ -return intel_mid_pci_get_power_state (pdev); -} - -static pci_power_t mid_pci_choose_state (struct pci_dev *pdev) -{ -return PCI_D3hot; -} - -static int mid_pci_wakeup (struct pci_dev *dev,bool enable) -{ -return 0 ; -} - -static bool mid_pci_need_resume (struct pci_dev *dev) -{ -return false; -} - -static const struct pci_platform_pm_ops mid_pci_platform_pm = { - .is_manageable = mid_pci_power_manageable, - .set_state = mid_pci_set_power_state, - .get_state = mid_pci_get_power_state, - .choose_state = mid_pci_choose_state, - .set_wakeup = mid_pci_wakeup, - .need_resume = mid_pci_need_resume, -}; - -/* -* This table should be in sync with the one in -* arch/x86/platform/intel-mid/pwr.c. -*/ -static const struct x86_cpu_id lpss_cpu_ids[] = { -X86_MATCH_INTEL_FAM6_MODEL (ATOM_SALTWELL_MID ,NULL ), -X86_MATCH_INTEL_FAM6_MODEL (ATOM_SILVERMONT_MID ,NULL ), - {} -}; - -static int __init mid_pci_init (void ) -{ -const struct x86_cpu_id *id; - - id =x86_match_cpu (lpss_cpu_ids); -if (id) -pci_set_platform_pm (&mid_pci_platform_pm); -return 0 ; -} -arch_initcall (mid_pci_init);Index:
linux-pm/arch/x86/platform/intel-mid/pwr.c
===================================================================arch/x86/platform/intel-mid/pwr.c +0
-150@@ -5,13 +5,6 @@* Copyright (C) 2016, Intel Corporation * * Author: Andy Shevchenko <[email protected]> -* -* Intel MID Power Management Unit device driver handles the South Complex PCI -* devices such as GPDMA, SPI, I2C, PWM, and so on. By default PCI core -* modifies bits in PMCSR register in the PCI configuration space. This is not -* enough on some SoCs like Intel Tangier. In such case PCI core sets a new -* power state of the device in question through a PM hook registered in struct -* pci_platform_pm_ops (see drivers/pci/pci-mid.c). */ #define pr_fmt (fmt) KBUILD_MODNAME ": " fmt@@ -103,11 +96,6 @@ struct mid_pwr {static struct mid_pwr *midpwr; -static u32 mid_pwr_get_state (struct mid_pwr *pwr,int reg) -{ -return readl (pwr->regs +PM_SSS (reg)); -} -static void mid_pwr_set_state (struct mid_pwr *pwr,int reg,u32 value) {writel (value, pwr->regs +PM_SSC (reg));@@ -150,143 +138,6 @@ static int mid_pwr_wait_for_cmd(struct mreturn mid_pwr_wait (pwr); } -static int __update_power_state (struct mid_pwr *pwr,int reg,int bit,int new) -{ -int curstate; -u32 power; -int ret; - -/* Check if the device is already in desired state */ - power =mid_pwr_get_state (pwr, reg); - curstate = (power >> bit) &3 ; -if (curstate == new) -return 0 ; - -/* Update the power state */ -mid_pwr_set_state (pwr, reg, (power & ~(3 << bit)) | (new << bit)); - -/* Send command to SCU */ - ret =mid_pwr_wait_for_cmd (pwr,CMD_SET_CFG ); -if (ret) -return ret; - -/* Check if the device is already in desired state */ - power =mid_pwr_get_state (pwr, reg); - curstate = (power >> bit) &3 ; -if (curstate != new) -return -EAGAIN ; - -return 0 ; -} - -static pci_power_t __find_weakest_power_state (struct mid_pwr_dev *lss, -struct pci_dev *pdev, -pci_power_t state) -{ -pci_power_t weakest = PCI_D3hot; -unsigned int j; - -/* Find device in cache or first free cell */ -for (j =0 ; j <LSS_MAX_SHARED_DEVS ; j++) { -if (lss[j].pdev == pdev || !lss[j].pdev) -break ; - } - -/* Store the desired state in cache */ -if (j <LSS_MAX_SHARED_DEVS ) { - lss[j].pdev = pdev; - lss[j].state = state; - }else { -dev_WARN (&pdev->dev,"No room for device in PWRMU LSS cache\n" ); - weakest = state; - } - -/* Find the power state we may use */ -for (j =0 ; j <LSS_MAX_SHARED_DEVS ; j++) { -if (lss[j].state < weakest) - weakest = lss[j].state; - } - -return weakest; -} - -static int __set_power_state (struct mid_pwr *pwr,struct pci_dev *pdev, -pci_power_t state,int id,int reg,int bit) -{ -const char *name; -int ret; - - state =__find_weakest_power_state (pwr->lss[id], pdev, state); - name =pci_power_name (state); - - ret =__update_power_state (pwr, reg, bit, (__force int )state); -if (ret) { -dev_warn (&pdev->dev,"Can't set power state %s: %d\n" , name, ret); -return ret; - } - -dev_vdbg (&pdev->dev,"Set power state %s\n" , name); -return 0 ; -} - -static int mid_pwr_set_power_state (struct mid_pwr *pwr,struct pci_dev *pdev, -pci_power_t state) -{ -int id, reg, bit; -int ret; - - id =intel_mid_pwr_get_lss_id (pdev); -if (id <0 ) -return id; - - reg = (id *LSS_PWS_BITS ) /32 ; - bit = (id *LSS_PWS_BITS ) %32 ; - -/* We support states between PCI_D0 and PCI_D3hot */ -if (state <PCI_D0 ) - state =PCI_D0 ; -if (state > PCI_D3hot) - state = PCI_D3hot; - -mutex_lock (&pwr->lock); - ret =__set_power_state (pwr, pdev, state, id, reg, bit); -mutex_unlock (&pwr->lock); -return ret; -} - -int intel_mid_pci_set_power_state (struct pci_dev *pdev,pci_power_t state) -{ -struct mid_pwr *pwr = midpwr; -int ret =0 ; - -might_sleep (); - -if (pwr && pwr->available) - ret =mid_pwr_set_power_state (pwr, pdev, state); -dev_vdbg (&pdev->dev,"set_power_state() returns %d\n" , ret); - -return 0 ; -} - -pci_power_t intel_mid_pci_get_power_state (struct pci_dev *pdev) -{ -struct mid_pwr *pwr = midpwr; -int id, reg, bit; -u32 power; - -if (!pwr || !pwr->available) -return PCI_UNKNOWN ; - - id =intel_mid_pwr_get_lss_id (pdev); -if (id <0 ) -return PCI_UNKNOWN ; - - reg = (id *LSS_PWS_BITS ) /32 ; - bit = (id *LSS_PWS_BITS ) %32 ; - power =mid_pwr_get_state (pwr, reg); -return (__force pci_power_t)((power >> bit) &3 ); -} -void intel_mid_pwr_power_off (void ) {struct mid_pwr *pwr = midpwr;@@ -469,7 +320,6 @@ static const struct mid_pwr_device_info .set_initial_state = tng_set_initial_state, }; -/* This table should be in sync with the one in drivers/pci/pci-mid.c */ static const struct pci_device_id mid_pwr_pci_ids[] = { {PCI_VDEVICE (INTEL ,PCI_DEVICE_ID_PENWELL ), (kernel_ulong_t)&pnw_info }, {PCI_VDEVICE (INTEL ,PCI_DEVICE_ID_TANGIER ), (kernel_ulong_t)&tng_info },Index:
linux-pm/arch/x86/include/asm/intel-mid.h
===================================================================arch/x86/include/asm/intel-mid.h +0
-3@@ -10,9 +10,6 @@#include <linux/pci.h> extern int intel_mid_pci_init (void ); -extern int intel_mid_pci_set_power_state (struct pci_dev *pdev,pci_power_t state); -extern pci_power_t intel_mid_pci_get_power_state (struct pci_dev *pdev); -extern void intel_mid_pwr_power_off (void );#define INTEL_MID_PWR_LSS_OFFSET 4
Rafael J. Wysocki
maintainerRe: [PATCH v1 1/5] PCI: PM: x86: Drop Intel MID PCI PM support
Quoted 14 lines · Ferry Toth
Hi,
Op 18-09-2021 om 15:21 schreef Rafael J. Wysocki:
Quoted 9 lines
From: Rafael J. Wysocki <[email protected]>
Support for Intel MID platforms has mostly gone away with the SFI support removal in commit
4590d98f5a4f("sfi: Remove framework for deprecated firmware"), but there are some pieces of it still in the tree. One of them is the MID PCI PM support code which gets in the way of subsequent PCI PM simplifications and trying to update it is rather pointless, so get rid of it completely along with the arch code pieces that are only used by it.
Quoted 5 lines
Removing PM support for MID will break (among others) Intel Edison, which is currently in use and running up to date vanilla kernel (v5.14) and user space.
I would happily test updates PM when they appear.
Thanks for the information, I'll use a different approach then.
PATCH 2/5 PCI: ACPI: PM: Do not use pci_platform_pm_ops for ACPI
In reply to a message not in the archiveFrom: Rafael J. Wysocki <[email protected]>
Using struct pci_platform_pm_ops for ACPI adds unnecessary indirection to the interactions between the PCI core and ACPI PM, which is also subject to retpolines.
Moreover, it is not particularly clear from the current code that, as far as PCI PM is concerned, "platform" really means just ACPI as long as CONFIG_ACPI is set and the ACPI support is not disabled (either via the kernel command line or because there are no usable ACPI tables on the system).
To address the above, rework the PCI PM code to invoke ACPI PM functions directly as needed and drop acpi_pci_platform_pm that is not necessary any more. Accordingly, update some of the ACPI PM functions in question to do extra checks in case the ACPI support is disabled (which previously was taken care of by avoiding to set the pci_platform_ops pointer by PCI in those cases).
Having done that, also drop struct pci_platform_pm_ops that has no more users.
--- drivers/pci/pci-acpi.c | 42 +++++++++----------- drivers/pci/pci.c | 99 ++++++++++--------------------------------------- drivers/pci/pci.h | 77 ++++++++++++++++++-------------------- 3 files changed, 79 insertions(+), 139 deletions(-)
drivers/pci/pci-acpi.c +20 -22
@@ -906,10 +906,13 @@ acpi_status pci_acpi_add_pm_notifier(str* choose highest power _SxD or any lower power */ -static pci_power_t acpi_pci_choose_state (struct pci_dev *pdev) +pci_power_t acpi_pci_choose_state (struct pci_dev *pdev) {int acpi_state, d_max; +if (acpi_pci_disabled) +return PCI_POWER_ERROR ; +if (pdev->no_d3cold) d_max =ACPI_STATE_D3_HOT ;else
@@ -965,7 +968,7 @@ int pci_dev_acpi_reset(struct pci_dev *dreturn 0 ; } -static bool acpi_pci_power_manageable (struct pci_dev *dev) +bool acpi_pci_power_manageable (struct pci_dev *dev) {struct acpi_device *adev =ACPI_COMPANION (&dev->dev);
@@ -974,13 +977,13 @@ static bool acpi_pci_power_manageable(streturn acpi_device_power_manageable (adev); } -static bool acpi_pci_bridge_d3 (struct pci_dev *dev) +bool acpi_pci_bridge_d3 (struct pci_dev *dev) {const union acpi_object *obj;struct acpi_device *adev;struct pci_dev *rpdev; -if (!dev->is_hotplug_bridge) +if (acpi_pci_disabled || !dev->is_hotplug_bridge)return false;/* Assume D3 support if the bridge is power-manageable by ACPI. */
@@ -1008,7 +1011,7 @@ static bool acpi_pci_bridge_d3(struct pcreturn obj->integer.value ==1 ; } -static int acpi_pci_set_power_state (struct pci_dev *dev,pci_power_t state) +int acpi_pci_set_power_state (struct pci_dev *dev,pci_power_t state) {struct acpi_device *adev =ACPI_COMPANION (&dev->dev);static const u8 state_conv[] = {
@@ -1046,7 +1049,7 @@ static int acpi_pci_set_power_state(strureturn error; } -static pci_power_t acpi_pci_get_power_state (struct pci_dev *dev) +pci_power_t acpi_pci_get_power_state (struct pci_dev *dev) {struct acpi_device *adev =ACPI_COMPANION (&dev->dev);static const pci_power_t state_conv[] = {
@@ -1068,7 +1071,7 @@ static pci_power_t acpi_pci_get_power_streturn state_conv[state]; } -static void acpi_pci_refresh_power_state (struct pci_dev *dev) +void acpi_pci_refresh_power_state (struct pci_dev *dev) {struct acpi_device *adev =ACPI_COMPANION (&dev->dev);
@@ -1093,17 +1096,23 @@ static int acpi_pci_propagate_wakeup(strreturn 0 ; } -static int acpi_pci_wakeup (struct pci_dev *dev,bool enable) +int acpi_pci_wakeup (struct pci_dev *dev,bool enable) { +if (acpi_pci_disabled) +return 0 ; +if (acpi_pm_device_can_wakeup (&dev->dev))return acpi_pm_set_device_wakeup (&dev->dev, enable);return acpi_pci_propagate_wakeup (dev->bus, enable); } -static bool acpi_pci_need_resume (struct pci_dev *dev) +bool acpi_pci_need_resume (struct pci_dev *dev) { -struct acpi_device *adev =ACPI_COMPANION (&dev->dev); +struct acpi_device *adev; + +if (acpi_pci_disabled) +return false;/* * In some cases (eg. Samsung 305V4A) leaving a bridge in suspend over
@@ -1118,6 +1127,7 @@ static bool acpi_pci_need_resume(structif (!adev || !acpi_device_power_manageable (adev))return false; + adev =ACPI_COMPANION (&dev->dev);if (adev->wakeup.flags.valid &&device_may_wakeup (&dev->dev) != !!adev->wakeup.prepare_count)return true;
@@ -1128,17 +1138,6 @@ static bool acpi_pci_need_resume(structreturn !!adev->power.flags.dsw_present; } -static const struct pci_platform_pm_ops acpi_pci_platform_pm = { - .bridge_d3 = acpi_pci_bridge_d3, - .is_manageable = acpi_pci_power_manageable, - .set_state = acpi_pci_set_power_state, - .get_state = acpi_pci_get_power_state, - .refresh_state = acpi_pci_refresh_power_state, - .choose_state = acpi_pci_choose_state, - .set_wakeup = acpi_pci_wakeup, - .need_resume = acpi_pci_need_resume, -}; -void acpi_pci_add_bus (struct pci_bus *bus) {union acpi_object *obj;
@@ -1448,7 +1447,6 @@ static int __init acpi_pci_init(void)if (acpi_pci_disabled)return 0 ; -pci_set_platform_pm (&acpi_pci_platform_pm);acpi_pci_slot_init ();acpiphp_init ();
drivers/pci/pci.c +22 -77
178 lines not on this page · raw message
drivers/pci/pci.h +37 -40
99 lines not on this page · raw message
PATCH 3/5 PCI: PM: Rearrange code in pci_target_state()
In reply to a message not in the archiveFrom: Rafael J. Wysocki <[email protected]>
Make pci_target_state() return D3cold or D0 without checking PME support if the current power state of the device is D3cold or if it does not support the standard PCI PM, respectively.
Next, drop the tergat_state local variable that has become redundant from that function.
--- drivers/pci/pci.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
drivers/pci/pci.c +9 -14
@@ -2520,8 +2520,6 @@ EXPORT_SYMBOL(pci_wake_from_d3);*/ static pci_power_t pci_target_state (struct pci_dev *dev,bool wakeup) { -pci_power_t target_state = PCI_D3hot; -if (acpi_pci_power_manageable (dev)) {/* * Use ACPI to find the target state for the device. If it
@@ -2533,32 +2531,29 @@ static pci_power_t pci_target_state(struswitch (state) {case PCI_POWER_ERROR :case PCI_UNKNOWN : -break ; +return PCI_D3hot; +case PCI_D1 :case PCI_D2 :if (pci_no_d1d2 (dev)) -break ; - fallthrough; -default : - target_state = state; +return PCI_D3hot; } -return target_state; +return state; } -if (!dev->pm_cap) - target_state =PCI_D0 ; -/* * If the device is in D3cold even though it's not power-manageable by * the platform, it may have been powered down by non-standard means. * Best to let it slumber. */ if (dev->current_state == PCI_D3cold) - target_state = PCI_D3cold; +return PCI_D3cold; +else if (!dev->pm_cap) +return PCI_D0 ;if (wakeup && dev->pme_support) { -pci_power_t state = target_state; +pci_power_t state = PCI_D3hot;/* * Find the deepest state from which the device can generate
@@ -2573,7 +2568,7 @@ static pci_power_t pci_target_state(strureturn PCI_D0 ; } -return target_state; +return PCI_D3hot; }/**
PATCH 4/5 PCI: PM: Make pci_choose_state() call pci_target_state()
In reply to a message not in the archiveFrom: Rafael J. Wysocki <[email protected]>
The pci_choose_state() and pci_target_state() implementations are somewhat divergent without a good reason, because they are used for similar purposes.
Change the pci_choose_state() implementation to use pci_target_state() internally except for transitions to the working state of the system in which case it is expected to return D0.
--- drivers/pci/pci-acpi.c | 3 -- drivers/pci/pci.c | 54 ++++++++++++++----------------------------------- 2 files changed, 16 insertions(+), 41 deletions(-)
drivers/pci/pci.c +16 -38
@@ -1331,44 +1331,6 @@ int pci_set_power_state(struct pci_dev * }EXPORT_SYMBOL (pci_set_power_state); -/** -* pci_choose_state - Choose the power state of a PCI device -* @dev: PCI device to be suspended -* @state: target sleep state for the whole system. This is the value -* that is passed to suspend() function. -* -* Returns PCI power state suitable for given device and given system -* message. -*/ -pci_power_t pci_choose_state (struct pci_dev *dev,pm_message_t state) -{ -pci_power_t ret; - -if (!dev->pm_cap) -return PCI_D0 ; - - ret =acpi_pci_choose_state (dev); -if (ret !=PCI_POWER_ERROR ) -return ret; - -switch (state.event) { -case PM_EVENT_ON : -return PCI_D0 ; -case PM_EVENT_FREEZE : -case PM_EVENT_PRETHAW : -/* REVISIT both freeze and pre-thaw "should" use D0 */ -case PM_EVENT_SUSPEND : -case PM_EVENT_HIBERNATE : -return PCI_D3hot; -default : -pci_info (dev,"unrecognized suspend event %d\n" , - state.event); -BUG (); - } -return PCI_D0 ; -} -EXPORT_SYMBOL (pci_choose_state); -#define PCI_EXP_SAVE_REGS 7 static struct pci_cap_saved_state *_pci_find_saved_cap(struct pci_dev *pci_dev,
@@ -2782,6 +2744,22 @@ void pci_dev_complete_resume(struct pci_spin_unlock_irq (&dev->power.lock); } +/** +* pci_choose_state - Choose the power state for a PCI device. +* @pci_dev: Target PCI device. +* @state: Target state for the whole system. +* +* Returns PCI power state suitable for @pci_dev and @state. +*/ +pci_power_t pci_choose_state (struct pci_dev *pci_dev,pm_message_t state) +{ +if (state.event ==PM_EVENT_ON ) +return PCI_D0 ; + +return pci_target_state (pci_dev,device_may_wakeup (&pci_dev->dev)); +} +EXPORT_SYMBOL (pci_choose_state); +void pci_config_pm_runtime_get (struct pci_dev *pdev) {struct device *dev = &pdev->dev;
drivers/pci/pci-acpi.c +0 -3
@@ -910,9 +910,6 @@ pci_power_t acpi_pci_choose_state(struct {int acpi_state, d_max; -if (acpi_pci_disabled) -return PCI_POWER_ERROR ; -if (pdev->no_d3cold) d_max =ACPI_STATE_D3_HOT ;else
PATCH 5/5 PCI: PM: ACPI: Drop unnecessary acpi_pci_power_manageable() calls
In reply to a message not in the archiveFrom: Rafael J. Wysocki <[email protected]>
Simplify acpi_pci_power_manageable() and drop two invocations of it that are not necessary, because the functions called when it returns 'true' do the requisite "power manageable" checks themselves.
--- drivers/pci/pci-acpi.c | 4 +--- drivers/pci/pci.c | 16 +++++----------- 2 files changed, 6 insertions(+), 14 deletions(-)
drivers/pci/pci.c +5 -11
@@ -1128,9 +1128,7 @@ void pci_update_current_state(struct pci*/ void pci_refresh_power_state (struct pci_dev *dev) { -if (acpi_pci_power_manageable (dev)) -acpi_pci_refresh_power_state (dev); - +acpi_pci_refresh_power_state (dev);pci_update_current_state (dev, dev->current_state); }
@@ -1143,14 +1141,10 @@ int pci_platform_power_transition(struct {int error; -if (acpi_pci_power_manageable (dev)) { - error =acpi_pci_set_power_state (dev, state); -if (!error) -pci_update_current_state (dev, state); - }else - error = -ENODEV ; - -if (error && !dev->pm_cap)/* Fall back to PCI_D0 */ + error =acpi_pci_set_power_state (dev, state); +if (!error) +pci_update_current_state (dev, state); +else if (!dev->pm_cap)/* Fall back to PCI_D0 */ dev->current_state =PCI_D0 ;return error;
drivers/pci/pci-acpi.c +1 -3
@@ -969,9 +969,7 @@ bool acpi_pci_power_manageable(struct pc {struct acpi_device *adev =ACPI_COMPANION (&dev->dev); -if (!adev) -return false; -return acpi_device_power_manageable (adev); +return adev &&acpi_device_power_manageable (adev); }bool acpi_pci_bridge_d3 (struct pci_dev *dev)