linux/drivers/pci/hotplug
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
..
acpi_pcihp.c PCI hotplug: Rename is_ejectable which also exists in dock.c 2011-07-22 08:25:35 -07:00
acpiphp_core.c PCI: Make current and maximum bus speeds part of the PCI core 2010-02-22 16:15:17 -08:00
acpiphp_glue.c PCI: Set device power state to PCI_D0 for device without native PM support 2011-12-14 08:26:42 -08:00
acpiphp_ibm.c sysfs: add struct file* to bin_attr callbacks 2010-05-21 09:37:31 -07:00
acpiphp.h headers: kobject.h redux 2011-01-10 08:51:44 -08:00
cpci_hotplug_core.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
cpci_hotplug_pci.c
cpci_hotplug.h
cpcihp_generic.c PCI: hotplug/cpcihp, fix pci device refcounting 2010-02-22 16:17:02 -08:00
cpcihp_zt5550.c
cpcihp_zt5550.h
cpqphp_core.c PCI hotplug: cpqphp: use pci_dev->vendor 2011-07-22 08:25:43 -07:00
cpqphp_ctrl.c PCI: Make current and maximum bus speeds part of the PCI core 2010-02-22 16:15:17 -08:00
cpqphp_nvram.c
cpqphp_nvram.h
cpqphp_pci.c PCI Hotplug: cpqphp: don't use pci_find_slot() 2009-06-11 12:04:16 -07:00
cpqphp_sysfs.c drivers: autoconvert trivial BKL users to private mutex 2010-10-05 15:01:04 +02:00
cpqphp.h PCI: Make current and maximum bus speeds part of the PCI core 2010-02-22 16:15:17 -08:00
fakephp.c PCI: use for_each_pci_dev() 2010-07-30 09:47:22 -07:00
ibmphp_core.c PCI: Make current and maximum bus speeds part of the PCI core 2010-02-22 16:15:17 -08:00
ibmphp_ebda.c PCI hotplug: ibmphp: Add check to prevent reading beyond mapped area 2010-11-11 09:34:31 -08:00
ibmphp_hpc.c PCI hotplug: ibmphp-hpc: semaphore cleanup 2010-10-15 13:09:48 -07:00
ibmphp_pci.c
ibmphp_res.c ibmphp: Rename add_range() to add_bus_range() to avoid conflict 2010-02-10 17:45:09 -08:00
ibmphp.h
Kconfig PCI: drivers/pci/slot.c should depend on CONFIG_SYSFS 2009-06-18 13:57:24 -07:00
Makefile PCI hotplug: acpiphp should be linked after vendor drivers 2009-11-04 08:47:14 -08:00
pci_hotplug_core.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
pciehp_acpi.c pci: add module.h to files implicitly relying on its presence. 2011-10-31 19:31:23 -04:00
pciehp_core.c pciehp: update workqueue usage 2010-10-18 08:31:02 +02:00
pciehp_ctrl.c PCI: pciehp: wait 1000 ms before Link Training check 2011-11-11 09:31:34 -08:00
pciehp_hpc.c PCI: pciehp: wait 100 ms after Link Training check 2011-11-11 09:31:43 -08:00
pciehp_pci.c PCI hotplug: pciehp: Fixed return value sign for pciehp_unconfigure_device 2010-07-30 09:29:15 -07:00
pciehp.h pciehp: update workqueue usage 2010-10-18 08:31:02 +02:00
pcihp_skeleton.c PCI hotplug: remove redundant .owner initializations 2009-06-16 14:30:12 -07:00
pcihp_slot.c pci: Fix files needing export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:31:22 -04:00
rpadlpar_core.c pci: add module.h to files implicitly relying on its presence. 2011-10-31 19:31:23 -04:00
rpadlpar_sysfs.c
rpadlpar.h
rpaphp_core.c Fix common misspellings 2011-03-31 11:26:23 -03:00
rpaphp_pci.c
rpaphp_slot.c headers: kobject.h redux 2011-01-10 08:51:44 -08:00
rpaphp.h
sgi_hotplug.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
shpchp_core.c PCI hotplug: shpchp: don't blindly claim non-AMD 0x7450 device IDs 2011-11-14 09:43:14 -08:00
shpchp_ctrl.c shpchp: update workqueue usage 2010-10-18 08:33:02 +02:00
shpchp_hpc.c PCI hotplug: shpchp: don't blindly claim non-AMD 0x7450 device IDs 2011-11-14 09:43:14 -08:00
shpchp_pci.c PCI hotplug: shpchp: Removed check for hotplug of display devices 2010-07-30 09:29:16 -07:00
shpchp_sysfs.c treewide: Convert uses of struct resource to resource_size(ptr) 2011-06-10 14:55:36 +02:00
shpchp.h shpchp: update workqueue usage 2010-10-18 08:33:02 +02:00