Merge tag 'v6.6-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[linux-2.6-microblaze.git] / drivers / pci / pci.c
index 702fe57..59c01d6 100644 (file)
@@ -1291,7 +1291,7 @@ end:
  *
  * Call pci_power_up() to put @dev into D0, read from its PCI_PM_CTRL register
  * to confirm the state change, restore its BARs if they might be lost and
- * reconfigure ASPM in acordance with the new power state.
+ * reconfigure ASPM in accordance with the new power state.
  *
  * If pci_restore_state() is going to be called right after a power state change
  * to D0, it is more efficient to use pci_power_up() directly instead of this
@@ -1686,7 +1686,7 @@ int pci_save_state(struct pci_dev *dev)
        /* XXX: 100% dword access ok here? */
        for (i = 0; i < 16; i++) {
                pci_read_config_dword(dev, i * 4, &dev->saved_config_space[i]);
-               pci_dbg(dev, "saving config space at offset %#x (reading %#x)\n",
+               pci_dbg(dev, "save config %#04x: %#010x\n",
                        i * 4, dev->saved_config_space[i]);
        }
        dev->state_saved = true;
@@ -1717,7 +1717,7 @@ static void pci_restore_config_dword(struct pci_dev *pdev, int offset,
                return;
 
        for (;;) {
-               pci_dbg(pdev, "restoring config space at offset %#x (was %#x, writing %#x)\n",
+               pci_dbg(pdev, "restore config %#04x: %#010x -> %#010x\n",
                        offset, val, saved_val);
                pci_write_config_dword(pdev, offset, saved_val);
                if (retry-- <= 0)
@@ -2420,10 +2420,13 @@ static void pci_pme_list_scan(struct work_struct *work)
 
        mutex_lock(&pci_pme_list_mutex);
        list_for_each_entry_safe(pme_dev, n, &pci_pme_list, list) {
-               if (pme_dev->dev->pme_poll) {
-                       struct pci_dev *bridge;
+               struct pci_dev *pdev = pme_dev->dev;
+
+               if (pdev->pme_poll) {
+                       struct pci_dev *bridge = pdev->bus->self;
+                       struct device *dev = &pdev->dev;
+                       int pm_status;
 
-                       bridge = pme_dev->dev->bus->self;
                        /*
                         * If bridge is in low power state, the
                         * configuration space of subordinate devices
@@ -2431,14 +2434,20 @@ static void pci_pme_list_scan(struct work_struct *work)
                         */
                        if (bridge && bridge->current_state != PCI_D0)
                                continue;
+
                        /*
-                        * If the device is in D3cold it should not be
-                        * polled either.
+                        * If the device is in a low power state it
+                        * should not be polled either.
                         */
-                       if (pme_dev->dev->current_state == PCI_D3cold)
+                       pm_status = pm_runtime_get_if_active(dev, true);
+                       if (!pm_status)
                                continue;
 
-                       pci_pme_wakeup(pme_dev->dev, NULL);
+                       if (pdev->current_state != PCI_D3cold)
+                               pci_pme_wakeup(pdev, NULL);
+
+                       if (pm_status > 0)
+                               pm_runtime_put(dev);
                } else {
                        list_del(&pme_dev->list);
                        kfree(pme_dev);
@@ -4196,16 +4205,12 @@ int pci_register_io_range(struct fwnode_handle *fwnode, phys_addr_t addr,
 
 phys_addr_t pci_pio_to_address(unsigned long pio)
 {
-       phys_addr_t address = (phys_addr_t)OF_BAD_ADDR;
-
 #ifdef PCI_IOBASE
-       if (pio >= MMIO_UPPER_LIMIT)
-               return address;
-
-       address = logic_pio_to_hwaddr(pio);
+       if (pio < MMIO_UPPER_LIMIT)
+               return logic_pio_to_hwaddr(pio);
 #endif
 
-       return address;
+       return (phys_addr_t) OF_BAD_ADDR;
 }
 EXPORT_SYMBOL_GPL(pci_pio_to_address);
 
@@ -5632,7 +5637,7 @@ int pci_try_reset_function(struct pci_dev *dev)
 EXPORT_SYMBOL_GPL(pci_try_reset_function);
 
 /* Do any devices on or below this bus prevent a bus reset? */
-static bool pci_bus_resetable(struct pci_bus *bus)
+static bool pci_bus_resettable(struct pci_bus *bus)
 {
        struct pci_dev *dev;
 
@@ -5642,7 +5647,7 @@ static bool pci_bus_resetable(struct pci_bus *bus)
 
        list_for_each_entry(dev, &bus->devices, bus_list) {
                if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
-                   (dev->subordinate && !pci_bus_resetable(dev->subordinate)))
+                   (dev->subordinate && !pci_bus_resettable(dev->subordinate)))
                        return false;
        }
 
@@ -5700,7 +5705,7 @@ unlock:
 }
 
 /* Do any devices on or below this slot prevent a bus reset? */
-static bool pci_slot_resetable(struct pci_slot *slot)
+static bool pci_slot_resettable(struct pci_slot *slot)
 {
        struct pci_dev *dev;
 
@@ -5712,7 +5717,7 @@ static bool pci_slot_resetable(struct pci_slot *slot)
                if (!dev->slot || dev->slot != slot)
                        continue;
                if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
-                   (dev->subordinate && !pci_bus_resetable(dev->subordinate)))
+                   (dev->subordinate && !pci_bus_resettable(dev->subordinate)))
                        return false;
        }
 
@@ -5848,7 +5853,7 @@ static int pci_slot_reset(struct pci_slot *slot, bool probe)
 {
        int rc;
 
-       if (!slot || !pci_slot_resetable(slot))
+       if (!slot || !pci_slot_resettable(slot))
                return -ENOTTY;
 
        if (!probe)
@@ -5915,7 +5920,7 @@ static int pci_bus_reset(struct pci_bus *bus, bool probe)
 {
        int ret;
 
-       if (!bus->self || !pci_bus_resetable(bus))
+       if (!bus->self || !pci_bus_resettable(bus))
                return -ENOTTY;
 
        if (probe)