PCI: of: Don't fail devm_pci_alloc_host_bridge() on missing 'ranges'
Rob Herring
reviewerPATCH 1/2 PCI: of: Don't fail devm_pci_alloc_host_bridge() on missing 'ranges'
Commit 669cbc708122 ("PCI: Move DT resource setup into devm_pci_alloc_host_bridge()") made devm_pci_alloc_host_bridge() fail on any DT resource parsing errors, but Broadcom iProc uses devm_pci_alloc_host_bridge() on BCMA bus devices that don't have DT resources. In particular, there is no 'ranges' property. Fix iProc by making 'ranges' optional.
If 'ranges' is required by a platform, there's going to be more errors latter on if it is missing.
--- drivers/pci/of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/of.c +1 -1
@@ -310,7 +310,7 @@ static int devm_of_pci_get_host_bridge_resources(struct device *dev,/* Check for ranges property */ err =of_pci_range_parser_init (&parser, dev_node);if (err) - goto failed; +return 0 ;dev_dbg (dev,"Parsing ranges property...\n" );for_each_of_pci_range (&parser, &range) {
Signature · 1 line
2.30.2
Rob Herring
reviewerPATCH 2/2 PCI: iproc: Fix BCMA probe resource handling
In commit 7ef1c871da16 ("PCI: iproc: Use pci_parse_request_of_pci_ranges()"), calling devm_request_pci_bus_resources() was dropped from the common iProc probe code, but is still needed for BCMA bus probing. Without it, there will be lots of warnings like this:
pci 0000:00:00.0: BAR 8: no space for [mem size 0x00c00000] pci 0000:00:00.0: BAR 8: failed to assign [mem size 0x00c00000]
Add back calling devm_request_pci_bus_resources() and adding the resources to pci_host_bridge.windows for BCMA bus probe.
--- drivers/pci/controller/pcie-iproc-bcma.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/pci/controller/pcie-iproc-bcma.c +6 -10
@@ -35,7 +35,6 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev) {struct device *dev = &bdev->dev;struct iproc_pcie *pcie; -LIST_HEAD (resources);struct pci_host_bridge *bridge;int ret;
@@ -60,19 +59,16 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev) pcie->mem.end = bdev->addr_s[0 ] +SZ_128M -1 ; pcie->mem.name ="PCIe MEM space" ; pcie->mem.flags =IORESOURCE_MEM ; -pci_add_resource (&resources, &pcie->mem); +pci_add_resource (&bridge->windows, &pcie->mem); + ret =devm_request_pci_bus_resources (dev, &bridge->windows); +if (ret) +return ret; pcie->map_irq = iproc_pcie_bcma_map_irq; - ret =iproc_pcie_setup (pcie, &resources); -if (ret) { -dev_err (dev,"PCIe controller setup failed\n" ); -pci_free_resource_list (&resources); -return ret; - } -bcma_set_drvdata (bdev, pcie); -return 0 ; + +return iproc_pcie_setup (pcie, &bridge->windows); }static void iproc_pcie_bcma_remove (struct bcma_device *bdev)
Signature · 1 line
2.30.2
Re: [PATCH 2/2] PCI: iproc: Fix BCMA probe resource handling
Quoted 12 lines · Rob Herring
In commit
7ef1c871da16("PCI: iproc: Usepci_parse_request_of_pci_ranges()"), callingdevm_request_pci_bus_resources()was dropped from the common iProc probe code, but is still needed for BCMA bus probing. Without it, there will be lots of warnings like this:pci 0000:00:00.0: BAR 8: no space for [mem size
0x00c00000] pci 0000:00:00.0: BAR 8: failed to assign [mem size0x00c00000]Add back calling
devm_request_pci_bus_resources()and adding the resources to pci_host_bridge.windows for BCMA bus probe.
Quoted 15 lines
Fixes 7ef1c871da16 ("PCI: iproc: Use pci_parse_request_of_pci_ranges()")Reported-by Rafał Miłecki <[email protected]>Cc Srinath Mannam <[email protected]>Cc Roman Bacik <[email protected]>Cc Bharat Gooty <[email protected]>Cc Abhishek Shah <[email protected]>Cc Jitendra Bhivare <[email protected]>Cc Ray Jui <[email protected]>Cc Florian Fainelli <[email protected]>Cc BCM Kernel Feedback <[email protected]>Cc Scott Branden <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc "Krzysztof Wilczyński" <[email protected]>Cc Bjorn Helgaas <[email protected]>Signed-off-by Rob Herring <[email protected]>
It works great again, thank you!
[ 6.624535] pcie_iproc_bcma bcma0:7: host bridge /axi@18000000/pcie@12000 ranges: [ 6.632048] pcie_iproc_bcma bcma0:7: No bus range found for /axi@18000000/pcie@12000, using [bus 00-ff] [ 6.641661] OF: /axi@18000000/pcie@12000: Missing device_type [ 6.647432] pcie_iproc_bcma bcma0:7: non-prefetchable memory resource required [ 6.783993] pcie_iproc_bcma bcma0:7: link: UP [ 6.788471] pcie_iproc_bcma bcma0:7: PCI host bridge to bus 0000:00 [ 6.794784] pci_bus 0000:00: root bus resource [bus 00-ff] [ 6.800288] pci_bus 0000:00: root bus resource [mem 0x08000000-0x0fffffff] [ 6.807216] pci 0000:00:00.0: [14e4:d612] type 01 class 0x060400 [ 6.813242] pci_bus 0000:00: 2-byte config write to 0000:00:00.0 offset 0x4 may corrupt adjacent RW1C bits [ 6.822927] pci_bus 0000:00: 2-byte config write to 0000:00:00.0 offset 0x4 may corrupt adjacent RW1C bits [ 6.832620] pci_bus 0000:00: 2-byte config write to 0000:00:00.0 offset 0x1c may corrupt adjacent RW1C bits [ 6.842387] pci_bus 0000:00: 2-byte config write to 0000:00:00.0 offset 0x1c may corrupt adjacent RW1C bits [ 6.852162] pci_bus 0000:00: 2-byte config write to 0000:00:00.0 offset 0x3e may corrupt adjacent RW1C bits [ 6.861951] pci 0000:00:00.0: PME# supported from D0 D3hot D3cold [ 6.868065] pci_bus 0000:00: 2-byte config write to 0000:00:00.0 offset 0x4c may corrupt adjacent RW1C bits [ 6.878472] pci_bus 0000:00: 2-byte config write to 0000:00:00.0 offset 0x3e may corrupt adjacent RW1C bits [ 6.888259] pci_bus 0000:00: 2-byte config write to 0000:00:00.0 offset 0x4 may corrupt adjacent RW1C bits [ 6.897947] pci_bus 0000:00: 1-byte config write to 0000:00:00.0 offset 0xc may corrupt adjacent RW1C bits [ 6.907634] PCI: bus0: Fast back to back transfers disabled [ 6.913224] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring [ 6.921255] pci_bus 0000:00: 2-byte config write to 0000:00:00.0 offset 0x3e may corrupt adjacent RW1C bits [ 6.931146] pci 0000:01:00.0: [14e4:4365] type 00 class 0x028000 [ 6.937212] pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x00007fff 64bit] [ 6.944032] pci 0000:01:00.0: reg 0x18: [mem 0x00000000-0x007fffff 64bit] [ 6.950839] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x000fffff 64bit pref] [ 6.958167] pci 0000:01:00.0: supports D1 D2 [ 6.963074] PCI: bus1: Fast back to back transfers disabled [ 6.968693] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01 [ 6.975354] pci 0000:00:00.0: BAR 8: assigned [mem 0x08000000-0x08bfffff] [ 6.982159] pci 0000:00:00.0: BAR 9: assigned [mem 0x08c00000-0x08cfffff 64bit pref] [ 6.989931] pci 0000:01:00.0: BAR 2: assigned [mem 0x08000000-0x087fffff 64bit] [ 6.997275] pci 0000:01:00.0: BAR 4: assigned [mem 0x08c00000-0x08cfffff 64bit pref] [ 7.005046] pci 0000:01:00.0: BAR 0: assigned [mem 0x08800000-0x08807fff 64bit] [ 7.012377] pci 0000:00:00.0: PCI bridge to [bus 01] [ 7.017354] pci 0000:00:00.0: bridge window [mem 0x08000000-0x08bfffff] [ 7.024162] pci 0000:00:00.0: bridge window [mem 0x08c00000-0x08cfffff 64bit pref] [ 7.032111] pcie_iproc_bcma bcma0:8: host bridge /axi@18000000/pcie@13000 ranges: [ 7.039647] pcie_iproc_bcma bcma0:8: No bus range found for /axi@18000000/pcie@13000, using [bus 00-ff] [ 7.049252] pcie_iproc_bcma bcma0:8: non-prefetchable memory resource required [ 7.183989] pcie_iproc_bcma bcma0:8: link: UP [ 7.188463] pcie_iproc_bcma bcma0:8: PCI host bridge to bus 0001:00 [ 7.194776] pci_bus 0001:00: root bus resource [bus 00-ff] [ 7.200280] pci_bus 0001:00: root bus resource [mem 0x20000000-0x27ffffff] [ 7.207206] pci 0001:00:00.0: [14e4:d612] type 01 class 0x060400 [ 7.213267] pci 0001:00:00.0: PME# supported from D0 D3hot D3cold [ 7.220014] PCI: bus0: Fast back to back transfers disabled [ 7.225619] pci 0001:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring [ 7.233772] pci 0001:01:00.0: [14e4:4365] type 00 class 0x028000 [ 7.239834] pci 0001:01:00.0: reg 0x10: [mem 0x00000000-0x00007fff 64bit] [ 7.246659] pci 0001:01:00.0: reg 0x18: [mem 0x00000000-0x007fffff 64bit] [ 7.253469] pci 0001:01:00.0: reg 0x20: [mem 0x00000000-0x000fffff 64bit pref] [ 7.260805] pci 0001:01:00.0: supports D1 D2 [ 7.265717] PCI: bus1: Fast back to back transfers disabled [ 7.271311] pci_bus 0001:01: busn_res: [bus 01-ff] end is updated to 01 [ 7.277970] pci 0001:00:00.0: BAR 8: assigned [mem 0x20000000-0x20bfffff] [ 7.284778] pci 0001:00:00.0: BAR 9: assigned [mem 0x20c00000-0x20cfffff 64bit pref] [ 7.292546] pci 0001:01:00.0: BAR 2: assigned [mem 0x20000000-0x207fffff 64bit] [ 7.299887] pci 0001:01:00.0: BAR 4: assigned [mem 0x20c00000-0x20cfffff 64bit pref] [ 7.307670] pci 0001:01:00.0: BAR 0: assigned [mem 0x20800000-0x20807fff 64bit] [ 7.315016] pci 0001:00:00.0: PCI bridge to [bus 01] [ 7.319995] pci 0001:00:00.0: bridge window [mem 0x20000000-0x20bfffff] [ 7.326807] pci 0001:00:00.0: bridge window [mem 0x20c00000-0x20cfffff 64bit pref] [ 7.334761] pcie_iproc_bcma bcma0:9: host bridge /axi@18000000/pcie@14000 ranges: [ 7.342279] pcie_iproc_bcma bcma0:9: No bus range found for /axi@18000000/pcie@14000, using [bus 00-ff] [ 7.351896] pcie_iproc_bcma bcma0:9: non-prefetchable memory resource required [ 7.483989] pcie_iproc_bcma bcma0:9: PHY or data link is INACTIVE! [ 7.490184] pcie_iproc_bcma bcma0:9: no PCIe EP device detected
Quoted 9 lines · Rob Herring
Commit
669cbc708122("PCI: Move DT resource setup intodevm_pci_alloc_host_bridge()") madedevm_pci_alloc_host_bridge()fail on any DT resource parsing errors, but Broadcom iProc usesdevm_pci_alloc_host_bridge()on BCMA bus devices that don't have DT resources. In particular, there is no 'ranges' property. Fix iProc by making 'ranges' optional.If 'ranges' is required by a platform, there's going to be more errors latter on if it is missing.
s/latter/later/
Quoted 6 lines
Fixes 669cbc708122 ("PCI: Move DT resource setup into devm_pci_alloc_host_bridge()")Reported-by Rafał Miłecki <[email protected]>Cc Srinath Mannam <[email protected]>Cc Roman Bacik <[email protected]>Cc Bharat Gooty <[email protected]>Cc Abhishek Shah <[email protected]>
Quoted 8 lines
Cc Jitendra Bhivare <[email protected]>Cc Ray Jui <[email protected]>Cc Florian Fainelli <[email protected]>Cc BCM Kernel Feedback <[email protected]>Cc Scott Branden <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Signed-off-by Rob Herring <[email protected]>
I assume Lorenzo will merge this along with the iproc change.
Quoted 20 lines
--- drivers/pci/of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/of.c +1
-1@@ -310,7 +310,7 @@ static int devm_of_pci_get_host_bridge_resources(struct device *dev,/* Check for ranges property */ err =of_pci_range_parser_init (&parser, dev_node);if (err) - goto failed; +return 0 ;dev_dbg (dev,"Parsing ranges property...\n" );for_each_of_pci_range (&parser, &range) {Signature · 1 line
2.30.2
Quoted 10 lines · Rob Herring
Commit
669cbc708122("PCI: Move DT resource setup intodevm_pci_alloc_host_bridge()") madedevm_pci_alloc_host_bridge()fail on any DT resource parsing errors, but Broadcom iProc usesdevm_pci_alloc_host_bridge()on BCMA bus devices that don't have DT resources. In particular, there is no 'ranges' property. Fix iProc by making 'ranges' optional.If 'ranges' is required by a platform, there's going to be more errors latter on if it is missing.
Quoted 14 lines
Fixes 669cbc708122 ("PCI: Move DT resource setup into devm_pci_alloc_host_bridge()")Reported-by Rafał Miłecki <[email protected]>Cc Srinath Mannam <[email protected]>Cc Roman Bacik <[email protected]>Cc Bharat Gooty <[email protected]>Cc Abhishek Shah <[email protected]>Cc Jitendra Bhivare <[email protected]>Cc Ray Jui <[email protected]>Cc Florian Fainelli <[email protected]>Cc BCM Kernel Feedback <[email protected]>Cc Scott Branden <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Signed-off-by Rob Herring <[email protected]>
You're great Rob, thank you!
I've tested it on top of the 669cbc708122 and linux-5.10.y.
Lorenzo Pieralisi
AppliedQuoted 8 lines · Rob Herring
Commit
669cbc708122("PCI: Move DT resource setup intodevm_pci_alloc_host_bridge()") madedevm_pci_alloc_host_bridge()fail on any DT resource parsing errors, but Broadcom iProc usesdevm_pci_alloc_host_bridge()on BCMA bus devices that don't have DT resources. In particular, there is no 'ranges' property. Fix iProc by making 'ranges' optional.[...]
Applied to pci/iproc, thanks!
[1/2] PCI: of: Don't fail devm_pci_alloc_host_bridge() on missing 'ranges'
https://git.kernel.org/lpieralisi/pci/c/d277f6e88c [2/2] PCI: iproc: Fix BCMA probe resource handling https://git.kernel.org/lpieralisi/pci/c/aeaea8969b
Thanks,
Lorenzo