From: "Sverdlin, Alexander (Nokia - DE/Ulm)" <alexander.sverdlin@nokia.com>
To: Marc Zyngier <maz@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Grant Likely <grant.likely@secretlab.ca>
Cc: "Sverdlin,
Alexander (Nokia - DE/Ulm)" <alexander.sverdlin@nokia.com>,
Mark Brown <broonie@kernel.org>,
Jon Hunter <jonathanh@nvidia.com>,
"Glavinic-Pecotic,
Matija (EXT - DE/Ulm)" <matija.glavinic-pecotic.ext@nokia.com>,
"Adamski,
Krzysztof (Nokia - PL/Wroclaw)" <krzysztof.adamski@nokia.com>,
"Bachorski,
Tomasz (Nokia - PL/Wroclaw)" <tomasz.bachorski@nokia.com>,
"Kosnikowski,
Wojciech (Nokia - PL/Wroclaw)" <wojciech.kosnikowski@nokia.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: [PATCH v2 2/3] genirq/irqdomain: Re-check mapping after associate in irq_create_mapping()
Date: Fri, 27 Sep 2019 15:00:44 +0000 [thread overview]
Message-ID: <20190927150025.26481-3-alexander.sverdlin@nokia.com> (raw)
In-Reply-To: <20190927150025.26481-1-alexander.sverdlin@nokia.com>
From: Alexander Sverdlin <alexander.sverdlin@nokia.com>
If two irq_create_mapping() calls perform a mapping of the same hwirq on
two CPU cores in parallel they both will get 0 from irq_find_mapping(),
both will allocate unique virq using irq_domain_alloc_descs() and both
will finally irq_domain_associate() it. Giving different virq numbers
to their callers.
In practice the first caller is usually an interrupt controller driver and
the seconds is some device requesting the interrupt providede by the above
interrupt controller.
In this case either the interrupt controller driver configures virq which
is not the one being "associated" with hwirq, or the "slave" device
requests the virq which is never being triggered.
Reported-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Reported-by: Tomasz Bachorski <tomasz.bachorski@nokia.com>
Reported-by: Wojciech Kosnikowski <wojciech.kosnikowski@nokia.com>
Cc: stable@vger.kernel.org
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
---
kernel/irq/irqdomain.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index ccbb048..ad62c08 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -661,6 +661,7 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
{
struct device_node *of_node;
int virq;
+ int ret;
pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq);
@@ -675,13 +676,6 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
of_node = irq_domain_get_of_node(domain);
- /* Check if mapping already exists */
- virq = irq_find_mapping(domain, hwirq);
- if (virq) {
- pr_debug("-> existing mapping on virq %d\n", virq);
- return virq;
- }
-
/* Allocate a virtual interrupt number */
virq = irq_domain_alloc_descs(-1, 1, hwirq, of_node_to_nid(of_node), NULL);
if (virq <= 0) {
@@ -689,8 +683,11 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
return 0;
}
- if (irq_domain_associate(domain, virq, hwirq)) {
+ ret = irq_domain_associate(domain, virq, hwirq);
+ if (ret) {
irq_free_desc(virq);
+ if (ret == -EEXIST)
+ return irq_find_mapping(domain, hwirq);
return 0;
}
--
2.4.6
next prev parent reply other threads:[~2019-09-27 15:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 15:00 [PATCH v2 0/3] Fix irq_domain vs. irq user race Sverdlin, Alexander (Nokia - DE/Ulm)
2019-09-27 15:00 ` [PATCH v2 1/3] genirq/irqdomain: Check for existing mapping in irq_domain_associate() Sverdlin, Alexander (Nokia - DE/Ulm)
2019-09-27 15:00 ` Sverdlin, Alexander (Nokia - DE/Ulm) [this message]
2019-09-27 15:00 ` [PATCH v2 3/3] genirq/irqdomain: Detect type race in irq_create_fwspec_mapping() Sverdlin, Alexander (Nokia - DE/Ulm)
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=20190927150025.26481-3-alexander.sverdlin@nokia.com \
--to=alexander.sverdlin@nokia.com \
--cc=broonie@kernel.org \
--cc=grant.likely@secretlab.ca \
--cc=jonathanh@nvidia.com \
--cc=krzysztof.adamski@nokia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matija.glavinic-pecotic.ext@nokia.com \
--cc=maz@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tomasz.bachorski@nokia.com \
--cc=wojciech.kosnikowski@nokia.com \
/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
all inboxes | Powered by JetHome®