linux/drivers/pci
Ajaykumar Hotchandani b51306c634 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 47e9037ac1, 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>
2011-12-14 08:26:42 -08:00
..
hotplug PCI: Set device power state to PCI_D0 for device without native PM support 2011-12-14 08:26:42 -08:00
pcie PCI / PM: Extend PME polling to all PCI devices 2011-10-14 09:05:31 -07:00
.gitignore
Kconfig Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci 2011-11-23 14:58:46 -08:00
Makefile PCI: Move ATS implementation into own file 2011-10-14 09:05:33 -07:00
access.c PCI: handle positive error codes 2011-05-10 15:43:36 -07:00
ats.c PCI: fix ats compile failure 2011-12-05 10:31:25 -08:00
bus.c PCI/sysfs: move bus cpuaffinity to class dev_attrs 2011-05-21 12:17:13 -07:00
hotplug-pci.c pci: Fix files needing export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:22 -04:00
hotplug.c
htirq.c pci: Fix files needing export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:22 -04:00
ioapic.c pci: Fix files needing export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:22 -04:00
iov.c PCI: defer enablement of SRIOV BARS 2011-12-05 10:30:22 -08:00
irq.c pci: Fix files needing export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:22 -04:00
msi.c pci: Fix files needing export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:22 -04:00
msi.h PCI: MSI: Move MSI-X entry definition to pci_regs.h 2010-12-23 12:53:07 -08:00
of.c PCI: OF: Don't crash when bridge parent is NULL. 2011-08-19 08:51:37 -07:00
pci-acpi.c PCI / PM: Remove unnecessary error variable from acpi_dev_run_wake() 2011-10-14 09:05:32 -07:00
pci-driver.c PCI / PM: Detect early wakeup in pci_pm_prepare() 2011-07-06 10:51:40 +02:00
pci-label.c pci-label.c: size_t misspelled as mode_t 2011-07-26 13:01:09 -04:00
pci-stub.c PCI: pci-stub: ignore zero-length id parameters 2010-12-23 12:53:52 -08:00
pci-sysfs.c pci: Fix files needing export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:22 -04:00
pci.c PCI: Set device power state to PCI_D0 for device without native PM support 2011-12-14 08:26:42 -08:00
pci.h PCI: make cardbus-bridge resources optional 2011-08-01 11:50:40 -07:00
probe.c PCI: Clean-up MPS debug output 2011-10-27 12:45:44 -07:00
proc.c BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
quirks.c pci: Fix files needing export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:22 -04:00
remove.c PCI/sysfs: move bus cpuaffinity to class dev_attrs 2011-05-21 12:17:13 -07:00
rom.c pci: Fix files needing export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:22 -04:00
search.c PCI: use for_each_pci_dev() 2010-07-30 09:47:22 -07:00
setup-bus.c PCI: Make pci_setup_bridge() non-static for use by arch code 2011-10-14 09:05:29 -07:00
setup-irq.c PCI: Make the struct pci_dev * argument of pci_fixup_irqs const. 2011-07-22 08:26:06 -07:00
setup-res.c pci: Fix files needing export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:22 -04:00
slot.c pci: add module.h to files implicitly relying on its presence. 2011-10-31 19:31:23 -04:00
syscall.c
vpd.c pci: Fix files needing export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:22 -04:00
xen-pcifront.c Merge branches 'stable/drivers-3.2', 'stable/drivers.bugfixes-3.2' and 'stable/pci.fixes-3.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen 2011-10-25 09:19:36 +02:00