diff mbox

[RFC,v8,4/7] of/irq: Adjust of pci irq parsing for multiple interrupts

Message ID 20171026132840.20946-5-jeffy.chen@rock-chips.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Jeffy Chen Oct. 26, 2017, 1:28 p.m. UTC
Currently we are considering the first irq as the PCI interrupt pin,
but a pci device may have multiple interrupts(e.g. PCIe WAKE# pin).

Only parse the PCI interrupt pin when the irq is unnamed or named as
"pci".

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v3: None
Changes in v2: None

 drivers/of/of_pci_irq.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Rob Herring Oct. 26, 2017, 8:02 p.m. UTC | #1
On Thu, Oct 26, 2017 at 8:28 AM, Jeffy Chen <jeffy.chen@rock-chips.com> wrote:
> Currently we are considering the first irq as the PCI interrupt pin,
> but a pci device may have multiple interrupts(e.g. PCIe WAKE# pin).
>
> Only parse the PCI interrupt pin when the irq is unnamed or named as
> "pci".

Why do you need this patch? You're moving the wakeup handling from the
PCI device to the bridge. The bridge device is not PCI interrupts, but
a platform device so this function doesn't matter.

Rob
Jeffy Chen Oct. 27, 2017, 2:05 a.m. UTC | #2
Hi Rob,

On 10/27/2017 04:02 AM, Rob Herring wrote:
> Why do you need this patch? You're moving the wakeup handling from the
> PCI device to the bridge. The bridge device is not PCI interrupts, but
> a platform device so this function doesn't matter.
>

because it's possible we have multiple PCI devices with individual WAKE# 
interrupt.

so Brian suggested we may need to support both of PCI device wakeup 
handling and the bridge wakeup handling in the pci core(as the ACPI) :)

> Rob
>
>
>
Rob Herring (Arm) Oct. 27, 2017, 2:38 p.m. UTC | #3
On Thu, Oct 26, 2017 at 09:28:37PM +0800, Jeffy Chen wrote:
> Currently we are considering the first irq as the PCI interrupt pin,
> but a pci device may have multiple interrupts(e.g. PCIe WAKE# pin).
> 
> Only parse the PCI interrupt pin when the irq is unnamed or named as
> "pci".
> 
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> ---
> 
> Changes in v8: None
> Changes in v7: None
> Changes in v6: None
> Changes in v5: None
> Changes in v3: None
> Changes in v2: None
> 
>  drivers/of/of_pci_irq.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c
> index 3a05568f65df..8b69211f0b88 100644
> --- a/drivers/of/of_pci_irq.c
> +++ b/drivers/of/of_pci_irq.c
> @@ -27,7 +27,18 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
>  	 */
>  	dn = pci_device_to_OF_node(pdev);
>  	if (dn) {
> -		rc = of_irq_parse_one(dn, 0, out_irq);
> +		struct property *prop;
> +		const char *name;
> +		int index = 0;
> +
> +		prop = of_find_property(dn, "interrupt-names", NULL);
> +		for (name = of_prop_next_string(prop, NULL); name;
> +		     name = of_prop_next_string(prop, name), index++) {
> +			if (!strcmp(name, "pci"))
> +				break;

Use of_property_match_string

> +		}
> +
> +		rc = of_irq_parse_one(dn, index, out_irq);
>  		if (!rc)
>  			return rc;
>  	}
> -- 
> 2.11.0
> 
>
Jeffy Chen Oct. 30, 2017, 2:05 a.m. UTC | #4
Hi Rob,

On 10/27/2017 10:38 PM, Rob Herring wrote:
>> +		prop = of_find_property(dn, "interrupt-names", NULL);
>> >+		for (name = of_prop_next_string(prop, NULL); name;
>> >+		     name = of_prop_next_string(prop, name), index++) {
>> >+			if (!strcmp(name, "pci"))
>> >+				break;
> Use of_property_match_string
>
i'm trying to find the first unnamed or "pci" named irq in the string 
array, so cannot use that API:)

but will change to of_property_for_each_string as Brian suggested.
Brian Norris Oct. 30, 2017, 6:46 p.m. UTC | #5
On Mon, Oct 30, 2017 at 10:05:51AM +0800, Jeffy Chen wrote:
> On 10/27/2017 10:38 PM, Rob Herring wrote:
> >>+		prop = of_find_property(dn, "interrupt-names", NULL);
> >>>+		for (name = of_prop_next_string(prop, NULL); name;
> >>>+		     name = of_prop_next_string(prop, name), index++) {
> >>>+			if (!strcmp(name, "pci"))
> >>>+				break;
> >Use of_property_match_string
> >
> i'm trying to find the first unnamed or "pci" named irq in the
> string array, so cannot use that API:)

Actually, why can't you? It does exactly what your loop does right now.
You'd just need to handle the -ENODATA case better. e.g., check if we
have an interrupt-names property -- if not, just take index 0; if so,
then use of_property_match_string().

Brian

> but will change to of_property_for_each_string as Brian suggested.
>
diff mbox

Patch

diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c
index 3a05568f65df..8b69211f0b88 100644
--- a/drivers/of/of_pci_irq.c
+++ b/drivers/of/of_pci_irq.c
@@ -27,7 +27,18 @@  int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
 	 */
 	dn = pci_device_to_OF_node(pdev);
 	if (dn) {
-		rc = of_irq_parse_one(dn, 0, out_irq);
+		struct property *prop;
+		const char *name;
+		int index = 0;
+
+		prop = of_find_property(dn, "interrupt-names", NULL);
+		for (name = of_prop_next_string(prop, NULL); name;
+		     name = of_prop_next_string(prop, name), index++) {
+			if (!strcmp(name, "pci"))
+				break;
+		}
+
+		rc = of_irq_parse_one(dn, index, out_irq);
 		if (!rc)
 			return rc;
 	}