From: Ryder Lee <ryder.lee-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
To: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Bjorn Helgaas <bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: Frank Rowand
<frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Benjamin Herrenschmidt
<benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>,
Lorenzo Pieralisi
<lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>,
linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Ryder Lee <ryder.lee-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Subject: [PATCH 1/2] of_pci_irq: add a check to fallback to standard device tree parsing
Date: Wed, 31 Jan 2018 15:41:49 +0800 [thread overview]
Message-ID: <31c765c53e85e41bfc001d110d69e46c9967f4e7.1516961656.git.ryder.lee@mediatek.com> (raw)
A root complex usually consist of a host bridge and multiple P2P bridges,
and someone may express that in the form of a root node with many subnodes
and list all four interrupts for each slot (child node) in the root node
like this:
pcie-controller {
...
interrupt-map-mask = <0xf800 0 0 7>;
interrupt-map = <0x0000 0 0 {INTx} &{interrupt parent} ...>
0x0800 0 0 {INTx} &{interrupt parent} ...>;
pcie@0,0 {
reg = <0x0000 0 0 0 0>;
...
};
pcie@1,0 {
reg = <0x0800 0 0 0 0>;
...
};
};
As shown above, we'd like to propagate IRQs from a root port to the devices
in the hierarchy below it in this way. However, it seems that the current
parser couldn't handle such cases and will get something unexpected below:
pcieport 0000:00:01.0: assign IRQ: got 213
igb 0000:01:00.0: assign IRQ: got 212
There is a device which is connected to 2nd slot, but the port doesn't share
the same IRQ with its downstream devices. The problem here is that, if the
loop found a P2P bridge, it wouldn't check whether the reg property exists
in ppnode or not but just pass the subordinate devfn to of_irq_parse_raw(),
thus the subsequent flow couldn't correctly resolve them.
Fix this by adding a check to fallback to standard device tree parsing.
Signed-off-by: Ryder Lee <ryder.lee-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
Please refer to the previous discussion thread: https://patchwork.ozlabs.org/patch/829108/
---
drivers/of/of_pci_irq.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c
index 3a05568..e445866 100644
--- a/drivers/of/of_pci_irq.c
+++ b/drivers/of/of_pci_irq.c
@@ -86,8 +86,18 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
out_irq->np = ppnode;
out_irq->args_count = 1;
out_irq->args[0] = pin;
- laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8));
- laddr[1] = laddr[2] = cpu_to_be32(0);
+
+ if (!dn && ppnode) {
+ const __be32 *addr;
+
+ addr = of_get_property(ppnode, "reg", NULL);
+ if (addr)
+ memcpy(laddr, addr, 3);
+ } else {
+ laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8));
+ laddr[1] = laddr[2] = cpu_to_be32(0);
+ }
+
rc = of_irq_parse_raw(laddr, out_irq);
if (rc)
goto err;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2018-01-31 7:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-31 7:41 Ryder Lee [this message]
2018-01-31 7:41 ` [PATCH 2/2] dt-bindings: PCI: MediaTek: Correct the interrupt-map properties Ryder Lee
2018-02-05 6:08 ` Rob Herring
2018-02-07 12:43 ` Ryder Lee
[not found] ` <31c765c53e85e41bfc001d110d69e46c9967f4e7.1516961656.git.ryder.lee-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2018-01-31 16:02 ` [PATCH 1/2] of_pci_irq: add a check to fallback to standard device tree parsing Rob Herring
2018-02-02 9:32 ` Ryder Lee
2018-02-05 21:36 ` Benjamin Herrenschmidt
2018-02-06 2:38 ` Ryder Lee
2018-02-06 4:05 ` Benjamin Herrenschmidt
[not found] ` <1517889903.2312.151.camel-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2018-02-06 4:31 ` Ryder Lee
2018-02-06 4:50 ` Benjamin Herrenschmidt
2018-02-06 5:42 ` Ryder Lee
2018-02-06 22:31 ` Benjamin Herrenschmidt
[not found] ` <1517956309.2312.172.camel-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2018-02-07 1:58 ` Ryder Lee
2018-03-15 17:43 ` Lorenzo Pieralisi
2018-03-16 0:58 ` Ryder Lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=31c765c53e85e41bfc001d110d69e46c9967f4e7.1516961656.git.ryder.lee@mediatek.com \
--to=ryder.lee-nus5lvnupcjwk0htik3j/w@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org \
--cc=bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).