Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1238666 > unrolled thread
| Started by | David Daney <ddaney.cavm@gmail.com> |
|---|---|
| First post | 2015-10-03 00:40 +0200 |
| Last post | 2015-10-03 05:10 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v4 3/5] PCI: Handle IORESOURCE_PCI_FIXED when sizing and assigning resources. David Daney <ddaney.cavm@gmail.com> - 2015-10-03 00:40 +0200
Re: [PATCH v4 3/5] PCI: Handle IORESOURCE_PCI_FIXED when sizing and assigning resources. Yinghai Lu <yinghai@kernel.org> - 2015-10-03 01:20 +0200
Re: [PATCH v4 3/5] PCI: Handle IORESOURCE_PCI_FIXED when sizing and assigning resources. Yinghai Lu <yinghai@kernel.org> - 2015-10-03 05:10 +0200
| From | David Daney <ddaney.cavm@gmail.com> |
|---|---|
| Date | 2015-10-03 00:40 +0200 |
| Subject | [PATCH v4 3/5] PCI: Handle IORESOURCE_PCI_FIXED when sizing and assigning resources. |
| Message-ID | <qfh9E-8tG-19@gated-at.bofh.it> |
From: David Daney <david.daney@cavium.com>
The new Enhanced Allocation (EA) capability support creates resources
with the IORESOURCE_PCI_FIXED set. This creates a couple of problems:
1) Since these resources cannot be relocated or resized, their
alignment is not really defined, and it is therefore not specified.
This causes a problem in pbus_size_mem() where resources with
unspecified alignment are disabled.
2) During resource assignment in pci_bus_assign_resources(),
IORESOURCE_PCI_FIXED resources are not given a parent. This, in
turn, causes pci_enable_resources() to fail with a "not claimed"
error.
So, in pbus_size_mem() skip IORESOURCE_PCI_FIXED resources, instead of
disabling them.
In __pci_bus_assign_resources(), for IORESOURCE_PCI_FIXED resources,
try to request the resource from a parent bus.
Signed-off-by: David Daney <david.daney@cavium.com>
---
drivers/pci/setup-bus.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 57 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 508cc56..8f9ed9b 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1037,9 +1037,10 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
struct resource *r = &dev->resource[i];
resource_size_t r_size;
- if (r->parent || ((r->flags & mask) != type &&
- (r->flags & mask) != type2 &&
- (r->flags & mask) != type3))
+ if (r->parent || (r->flags | IORESOURCE_PCI_FIXED) ||
+ ((r->flags & mask) != type &&
+ (r->flags & mask) != type2 &&
+ (r->flags & mask) != type3))
continue;
r_size = resource_size(r);
#ifdef CONFIG_PCI_IOV
@@ -1340,6 +1341,57 @@ void pci_bus_size_bridges(struct pci_bus *bus)
}
EXPORT_SYMBOL(pci_bus_size_bridges);
+static void assign_fixed_resource_on_bus(struct pci_bus *b, struct resource *r)
+{
+ int i;
+ struct resource *parent_r;
+ unsigned long mask = IORESOURCE_IO | IORESOURCE_MEM |
+ IORESOURCE_PREFETCH;
+
+ pci_bus_for_each_resource(b, parent_r, i) {
+ if (!parent_r)
+ continue;
+
+ if ((r->flags & mask) == (parent_r->flags & mask) &&
+ resource_contains(parent_r, r))
+ request_resource(parent_r, r);
+ }
+}
+
+/*
+ * Try to assign any resources marked as IORESOURCE_PCI_FIXED, as they
+ * are skipped by pbus_assign_resources_sorted().
+ */
+static void pdev_assign_fixed_resources(struct pci_dev *dev)
+{
+ int i;
+
+ for (i = 0; i < PCI_NUM_RESOURCES; i++) {
+ struct pci_bus *b;
+ struct resource *r = &dev->resource[i];
+
+ if (r->parent || !(r->flags & IORESOURCE_PCI_FIXED) ||
+ !(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
+ continue;
+
+ b = dev->bus;
+ while (b && !r->parent) {
+ assign_fixed_resource_on_bus(b, r);
+ b = b->parent;
+ }
+ if (!r->parent) {
+ /*
+ * If that didn't work, try to fallback to the
+ * ultimate parent.
+ */
+ if (r->flags & IORESOURCE_IO)
+ request_resource(&ioport_resource, r);
+ else
+ request_resource(&iomem_resource, r);
+ }
+ }
+}
+
void __pci_bus_assign_resources(const struct pci_bus *bus,
struct list_head *realloc_head,
struct list_head *fail_head)
@@ -1350,6 +1402,8 @@ void __pci_bus_assign_resources(const struct pci_bus *bus,
pbus_assign_resources_sorted(bus, realloc_head, fail_head);
list_for_each_entry(dev, &bus->devices, bus_list) {
+ pdev_assign_fixed_resources(dev);
+
b = dev->subordinate;
if (!b)
continue;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Date | 2015-10-03 01:20 +0200 |
| Subject | Re: [PATCH v4 3/5] PCI: Handle IORESOURCE_PCI_FIXED when sizing and assigning resources. |
| Message-ID | <qfhMm-10f-13@gated-at.bofh.it> |
| In reply to | #1238666 |
On Fri, Oct 2, 2015 at 3:37 PM, David Daney <ddaney.cavm@gmail.com> wrote:
> From: David Daney <david.daney@cavium.com>
>
> The new Enhanced Allocation (EA) capability support creates resources
> with the IORESOURCE_PCI_FIXED set. This creates a couple of problems:
>
> 1) Since these resources cannot be relocated or resized, their
> alignment is not really defined, and it is therefore not specified.
> This causes a problem in pbus_size_mem() where resources with
> unspecified alignment are disabled.
>
> 2) During resource assignment in pci_bus_assign_resources(),
> IORESOURCE_PCI_FIXED resources are not given a parent. This, in
> turn, causes pci_enable_resources() to fail with a "not claimed"
> error.
>
> So, in pbus_size_mem() skip IORESOURCE_PCI_FIXED resources, instead of
> disabling them.
>
> In __pci_bus_assign_resources(), for IORESOURCE_PCI_FIXED resources,
> try to request the resource from a parent bus.
Can you check if
https://patchwork.kernel.org/patch/7304971/
[v6,05/53] PCI: Don't release fixed resource for realloc
https://patchwork.kernel.org/patch/7304371/
[v6,06/53] PCI: Claim fixed resource during remove/rescan path
address the the problem that you met?
Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Date | 2015-10-03 05:10 +0200 |
| Subject | Re: [PATCH v4 3/5] PCI: Handle IORESOURCE_PCI_FIXED when sizing and assigning resources. |
| Message-ID | <qflmV-6d8-1@gated-at.bofh.it> |
| In reply to | #1238701 |
On Fri, Oct 2, 2015 at 4:38 PM, David Daney <ddaney@caviumnetworks.com> wrote: > On 10/02/2015 04:14 PM, Yinghai Lu wrote: >> >> https://patchwork.kernel.org/patch/7304371/ >> [v6,06/53] PCI: Claim fixed resource during remove/rescan path > > > This one is interesting, but I don't think it will work. > > pci_claim_resource() calls pci_find_parent_resource(), which will fail in > important use cases. > > It is perfectly legal for a bridge provisioned by EA to not specify any > resources. In this case we must walk up the bus tree until we find > something that contains the device resource, and can thus be a parent. > > That is a big part of what my patch is doing. looks we need another resource flags for EA in addition to FIXED as it could out side of bridge MMIO range. > > As for the merits of assigning fixed resources from the FINAL fixup, rather > than in __pci_bus_assign_resources(), I am unsure. usually __pci_bus_assign_resources() is used for unassigned one. so I don't want it mixed with request resource there. Thanks Yinghai -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web