2021-04-13 09:00:15

by Ilya Lipnitskiy

[permalink] [raw]
Subject: [PATCH 0/8] MIPS: Fixes for PCI legacy drivers (rt2880, rt3883)

One major fix for rt2880-pci in the first patch - fixes breakage that
existed since v4.14.

Other more minor fixes, cleanups, and improvements that either free up
memory, make dmesg messages clearer, or remove redundant dmesg output.

Ilya Lipnitskiy (8):
MIPS: pci-rt2880: fix slot 0 configuration
MIPS: pci-rt2880: remove unneeded locks
MIPS: pci-rt3883: trivial: remove unused variable
MIPS: pci-rt3883: more accurate DT error messages
MIPS: pci-legacy: stop using of_pci_range_to_resource
MIPS: pci-legacy: remove redundant info messages
MIPS: pci-legacy: remove busn_resource field
MIPS: pci-legacy: use generic pci_enable_resources

arch/mips/include/asm/pci.h | 1 -
arch/mips/pci/pci-legacy.c | 57 ++++++---------------------------
arch/mips/pci/pci-rt2880.c | 63 +++++++++++++++++++------------------
arch/mips/pci/pci-rt3883.c | 10 ++----
4 files changed, 44 insertions(+), 87 deletions(-)

--
2.31.1


2021-04-13 09:01:01

by Ilya Lipnitskiy

[permalink] [raw]
Subject: [PATCH 4/8] MIPS: pci-rt3883: more accurate DT error messages

Existing strings do not make sense: one is always NULL and the other
refers to the wrong parent node.

Signed-off-by: Ilya Lipnitskiy <[email protected]>
---
arch/mips/pci/pci-rt3883.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/mips/pci/pci-rt3883.c b/arch/mips/pci/pci-rt3883.c
index e422f78db5bc..aebd4964ea34 100644
--- a/arch/mips/pci/pci-rt3883.c
+++ b/arch/mips/pci/pci-rt3883.c
@@ -431,8 +431,7 @@ static int rt3883_pci_probe(struct platform_device *pdev)

if (!rpc->intc_of_node) {
dev_err(dev, "%pOF has no %s child node",
- rpc->intc_of_node,
- "interrupt controller");
+ np, "interrupt controller");
return -EINVAL;
}

@@ -446,8 +445,7 @@ static int rt3883_pci_probe(struct platform_device *pdev)

if (!rpc->pci_controller.of_node) {
dev_err(dev, "%pOF has no %s child node",
- rpc->intc_of_node,
- "PCI host bridge");
+ np, "PCI host bridge");
err = -EINVAL;
goto err_put_intc_node;
}
--
2.31.1

2021-04-13 09:01:23

by Ilya Lipnitskiy

[permalink] [raw]
Subject: [PATCH 6/8] MIPS: pci-legacy: remove redundant info messages

Remove the following pci-legacy message:
PCI host bridge /pci@440000/host-bridge ranges:
MEM 0x0000000020000000..0x000000002fffffff
IO 0x0000000000460000..0x000000000046ffff

It is followed shortly by the same data from pci_register_host_bridge:
PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [mem 0x20000000-0x2fffffff]
pci_bus 0000:00: root bus resource [io 0x460000-0x46ffff]

Signed-off-by: Ilya Lipnitskiy <[email protected]>
---
arch/mips/pci/pci-legacy.c | 7 -------
1 file changed, 7 deletions(-)

diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c
index 3a909194284a..ec3f52ade72d 100644
--- a/arch/mips/pci/pci-legacy.c
+++ b/arch/mips/pci/pci-legacy.c
@@ -140,7 +140,6 @@ void pci_load_of_ranges(struct pci_controller *hose, struct device_node *node)
struct of_pci_range range;
struct of_pci_range_parser parser;

- pr_info("PCI host bridge %pOF ranges:\n", node);
hose->of_node = node;

if (of_pci_range_parser_init(&parser, node))
@@ -151,18 +150,12 @@ void pci_load_of_ranges(struct pci_controller *hose, struct device_node *node)

