diff options
author | Ajaykumar Hotchandani <ajaykumar.hotchandani@oracle.com> | 2011-12-12 03:27:36 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2011-12-14 11:26:42 -0500 |
commit | b51306c63449d7f06ffa689036ba49eb46e898b5 (patch) | |
tree | 6f3ad6817681c1ee2a7d7abc86d85695564924ea /drivers/pci | |
parent | 619a5182d1f38a3d629ee48e04fa182ef9170052 (diff) |
PCI: Set device power state to PCI_D0 for device without native PM support
During test of one IB card with guest VM, found that, msi is not
initialized properly.
It turns out __write_msi_msg will do nothing if device current_state is
not PCI_D0. And, that pci device does not have pm_cap in guest VM.
There is an error in setting of power state to PCI_D0 in
pci_enable_device(), but error is not returned for this. Following is
code flow:
pci_enable_device() --> __pci_enable_device_flags() -->
do_pci_enable_device() --> pci_set_power_state() -->
__pci_start_power_transition()
We have following condition inside __pci_start_power_transition():
if (platform_pci_power_manageable(dev)) {
error = platform_pci_set_power_state(dev, state);
if (!error)
pci_update_current_state(dev, state);
} else {
error = -ENODEV;
/* Fall back to PCI_D0 if native PM is not supported */
if (!dev->pm_cap)
dev->current_state = PCI_D0;
}
Here, from platform_pci_set_power_state(), acpi_pci_set_power_state() is
getting called and that is failing with ENODEV because of following
condition:
if (!handle || ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0",&tmp)))
return -ENODEV;
Because of that, pci_update_current_state() is not getting called.
With this patch, if device power state can not be set via
platform_pci_set_power_state and that device does not have native pm
support, then PCI device power state will be set to PCI_D0.
-v2: This also reverts 47e9037ac16637cd7f12b8790ea7ce6680e42168, as it's
not needed after this change.
Acked-by: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Ajaykumar Hotchandani<ajaykumar.hotchandani@oracle.com>
Signed-off-by: Yinghai Lu<yinghai.lu@oracle.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/hotplug/acpiphp_glue.c | 1 | ||||
-rw-r--r-- | drivers/pci/pci.c | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 68360d5b494a..9ddf69e3bbef 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -225,7 +225,6 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
225 | 225 | ||
226 | pdev = pci_get_slot(pbus, PCI_DEVFN(device, function)); | 226 | pdev = pci_get_slot(pbus, PCI_DEVFN(device, function)); |
227 | if (pdev) { | 227 | if (pdev) { |
228 | pdev->current_state = PCI_D0; | ||
229 | slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); | 228 | slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); |
230 | pci_dev_put(pdev); | 229 | pci_dev_put(pdev); |
231 | } | 230 | } |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 4788413f43d7..faccb8937706 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -664,6 +664,9 @@ static int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state) | |||
664 | error = platform_pci_set_power_state(dev, state); | 664 | error = platform_pci_set_power_state(dev, state); |
665 | if (!error) | 665 | if (!error) |
666 | pci_update_current_state(dev, state); | 666 | pci_update_current_state(dev, state); |
667 | /* Fall back to PCI_D0 if native PM is not supported */ | ||
668 | if (!dev->pm_cap) | ||
669 | dev->current_state = PCI_D0; | ||
667 | } else { | 670 | } else { |
668 | error = -ENODEV; | 671 | error = -ENODEV; |
669 | /* Fall back to PCI_D0 if native PM is not supported */ | 672 | /* Fall back to PCI_D0 if native PM is not supported */ |