]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
Merge branches 'pci/domain' and 'pci/hotplug' into next
authorBjorn Helgaas <bhelgaas@google.com>
Mon, 29 Dec 2014 16:09:19 +0000 (09:09 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 29 Dec 2014 16:09:19 +0000 (09:09 -0700)
* pci/domain:
  ARM/PCI: Move to generic PCI domains
  CNS3xxx: Remove artificial dependency on pci_sys_data domain.
  PCI: Move domain assignment from arm64 to generic code

* pci/hotplug:
  PCI: Delete unnecessary NULL pointer checks

arch/arm/Kconfig
arch/arm/include/asm/mach/pci.h
arch/arm/include/asm/pci.h
arch/arm/kernel/bios32.c
arch/arm/mach-cns3xxx/pcie.c
arch/arm64/kernel/pci.c
drivers/pci/host/pci-mvebu.c
drivers/pci/host/pcie-designware.c
drivers/pci/host/pcie-rcar.c
drivers/pci/hotplug/cpci_hotplug_core.c
drivers/pci/pci.c

index 97d07ed60a0b7b01cad35891c7695a2d3d4a1640..dcb2e0c55be4ab16c19e3f5c87d64b6780092f5d 100644 (file)
@@ -1279,6 +1279,9 @@ config PCI_DOMAINS
        bool
        depends on PCI
 
+config PCI_DOMAINS_GENERIC
+       def_bool PCI_DOMAINS
+
 config PCI_NANOENGINE
        bool "BSE nanoEngine PCI support"
        depends on SA1100_NANOENGINE
index 8292b5f81e23479d35c6e28a0059af22a08957ac..28b9bb35949e08a93bdcf940d125cedbe6c55b63 100644 (file)
@@ -19,9 +19,6 @@ struct pci_bus;
 struct device;
 
 struct hw_pci {
-#ifdef CONFIG_PCI_DOMAINS
-       int             domain;
-#endif
 #ifdef CONFIG_PCI_MSI
        struct msi_controller *msi_ctrl;
 #endif
@@ -45,9 +42,6 @@ struct hw_pci {
  * Per-controller structure
  */
 struct pci_sys_data {
-#ifdef CONFIG_PCI_DOMAINS
-       int             domain;
-#endif
 #ifdef CONFIG_PCI_MSI
        struct msi_controller *msi_ctrl;
 #endif
index 7e95d8535e24fc0cf1200800bed42fed53b825d7..585dc33a7a240bb7ae58804acf6b1e4bea1c3d90 100644 (file)
@@ -18,13 +18,6 @@ static inline int pcibios_assign_all_busses(void)
 }
 
 #ifdef CONFIG_PCI_DOMAINS
-static inline int pci_domain_nr(struct pci_bus *bus)
-{
-       struct pci_sys_data *root = bus->sysdata;
-
-       return root->domain;
-}
-
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
        return pci_domain_nr(bus);
index a4effd6d8f2f52aa3f3c82c1b7b98d650d2263ab..ddd75c58b1e8f3f2a27e407b95ac040c54b79dd2 100644 (file)
@@ -463,9 +463,6 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,
                if (!sys)
                        panic("PCI: unable to allocate sys data!");
 
-#ifdef CONFIG_PCI_DOMAINS
-               sys->domain  = hw->domain;
-#endif
 #ifdef CONFIG_PCI_MSI
                sys->msi_ctrl = hw->msi_ctrl;
 #endif
index 45d6bd09e6ef2940240134096f5fab8456e474aa..f6bf9f623d70b68bb7732029f436391de1253627 100644 (file)
@@ -30,18 +30,15 @@ struct cns3xxx_pcie {
        unsigned int irqs[2];
        struct resource res_io;
        struct resource res_mem;
-       struct hw_pci hw_pci;
-
+       int port;
        bool linked;
 };
 
-static struct cns3xxx_pcie cns3xxx_pcie[]; /* forward decl. */
-
 static struct cns3xxx_pcie *sysdata_to_cnspci(void *sysdata)
 {
        struct pci_sys_data *root = sysdata;
 
-       return &cns3xxx_pcie[root->domain];
+       return root->private_data;
 }
 
 static struct cns3xxx_pcie *pdev_to_cnspci(const struct pci_dev *dev)
@@ -192,13 +189,7 @@ static struct cns3xxx_pcie cns3xxx_pcie[] = {
                        .flags = IORESOURCE_MEM,
                },
                .irqs = { IRQ_CNS3XXX_PCIE0_RC, IRQ_CNS3XXX_PCIE0_DEVICE, },
-               .hw_pci = {
-                       .domain = 0,
-                       .nr_controllers = 1,
-                       .ops = &cns3xxx_pcie_ops,
-                       .setup = cns3xxx_pci_setup,
-                       .map_irq = cns3xxx_pcie_map_irq,
-               },
+               .port = 0,
        },
        [1] = {
                .host_regs = (void __iomem *)CNS3XXX_PCIE1_HOST_BASE_VIRT,
@@ -217,19 +208,13 @@ static struct cns3xxx_pcie cns3xxx_pcie[] = {
                        .flags = IORESOURCE_MEM,
                },
                .irqs = { IRQ_CNS3XXX_PCIE1_RC, IRQ_CNS3XXX_PCIE1_DEVICE, },
-               .hw_pci = {
-                       .domain = 1,
-                       .nr_controllers = 1,
-                       .ops = &cns3xxx_pcie_ops,
-                       .setup = cns3xxx_pci_setup,
-                       .map_irq = cns3xxx_pcie_map_irq,
-               },
+               .port = 1,
        },
 };
 
 static void __init cns3xxx_pcie_check_link(struct cns3xxx_pcie *cnspci)
 {
-       int port = cnspci->hw_pci.domain;
+       int port = cnspci->port;
        u32 reg;
        unsigned long time;
 
@@ -260,9 +245,9 @@ static void __init cns3xxx_pcie_check_link(struct cns3xxx_pcie *cnspci)
 
 static void __init cns3xxx_pcie_hw_init(struct cns3xxx_pcie *cnspci)
 {
-       int port = cnspci->hw_pci.domain;
+       int port = cnspci->port;
        struct pci_sys_data sd = {
-               .domain = port,
+               .private_data = cnspci,
        };
        struct pci_bus bus = {
                .number = 0,
@@ -323,6 +308,14 @@ static int cns3xxx_pcie_abort_handler(unsigned long addr, unsigned int fsr,
 void __init cns3xxx_pcie_init_late(void)
 {
        int i;
+       void *private_data;
+       struct hw_pci hw_pci = {
+              .nr_controllers = 1,
+              .ops = &cns3xxx_pcie_ops,
+              .setup = cns3xxx_pci_setup,
+              .map_irq = cns3xxx_pcie_map_irq,
+              .private_data = &private_data,
+       };
 
        pcibios_min_io = 0;
        pcibios_min_mem = 0;
@@ -335,7 +328,8 @@ void __init cns3xxx_pcie_init_late(void)
                cns3xxx_pwr_soft_rst(0x1 << PM_SOFT_RST_REG_OFFST_PCIE(i));
                cns3xxx_pcie_check_link(&cns3xxx_pcie[i]);
                cns3xxx_pcie_hw_init(&cns3xxx_pcie[i]);
-               pci_common_init(&cns3xxx_pcie[i].hw_pci);
+               private_data = &cns3xxx_pcie[i];
+               pci_common_init(&hw_pci);
        }
 
        pci_assign_unassigned_resources();
index ce5836c14ec1d8e9c1fa46a01d7f09bee80880ac..6f93c24ca80122f4844801d42b1bde561bc01909 100644 (file)
@@ -46,25 +46,3 @@ int pcibios_add_device(struct pci_dev *dev)
 
        return 0;
 }
-
-
-#ifdef CONFIG_PCI_DOMAINS_GENERIC
-static bool dt_domain_found = false;
-
-void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
-{
-       int domain = of_get_pci_domain_nr(parent->of_node);
-
-       if (domain >= 0) {
-               dt_domain_found = true;
-       } else if (dt_domain_found == true) {
-               dev_err(parent, "Node %s is missing \"linux,pci-domain\" property in DT\n",
-                       parent->of_node->full_name);
-               return;
-       } else {
-               domain = pci_get_new_domain_nr();
-       }
-
-       bus->domain_nr = domain;
-}
-#endif
index 1dd759596b0adf83e1d3eade94d834bfa617a18c..1309cfbaa71960471acb7e63ba84ab0d40be3e08 100644 (file)
@@ -101,9 +101,7 @@ struct mvebu_pcie {
        struct mvebu_pcie_port *ports;
        struct msi_controller *msi;
        struct resource io;
-       char io_name[30];
        struct resource realio;
-       char mem_name[30];
        struct resource mem;
        struct resource busn;
        int nports;
@@ -723,18 +721,9 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)
 {
        struct mvebu_pcie *pcie = sys_to_pcie(sys);
        int i;
-       int domain = 0;
 
-#ifdef CONFIG_PCI_DOMAINS
-       domain = sys->domain;
-#endif
-
-       snprintf(pcie->mem_name, sizeof(pcie->mem_name), "PCI MEM %04x",
-                domain);
-       pcie->mem.name = pcie->mem_name;
-
-       snprintf(pcie->io_name, sizeof(pcie->io_name), "PCI I/O %04x", domain);
-       pcie->realio.name = pcie->io_name;
+       pcie->mem.name = "PCI MEM";
+       pcie->realio.name = "PCI I/O";
 
        if (request_resource(&iomem_resource, &pcie->mem))
                return 0;
index df781cdf13c1871e265eb933e8baadde09e2dd0a..eef311115899f7b79f28e4b6521da6fe56915245 100644 (file)
@@ -508,9 +508,6 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
        dw_pci.private_data = (void **)&pp;
 
        pci_common_init_dev(pp->dev, &dw_pci);
-#ifdef CONFIG_PCI_DOMAINS
-       dw_pci.domain++;
-#endif
 
        return 0;
 }
index 748786c402fcb2b38ab0daa43498501687f2963e..ba28078b70e3dcd6cae29670faad13e36f3e576e 100644 (file)
@@ -397,9 +397,6 @@ static void rcar_pcie_enable(struct rcar_pcie *pcie)
 #endif
 
        pci_common_init_dev(&pdev->dev, &rcar_pci);
-#ifdef CONFIG_PCI_DOMAINS
-       rcar_pci.domain++;
-#endif
 }
 
 static int phy_wait_for_ack(struct rcar_pcie *pcie)
index a5a7fd8332ac1cb7557285298d2824a05f127f00..46db29395a62b0cdec6400f7bc4d8e781b604592 100644 (file)
@@ -214,8 +214,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 
        kfree(slot->hotplug_slot->info);
        kfree(slot->hotplug_slot);
-       if (slot->dev)
-               pci_dev_put(slot->dev);
+       pci_dev_put(slot->dev);
        kfree(slot);
 }
 
index cab05f31223f08166cc0a8e179759fc99812a286..c419554d0b4b7aadbdf90f7402256bade8edd551 100644 (file)
@@ -10,6 +10,8 @@
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/of.h>
+#include <linux/of_pci.h>
 #include <linux/pci.h>
 #include <linux/pm.h>
 #include <linux/slab.h>
@@ -4439,6 +4441,53 @@ int pci_get_new_domain_nr(void)
 {
        return atomic_inc_return(&__domain_nr);
 }
+
+#ifdef CONFIG_PCI_DOMAINS_GENERIC
+void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
+{
+       static int use_dt_domains = -1;
+       int domain = of_get_pci_domain_nr(parent->of_node);
+
+       /*
+        * Check DT domain and use_dt_domains values.
+        *
+        * If DT domain property is valid (domain >= 0) and
+        * use_dt_domains != 0, the DT assignment is valid since this means
+        * we have not previously allocated a domain number by using
+        * pci_get_new_domain_nr(); we should also update use_dt_domains to
+        * 1, to indicate that we have just assigned a domain number from
+        * DT.
+        *
+        * If DT domain property value is not valid (ie domain < 0), and we
+        * have not previously assigned a domain number from DT
+        * (use_dt_domains != 1) we should assign a domain number by
+        * using the:
+        *
+        * pci_get_new_domain_nr()
+        *
+        * API and update the use_dt_domains value to keep track of method we
+        * are using to assign domain numbers (use_dt_domains = 0).
+        *
+        * All other combinations imply we have a platform that is trying
+        * to mix domain numbers obtained from DT and pci_get_new_domain_nr(),
+        * which is a recipe for domain mishandling and it is prevented by
+        * invalidating the domain value (domain = -1) and printing a
+        * corresponding error.
+        */
+       if (domain >= 0 && use_dt_domains) {
+               use_dt_domains = 1;
+       } else if (domain < 0 && use_dt_domains != 1) {
+               use_dt_domains = 0;
+               domain = pci_get_new_domain_nr();
+       } else {
+               dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n",
+                       parent->of_node->full_name);
+               domain = -1;
+       }
+
+       bus->domain_nr = domain;
+}
+#endif
 #endif
 
 /**