diff mbox series

[v2,17/19] PCI: of_property: Add interrupt-controller property in PCI device nodes

Message ID 20240527161450.326615-18-herve.codina@bootlin.com (mailing list archive)
State Not Applicable
Headers show
Series Add support for the LAN966x PCI device using a DT overlay | expand

Checks

Context Check Description
netdev/series_format fail Series longer than 15 patches
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 904 this patch: 904
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 2 of 2 maintainers
netdev/build_clang success Errors and warnings before: 906 this patch: 906
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 908 this patch: 908
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Herve Codina May 27, 2024, 4:14 p.m. UTC
PCI devices and bridges DT nodes created during the PCI scan are created
with the interrupt-map property set to handle interrupts.

In order to set this interrupt-map property at a specific level, a
phandle to the parent interrupt controller is needed. On systems that
are not fully described by a device-tree, the parent interrupt
controller may be unavailable (i.e. not described by the device-tree).

As mentioned in the [1], avoiding the use of the interrupt-map property
and considering a PCI device as an interrupt controller itself avoid the
use of a parent interrupt phandle.

In that case, the PCI device itself as an interrupt controller is
responsible for routing the interrupts described in the device-tree
world (DT overlay) to the PCI interrupts.

Add the 'interrupt-controller' property in the PCI device DT node.

[1]: https://lore.kernel.org/lkml/CAL_Jsq+je7+9ATR=B6jXHjEJHjn24vQFs4Tvi9=vhDeK9n42Aw@mail.gmail.com/

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
 drivers/pci/of_property.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Bjorn Helgaas June 6, 2024, 7:26 p.m. UTC | #1
On Mon, May 27, 2024 at 06:14:44PM +0200, Herve Codina wrote:
> PCI devices and bridges DT nodes created during the PCI scan are created
> with the interrupt-map property set to handle interrupts.
> 
> In order to set this interrupt-map property at a specific level, a
> phandle to the parent interrupt controller is needed. On systems that
> are not fully described by a device-tree, the parent interrupt
> controller may be unavailable (i.e. not described by the device-tree).
> 
> As mentioned in the [1], avoiding the use of the interrupt-map property
> and considering a PCI device as an interrupt controller itself avoid the
> use of a parent interrupt phandle.
> 
> In that case, the PCI device itself as an interrupt controller is
> responsible for routing the interrupts described in the device-tree
> world (DT overlay) to the PCI interrupts.
> 
> Add the 'interrupt-controller' property in the PCI device DT node.
> 
> [1]: https://lore.kernel.org/lkml/CAL_Jsq+je7+9ATR=B6jXHjEJHjn24vQFs4Tvi9=vhDeK9n42Aw@mail.gmail.com/
> 
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>

No objection from me, but I'd like an ack/review from Rob.

