From: Jon Hunter <jonathanh@nvidia.com>
To: "Thomas Gleixner" <tglx@linutronix.de>,
"Jason Cooper" <jason@lakedaemon.net>,
"Marc Zyngier" <marc.zyngier@arm.com>,
"Benoît Cousson" <bcousson@baylibre.com>,
"Tony Lindgren" <tony@atomide.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Pawel Moll" <pawel.moll@arm.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Ian Campbell" <ijc+devicetree@hellion.org.uk>,
"Kumar Gala" <galak@codeaurora.org>,
"Stephen Warren" <swarren@wwwdotorg.org>,
"Thierry Reding" <thierry.reding@gmail.com>
Cc: Kevin Hilman <khilman@kernel.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Grygorii Strashko <grygorii.strashko@ti.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Linus Walleij <linus.walleij@linaro.org>,
<linux-tegra@vger.kernel.org>, <linux-omap@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 06/15] irqdomain: Ensure type settings match for an existing mapping
Date: Thu, 17 Mar 2016 18:18:09 +0000 [thread overview]
Message-ID: <56EAF4E1.5020201@nvidia.com> (raw)
In-Reply-To: <1458224359-32665-7-git-send-email-jonathanh@nvidia.com>
On 17/03/16 14:19, Jon Hunter wrote:
> When mapping an IRQ, if a mapping already exists, then we simply return
> the virtual IRQ number. However, we do not check that the type settings
> for the existing mapping match those for the mapping that is about to be
> created. It may be unlikely that the type settings would not match, but
> check for this and don't return a valid IRQ mapping if the type settings
> do not match.
>
> WARN if the type return by irq_domain_translate() has bits outside the
> sense mask set and then clear these bits. If these bits are not cleared
> then this will cause the comparision of the type settings for an
> existing mapping to fail with that of the new mapping even if the sense
> bit themselves match. The reason being is that the existing type
> settings are read by calling irq_get_trigger_type() which will clear
> any bits outside the sense mask. This will allow us to detect irqchips
> that are not correctly clearing these bits and fix them.
>
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> ---
> kernel/irq/irqdomain.c | 59 ++++++++++++++++++++++++++++++++++++--------------
> 1 file changed, 43 insertions(+), 16 deletions(-)
>
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 3a519a01118b..0ea285baa619 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -549,6 +549,13 @@ static int irq_domain_translate(struct irq_domain *d,
> fwspec->param, fwspec->param_count,
> hwirq, type);
>
> + /*
> + * WARN if the irqchip returns a type with bits
> + * outside the sense mask set and clear these bits.
> + */
> + if (WARN_ON(*type & ~IRQ_TYPE_SENSE_MASK))
> + *type &= IRQ_TYPE_SENSE_MASK;
> +
> /* If domain has no translation, then we assume interrupt line */
> *hwirq = fwspec->param[0];
> return 0;
> @@ -570,6 +577,7 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)
> {
> struct irq_domain *domain;
> irq_hw_number_t hwirq;
> + unsigned int cur_type = IRQ_TYPE_NONE;
> unsigned int type = IRQ_TYPE_NONE;
> int virq;
>
> @@ -592,23 +600,42 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)
> if (irq_domain_translate(domain, fwspec, &hwirq, &type))
> return 0;
>
> - if (irq_domain_is_hierarchy(domain)) {
> - /*
> - * If we've already configured this interrupt,
> - * don't do it again, or hell will break loose.
> - */
> - virq = irq_find_mapping(domain, hwirq);
> - if (virq)
> - return virq;
> -
> - virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, fwspec);
> - if (virq <= 0)
> - return 0;
> + /*
> + * If we've already configured this interrupt,
> + * don't do it again, or hell will break loose.
> + */
> + virq = irq_find_mapping(domain, hwirq);
> + if (!virq) {
> + if (irq_domain_is_hierarchy(domain)) {
> + virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE,
> + fwspec);
> + if (virq <= 0)
> + return 0;
> + } else {
> + /* Create mapping */
> + virq = irq_create_mapping(domain, hwirq);
> + if (!virq)
> + return virq;
> + }
> } else {
> - /* Create mapping */
> - virq = irq_create_mapping(domain, hwirq);
> - if (!virq)
> - return virq;
> + cur_type = irq_get_trigger_type(virq);
> + }
> +
> + /*
> + * If the trigger type is not specified or matches the current
> + * trigger type then we are done so return the interrupt number.
> + */
> + if (type == IRQ_TYPE_NONE || type == cur_type)
> + return virq;
> +
> + /*
> + * If the trigger type is already set and does
> + * not match this interrupt, then return 0.
> + */
> + if (cur_type != IRQ_TYPE_NONE) {
> + pr_warn("type mismatch, failed to map hwirq-%lu for %s!\n",
> + hwirq, of_node_full_name(to_of_node(fwspec->fwnode)));
> + return 0;
If we created a new mapping and return here, then this will leak the
mapping. I will fix this. Sorry should have caught this before!
Jon
next prev parent reply other threads:[~2016-03-17 18:18 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-17 14:19 [PATCH 00/15] Add support for Tegra210 AGIC Jon Hunter
2016-03-17 14:19 ` [PATCH 01/15] ARM: tegra: Correct interrupt type for ARM TWD Jon Hunter
2016-04-01 23:25 ` Kevin Hilman
2016-04-05 14:04 ` Thierry Reding
2016-03-17 14:19 ` [PATCH 02/15] ARM: OMAP: " Jon Hunter
2016-03-18 15:41 ` Grygorii Strashko
2016-03-29 14:02 ` Jon Hunter
2016-03-30 21:23 ` Tony Lindgren
2016-03-17 14:19 ` [PATCH 03/15] irqchip/gic: Don't unnecessarily write the IRQ configuration Jon Hunter
2016-04-09 10:50 ` Marc Zyngier
2016-03-17 14:19 ` [PATCH 04/15] irqchip/gic: WARN if setting the interrupt type fails Jon Hunter
2016-03-17 14:51 ` Thomas Gleixner
2016-03-17 15:04 ` Jon Hunter
2016-03-17 15:18 ` Jason Cooper
2016-03-17 16:20 ` Jon Hunter
2016-03-18 9:20 ` Geert Uytterhoeven
2016-03-18 9:54 ` Jon Hunter
2016-03-18 10:22 ` Geert Uytterhoeven
2016-04-09 10:58 ` Marc Zyngier
2016-04-11 15:31 ` Jon Hunter
2016-04-11 15:39 ` Marc Zyngier
2016-04-12 8:50 ` Jon Hunter
2016-04-12 10:14 ` Marc Zyngier
2016-03-17 14:19 ` [PATCH 05/15] irqchip: Mask the non-type/sense bits when translating an IRQ Jon Hunter
2016-04-09 11:03 ` Marc Zyngier
2016-04-19 14:14 ` Jon Hunter
2016-04-19 14:23 ` Marc Zyngier
2016-03-17 14:19 ` [PATCH 06/15] irqdomain: Ensure type settings match for an existing mapping Jon Hunter
2016-03-17 18:18 ` Jon Hunter [this message]
2016-03-18 10:03 ` Grygorii Strashko
2016-03-18 10:33 ` Jon Hunter
2016-03-17 14:19 ` [PATCH 07/15] irqdomain: Don't set type when mapping an IRQ Jon Hunter
2016-03-17 14:55 ` Thomas Gleixner
2016-03-17 15:06 ` Jon Hunter
2016-03-17 18:19 ` Jon Hunter
2016-03-17 14:19 ` [PATCH 08/15] genirq: Add runtime power management support for IRQ chips Jon Hunter
2016-03-17 15:02 ` Marc Zyngier
2016-03-17 15:13 ` Jon Hunter
2016-03-17 15:28 ` Marc Zyngier
2016-03-22 11:46 ` Linus Walleij
2016-03-17 15:02 ` Thomas Gleixner
2016-03-17 15:46 ` Jon Hunter
2016-03-18 11:11 ` Grygorii Strashko
2016-03-18 12:27 ` Jon Hunter
2016-03-18 14:23 ` Grygorii Strashko
2016-03-18 14:40 ` Jon Hunter
2016-03-18 14:56 ` Jon Hunter
2016-03-18 17:52 ` Grygorii Strashko
2016-03-21 10:09 ` Jon Hunter
2016-03-17 14:19 ` [PATCH 09/15] irqchip/gic: Don't initialise chip if mapping IO space fails Jon Hunter
2016-04-09 11:09 ` Marc Zyngier
2016-03-17 14:19 ` [PATCH 10/15] irqchip/gic: Remove static irq_chip definition for eoimode1 Jon Hunter
2016-03-22 11:49 ` Linus Walleij
2016-04-09 11:38 ` Marc Zyngier
2016-03-17 14:19 ` [PATCH 11/15] irqchip/gic: Return an error if GIC initialisation fails Jon Hunter
2016-04-09 11:43 ` Marc Zyngier
2016-03-17 14:19 ` [PATCH 12/15] irqchip/gic: Pass GIC pointer to save/restore functions Jon Hunter
2016-04-09 11:52 ` Marc Zyngier
2016-03-17 14:19 ` [PATCH 13/15] irqchip/gic: Prepare for adding platform driver Jon Hunter
2016-03-29 13:04 ` Geert Uytterhoeven
2016-03-29 13:59 ` Jon Hunter
2016-03-17 14:19 ` [PATCH 14/15] dt-bindings: arm-gic: Drop 'clock-names' from binding document Jon Hunter
2016-03-17 20:14 ` Rob Herring
2016-03-18 8:37 ` Jon Hunter
2016-04-12 8:54 ` Jon Hunter
2016-03-18 9:13 ` Geert Uytterhoeven
2016-03-18 10:13 ` Jon Hunter
2016-03-18 10:52 ` Geert Uytterhoeven
2016-03-18 10:56 ` Jon Hunter
2016-03-18 12:05 ` Geert Uytterhoeven
2016-03-18 12:42 ` Jon Hunter
2016-03-18 12:47 ` Grygorii Strashko
2016-03-18 13:02 ` Geert Uytterhoeven
2016-03-18 18:36 ` Grygorii Strashko
2016-03-17 14:19 ` [PATCH 15/15] irqchip/gic: Add support for tegra AGIC interrupt controller Jon Hunter
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=56EAF4E1.5020201@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=bcousson@baylibre.com \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=geert@linux-m68k.org \
--cc=grygorii.strashko@ti.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jason@lakedaemon.net \
--cc=khilman@kernel.org \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=swarren@wwwdotorg.org \
--cc=tglx@linutronix.de \
--cc=thierry.reding@gmail.com \
--cc=tony@atomide.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
Powered by JetHome