Skip to contentSkip to conversation

bus: mvebu-mbus: Fix incorrect size for PCI aperture resources

PATCH New Jason Gunthorpe 4 participants 8 messages Feb 12, 2014 – Feb 18, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 bus: mvebu-mbus: Fix incorrect size for PCI aperture resources

reg[0] is the DT base, reg[1] is the DT length in bytes, struct resource.end is the inclusive end address, so a -1 is required.

Tested on kirkwood.

---
 drivers/bus/mvebu-mbus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/mvebu-mbus.c +2 -2
index 2394e97..7fd54e9 100644
@@ -876,14 +876,14 @@ static void __init mvebu_mbus_get_pcie_resources(struct device_node *np,
 	ret = of_property_read_u32_array(np, "pcie-mem-aperture", reg, ARRAY_SIZE(reg));
 	if (!ret) {
 		mem->start = reg[0];
-		mem->end = mem->start + reg[1];
+		mem->end = mem->start + reg[1] - 1;
 		mem->flags = IORESOURCE_MEM;
 	}
 
 	ret = of_property_read_u32_array(np, "pcie-io-aperture", reg, ARRAY_SIZE(reg));
 	if (!ret) {
 		io->start = reg[0];
-		io->end = io->start + reg[1];
+		io->end = io->start + reg[1] - 1;
 		io->flags = IORESOURCE_IO;
 	}
 }
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 2/2 PCI: mvebu - Call request_resources on the apertures

It is typical for host drivers to request a resource for the aperture, once this is done the PCI core will properly populate resources for all BARs in the system.

With this patch cat /proc/iomem will now show:

e0000000-efffffff : PCI MEM 0000
e0000000-e00fffff : PCI Bus 0000:01

    e0000000-e001ffff : 0000:01:00.0

Tested on Kirkwood

---
 drivers/pci/host/pci-mvebu.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

Arnd: Please confirm your SOB line, thanks.