> ---
>  drivers/pci/of_property.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c
> index 03539e505372..5a0b98e69795 100644
> --- a/drivers/pci/of_property.c
> +++ b/drivers/pci/of_property.c
> @@ -183,6 +183,26 @@ static int of_pci_prop_interrupts(struct pci_dev *pdev,
>  	return of_changeset_add_prop_u32(ocs, np, "interrupts", (u32)pin);
>  }
>  
> +static int of_pci_prop_intr_ctrl(struct pci_dev *pdev, struct of_changeset *ocs,
> +				 struct device_node *np)
> +{
> +	int ret;
> +	u8 pin;
> +
> +	ret = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
> +	if (ret != 0)
> +		return ret;
> +
> +	if (!pin)
> +		return 0;
> +
> +	ret = of_changeset_add_prop_u32(ocs, np, "#interrupt-cells", 1);
> +	if (ret)
> +		return ret;
> +
> +	return of_changeset_add_prop_bool(ocs, np, "interrupt-controller");
> +}
> +
>  static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
>  				struct device_node *np)
>  {
> @@ -336,6 +356,10 @@ int of_pci_add_properties(struct pci_dev *pdev, struct of_changeset *ocs,
>  		ret = of_pci_prop_intr_map(pdev, ocs, np);
>  		if (ret)
>  			return ret;
> +	} else {
> +		ret = of_pci_prop_intr_ctrl(pdev, ocs, np);
> +		if (ret)
> +			return ret;
>  	}
>  
>  	ret = of_pci_prop_ranges(pdev, ocs, np);
> -- 
> 2.45.0
>
Rob Herring (Arm) June 10, 2024, 9:37 p.m. UTC | #2
On Thu, Jun 06, 2024 at 02:26:12PM -0500, Bjorn Helgaas wrote:
> On Mon, May 27, 2024 at 06:14:44PM +0200, Herve Codina wrote:
> > PCI devices and bridges DT nodes created during the PCI scan are created
> > with the interrupt-map property set to handle interrupts.
> > 
> > In order to set this interrupt-map property at a specific level, a
> > phandle to the parent interrupt controller is needed. On systems that
> > are not fully described by a device-tree, the parent interrupt
> > controller may be unavailable (i.e. not described by the device-tree).
> > 
> > As mentioned in the [1], avoiding the use of the interrupt-map property
> > and considering a PCI device as an interrupt controller itself avoid the
> > use of a parent interrupt phandle.
> > 
> > In that case, the PCI device itself as an interrupt controller is
> > responsible for routing the interrupts described in the device-tree
> > world (DT overlay) to the PCI interrupts.
> > 
> > Add the 'interrupt-controller' property in the PCI device DT node.
> > 
> > [1]: https://lore.kernel.org/lkml/CAL_Jsq+je7+9ATR=B6jXHjEJHjn24vQFs4Tvi9=vhDeK9n42Aw@mail.gmail.com/
> > 
> > Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> 
> No objection from me, but I'd like an ack/review from Rob.

Given it is more DT patches in the series, how about I take them and 
this one with your ack instead?

Rob
Bjorn Helgaas June 11, 2024, 5:13 p.m. UTC | #3
On Mon, Jun 10, 2024 at 03:37:35PM -0600, Rob Herring wrote:
> On Thu, Jun 06, 2024 at 02:26:12PM -0500, Bjorn Helgaas wrote:
> > On Mon, May 27, 2024 at 06:14:44PM +0200, Herve Codina wrote:
> > > PCI devices and bridges DT nodes created during the PCI scan are created
> > > with the interrupt-map property set to handle interrupts.
> > > 
> > > In order to set this interrupt-map property at a specific level, a
> > > phandle to the parent interrupt controller is needed. On systems that
> > > are not fully described by a device-tree, the parent interrupt
> > > controller may be unavailable (i.e. not described by the device-tree).
> > > 
> > > As mentioned in the [1], avoiding the use of the interrupt-map property
> > > and considering a PCI device as an interrupt controller itself avoid the
> > > use of a parent interrupt phandle.
> > > 
> > > In that case, the PCI device itself as an interrupt controller is
> > > responsible for routing the interrupts described in the device-tree
> > > world (DT overlay) to the PCI interrupts.
> > > 
> > > Add the 'interrupt-controller' property in the PCI device DT node.
> > > 
> > > [1]: https://lore.kernel.org/lkml/CAL_Jsq+je7+9ATR=B6jXHjEJHjn24vQFs4Tvi9=vhDeK9n42Aw@mail.gmail.com/
> > > 
> > > Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> > 
> > No objection from me, but I'd like an ack/review from Rob.
> 
> Given it is more DT patches in the series, how about I take them and 
> this one with your ack instead?

Sure.  There's very little PCI content here, so I didn't plan to take
them; I just thought this needed at least your ack :)

Acked-by: Bjorn Helgaas <bhelgaas@google.com>
diff mbox series

Patch

diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c
index 03539e505372..5a0b98e69795 100644
--- a/drivers/pci/of_property.c
+++ b/drivers/pci/of_property.c
@@ -183,6 +183,26 @@  static int of_pci_prop_interrupts(struct pci_dev *pdev,
 	return of_changeset_add_prop_u32(ocs, np, "interrupts", (u32)pin);
 }
 
+static int of_pci_prop_intr_ctrl(struct pci_dev *pdev, struct of_changeset *ocs,
+				 struct device_node *np)
+{
+	int ret;
+	u8 pin;
+
+	ret = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
+	if (ret != 0)
+		return ret;
+
+	if (!pin)
+		return 0;
+
+	ret = of_changeset_add_prop_u32(ocs, np, "#interrupt-cells", 1);
+	if (ret)
+		return ret;
+
+	return of_changeset_add_prop_bool(ocs, np, "interrupt-controller");
+}
+
 static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
 				struct device_node *np)
 {
@@ -336,6 +356,10 @@  int of_pci_add_properties(struct pci_dev *pdev, struct of_changeset *ocs,
 		ret = of_pci_prop_intr_map(pdev, ocs, np);
 		if (ret)
 			return ret;
+	} else {
+		ret = of_pci_prop_intr_ctrl(pdev, ocs, np);
+		if (ret)
+			return ret;
 	}
 
 	ret = of_pci_prop_ranges(pdev, ocs, np);