Skip to contentSkip to conversation

PCI: xgene: fix breakage from generic config usage

PATCH In review Mark Salter 3 participants 3 messages Mar 4, 2015 – Mar 6, 2015 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: xgene: fix breakage from generic config usage

Commit 350f8be5bb402 ("PCI: xgene: Convert to use generic config accessors") breaks PCI on the X-Gene platform. It creates two problems with the xgene_pcie_map_bus() function. First, it returns an int but should return a void __iomem *, but that's just a compile-time warning. The breakage is caused by the offset not being added to the base of the config map. So all config reads and writes operate on the first four bytes of config space. This patch fixes both issues.

---
 drivers/pci/host/pci-xgene.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/pci/host/pci-xgene.c +7 -3
index 52bb25c..b87f80b 100644
@@ -129,17 +129,21 @@ static bool xgene_pcie_hide_rc_bars(struct pci_bus *bus, int offset)
 	return false;
 }
 
-static int xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
-			      int offset)
+static void __iomem *xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
+					int offset)
 {
 	struct xgene_pcie_port *port = bus->sysdata;
+	void __iomem *base;
 
 	if ((pci_is_root_bus(bus) && devfn != 0) || !port->link_up ||
 	    xgene_pcie_hide_rc_bars(bus, offset))
 		return NULL;
 
 	xgene_pcie_set_rtdid_reg(bus, devfn);
-	return xgene_pcie_get_cfg_base(bus);
+	base = xgene_pcie_get_cfg_base(bus);
+	if (base)
+		base += offset;
+	return base;
 }
 
 static struct pci_ops xgene_pcie_ops = {
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#1 lore raw
Quoted 50 lines · Mark Salter

Commit 350f8be5bb402 ("PCI: xgene: Convert to use generic config accessors") breaks PCI on the X-Gene platform. It creates two problems with the xgene_pcie_map_bus() function. First, it returns an int but should return a void __iomem *, but that's just a compile-time warning. The breakage is caused by the offset not being added to the base of the config map. So all config reads and writes operate on the first four bytes of config space. This patch fixes both issues.

---
 drivers/pci/host/pci-xgene.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/pci/host/pci-xgene.c +7 -4
index 52bb25c..b87f80b 100644
@@ -129,17 +129,21 @@ static bool xgene_pcie_hide_rc_bars(struct pci_bus *bus, int offset)
        return false;
 }
 
-static int xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
-                             int offset)
+static void __iomem *xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
+                                       int offset)
 {
        struct xgene_pcie_port *port = bus->sysdata;
+       void __iomem *base;
 
        if ((pci_is_root_bus(bus) && devfn != 0) || !port->link_up ||
            xgene_pcie_hide_rc_bars(bus, offset))
                return NULL;
 
        xgene_pcie_set_rtdid_reg(bus, devfn);
-       return xgene_pcie_get_cfg_base(bus);
+       base = xgene_pcie_get_cfg_base(bus);
+       if (base)
+               base += offset;
+       return base;
 }
 
 static struct pci_ops xgene_pcie_ops = {
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#2 lore raw
In reply to Mark Salter
Quoted 10 lines · Mark Salter

Commit 350f8be5bb402 ("PCI: xgene: Convert to use generic config accessors") breaks PCI on the X-Gene platform. It creates two problems with the xgene_pcie_map_bus() function. First, it returns an int but should return a void __iomem *, but that's just a compile-time warning. The breakage is caused by the offset not being added to the base of the config map. So all config reads and writes operate on the first four bytes of config space. This patch fixes both issues.

I forgot to copy you, Mark, but I applied Feng's earlier patch [1], which I think is equivalent to yours.

[1] https://patchwork.ozlabs.org/patch/440759/

Quoted 36 lines
---
 drivers/pci/host/pci-xgene.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/pci/host/pci-xgene.c +7 -3
index 52bb25c..b87f80b 100644
@@ -129,17 +129,21 @@ static bool xgene_pcie_hide_rc_bars(struct pci_bus *bus, int offset)
 	return false;
 }
 
-static int xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
-			      int offset)
+static void __iomem *xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
+					int offset)
 {
 	struct xgene_pcie_port *port = bus->sysdata;
+	void __iomem *base;
 
 	if ((pci_is_root_bus(bus) && devfn != 0) || !port->link_up ||
 	    xgene_pcie_hide_rc_bars(bus, offset))
 		return NULL;
 
 	xgene_pcie_set_rtdid_reg(bus, devfn);
-	return xgene_pcie_get_cfg_base(bus);
+	base = xgene_pcie_get_cfg_base(bus);
+	if (base)
+		base += offset;
+	return base;
 }
 
 static struct pci_ops xgene_pcie_ops = {
Signature · 1 line
1.8.3.1