PCI: clip firmware assigned resources
Subsystems (7)
v2 cover PCI: clip firmware assigned resources
During the fix https://bugzilla.kernel.org/show_bug.cgi?id=85491,
Bjorn suggest that we should clip the resources instead of just reject them.
We should only need first two for x86. others for related arches to keep them consistent.
-v2: only handle bridge resource, and add pci_claim_bridge_resource
in pci core code.
Thanks
Yinghai
Yinghai Lu (10):
PCI: clip firmware assigned resource under parent bridge's PCI, x86: clip firmware assigned resource under parent bridge's PCI, alpha: clip firmware assigned resource under parent bridge's PCI, frv: clip firmware assigned resource under parent bridge's PCI, ia64: clip firmware assigned resource under parent bridge's PCI, microblaze: clip firmware assigned resource under parent bridge's PCI, mn10300: clip firmware assigned resource under parent bridge's PCI, parisc: clip firmware assigned resource under parent bridge's PCI, powerpc: clip firmware assigned resource under parent bridge's PCI, sparc: clip firmware assigned resource under parent bridge's
arch/alpha/kernel/pci.c | 8 +++-- arch/frv/mb93090-mb00/pci-frv.c | 2 +- arch/ia64/pci/pci.c | 48 +++++++++++++--------------- arch/microblaze/pci/pci-common.c | 13 +++++++- arch/mn10300/unit-asb2305/pci-asb2305.c | 2 +- arch/mn10300/unit-asb2305/pci.c | 47 +++++++++++++-------------- arch/powerpc/kernel/pci-common.c | 12 ++++++- arch/sparc/kernel/pci.c | 5 ++- arch/x86/pci/i386.c | 2 +- drivers/parisc/lba_pci.c | 5 ++- drivers/pci/bus.c | 39 +++++++++++++++++++++++ drivers/pci/pci.h | 1 + drivers/pci/setup-bus.c | 56 ++++++++++++++++++++++++++------- include/linux/pci.h | 1 + 14 files changed, 165 insertions(+), 76 deletions(-)
Signature · 1 line
1.8.4.5
PATCH v2 1/10 PCI: clip firmware assigned resource under parent bridge's
Some bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
This one is core part, arch changes will be in following patches.
-v2: add pci_claim_bridge_resource to core according to Bjorn.
--- drivers/pci/bus.c | 39 ++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 1 + drivers/pci/setup-bus.c | 56 ++++++++++++++++++++++++++++++++++++++----------- include/linux/pci.h | 1 + 4 files changed, 85 insertions(+), 12 deletions(-)
drivers/pci/bus.c +39 -0
@@ -228,6 +228,45 @@ int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, }EXPORT_SYMBOL (pci_bus_alloc_resource); +bool pci_bus_clip_resource (struct pci_dev *dev,int idx) +{ +struct pci_bus *bus = dev->bus; +struct resource *res = &dev->resource[idx]; +struct resource orig_res = *res; +struct resource *r; +int i; + +pci_bus_for_each_resource (bus, r, i) { +resource_size_t start, end; + +if (!r) +continue ; + +if (resource_type (res) !=resource_type (r)) +continue ; + + start =max (r->start, res->start); + end =min (r->end, res->end); + +/* no overlap ? */ +if (start > end) +continue ; + +if (res->start == start && res->end == end) +return false; + +/* changed */ + res->start = start; + res->end = end; +dev_printk (KERN_DEBUG , &dev->dev,"%pR ==> %pR\n" , + &orig_res, res); + +return true; + } + +return false; +} +void __weak pcibios_resource_survey_bus (struct pci_bus *bus) { }/**
drivers/pci/pci.h +1 -0
@@ -208,6 +208,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus,void __pci_bus_assign_resources (const struct pci_bus *bus,struct list_head *realloc_head,struct list_head *fail_head); +bool pci_bus_clip_resource (struct pci_dev *dev,int idx);/** * pci_ari_enabled - query ARI forwarding status
drivers/pci/setup-bus.c +44 -12
110 lines not on this page · raw message
include/linux/pci.h +1 -0
@@ -1065,6 +1065,7 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx);void pci_bus_assign_resources (const struct pci_bus *bus);void pci_bus_size_bridges (struct pci_bus *bus);int pci_claim_resource (struct pci_dev *,int ); +int pci_claim_bridge_resource (struct pci_dev *bridge,int i);void pci_assign_unassigned_resources (void );void pci_assign_unassigned_bridge_resources (struct pci_dev *bridge);void pci_assign_unassigned_bus_resources (struct pci_bus *bus);
Signature · 1 line
1.8.4.5
PATCH v2 2/10 PCI, x86: clip firmware assigned resource under parent bridge's
In reply to Yinghai LuSome bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
--- arch/x86/pci/i386.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/pci/i386.c +1 -1
@@ -216,7 +216,7 @@ static void pcibios_allocate_bridge_resources(struct pci_dev *dev)continue ;if (r->parent)/* Already allocated */ continue ; -if (!r->start ||pci_claim_resource (dev, idx) <0 ) { +if (!r->start ||pci_claim_bridge_resource (dev, idx) <0 ) {/* * Something is wrong with the region. * Invalidate the resource to prevent
Signature · 1 line
1.8.4.5
PATCH v2 3/10 PCI, alpha: clip firmware assigned resource under parent bridge's
In reply to Yinghai LuSome bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
We'd like to fix other arches instead of just x86.
--- arch/alpha/kernel/pci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/alpha/kernel/pci.c +6 -2
@@ -285,8 +285,12 @@ pcibios_claim_one_bus(struct pci_bus *b)if (r->parent || !r->start || !r->flags)continue ;if (pci_has_flag (PCI_PROBE_ONLY ) || - (r->flags &IORESOURCE_PCI_FIXED )) -pci_claim_resource (dev, i); + (r->flags &IORESOURCE_PCI_FIXED )) { +if (pci_claim_resource (dev, i) ==0 ) +continue ; + +pci_claim_bridge_resource (dev, i); + } } }
Signature · 1 line
1.8.4.5
PATCH v2 4/10 PCI, frv: clip firmware assigned resource under parent bridge's
In reply to Yinghai LuSome bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
We'd like to fix other arches instead of just x86.
--- arch/frv/mb93090-mb00/pci-frv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/frv/mb93090-mb00/pci-frv.c +1 -1
@@ -94,7 +94,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) r = &dev->resource[idx];if (!r->start)continue ; -pci_claim_resource (dev, idx); + pci_claim_bridge_resource(dev, idx) } }pcibios_allocate_bus_resources (&bus->children);
Signature · 1 line
1.8.4.5
Re: [PATCH v2 04/10] PCI, frv: clip firmware assigned resource under parent bridge's
Quoted 20 lines · Yinghai Lu
Some bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
We'd like to fix other arches instead of just x86.
Reported-by Marek Kordik <[email protected]>Fixes 5b28541552ef ("PCI: Restrict 64-bit prefetchable bridge windows to 64-bit resources")Signed-off-by Yinghai Lu <[email protected]>Cc David Howells <[email protected]>Cc Paul Gortmaker <[email protected]>--- arch/frv/mb93090-mb00/pci-frv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/frv/mb93090-mb00/pci-frv.c +0
-0
arch/frv/mb93090-mb00/pci-frv.c static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) · line 97
Quoted 5 lines
arch/frv/mb93090-mb00/pci-frv.c +1
-1@@ -94,7 +94,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) r = &dev->resource[idx];if (!r->start)continue ; -pci_claim_resource (dev, idx); +pci_claim_bridge_resource (dev, idx)
miss ; here.
Please let me know if you can fix it manually.
Sorry about that.
Thanks
Yinghai
Bjorn Helgaas
maintainerRe: [PATCH v2 04/10] PCI, frv: clip firmware assigned resource under parent bridge's
Quoted 29 lines · Yinghai Lu
Quoted 20 lines · Yinghai Lu
Some bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
We'd like to fix other arches instead of just x86.
Reported-by Marek Kordik <[email protected]>Fixes 5b28541552ef ("PCI: Restrict 64-bit prefetchable bridge windows to 64-bit resources")Signed-off-by Yinghai Lu <[email protected]>Cc David Howells <[email protected]>Cc Paul Gortmaker <[email protected]>--- arch/frv/mb93090-mb00/pci-frv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/frv/mb93090-mb00/pci-frv.c +0
-0arch/frv/mb93090-mb00/pci-frv.c static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) · line 97
Quoted 5 lines
arch/frv/mb93090-mb00/pci-frv.c +1
-1@@ -94,7 +94,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) r = &dev->resource[idx];if (!r->start)continue ; -pci_claim_resource (dev, idx); +pci_claim_bridge_resource (dev, idx)miss ; here.
Quoted 1 line
Please let me know if you can fix it manually.
Fixed, thanks.
PATCH v2 5/10 PCI, ia64: clip firmware assigned resource under parent bridge's
In reply to Yinghai LuSome bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
We'd like to fix other arches instead of just x86.
--- arch/ia64/pci/pci.c | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-)
arch/ia64/pci/pci.c +21 -27
@@ -487,45 +487,39 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)return 0 ; } -static int is_valid_resource (struct pci_dev *dev,int idx) +void pcibios_fixup_device_resources (struct pci_dev *dev) { -unsigned int i, type_mask =IORESOURCE_IO |IORESOURCE_MEM ; -struct resource *devr = &dev->resource[idx], *busr; +int idx;if (!dev->bus) -return 0 ; - -pci_bus_for_each_resource (dev->bus, busr, i) { -if (!busr || ((busr->flags ^ devr->flags) & type_mask)) -continue ; -if ((devr->start) && (devr->start >= busr->start) && - (devr->end <= busr->end)) -return 1 ; - } -return 0 ; -} +return ; -static void pcibios_fixup_resources (struct pci_dev *dev,int start,int limit) -{ -int i; +for (idx =0 ; idx <PCI_BRIDGE_RESOURCES ; idx++) { +struct resource *r = &dev->resource[idx]; -for (i = start; i < limit; i++) { -if (!dev->resource[i].flags) +if (!r->flags || r->parent || !r->start)continue ; -if ((is_valid_resource (dev, i))) -pci_claim_resource (dev, i); - } -} -void pcibios_fixup_device_resources (struct pci_dev *dev) -{ -pcibios_fixup_resources (dev,0 ,PCI_BRIDGE_RESOURCES ); +pci_claim_resource (dev, idx); + } }EXPORT_SYMBOL_GPL (pcibios_fixup_device_resources);static void pcibios_fixup_bridge_resources (struct pci_dev *dev) { -pcibios_fixup_resources (dev,PCI_BRIDGE_RESOURCES ,PCI_NUM_RESOURCES ); +int idx; + +if (!dev->bus) +return ; + +for (idx =PCI_BRIDGE_RESOURCES ; idx <PCI_NUM_RESOURCES ; idx++) { +struct resource *r = &dev->resource[idx]; + +if (!r->flags || r->parent || !r->start) +continue ; + +pci_claim_bridge_resource (dev, idx); + } }/*
Signature · 1 line
1.8.4.5
PATCH v2 6/10 PCI, microblaze: clip firmware assigned resource under parent bridge's
In reply to Yinghai LuSome bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
We'd like to fix other arches instead of just x86.
--- arch/microblaze/pci/pci-common.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
arch/microblaze/pci/pci-common.c +12 -1
@@ -1026,6 +1026,8 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus) pr, (pr && pr->name) ? pr->name : "nil");if (pr && !(pr->flags &IORESOURCE_UNSET )) { +struct pci_dev *dev = bus->self; +if (request_resource (pr, res) ==0 )continue ;/*
@@ -1035,6 +1037,12 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus)*/ if (reparent_resources (pr, res) ==0 )continue ; + +if (dev && i <PCI_BRIDGE_RESOURCE_NUM && +pci_claim_bridge_resource (dev, + i +PCI_BRIDGE_RESOURCES ) ==0 ) +continue ; + }pr_warn ("PCI: Cannot allocate resource region " );pr_cont ("%d of PCI bridge %d, will remap\n" , i, bus->number);
@@ -1227,7 +1235,10 @@ void pcibios_claim_one_bus(struct pci_bus *bus) (unsigned long long )r->end, (unsigned int)r->flags); -pci_claim_resource (dev, i); +if (pci_claim_resource (dev, i) ==0 ) +continue ; + +pci_claim_bridge_resource (dev, i); } }
Signature · 1 line
1.8.4.5
PATCH v2 7/10 PCI, mn10300: clip firmware assigned resource under parent bridge's
In reply to Yinghai LuSome bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
We'd like to fix other arches instead of just x86.
--- arch/mn10300/unit-asb2305/pci-asb2305.c | 2 +- arch/mn10300/unit-asb2305/pci.c | 47 +++++++++++++++------------------ 2 files changed, 22 insertions(+), 27 deletions(-)
arch/mn10300/unit-asb2305/pci-asb2305.c +1 -1
@@ -106,7 +106,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)if (!r->flags)continue ;if (!r->start || -pci_claim_resource (dev, idx) <0 ) { +pci_claim_bridge_resource (dev, idx) <0 ) { printk(KERN_ERR "PCI:" " Cannot allocate resource" " region %d of bridge %s\n",
arch/mn10300/unit-asb2305/pci.c +21 -26
70 lines not on this page · raw message
Signature · 1 line
1.8.4.5
PATCH v2 8/10 PCI, parisc: clip firmware assigned resource under parent bridge's
In reply to Yinghai LuSome bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
We'd like to fix other arches instead of just x86.
--- drivers/parisc/lba_pci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/parisc/lba_pci.c +2 -3
@@ -694,9 +694,8 @@ lba_fixup_bus(struct pci_bus *bus)int i;/* PCI-PCI Bridge */ pci_read_bridge_bases (bus); -for (i =PCI_BRIDGE_RESOURCES ; i <PCI_NUM_RESOURCES ; i++) { -pci_claim_resource (bus->self, i); - } +for (i =PCI_BRIDGE_RESOURCES ; i <PCI_NUM_RESOURCES ; i++) +pci_claim_bridge_resource (bus->self, i); }else {/* Host-PCI Bridge */ int err;
Signature · 1 line
1.8.4.5
PATCH v2 9/10 PCI, powerpc: clip firmware assigned resource under parent bridge's
In reply to Yinghai LuSome bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
We'd like to fix other arches instead of just x86.
--- arch/powerpc/kernel/pci-common.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/powerpc/kernel/pci-common.c +11 -1
@@ -1184,6 +1184,8 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus) pr, (pr && pr->name) ? pr->name : "nil");if (pr && !(pr->flags &IORESOURCE_UNSET )) { +struct pci_dev *dev = bus->self; +if (request_resource (pr, res) ==0 )continue ;/*
@@ -1193,6 +1195,11 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus)*/ if (reparent_resources (pr, res) ==0 )continue ; + +if (dev && i <PCI_BRIDGE_RESOURCE_NUM && +pci_claim_bridge_resource (dev, + i +PCI_BRIDGE_RESOURCES ) ==0 ) +continue ; }pr_warning ("PCI: Cannot allocate resource region " "%d of PCI bridge %d, will remap\n" , i, bus->number);
@@ -1401,7 +1408,10 @@ void pcibios_claim_one_bus(struct pci_bus *bus) (unsigned long long )r->end, (unsigned int)r->flags); -pci_claim_resource (dev, i); +if (pci_claim_resource (dev, i) ==0 ) +continue ; + +pci_claim_bridge_resource (dev, i); } }
Signature · 1 line
1.8.4.5
PATCH v2 10/10 PCI, sparc: clip firmware assigned resource under parent bridge's
In reply to Yinghai LuSome bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
We'd like to fix other arches instead of just x86.
--- arch/sparc/kernel/pci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/sparc/kernel/pci.c +4 -1
@@ -639,7 +639,10 @@ static void pci_claim_bus_resources(struct pci_bus *bus) (unsigned long long )r->end, (unsigned int)r->flags); -pci_claim_resource (dev, i); +if (pci_claim_resource (dev, i) =0 ) +continue ; + +pci_claim_bridge_resource (dev, i); } }
Signature · 1 line
1.8.4.5
Re: [PATCH v2 10/10] PCI, sparc: clip firmware assigned resource under parent bridge's
From: Yinghai Lu <[email protected]>
Date: Wed, 14 Jan 2015 20:31:37 -0800
Quoted 9 lines
Some bios put range that is not fully coverred by root bus resources. Try to clip them and update them in pci bridge bars.
We'd like to fix other arches instead of just x86.
Reported-by Marek Kordik <[email protected]>Fixes 5b28541552ef ("PCI: Restrict 64-bit prefetchable bridge windows to 64-bit resources")Signed-off-by Yinghai Lu <[email protected]>
Quoted 26 lines · Yinghai Lu
During the fix https://bugzilla.kernel.org/show_bug.cgi?id=85491,
Bjorn suggest that we should clip the resources instead of just reject them.We should only need first two for x86. others for related arches to keep them consistent.
-v2: only handle bridge resource, and add
pci_claim_bridge_resource
in pci core code.Thanks
Yinghai
Yinghai Lu (10):
PCI: clip firmware assigned resource under parent bridge's PCI, x86: clip firmware assigned resource under parent bridge's PCI, alpha: clip firmware assigned resource under parent bridge's PCI, frv: clip firmware assigned resource under parent bridge's PCI, ia64: clip firmware assigned resource under parent bridge's PCI, microblaze: clip firmware assigned resource under parent bridge's PCI, mn10300: clip firmware assigned resource under parent bridge's PCI, parisc: clip firmware assigned resource under parent bridge's PCI, powerpc: clip firmware assigned resource under parent bridge's PCI, sparc: clip firmware assigned resource under parent bridge's
Quoted 15 lines
arch/alpha/kernel/pci.c | 8 +++-- arch/frv/mb93090-mb00/pci-frv.c | 2 +- arch/ia64/pci/pci.c | 48 +++++++++++++--------------- arch/microblaze/pci/pci-common.c | 13 +++++++- arch/mn10300/unit-asb2305/pci-asb2305.c | 2 +- arch/mn10300/unit-asb2305/pci.c | 47 +++++++++++++-------------- arch/powerpc/kernel/pci-common.c | 12 ++++++- arch/sparc/kernel/pci.c | 5 ++- arch/x86/pci/i386.c | 2 +- drivers/parisc/lba_pci.c | 5 ++- drivers/pci/bus.c | 39 +++++++++++++++++++++++ drivers/pci/pci.h | 1 + drivers/pci/setup-bus.c | 56 ++++++++++++++++++++++++++------- include/linux/pci.h | 1 + 14 files changed, 165 insertions(+), 76 deletions(-)
Applied to for-linus for v3.19, thanks. This is significantly different from v1, so I didn't add acks and testing info from Helge and Wei.
Bjorn