mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCHv2] PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup
@ 2026-07-16 20:58 Rosen Penev
  2026-07-29 16:00 ` Manivannan Sadhasivam
  0 siblings, 1 reply; 6+ messages in thread
From: Rosen Penev @ 2026-07-16 20:58 UTC (permalink / raw)
  To: linux-pci
  Cc: Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Michal Simek,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	moderated list:ARM/ZYNQ ARCHITECTURE, open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

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
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 v2: use dev_err_probe to handle EPROBE_DEFER.
 drivers/pci/controller/pcie-xilinx.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c
index 4aa139abac16..58532296182f 100644
--- a/drivers/pci/controller/pcie-xilinx.c
+++ b/drivers/pci/controller/pcie-xilinx.c
@@ -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);
@@ -585,10 +588,8 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
 	pcie->dev = dev;
 
 	err = xilinx_pcie_parse_dt(pcie);
-	if (err) {
-		dev_err(dev, "Parsing DT failed\n");
-		return err;
-	}
+	if (err)
+		return dev_err_probe(dev, err, "Parsing DT failed\n");
 
 	xilinx_pcie_init_port(pcie);
 
-- 
2.55.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2] PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup
  2026-07-16 20:58 [PATCHv2] PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup Rosen Penev
@ 2026-07-29 16:00 ` Manivannan Sadhasivam
  2026-07-29 18:18   ` Rosen Penev
  0 siblings, 1 reply; 6+ messages in thread
From: Manivannan Sadhasivam @ 2026-07-29 16:00 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-pci, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring, Bjorn Helgaas, Michal Simek, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt,
	moderated list:ARM/ZYNQ ARCHITECTURE, open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

On Thu, Jul 16, 2026 at 01:58:11PM -0700, Rosen Penev wrote:
> 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.
> 

What is the benefit of using fwnode API for OF only driver?

- Mani

> 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
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  v2: use dev_err_probe to handle EPROBE_DEFER.
>  drivers/pci/controller/pcie-xilinx.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c
> index 4aa139abac16..58532296182f 100644
> --- a/drivers/pci/controller/pcie-xilinx.c
> +++ b/drivers/pci/controller/pcie-xilinx.c
> @@ -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);
> @@ -585,10 +588,8 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
>  	pcie->dev = dev;
>  
>  	err = xilinx_pcie_parse_dt(pcie);
> -	if (err) {
> -		dev_err(dev, "Parsing DT failed\n");
> -		return err;
> -	}
> +	if (err)
> +		return dev_err_probe(dev, err, "Parsing DT failed\n");
>  
>  	xilinx_pcie_init_port(pcie);
>  
> -- 
> 2.55.0
> 

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2] PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup
  2026-07-29 16:00 ` Manivannan Sadhasivam
@ 2026-07-29 18:18   ` Rosen Penev
  2026-07-30  3:48     ` Manivannan Sadhasivam
  0 siblings, 1 reply; 6+ messages in thread
From: Rosen Penev @ 2026-07-29 18:18 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: linux-pci, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring, Bjorn Helgaas, Michal Simek, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt,
	moderated list:ARM/ZYNQ ARCHITECTURE, open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

On Wed, Jul 29, 2026 at 9:00 AM Manivannan Sadhasivam <mani@kernel.org> wrote:
>
> On Thu, Jul 16, 2026 at 01:58:11PM -0700, Rosen Penev wrote:
> > 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.
> >
>
> What is the benefit of using fwnode API for OF only driver?
I get conflicting information. Apparently of_irq_get needs a call to
irq_dispose_mapping but fwnode_irq_get does not. irq_of_parse_and_map
definitely does.
>
> - Mani
>
> > 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
> > Signed-off-by: Rosen Penev <rosenp@gmail.com>
> > ---
> >  v2: use dev_err_probe to handle EPROBE_DEFER.
> >  drivers/pci/controller/pcie-xilinx.c | 15 ++++++++-------
> >  1 file changed, 8 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c
> > index 4aa139abac16..58532296182f 100644
> > --- a/drivers/pci/controller/pcie-xilinx.c
> > +++ b/drivers/pci/controller/pcie-xilinx.c
> > @@ -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);
> > @@ -585,10 +588,8 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
> >       pcie->dev = dev;
> >
> >       err = xilinx_pcie_parse_dt(pcie);
> > -     if (err) {
> > -             dev_err(dev, "Parsing DT failed\n");
> > -             return err;
> > -     }
> > +     if (err)
> > +             return dev_err_probe(dev, err, "Parsing DT failed\n");
> >
> >       xilinx_pcie_init_port(pcie);
> >
> > --
> > 2.55.0
> >
>
> --
> மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2] PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup
  2026-07-29 18:18   ` Rosen Penev
@ 2026-07-30  3:48     ` Manivannan Sadhasivam
  2026-07-30 18:54       ` Rosen Penev
  0 siblings, 1 reply; 6+ messages in thread
From: Manivannan Sadhasivam @ 2026-07-30  3:48 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-pci, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring, Bjorn Helgaas, Michal Simek, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt,
	moderated list:ARM/ZYNQ ARCHITECTURE, open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

On Wed, Jul 29, 2026 at 11:18:15AM -0700, Rosen Penev wrote:
> On Wed, Jul 29, 2026 at 9:00 AM Manivannan Sadhasivam <mani@kernel.org> wrote:
> >
> > On Thu, Jul 16, 2026 at 01:58:11PM -0700, Rosen Penev wrote:
> > > 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.
> > >
> >
> > What is the benefit of using fwnode API for OF only driver?
> I get conflicting information. Apparently of_irq_get needs a call to
> irq_dispose_mapping but fwnode_irq_get does not.

That's not true. fwnode_irq_get() becomes a wrapper to of_irq_get() if OF is
used. So both needs a call to irq_dispose_mapping() in the error path.

- Mani

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2] PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup
  2026-07-30  3:48     ` Manivannan Sadhasivam
