Skip to contentSkip to conversation

PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup

PATCH Superseded Rosen Penev 3 participants 3 messages Jul 15

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup

Replace irq_of_parse_and_map() with fwnode_irq_get(dev_fwnode(dev), 0) in xilinx_pcie_parse_dt(). For an OF-backed device this is equivalent to the previous call, but uses the generic firmware-node API.

Unlike irq_of_parse_and_map(), fwnode_irq_get() returns a positive IRQ or a negative errno and never 0 (it rewrites 0 to -EINVAL). Store the result in an int and check for irq < 0, returning the error (including -EPROBE_DEFER). This also adds the error handling the previous code lacked, where irq_of_parse_and_map() failures were passed straight into devm_request_irq().

Built for ARM (multi_v7_defconfig + CONFIG_PCIE_XILINX) with LLVM=1; drivers/pci/controller/pcie-xilinx.o compiles cleanly.

Assisted-by opencode:hy3-free
---
 drivers/pci/controller/pcie-xilinx.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/controller/pcie-xilinx.c +6 -3
index 4aa139abac16..a7b069f7673a 100644
@@ -20,10 +20,10 @@
 #include <linux/of_address.h>
 #include <linux/of_pci.h>
 #include <linux/of_platform.h>
-#include <linux/of_irq.h>
 #include <linux/pci.h>
 #include <linux/pci-ecam.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 
 #include "../pci.h"
 
@@ -535,7 +535,7 @@ static int xilinx_pcie_parse_dt(struct xilinx_pcie *pcie)
 	struct device *dev = pcie->dev;
 	struct device_node *node = dev->of_node;
 	struct resource regs;
-	unsigned int irq;
+	int irq;
 	int err;
 
 	err = of_address_to_resource(node, 0, &regs);
@@ -548,7 +548,10 @@ static int xilinx_pcie_parse_dt(struct xilinx_pcie *pcie)
 	if (IS_ERR(pcie->reg_base))
 		return PTR_ERR(pcie->reg_base);
 
-	irq = irq_of_parse_and_map(node, 0);
+	irq = fwnode_irq_get(dev_fwnode(dev), 0);
+	if (irq < 0)
+		return irq;
+
 	err = devm_request_irq(dev, irq, xilinx_pcie_intr_handler,
 			       IRQF_SHARED | IRQF_NO_THREAD,
 			       "xilinx-pcie", pcie);
Signature · 1 line
2.55.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Missing `dev_err_probe()` causes spurious boot log spam on probe deferral. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Missing dev_err_probe() causes spurious boot log spam on probe deferral. --

--- Patch [1]: [PATCH] PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup --- commit 3b83750c982aed2e3747f9f586daf87ae00edeec
Author: Rosen Penev <[email protected]>

PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup

This commit replaces irq_of_parse_and_map() with fwnode_irq_get() in xilinx_pcie_parse_dt(). It also introduces error handling for the returned IRQ value, propagating negative errors (including -EPROBE_DEFER) up the stack instead of passing failures to devm_request_irq().

Quoted 3 lines
drivers/pci/controller/pcie-xilinx.c +0 -0

[ ... ]

drivers/pci/controller/pcie-xilinx.c static int xilinx_pcie_parse_dt(struct xilinx_pcie *pcie) · line 554

Quoted 9 lines
drivers/pci/controller/pcie-xilinx.c +4 -1
@@ -548,7 +548,10 @@ static int xilinx_pcie_parse_dt(struct xilinx_pcie *pcie)
 	if (IS_ERR(pcie->reg_base))
 		return PTR_ERR(pcie->reg_base);
 
-	irq = irq_of_parse_and_map(node, 0);
+	irq = fwnode_irq_get(dev_fwnode(dev), 0);
+	if (irq < 0)
+		return irq;
+

[Severity: Low]
Does this introduce spurious boot log spam during probe deferral?

Since fwnode_irq_get() can return -EPROBE_DEFER, returning it directly here propagates the deferral up to the caller, xilinx_pcie_probe().

In xilinx_pcie_probe(), the error is handled like this:

	err = xilinx_pcie_parse_dt(pcie);
	if (err) {
		dev_err(dev, "Parsing DT failed\n");
		return err;
	}

Would it make sense to update xilinx_pcie_probe() to use dev_err_probe() to handle the newly propagated -EPROBE_DEFER quietly?

Quoted 3 lines
drivers/pci/controller/pcie-xilinx.c +0 -0
 	err = devm_request_irq(dev, irq, xilinx_pcie_intr_handler,
 			       IRQF_SHARED | IRQF_NO_THREAD,
 			       "xilinx-pcie", pcie);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Rosen Penev
Quoted 46 lines

Replace irq_of_parse_and_map() with fwnode_irq_get(dev_fwnode(dev), 0) in xilinx_pcie_parse_dt(). For an OF-backed device this is equivalent to the previous call, but uses the generic firmware-node API.

Unlike irq_of_parse_and_map(), fwnode_irq_get() returns a positive IRQ or a negative errno and never 0 (it rewrites 0 to -EINVAL). Store the result in an int and check for irq < 0, returning the error (including -EPROBE_DEFER). This also adds the error handling the previous code lacked, where irq_of_parse_and_map() failures were passed straight into devm_request_irq().

Built for ARM (multi_v7_defconfig + CONFIG_PCIE_XILINX) with LLVM=1; drivers/pci/controller/pcie-xilinx.o compiles cleanly.

Assisted-by opencode:hy3-free
---
  drivers/pci/controller/pcie-xilinx.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/controller/pcie-xilinx.c +2 -2
index 4aa139abac16..a7b069f7673a 100644
@@ -20,10 +20,10 @@
  #include <linux/of_address.h>
  #include <linux/of_pci.h>
  #include <linux/of_platform.h>
-#include <linux/of_irq.h>
  #include <linux/pci.h>
  #include <linux/pci-ecam.h>
  #include <linux/platform_device.h>
+#include <linux/property.h>
 
  #include "../pci.h"
 
@@ -535,7 +535,7 @@ static int xilinx_pcie_parse_dt(struct xilinx_pcie *pcie)
  	struct device *dev = pcie->dev;
  	struct device_node *node = dev->of_node;
  	struct resource regs;
-	unsigned int irq;
+	int irq;
  	int err;
 
  	err = of_address_to_resource(node, 0, &regs);

drivers/pci/controller/pcie-xilinx.c static int xilinx_pcie_parse_dt(struct xilinx_pcie *pcie) · line 554

Quoted 8 lines
drivers/pci/controller/pcie-xilinx.c +3 -1
@@ -548,7 +548,10 @@ static int xilinx_pcie_parse_dt(struct xilinx_pcie *pcie)
  	if (IS_ERR(pcie->reg_base))
  		return PTR_ERR(pcie->reg_base);
 
-	irq = irq_of_parse_and_map(node, 0);
+	irq = fwnode_irq_get(dev_fwnode(dev), 0);
+	if (irq < 0)
+		return irq;
 

Thanks for the patch.
Nit - as Sashiko review mentioned better to update xilinx_pcie_probe() to use dev_err_probe() to avoid noise on defer.

Rest changes looks fine.

Thanks,
Radhey> err = devm_request_irq(dev, irq, xilinx_pcie_intr_handler,

Quoted 2 lines
drivers/pci/controller/pcie-xilinx.c +0 -0
  			       IRQF_SHARED | IRQF_NO_THREAD,
  			       "xilinx-pcie", pcie);