PCI: Move pci_read_bridge_windows() below individual window accessors
authorBjorn Helgaas <bhelgaas@google.com>
Mon, 4 Dec 2023 23:39:15 +0000 (17:39 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 15 Dec 2023 23:28:43 +0000 (17:28 -0600)
Move pci_read_bridge_windows() below the functions that read the I/O,
memory, and prefetchable memory windows, so pci_read_bridge_windows() can
use them in the future.  No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/probe.c

index e2669562389c16b89408935b6f7bc3a55df0fcd7..75bb48b72e854e9d8fc5becbbc511e470e06560b 100644 (file)
@@ -344,57 +344,6 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
        }
 }
 
-static void pci_read_bridge_windows(struct pci_dev *bridge)
-{
-       u16 io;
-       u32 pmem, tmp;
-
-       pci_read_config_word(bridge, PCI_IO_BASE, &io);
-       if (!io) {
-               pci_write_config_word(bridge, PCI_IO_BASE, 0xe0f0);
-               pci_read_config_word(bridge, PCI_IO_BASE, &io);
-               pci_write_config_word(bridge, PCI_IO_BASE, 0x0);
-       }
-       if (io)
-               bridge->io_window = 1;
-
-       /*
-        * DECchip 21050 pass 2 errata: the bridge may miss an address
-        * disconnect boundary by one PCI data phase.  Workaround: do not
-        * use prefetching on this device.
-        */
-       if (bridge->vendor == PCI_VENDOR_ID_DEC && bridge->device == 0x0001)
-               return;
-
-       pci_read_config_dword(bridge, PCI_PREF_MEMORY_BASE, &pmem);
-       if (!pmem) {
-               pci_write_config_dword(bridge, PCI_PREF_MEMORY_BASE,
-                                              0xffe0fff0);
-               pci_read_config_dword(bridge, PCI_PREF_MEMORY_BASE, &pmem);
-               pci_write_config_dword(bridge, PCI_PREF_MEMORY_BASE, 0x0);
-       }
-       if (!pmem)
-               return;
-
-       bridge->pref_window = 1;
-
-       if ((pmem & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) {
-
-               /*
-                * Bridge claims to have a 64-bit prefetchable memory
-                * window; verify that the upper bits are actually
-                * writable.
-                */
-               pci_read_config_dword(bridge, PCI_PREF_BASE_UPPER32, &pmem);
-               pci_write_config_dword(bridge, PCI_PREF_BASE_UPPER32,
-                                      0xffffffff);
-               pci_read_config_dword(bridge, PCI_PREF_BASE_UPPER32, &tmp);
-               pci_write_config_dword(bridge, PCI_PREF_BASE_UPPER32, pmem);
-               if (tmp)
-                       bridge->pref_64_window = 1;
-       }
-}
-
 static void pci_read_bridge_io(struct pci_bus *child)
 {
        struct pci_dev *dev = child->self;
@@ -510,6 +459,57 @@ static void pci_read_bridge_mmio_pref(struct pci_bus *child)
        }
 }
 
+static void pci_read_bridge_windows(struct pci_dev *bridge)
+{
+       u16 io;
+       u32 pmem, tmp;
+
+       pci_read_config_word(bridge, PCI_IO_BASE, &io);
+       if (!io) {
+               pci_write_config_word(bridge, PCI_IO_BASE, 0xe0f0);
+               pci_read_config_word(bridge, PCI_IO_BASE, &io);
+               pci_write_config_word(bridge, PCI_IO_BASE, 0x0);
+       }
+       if (io)
+               bridge->io_window = 1;
+
+       /*
+        * DECchip 21050 pass 2 errata: the bridge may miss an address
+        * disconnect boundary by one PCI data phase.  Workaround: do not
+        * use prefetching on this device.
+        */
+       if (bridge->vendor == PCI_VENDOR_ID_DEC && bridge->device == 0x0001)
+               return;
+
+       pci_read_config_dword(bridge, PCI_PREF_MEMORY_BASE, &pmem);
+       if (!pmem) {
+               pci_write_config_dword(bridge, PCI_PREF_MEMORY_BASE,
+                                              0xffe0fff0);
+               pci_read_config_dword(bridge, PCI_PREF_MEMORY_BASE, &pmem);
+               pci_write_config_dword(bridge, PCI_PREF_MEMORY_BASE, 0x0);
+       }
+       if (!pmem)
+               return;
+
+       bridge->pref_window = 1;
+
+       if ((pmem & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) {
+
+               /*
+                * Bridge claims to have a 64-bit prefetchable memory
+                * window; verify that the upper bits are actually
+                * writable.
+                */
+               pci_read_config_dword(bridge, PCI_PREF_BASE_UPPER32, &pmem);
+               pci_write_config_dword(bridge, PCI_PREF_BASE_UPPER32,
+                                      0xffffffff);
+               pci_read_config_dword(bridge, PCI_PREF_BASE_UPPER32, &tmp);
+               pci_write_config_dword(bridge, PCI_PREF_BASE_UPPER32, pmem);
+               if (tmp)
+                       bridge->pref_64_window = 1;
+       }
+}
+
 void pci_read_bridge_bases(struct pci_bus *child)
 {
        struct pci_dev *dev = child->self;