Skip to contentSkip to conversation

PCI: of: Update parent unit address generation in of_pci_prop_intr_map()

PATCH Applied Lorenzo Pieralisi 4 participants 5 messages Aug 18, 2025 – Sep 11, 2025 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: of: Update parent unit address generation in of_pci_prop_intr_map()

Some interrupt controllers require an #address-cells property in their bindings without requiring a "reg" property to be present.

The current logic used to craft an interrupt-map property in of_pci_prop_intr_map() is based on reading the #address-cells property in the interrupt-parent and, if != 0, read the interrupt parent "reg" property to determine the parent unit address to be used to create the parent unit interrupt specifier.

First of all, it is not correct to read the "reg" property of the interrupt-parent with an #address-cells value taken from the interrupt-parent node, because the #address-cells value define the number of address cells required by child nodes.

More importantly, for all modern interrupt controllers, the parent unit address is irrelevant in HW in relation to the device<->interrupt-controller connection and the kernel actually ignores the parent unit address value when hierarchically parsing the interrupt-map property (ie of_irq_parse_raw()).

For the reasons above, remove the code parsing the interrupt parent "reg" property in of_pci_prop_intr_map() - it is not needed and as it is it is detrimental in that it prevents interrupt-map property generation on systems with an interrupt-controller that has no "reg" property in its interrupt-controller node - and leave the parent unit address always initialized to 0 since it is simply ignored by the kernel.

---
 drivers/pci/of_property.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/pci/of_property.c +14 -7
index 506fcd507113..09b7bc335ec5 100644
@@ -279,13 +279,20 @@ static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
 			mapp++;
 			*mapp = out_irq[i].np->phandle;
 			mapp++;
-			if (addr_sz[i]) {
-				ret = of_property_read_u32_array(out_irq[i].np,
-								 "reg", mapp,
-								 addr_sz[i]);
-				if (ret)
-					goto failed;
-			}
+
+			/*
+			 * A device address does not affect the
+			 * device<->interrupt-controller HW connection for all
+			 * modern interrupt controllers; moreover, the kernel
+			 * (ie of_irq_parse_raw()) ignores the values in the
+			 * parent unit address cells while parsing the interrupt-map
+			 * property because they are irrelevant for interrupts mapping
+			 * in modern system.
+			 *
+			 * Leave the parent unit address initialized to 0 - just
+			 * take into account the #address-cells size to build
+			 * the property properly.
+			 */
 			mapp += addr_sz[i];
 			memcpy(mapp, out_irq[i].args,
 			       out_irq[i].args_count * sizeof(u32));
Signature · 1 line
2.48.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 56 lines · Lorenzo Pieralisi

Some interrupt controllers require an #address-cells property in their bindings without requiring a "reg" property to be present.

The current logic used to craft an interrupt-map property in of_pci_prop_intr_map() is based on reading the #address-cells property in the interrupt-parent and, if != 0, read the interrupt parent "reg" property to determine the parent unit address to be used to create the parent unit interrupt specifier.

First of all, it is not correct to read the "reg" property of the interrupt-parent with an #address-cells value taken from the interrupt-parent node, because the #address-cells value define the number of address cells required by child nodes.

More importantly, for all modern interrupt controllers, the parent unit address is irrelevant in HW in relation to the device<->interrupt-controller connection and the kernel actually ignores the parent unit address value when hierarchically parsing the interrupt-map property (ie of_irq_parse_raw()).

For the reasons above, remove the code parsing the interrupt parent "reg" property in of_pci_prop_intr_map() - it is not needed and as it is it is detrimental in that it prevents interrupt-map property generation on systems with an interrupt-controller that has no "reg" property in its interrupt-controller node - and leave the parent unit address always initialized to 0 since it is simply ignored by the kernel.

---
  drivers/pci/of_property.c | 21 ++++++++++++++-------
  1 file changed, 14 insertions(+), 7 deletions(-)
drivers/pci/of_property.c +4 -7
index 506fcd507113..09b7bc335ec5 100644
@@ -279,13 +279,20 @@ static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
  			mapp++;
  			*mapp = out_irq[i].np->phandle;
  			mapp++;
-			if (addr_sz[i]) {
-				ret = of_property_read_u32_array(out_irq[i].np,
-								 "reg", mapp,
-								 addr_sz[i]);
-				if (ret)
-					goto failed;
-			}
+
+			/*
+			 * A device address does not affect the
+			 * device<->interrupt-controller HW connection for all

drivers/pci/of_property.c static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs, · line 295

Quoted 10 lines
drivers/pci/of_property.c +10 -0
+			 * modern interrupt controllers; moreover, the kernel
+			 * (ie of_irq_parse_raw()) ignores the values in the
+			 * parent unit address cells while parsing the interrupt-map
+			 * property because they are irrelevant for interrupts mapping
+			 * in modern system.
+			 *
+			 * Leave the parent unit address initialized to 0 - just
+			 * take into account the #address-cells size to build
+			 * the property properly.
+			 */
Quoted 3 lines
drivers/pci/of_property.c +0 -0
  			mapp += addr_sz[i];
  			memcpy(mapp, out_irq[i].args,
  			       out_irq[i].args_count * sizeof(u32));
#2 lore raw
In reply to Lorenzo Pieralisi

On Mon, Aug 18, 2025 at 11:35:04AM +0200, Lorenzo Pieralisi wrote:

[...]

