Re: [RFC v2 3/5] PCIe, Add runtime PM support to PCIe port
From: huang ying
Date: Sat May 05 2012 - 02:53:22 EST
On Sat, May 5, 2012 at 3:50 AM, Bjorn Helgaas <bhelgaas@xxxxxxxxxx> wrote:
> On Fri, May 4, 2012 at 2:13 AM, Huang Ying <ying.huang@xxxxxxxxx> wrote:
>> From: Zheng Yan <zheng.z.yan@xxxxxxxxx>
>>
>> This patch adds runtime PM support to PCIe port. ÂThis is needed by
>> PCIe D3cold support, where PCIe device in slot may be powered on/off
>> by PCIe port.
>
> I assume this works for integrated PCIe devices as well as those that
> are plugged into a slot and can be physically removed -- maybe the
> text "in slot" is superfluous?
"in slot" is used here, because usually integrated PCIe devices has
ACPI node and method attached with them while that is not the case for
PCIe devices in slot. I will make it more clear with something as
follow:
Some PCIe devices have not direct platform support (such as ACPI node
and method) to be powered on/off. But they may be powered on/off by
the corresponding PCIe port.
>> Because runtime suspend is broken for some chipset, a white list is
>> used to enable runtime PM support for only chipset known to work.
>
> A whitelist requires perpetual maintenance. ÂEvery time a new working
> chipset comes out, you have to update the whitelist. ÂThat doesn't
> seem right.
>
>> Signed-off-by: Zheng Yan <zheng.z.yan@xxxxxxxxx>
>> Signed-off-by: Huang Ying <ying.huang@xxxxxxxxx>
>> ---
>> Âdrivers/pci/pci.c       Â|  Â9 +++++++++
>> Âdrivers/pci/pcie/portdrv_pci.c | Â 40 ++++++++++++++++++++++++++++++++++++++++
>> Â2 files changed, 49 insertions(+)
>>
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -1476,6 +1476,15 @@ bool pci_check_pme_status(struct pci_dev
>> Â*/
>> Âstatic int pci_pme_wakeup(struct pci_dev *dev, void *pme_poll_reset)
>> Â{
>> + Â Â Â struct pci_dev *bridge = dev->bus->self;
>> +
>> + Â Â Â /*
>> + Â Â Â Â* If bridge is in low power state, the configuration space of
>> + Â Â Â Â* subordinate devices may be not accessible
>> + Â Â Â Â*/
>
> This comment would make more sense as "If the upstream bridge is in a
> low power state, the configuration space of this device is not
> accessible."
Yes. Will change this.
>> + Â Â Â if (bridge && bridge->current_state != PCI_D0)
>> + Â Â Â Â Â Â Â return 0;
>> +
>> Â Â Â Âif (pme_poll_reset && dev->pme_poll)
>> Â Â Â Â Â Â Â Âdev->pme_poll = false;
>>
>> --- a/drivers/pci/pcie/portdrv_pci.c
>> +++ b/drivers/pci/pcie/portdrv_pci.c
>> @@ -11,6 +11,7 @@
>> Â#include <linux/kernel.h>
>> Â#include <linux/errno.h>
>> Â#include <linux/pm.h>
>> +#include <linux/pm_runtime.h>
>> Â#include <linux/init.h>
>> Â#include <linux/pcieport_if.h>
>> Â#include <linux/aer.h>
>> @@ -99,6 +100,27 @@ static int pcie_port_resume_noirq(struct
>> Â Â Â Âreturn 0;
>> Â}
>>
>> +#ifdef CONFIG_PM_RUNTIME
>> +static int pcie_port_runtime_suspend(struct device *dev)
>> +{
>> + Â Â Â struct pci_dev *pdev = to_pci_dev(dev);
>> +
>> + Â Â Â pci_save_state(pdev);
>> + Â Â Â return 0;
>> +}
>> +
>> +static int pcie_port_runtime_resume(struct device *dev)
>> +{
>> + Â Â Â struct pci_dev *pdev = to_pci_dev(dev);
>> +
>> + Â Â Â pci_restore_state(pdev);
>> + Â Â Â return 0;
>> +}
>> +#else
>> +#define pcie_port_runtime_suspend   ÂNULL
>> +#define pcie_port_runtime_resume    NULL
>> +#endif
>> +
>> Âstatic const struct dev_pm_ops pcie_portdrv_pm_ops = {
>>    Â.suspend    Â= pcie_port_device_suspend,
>>    Â.resume     = pcie_port_device_resume,
>> @@ -107,6 +129,8 @@ static const struct dev_pm_ops pcie_port
>>    Â.poweroff    = pcie_port_device_suspend,
>>    Â.restore    Â= pcie_port_device_resume,
>>    Â.resume_noirq  = pcie_port_resume_noirq,
>> + Â Â Â .runtime_suspend = pcie_port_runtime_suspend,
>> + Â Â Â .runtime_resume = pcie_port_runtime_resume,
>> Â};
>>
>> Â#define PCIE_PORTDRV_PM_OPS Â Â(&pcie_portdrv_pm_ops)
>> @@ -117,6 +141,18 @@ static const struct dev_pm_ops pcie_port
>> Â#endif /* !PM */
>>
>> Â/*
>> + * PCIe port runtime suspend is broken for some chipset, so use a
>> + * white list to disable runtime PM for these chipset.
>
> If you're *disabling* runtime PM for these chipsets, I'd call this a
> blacklist (and a blacklist makes more sense to me from a maintenance
> standpoint, because you only have to update it when new broken chips
> are discovered).
Yes. I think blacklist may be better.
Best Regards,
Huang Ying
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/