@ 2026-07-30 18:54       ` Rosen Penev
  2026-08-03 15:28         ` Manivannan Sadhasivam
  0 siblings, 1 reply; 6+ messages in thread
From: Rosen Penev @ 2026-07-30 18:54 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: linux-pci, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring, Bjorn Helgaas, Michal Simek, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt,
	moderated list:ARM/ZYNQ ARCHITECTURE, open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

On Wed, Jul 29, 2026 at 8:48 PM Manivannan Sadhasivam <mani@kernel.org> wrote:
>
> On Wed, Jul 29, 2026 at 11:18:15AM -0700, Rosen Penev wrote:
> > On Wed, Jul 29, 2026 at 9:00 AM Manivannan Sadhasivam <mani@kernel.org> wrote:
> > >
> > > On Thu, Jul 16, 2026 at 01:58:11PM -0700, Rosen Penev wrote:
> > > > 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.
> > > >
> > >
> > > What is the benefit of using fwnode API for OF only driver?
> > I get conflicting information. Apparently of_irq_get needs a call to
> > irq_dispose_mapping but fwnode_irq_get does not.
>
> That's not true. fwnode_irq_get() becomes a wrapper to of_irq_get() if OF is
> used. So both needs a call to irq_dispose_mapping() in the error path.
I don't see  irq_dispose_mapping() for fwnode_irq_get() in the codebase.
>
> - Mani
>
> --
> மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2] PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup
  2026-07-30 18:54       ` Rosen Penev
@ 2026-08-03 15:28         ` Manivannan Sadhasivam
  0 siblings, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2026-08-03 15:28 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-pci, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring, Bjorn Helgaas, Michal Simek, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt,
	moderated list:ARM/ZYNQ ARCHITECTURE, open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

On Thu, Jul 30, 2026 at 11:54:29AM -0700, Rosen Penev wrote:
> On Wed, Jul 29, 2026 at 8:48 PM Manivannan Sadhasivam <mani@kernel.org> wrote:
> >
> > On Wed, Jul 29, 2026 at 11:18:15AM -0700, Rosen Penev wrote:
> > > On Wed, Jul 29, 2026 at 9:00 AM Manivannan Sadhasivam <mani@kernel.org> wrote:
> > > >
> > > > On Thu, Jul 16, 2026 at 01:58:11PM -0700, Rosen Penev wrote:
> > > > > 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.
> > > > >
> > > >
> > > > What is the benefit of using fwnode API for OF only driver?
> > > I get conflicting information. Apparently of_irq_get needs a call to
> > > irq_dispose_mapping but fwnode_irq_get does not.
> >
> > That's not true. fwnode_irq_get() becomes a wrapper to of_irq_get() if OF is
> > used. So both needs a call to irq_dispose_mapping() in the error path.
> I don't see  irq_dispose_mapping() for fwnode_irq_get() in the codebase.

That doesn't matter. You need to check with irqchip maintainers and see if those
drivers need fix or not.

- Mani

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-03 15:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-16 20:58 [PATCHv2] PCI: xilinx: use fwnode_irq_get() for INTx IRQ lookup Rosen Penev
2026-07-29 16:00 ` Manivannan Sadhasivam
2026-07-29 18:18   ` Rosen Penev
2026-07-30  3:48     ` Manivannan Sadhasivam
2026-07-30 18:54       ` Rosen Penev
2026-08-03 15:28         ` Manivannan Sadhasivam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®