switch (range.flags & IORESOURCE_TYPE_BITS) {
case IORESOURCE_IO:
- pr_info(" IO 0x%016llx..0x%016llx\n",
- range.cpu_addr,
- range.cpu_addr + range.size - 1);
hose->io_map_base =
(unsigned long)ioremap(range.cpu_addr,
range.size);
res = hose->io_resource;
break;
case IORESOURCE_MEM:
- pr_info(" MEM 0x%016llx..0x%016llx\n",
- range.cpu_addr,
- range.cpu_addr + range.size - 1);
res = hose->mem_resource;
break;
}
--
2.31.1

2021-04-13 13:42:56

by Ilya Lipnitskiy

[permalink] [raw]
Subject: [PATCH 7/8] MIPS: pci-legacy: remove busn_resource field

No drivers set the busn_resource field in the pci_controller struct.
Commit 7ee214b540d9 ("MIPS: PCI: Remove unused busn_offset") almost
removed it over 3 years ago. Remove it for good to free up memory and
eliminate messages like:
pci_bus 0000:00: root bus resource [??? 0x00000000 flags 0x0]

Signed-off-by: Ilya Lipnitskiy <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
---
arch/mips/include/asm/pci.h | 1 -
arch/mips/pci/pci-legacy.c | 1 -
2 files changed, 2 deletions(-)

diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 6f48649201c5..9ffc8192adae 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -38,7 +38,6 @@ struct pci_controller {
struct resource *io_resource;
unsigned long io_offset;
unsigned long io_map_base;
- struct resource *busn_resource;

#ifndef CONFIG_PCI_DOMAINS_GENERIC
unsigned int index;
diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c
index ec3f52ade72d..78c22987bef0 100644
--- a/arch/mips/pci/pci-legacy.c
+++ b/arch/mips/pci/pci-legacy.c
@@ -89,7 +89,6 @@ static void pcibios_scanbus(struct pci_controller *hose)
hose->mem_resource, hose->mem_offset);
pci_add_resource_offset(&resources,
hose->io_resource, hose->io_offset);
- pci_add_resource(&resources, hose->busn_resource);
list_splice_init(&resources, &bridge->windows);
bridge->dev.parent = NULL;
bridge->sysdata = hose;
--
2.31.1

2021-04-13 13:42:56

by Ilya Lipnitskiy

[permalink] [raw]
Subject: [PATCH 8/8] MIPS: pci-legacy: use generic pci_enable_resources

Follow the reasoning from commit 842de40d93e0 ("PCI: add generic
pci_enable_resources()"):

The only functional difference from the MIPS version is that the
generic one uses "!r->parent" to check for resource collisions
instead of "!r->start && r->end".

That should have no effect on any pci-legacy driver.

Suggested-by: Bjorn Helgaas <[email protected]>
Signed-off-by: Ilya Lipnitskiy <[email protected]>
---
arch/mips/pci/pci-legacy.c | 40 ++------------------------------------
1 file changed, 2 insertions(+), 38 deletions(-)

diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c
index 78c22987bef0..c24226ea0a6e 100644
--- a/arch/mips/pci/pci-legacy.c
+++ b/arch/mips/pci/pci-legacy.c
@@ -241,47 +241,11 @@ static int __init pcibios_init(void)

subsys_initcall(pcibios_init);

-static int pcibios_enable_resources(struct pci_dev *dev, int mask)
-{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for (idx=0; idx < PCI_NUM_RESOURCES; idx++) {
- /* Only set up the requested stuff */
- if (!(mask & (1<<idx)))
- continue;
-
- r = &dev->resource[idx];
- if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
- continue;
- if ((idx == PCI_ROM_RESOURCE) &&
- (!(r->flags & IORESOURCE_ROM_ENABLE)))
- continue;
- if (!r->start && r->end) {
- pci_err(dev,
- "can't enable device: resource collisions\n");
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (cmd != old_cmd) {
- pci_info(dev, "enabling device (%04x -> %04x)\n", old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
-}
-
int pcibios_enable_device(struct pci_dev *dev, int mask)
{
- int err;
+ int err = pci_enable_resources(dev, mask);

- if ((err = pcibios_enable_resources(dev, mask)) < 0)
+ if (err < 0)
return err;

return pcibios_plat_dev_init(dev);
--
2.31.1