Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1373879
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v11 12/60] PCI: Check pref compatible bit for mem64 resource of PCIe device |
| Date | 2016-04-08 02:30 +0200 |
| Message-ID | <rlste-3DX-49@gated-at.bofh.it> (permalink) |
| References | <rlsjv-3zZ-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
We still get "no compatible bridge window" warning on sparc T5-8
after we add support for 64bit resource parsing for root bus.
PCI: scan_bus[/pci@300/pci@1/pci@0/pci@6] bus no 8
PCI: Claiming 0000:00:01.0: Resource 15: 0000800100000000..00008004afffffff [220c]
PCI: Claiming 0000:01:00.0: Resource 15: 0000800100000000..00008004afffffff [220c]
PCI: Claiming 0000:02:04.0: Resource 15: 0000800100000000..000080012fffffff [220c]
PCI: Claiming 0000:03:00.0: Resource 15: 0000800100000000..000080012fffffff [220c]
PCI: Claiming 0000:04:06.0: Resource 14: 0000800100000000..000080010fffffff [220c]
PCI: Claiming 0000:05:00.0: Resource 0: 0000800100000000..0000800100001fff [204]
pci 0000:05:00.0: can't claim BAR 0 [mem 0x800100000000-0x800100001fff]: no compatible bridge window
All the bridges 64-bit resource have pref bit, but the device resource does not
have pref set, then we can not find parent for the device resource,
as we can not put non-pref mmio under pref mmio.
According to pcie spec errta
https://www.pcisig.com/specifications/pciexpress/base2/PCIe_Base_r2.1_Errata_08Jun10.pdf
page 13, in some case it is ok to mark some as pref.
Mark if the entire path from the host to the adapter is over PCI Express.
Set pref compatible bit for claim/sizing/assign for 64bit mem resource
on that pcie device.
-v2: set pref for mmio 64 when whole path is PCI Express, according to David Miller.
-v3: don't set pref directly, change to UNDER_PREF, and set PREF before
sizing and assign resource, and cleart PREF afterwards. requested by BenH.
-v4: use on_all_pcie_path device flag instead.
-v6: update after pci_find_bus_resource() change
Fixes: commit d63e2e1f3df9 ("sparc/PCI: Clip bridge windows to fit in upstream windows")
Link: http://lkml.kernel.org/r/CAE9FiQU1gJY1LYrxs+ma5LCTEEe4xmtjRG0aXJ9K_Tsu+m9Wuw@mail.gmail.com
Reported-by: David Ahern <david.ahern@oracle.com>
Tested-by: David Ahern <david.ahern@oracle.com>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=81431
Tested-by: TJ <linux@iam.tj>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Tested-by: Khalid Aziz <khalid.aziz@oracle.com>
---
arch/sparc/kernel/pci.c | 2 +-
arch/sparc/kernel/pci_common.c | 2 +-
drivers/pci/pci.c | 8 +++++---
drivers/pci/pci.h | 2 ++
drivers/pci/probe.c | 33 +++++++++++++++++++++++++++++++++
drivers/pci/setup-bus.c | 23 +++++++++++++++++++----
drivers/pci/setup-res.c | 4 ++++
include/linux/pci.h | 3 ++-
8 files changed, 67 insertions(+), 10 deletions(-)
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 9415abc..e46e739 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -761,7 +761,7 @@ static int __pci_mmap_make_offset_bus(struct pci_dev *pdev, struct vm_area_struc
bus = pdev->bus;
while (bus->parent)
bus = bus->parent;
- root_bus_res = pci_find_bus_resource(bus, &res);
+ root_bus_res = pci_find_bus_resource(bus, &res, res.flags);
if (!root_bus_res)
return -EINVAL;
diff --git a/arch/sparc/kernel/pci_common.c b/arch/sparc/kernel/pci_common.c
index 1ebc7ff..6f206a1 100644
--- a/arch/sparc/kernel/pci_common.c
+++ b/arch/sparc/kernel/pci_common.c
@@ -343,7 +343,7 @@ static void pci_register_region(struct pci_bus *bus, const char *name,
region.start = rstart;
region.end = rstart + size - 1UL;
pcibios_bus_to_resource(bus, res, ®ion);
- bus_res = pci_find_bus_resource(bus, res);
+ bus_res = pci_find_bus_resource(bus, res, res->flags);
if (!bus_res) {
kfree(res);
return;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 313dea5..bd72df3 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -415,7 +415,7 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap)
EXPORT_SYMBOL_GPL(pci_find_ht_capability);
struct resource *pci_find_bus_resource(const struct pci_bus *bus,
- struct resource *res)
+ struct resource *res, int flags)
{
struct resource *r;
int i;
@@ -430,7 +430,7 @@ struct resource *pci_find_bus_resource(const struct pci_bus *bus,
* not, the allocator made a mistake.
*/
if (r->flags & IORESOURCE_PREFETCH &&
- !(res->flags & IORESOURCE_PREFETCH))
+ !(flags & IORESOURCE_PREFETCH))
return NULL;
/*
@@ -458,7 +458,9 @@ struct resource *pci_find_bus_resource(const struct pci_bus *bus,
struct resource *pci_find_parent_resource(const struct pci_dev *dev,
struct resource *res)
{
- return pci_find_bus_resource(dev->bus, res);
+ int flags = pci_resource_pref_compatible(dev, res);
+
+ return pci_find_bus_resource(dev->bus, res, flags);
}
EXPORT_SYMBOL(pci_find_parent_resource);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index d0fb934..90e6e3e 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -335,4 +335,6 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
}
#endif
+int pci_resource_pref_compatible(const struct pci_dev *dev,
+ struct resource *res);
#endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8004f67..48e6f29 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1731,6 +1731,36 @@ static void pci_dma_configure(struct pci_dev *dev)
pci_put_host_bridge_device(bridge);
}
+static bool pci_up_path_over_pcie(struct pci_bus *bus)
+{
+ if (pci_is_root_bus(bus))
+ return true;
+
+ if (bus->self && !pci_is_pcie(bus->self))
+ return false;
+
+ return pci_up_path_over_pcie(bus->parent);
+}
+
+/*
+ * According to
+ * https://www.pcisig.com/specifications/pciexpress/base2/PCIe_Base_r2.1_Errata_08Jun10.pdf
+ * page 13, system firmware could put some 64bit non-pref under 64bit pref,
+ * on some cases.
+ * Let's mark if entire path from the host to the adapter is over PCI
+ * Express. later will use that compute pref compaitable bit.
+ */
+static void pci_set_on_all_pcie_path(struct pci_dev *dev)
+{
+ if (!pci_is_pcie(dev))
+ return;
+
+ if (!pci_up_path_over_pcie(dev->bus))
+ return;
+
+ dev->on_all_pcie_path = 1;
+}
+
void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
{
int ret;
@@ -1761,6 +1791,9 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
/* Initialize various capabilities */
pci_init_capabilities(dev);
+ /* After pcie_cap is assigned */
+ pci_set_on_all_pcie_path(dev);
+
/*
* Add the device to our list of discovered devices
* and the bus list for fixup functions, etc.
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 55641a3..b3b1565 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -738,6 +738,20 @@ int pci_claim_bridge_resource(struct pci_dev *bridge, int i)
return -EINVAL;
}
+int pci_resource_pref_compatible(const struct pci_dev *dev,
+ struct resource *res)
+{
+ if (res->flags & IORESOURCE_PREFETCH)
+ return res->flags;
+
+ if ((res->flags & IORESOURCE_MEM) &&
+ (res->flags & IORESOURCE_MEM_64) &&
+ dev->on_all_pcie_path)
+ return res->flags | IORESOURCE_PREFETCH;
+
+ return res->flags;
+}
+
/* Check whether the bridge supports optional I/O and
prefetchable memory ranges. If not, the respective
base/limit registers must be read-only and read as 0. */
@@ -1035,11 +1049,12 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *r = &dev->resource[i];
resource_size_t r_size;
+ int flags = pci_resource_pref_compatible(dev, r);
- if (r->parent || (r->flags & IORESOURCE_PCI_FIXED) ||
- ((r->flags & mask) != type &&
- (r->flags & mask) != type2 &&
- (r->flags & mask) != type3))
+ if (r->parent || (flags & IORESOURCE_PCI_FIXED) ||
+ ((flags & mask) != type &&
+ (flags & mask) != type2 &&
+ (flags & mask) != type3))
continue;
r_size = resource_size(r);
#ifdef CONFIG_PCI_IOV
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 66c4d8f..f741fed 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -257,15 +257,19 @@ static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,
static int _pci_assign_resource(struct pci_dev *dev, int resno,
resource_size_t size, resource_size_t min_align)
{
+ struct resource *res = dev->resource + resno;
+ int old_flags = res->flags;
struct pci_bus *bus;
int ret;
+ res->flags = pci_resource_pref_compatible(dev, res);
bus = dev->bus;
while ((ret = __pci_assign_resource(bus, dev, resno, size, min_align))) {
if (!bus->parent || !bus->self->transparent)
break;
bus = bus->parent;
}
+ res->flags = old_flags;
return ret;
}
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 795b4c7..1527735 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -305,6 +305,7 @@ struct pci_dev {
powered on/off by the
corresponding bridge */
unsigned int ignore_hotplug:1; /* Ignore hotplug events */
+ unsigned int on_all_pcie_path:1; /* up to host-bridge all pcie */
unsigned int d3_delay; /* D3->D0 transition time in ms */
unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */
@@ -808,7 +809,7 @@ void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
struct pci_bus_region *region);
struct resource *pci_find_bus_resource(const struct pci_bus *bus,
- struct resource *res);
+ struct resource *res, int flags);
void pcibios_scan_specific_bus(int busn);
struct pci_bus *pci_find_bus(int domain, int busnr);
void pci_bus_add_devices(const struct pci_bus *bus);
--
1.8.4.5
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v11 00/60] PCI: Resource allocation cleanup for v4.7 Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 22/60] PCI: Get new realloc size for bridge for last try Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 42/60] PCI: Skip required+optional if there is no optional Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 25/60] PCI: Reuse res_to_dev_res() in reassign_resources_sorted() Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 29/60] PCI: Don't add too much optional size for hotplug bridge MMIO Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 35/60] PCI: Simplify res reference using in __assign_resources_sorted() Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 32/60] PCI: Rename pdev_sort_resources() to pdev_assign_resources_prepare() Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 34/60] PCI: Add debug printout during releasing partial assigned resources Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 26/60] PCI: Use correct align for optional only resources during sorting Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 38/60] PCI: Check if resource is allocated before trying to assign one Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 31/60] PCI: Remove duplicated code for resource sorting Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 56/60] PCI: Add debug print out for min_align and alt_size Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 12/60] PCI: Check pref compatible bit for mem64 resource of PCIe device Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 58/60] PCI: Introduce resource_disabled() Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 24/60] PCI: Cleanup res_to_dev_res() printout Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 39/60] PCI: Separate out save_resources()/restore_resources() Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 49/60] PCI: Don't add too much io port for hotplug bridge with old size Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 54/60] resources: Make allocate_resource() return best fit resource Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 46/60] PCI: Fix size calculation with old_size on rescan path Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 48/60] PCI: Move ISA io port align out of calculate_iosize() Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 02/60] alpha/PCI: Only check iomem_is_exclusive() for IORESOURCE_MEM, not IORESOURCE_IO Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 41/60] PCI: Separate required+optional assigning to another function Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 33/60] PCI: Treat ROM resource as optional during realloc Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:30 +0200
[PATCH v11 28/60] PCI: Optimize bus align/size calculation for optional during sizing Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 04/60] sparc/PCI: Use correct offset for bus address to resource Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 23/60] PCI: Don't release sibling bridge resources during hotplug Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 05/60] sparc/PCI: Reserve legacy mmio after PCI mmio Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 53/60] PCI: Kill macro checking for bus io port sizing Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 03/60] PCI: Add pci_find_bus_resource() Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 11/60] OF/PCI: Add IORESOURCE_MEM_64 for 64-bit resource Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 06/60] sparc/PCI: Add IORESOURCE_MEM_64 for 64-bit resource in OF parsing Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 08/60] PCI: Kill wrong quirk about M7101 Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 14/60] PCI: Add has_mem64 for struct host_bridge Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 30/60] PCI: Reorder resources list for required/optional resources Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 44/60] PCI: Add alt_size ressource allocation support Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
Re: [PATCH v11 44/60] PCI: Add alt_size ressource allocation support Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-08 03:00 +0200
Re: [PATCH v11 44/60] PCI: Add alt_size ressource allocation support Yinghai Lu <yinghai@kernel.org> - 2016-04-08 08:00 +0200
Re: [PATCH v11 44/60] PCI: Add alt_size ressource allocation support Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2016-04-08 08:40 +0200
[PATCH v11 13/60] PCI: Only treat non-pref mmio64 as pref if all bridges have MEM_64 Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
[PATCH v11 19/60] PCI: Set resource to FIXED for LSI devices Yinghai Lu <yinghai@kernel.org> - 2016-04-08 02:40 +0200
Re: [PATCH v11 00/60] PCI: Resource allocation cleanup for v4.7 Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-08 03:00 +0200
Re: [PATCH v11 00/60] PCI: Resource allocation cleanup for v4.7 Yinghai Lu <yinghai@kernel.org> - 2016-04-09 07:40 +0200
[PATCH v11 50/60] PCI: Unify calculate_size() for io port and MMIO Yinghai Lu <yinghai@kernel.org> - 2016-04-08 03:20 +0200
csiph-web