Quoted 17 lines
 drivers/pci/of_property.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/pci/of_property.c +0 -6
index 506fcd507113..09b7bc335ec5 100644
@@ -279,13 +279,20 @@ static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
 			mapp++;
 			*mapp = out_irq[i].np->phandle;
 			mapp++;
-			if (addr_sz[i]) {
-				ret = of_property_read_u32_array(out_irq[i].np,
-								 "reg", mapp,
-								 addr_sz[i]);
-				if (ret)
-					goto failed;

drivers/pci/of_property.c static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs, · line 290

Quoted 10 lines
drivers/pci/of_property.c +9 -1
-			}
+
+			/*
+			 * A device address does not affect the
+			 * device<->interrupt-controller HW connection for all
+			 * modern interrupt controllers; moreover, the kernel
+			 * (ie of_irq_parse_raw()) ignores the values in the
+			 * parent unit address cells while parsing the interrupt-map
+			 * property because they are irrelevant for interrupts mapping
+			 * in modern system.

Rob,

if you apply directly the line above should be "in modern systems" please.

Thanks,
Lorenzo

Quoted 11 lines
drivers/pci/of_property.c +5 -0
+			 *
+			 * Leave the parent unit address initialized to 0 - just
+			 * take into account the #address-cells size to build
+			 * the property properly.
+			 */
 			mapp += addr_sz[i];
 			memcpy(mapp, out_irq[i].args,
 			       out_irq[i].args_count * sizeof(u32));
Signature · 1 line
2.48.0
Reviewed-by
#3 lore raw
Quoted 35 lines · Lorenzo Pieralisi

On Mon, Aug 18, 2025 at 11:35:04AM +0200, Lorenzo Pieralisi wrote:

[...]

Quoted 17 lines
 drivers/pci/of_property.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/pci/of_property.c +0 -6
index 506fcd507113..09b7bc335ec5 100644
@@ -279,13 +279,20 @@ static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
                      mapp++;
                      *mapp = out_irq[i].np->phandle;
                      mapp++;
-                     if (addr_sz[i]) {
-                             ret = of_property_read_u32_array(out_irq[i].np,
-                                                              "reg", mapp,
-                                                              addr_sz[i]);
-                             if (ret)
-                                     goto failed;

drivers/pci/of_property.c static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs, · line 290

Quoted 10 lines
drivers/pci/of_property.c +9 -1
-                     }
+
+                     /*
+                      * A device address does not affect the
+                      * device<->interrupt-controller HW connection for all
+                      * modern interrupt controllers; moreover, the kernel
+                      * (ie of_irq_parse_raw()) ignores the values in the
+                      * parent unit address cells while parsing the interrupt-map
+                      * property because they are irrelevant for interrupts mapping
+                      * in modern system.

Rob,

Quoted 1 line

if you apply directly the line above should be "in modern systems" please.

But this should go via PCI tree.

#4 lore raw
In reply to Lorenzo Pieralisi
Quoted 28 lines · Lorenzo Pieralisi

Some interrupt controllers require an #address-cells property in their bindings without requiring a "reg" property to be present.

The current logic used to craft an interrupt-map property in of_pci_prop_intr_map() is based on reading the #address-cells property in the interrupt-parent and, if != 0, read the interrupt parent "reg" property to determine the parent unit address to be used to create the parent unit interrupt specifier.

First of all, it is not correct to read the "reg" property of the interrupt-parent with an #address-cells value taken from the interrupt-parent node, because the #address-cells value define the number of address cells required by child nodes.

More importantly, for all modern interrupt controllers, the parent unit address is irrelevant in HW in relation to the device<->interrupt-controller connection and the kernel actually ignores the parent unit address value when hierarchically parsing the interrupt-map property (ie of_irq_parse_raw()).

For the reasons above, remove the code parsing the interrupt parent "reg" property in of_pci_prop_intr_map() - it is not needed and as it is it is detrimental in that it prevents interrupt-map property generation on systems with an interrupt-controller that has no "reg" property in its interrupt-controller node - and leave the parent unit address always initialized to 0 since it is simply ignored by the kernel.

Quoted 5 lines

Applied to pci/of for v6.18, thanks, Lorenzo!

Quoted 39 lines
---
 drivers/pci/of_property.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/pci/of_property.c +14 -7
index 506fcd507113..09b7bc335ec5 100644
@@ -279,13 +279,20 @@ static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
 			mapp++;
 			*mapp = out_irq[i].np->phandle;
 			mapp++;
-			if (addr_sz[i]) {
-				ret = of_property_read_u32_array(out_irq[i].np,
-								 "reg", mapp,
-								 addr_sz[i]);
-				if (ret)
-					goto failed;
-			}
+
+			/*
+			 * A device address does not affect the
+			 * device<->interrupt-controller HW connection for all
+			 * modern interrupt controllers; moreover, the kernel
+			 * (ie of_irq_parse_raw()) ignores the values in the
+			 * parent unit address cells while parsing the interrupt-map
+			 * property because they are irrelevant for interrupts mapping
+			 * in modern system.
+			 *
+			 * Leave the parent unit address initialized to 0 - just
+			 * take into account the #address-cells size to build
+			 * the property properly.
+			 */
 			mapp += addr_sz[i];
 			memcpy(mapp, out_irq[i].args,
 			       out_irq[i].args_count * sizeof(u32));
Signature · 1 line
2.48.0