drivers/pci/host/pci-mvebu.c +23 -1
index ef8691a..360a024 100644
@@ -109,7 +109,9 @@ struct mvebu_pcie {
 	struct mvebu_pcie_port *ports;
 	struct msi_chip *msi;
 	struct resource io;
+	char io_name[30];
 	struct resource realio;
+	char mem_name[30];
 	struct resource mem;
 	struct resource busn;
 	int nports;
@@ -681,10 +683,30 @@ 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;
 
-	if (resource_size(&pcie->realio) != 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;
+
+	if (request_resource(&iomem_resource, &pcie->mem))
+		return 0;
+
+	if (resource_size(&pcie->realio) != 0) {
+		if (request_resource(&ioport_resource, &pcie->realio)) {
+			release_resource(&pcie->mem);
+			return 0;
+		}
 		pci_add_resource_offset(&sys->resources, &pcie->realio,
 					sys->io_offset);
+	}
 	pci_add_resource_offset(&sys->resources, &pcie->mem, sys->mem_offset);
 	pci_add_resource(&sys->resources, &pcie->busn);
 
Signature · 1 line
1.8.1.2
#2 lore raw

PATCH 2/2 PCI: mvebu - Call request_resources on the apertures

Quoted 12 lines · On Wednesday 12 February 2014 15:57:08 Jason Gunthorpe wrote:

It is typical for host drivers to request a resource for the aperture, once this is done the PCI core will properly populate resources for all BARs in the system.

With this patch cat /proc/iomem will now show:

e0000000-efffffff : PCI MEM 0000
e0000000-e00fffff : PCI Bus 0000:01

    e0000000-e001ffff : 0000:01:00.0

Tested on Kirkwood

Quoted 8 lines
---
 drivers/pci/host/pci-mvebu.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

Arnd: Please confirm your SOB line, thanks.

Yes, that's good. Thanks for taking care of this.

Arnd

maintainer
#4 lore raw

PATCH 1/2 bus: mvebu-mbus: Fix incorrect size for PCI aperture resources

In reply to Jason Gunthorpe
Quoted 7 lines · Jason Gunthorpe

reg[0] is the DT base, reg[1] is the DT length in bytes, struct resource.end is the inclusive end address, so a -1 is required.

Tested on kirkwood.

Do these two patches need to go together? I don't maintain drivers/bus/mvebu-mbus.c, but if these should be kept together, I'd be happy to merge them both, given the appropriate ack from Jason C or Thomas.

Quoted 32 lines
---
 drivers/bus/mvebu-mbus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/mvebu-mbus.c +2 -2
index 2394e97..7fd54e9 100644
@@ -876,14 +876,14 @@ static void __init mvebu_mbus_get_pcie_resources(struct device_node *np,
 	ret = of_property_read_u32_array(np, "pcie-mem-aperture", reg, ARRAY_SIZE(reg));
 	if (!ret) {
 		mem->start = reg[0];
-		mem->end = mem->start + reg[1];
+		mem->end = mem->start + reg[1] - 1;
 		mem->flags = IORESOURCE_MEM;
 	}
 
 	ret = of_property_read_u32_array(np, "pcie-io-aperture", reg, ARRAY_SIZE(reg));
 	if (!ret) {
 		io->start = reg[0];
-		io->end = io->start + reg[1];
+		io->end = io->start + reg[1] - 1;
 		io->flags = IORESOURCE_IO;
 	}
 }
Signature · 6 lines
1.8.1.2

--
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
#5 lore raw

PATCH 1/2 bus: mvebu-mbus: Fix incorrect size for PCI aperture resources

Quoted 5 lines · Bjorn Helgaas
Quoted 4 lines · Jason Gunthorpe

reg[0] is the DT base, reg[1] is the DT length in bytes, struct resource.end is the inclusive end address, so a -1 is required.

Quoted 7 lines
Quoted 3 lines

Tested on kirkwood.

Do these two patches need to go together? I don't maintain drivers/bus/mvebu-mbus.c, but if these should be kept together, I'd be happy to merge them both, given the appropriate ack from Jason C or Thomas.

I have one small change for mvebu-mbus queued up, which won't conflict here. Please take both:

thx,

Jason.

maintainer
#6 lore raw

PATCH 1/2 bus: mvebu-mbus: Fix incorrect size for PCI aperture resources

Quoted 10 lines · Jason Cooper
Quoted 9 lines · Bjorn Helgaas
Quoted 7 lines · Jason Gunthorpe

reg[0] is the DT base, reg[1] is the DT length in bytes, struct resource.end is the inclusive end address, so a -1 is required.

Tested on kirkwood.

Quoted 8 lines
Quoted 3 lines

Do these two patches need to go together? I don't maintain drivers/bus/mvebu-mbus.c, but if these should be kept together, I'd be happy to merge them both, given the appropriate ack from Jason C or Thomas.

I have one small change for mvebu-mbus queued up, which won't conflict here. Please take both:

I added the acks and applied both patches to pci/host-mvebu for v3.15, thanks!

Bjorn

#7 lore raw

PATCH 1/2 bus: mvebu-mbus: Fix incorrect size for PCI aperture resources

In reply to Bjorn Helgaas
Quoted 5 lines · Bjorn Helgaas
Quoted 4 lines · Jason Gunthorpe

reg[0] is the DT base, reg[1] is the DT length in bytes, struct resource.end is the inclusive end address, so a -1 is required.

Quoted 7 lines
Quoted 3 lines

Tested on kirkwood.

Do these two patches need to go together? I don't maintain drivers/bus/mvebu-mbus.c, but if these should be kept together, I'd be happy to merge them both, given the appropriate ack from Jason C or Thomas.

I recommend keeping them together, requesting the wrong resource size range in PCI-E did not fail on my test system, but it has the potential to fail on systems with a different memory layout.

Thanks,
Jason