LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/3] Fix handling of multi-level OF nodes
@ 2021-08-05 8:28 Mauro Carvalho Chehab
2021-08-05 8:28 ` [PATCH 1/3] PCI: of: Fix handling of multi-level PCI devices Mauro Carvalho Chehab
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2021-08-05 8:28 UTC (permalink / raw)
To: Rob Herring
Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, linux-kernel, linux-pci
Hi Rob,
This series address the issues related to not add all of_node data at sysfs.
Patch 1 is the real fix.
Patch 2 just changes the order of init, in order to allow printing what's
happening when registering a device;
Patch 3 is just debug.
With patch 1 applied, the sysfs nodes seem to match the PCI configuration:
$ find /sys/devices/platform/soc/f4000000.pcie/ -name of_node
/sys/devices/platform/soc/f4000000.pcie/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:07.0/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:07.0/pci_bus/0000:06/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/pci_bus/0000:02/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:05.0/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:05.0/pci_bus/0000:05/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:01.0/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:01.0/pci_bus/0000:03/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/pci_bus/0000:01/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/pci_bus/0000:00/of_node
Mauro Carvalho Chehab (3):
PCI: of: Fix handling of multi-level PCI devices
PCI: of: Setup PCI before setting the OF node
PCI: of: Add some debug printks to track problems with of_node setup
drivers/pci/of.c | 9 +++++++++
drivers/pci/probe.c | 5 ++---
2 files changed, 11 insertions(+), 3 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] PCI: of: Fix handling of multi-level PCI devices
2021-08-05 8:28 [PATCH 0/3] Fix handling of multi-level OF nodes Mauro Carvalho Chehab
@ 2021-08-05 8:28 ` Mauro Carvalho Chehab
2021-08-06 22:52 ` Bjorn Helgaas
2021-08-05 8:28 ` [PATCH 2/3] PCI: of: Setup PCI before setting the OF node Mauro Carvalho Chehab
2021-08-05 8:29 ` [PATCH 3/3] PCI: of: Add some debug printks to track problems with of_node setup Mauro Carvalho Chehab
2 siblings, 1 reply; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2021-08-05 8:28 UTC (permalink / raw)
To: Rob Herring
Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Bjorn Helgaas,
linux-kernel, linux-pci
When the DT schema is like:
pcie@f4000000 {
pcie@0,0 {
pcie@1,0 {
};
pcie@5,0 {
};
pcie@7,0 {
};
};
};
The logic under pci_set_bus_of_node() will try to setup some
buses with a NULL node, causing it to register just a small
set of devices:
$ find /sys/devices/platform/soc/f4000000.pcie/ -name of_node
/sys/devices/platform/soc/f4000000.pcie/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/pci_bus/0000:01/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/pci_bus/0000:00/of_node
On such case, it needs to go to the parent node, in order to register
everything:
$ find /sys/devices/platform/soc/f4000000.pcie/ -name of_node
/sys/devices/platform/soc/f4000000.pcie/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:07.0/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:07.0/pci_bus/0000:06/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/pci_bus/0000:02/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:05.0/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:05.0/pci_bus/0000:05/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:01.0/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:01.0/pci_bus/0000:03/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/pci_bus/0000:01/of_node
/sys/devices/platform/soc/f4000000.pcie/pci0000:00/pci_bus/0000:00/of_node
Adding some debug prints with such change will produce the following
output:
$ dmesg|grep of_node
[ 4.932405] (null): pci_set_bus_of_node: of_node: /soc/pcie@f4000000
[ 4.985916] pci 0000:00:00.0: pci_set_of_node: of_node: /soc/pcie@f4000000
[ 5.014190] pci_bus 0000:01: pci_set_bus_of_node: of_node: /soc/pcie@f4000000/pcie@0,0
[ 5.065680] pci 0000:01:00.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0
[ 5.118754] pci_bus 0000:02: pci_set_bus_of_node: use of_node of the parent
[ 5.135279] pci_bus 0000:02: pci_set_bus_of_node: of_node: /soc/pcie@f4000000/pcie@0,0
[ 5.158921] pci 0000:02:01.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0
[ 5.187393] pci 0000:02:04.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0
[ 5.215982] pci 0000:02:05.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0
[ 5.244607] pci 0000:02:07.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0
[ 5.272825] pci 0000:02:09.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0
[ 5.335258] pci_bus 0000:03: pci_set_bus_of_node: of_node: /soc/pcie@f4000000/pcie@0,0/pcie@1,0
[ 5.367538] pci 0000:03:00.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0/pcie@1,0
[ 5.415959] pci_bus 0000:04: pci_set_bus_of_node: use of_node of the parent
[ 5.424190] pci_bus 0000:04: pci_set_bus_of_node: of_node: (null)
[ 5.438727] pci_bus 0000:05: pci_set_bus_of_node: of_node: /soc/pcie@f4000000/pcie@0,0/pcie@5,0
[ 5.455691] pci_bus 0000:06: pci_set_bus_of_node: of_node: /soc/pcie@f4000000/pcie@0,0/pcie@7,0
[ 5.491643] pci 0000:06:00.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0/pcie@7,0
[ 5.526157] pci_bus 0000:07: pci_set_bus_of_node: use of_node of the parent
[ 5.534361] pci_bus 0000:07: pci_set_bus_of_node: of_node: (null)
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/pci/of.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index a143b02b2dcd..b6fa3bd46ae6 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -41,6 +41,8 @@ void pci_set_bus_of_node(struct pci_bus *bus)
node = pcibios_get_phb_of_node(bus);
} else {
node = of_node_get(bus->self->dev.of_node);
+ if (!node)
+ node = of_node_get(bus->self->dev.parent->of_node);
if (node && of_property_read_bool(node, "external-facing"))
bus->self->external_facing = true;
}
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] PCI: of: Setup PCI before setting the OF node
2021-08-05 8:28 [PATCH 0/3] Fix handling of multi-level OF nodes Mauro Carvalho Chehab
2021-08-05 8:28 ` [PATCH 1/3] PCI: of: Fix handling of multi-level PCI devices Mauro Carvalho Chehab
@ 2021-08-05 8:28 ` Mauro Carvalho Chehab
2021-08-05 8:29 ` [PATCH 3/3] PCI: of: Add some debug printks to track problems with of_node setup Mauro Carvalho Chehab
2 siblings, 0 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2021-08-05 8:28 UTC (permalink / raw)
To: Rob Herring
Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Bjorn Helgaas,
linux-kernel, linux-pci
With this change, it is easier to add a debug printk at
pci_set_of_node() in order to address possible issues.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/pci/probe.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 79177ac37880..c5dfc1afb1d3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2374,15 +2374,14 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
dev->vendor = l & 0xffff;
dev->device = (l >> 16) & 0xffff;
- pci_set_of_node(dev);
-
if (pci_setup_device(dev)) {
- pci_release_of_node(dev);
pci_bus_put(dev->bus);
kfree(dev);
return NULL;
}
+ pci_set_of_node(dev);
+
return dev;
}
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] PCI: of: Add some debug printks to track problems with of_node setup
2021-08-05 8:28 [PATCH 0/3] Fix handling of multi-level OF nodes Mauro Carvalho Chehab
2021-08-05 8:28 ` [PATCH 1/3] PCI: of: Fix handling of multi-level PCI devices Mauro Carvalho Chehab
2021-08-05 8:28 ` [PATCH 2/3] PCI: of: Setup PCI before setting the OF node Mauro Carvalho Chehab
@ 2021-08-05 8:29 ` Mauro Carvalho Chehab
2 siblings, 0 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2021-08-05 8:29 UTC (permalink / raw)
To: Rob Herring
Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Bjorn Helgaas,
linux-kernel, linux-pci
In order to be able to identify why some of_nodes are not created,
we need to add some debug prints.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/pci/of.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index b6fa3bd46ae6..7b8c2b87eb25 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -18,6 +18,9 @@
#ifdef CONFIG_PCI
void pci_set_of_node(struct pci_dev *dev)
{
+ dev_dbg(&dev->dev, "%s: of_node: %pOF\n",
+ __func__, dev->bus->dev.of_node);
+
if (!dev->bus->dev.of_node)
return;
dev->dev.of_node = of_pci_find_child_device(dev->bus->dev.of_node,
@@ -41,12 +44,16 @@ void pci_set_bus_of_node(struct pci_bus *bus)
node = pcibios_get_phb_of_node(bus);
} else {
node = of_node_get(bus->self->dev.of_node);
- if (!node)
+ if (!node) {
node = of_node_get(bus->self->dev.parent->of_node);
+ dev_dbg(&bus->dev, "%s: use of_node of the parent",
+ __func__);
+ }
if (node && of_property_read_bool(node, "external-facing"))
bus->self->external_facing = true;
}
+ dev_dbg(&bus->dev, "%s: of_node: %pOF\n", __func__, node);
bus->dev.of_node = node;
if (bus->dev.of_node)
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] PCI: of: Fix handling of multi-level PCI devices
2021-08-05 8:28 ` [PATCH 1/3] PCI: of: Fix handling of multi-level PCI devices Mauro Carvalho Chehab
@ 2021-08-06 22:52 ` Bjorn Helgaas
0 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2021-08-06 22:52 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Rob Herring, linuxarm, mauro.chehab, Bjorn Helgaas, linux-kernel,
linux-pci
On Thu, Aug 05, 2021 at 10:28:58AM +0200, Mauro Carvalho Chehab wrote:
> $ dmesg|grep of_node
Adding "|cut -b16-" or so would make this more readable. Could also
indent by two spaces instead of a tab if that would help.
> [ 4.932405] (null): pci_set_bus_of_node: of_node: /soc/pcie@f4000000
> [ 4.985916] pci 0000:00:00.0: pci_set_of_node: of_node: /soc/pcie@f4000000
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-06 22:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-05 8:28 [PATCH 0/3] Fix handling of multi-level OF nodes Mauro Carvalho Chehab
2021-08-05 8:28 ` [PATCH 1/3] PCI: of: Fix handling of multi-level PCI devices Mauro Carvalho Chehab
2021-08-06 22:52 ` Bjorn Helgaas
2021-08-05 8:28 ` [PATCH 2/3] PCI: of: Setup PCI before setting the OF node Mauro Carvalho Chehab
2021-08-05 8:29 ` [PATCH 3/3] PCI: of: Add some debug printks to track problems with of_node setup Mauro Carvalho Chehab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).