mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Burton <paul.burton@imgtec.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	jeffy <jeffy.chen@rock-chips.com>,
	Brian Norris <briannorris@chromium.org>,
	Marc Zyngier <marc.zyngier@arm.com>, <dianders@chromium.org>,
	<tfiga@chromium.org>, <james.hogan@imgtec.com>
Subject: Re: [2/2] genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts
Date: Wed, 6 Sep 2017 07:01:54 -0700	[thread overview]
Message-ID: <2582391.E0BmZJ6Wil@np-p-burton> (raw)
In-Reply-To: <alpine.DEB.2.20.1709061009180.1843@nanos>

[-- Attachment #1: Type: text/plain, Size: 3257 bytes --]

Hi Thomas,

On Wednesday, 6 September 2017 01:16:48 PDT Thomas Gleixner wrote:
> On Tue, 5 Sep 2017, Paul Burton wrote:
> > I'm currently attempting to clean up a hack that we have in the MIPS GIC
> > irqchip driver - we have some interrupts which are really per-CPU, but are
> > currently used with the regular non-per-CPU IRQ APIs. Please search for
> > usage of gic_all_vpes_local_irq_controller (or for the string "HACK") in
> > drivers/ irqchip/irq-mips-gic.c if you wish to find what I'm talking
> > about. The important details are that the interrupts in question are both
> > per-CPU and on many systems are shared (between the CPU timer,
> > performance counters & fast debug channel).
> > 
> > I have been attempting to move towards using the per-CPU APIs instead in
> > order to remove this hack - ie. using setup_percpu_irq() &
> > enable_percpu_irq() in> 
> > place of plain old setup_irq(). Unfortunately what I've run into is this:
> >   - Per-CPU interrupts get the IRQ_NOAUTOEN flag set by default, in
> >   
> >     irq_set_percpu_devid_flags(). I can see why this makes sense in the
> >     general case, since the alternative is setup_percpu_irq() enabling the
> >     interrupt on the CPU that calls it & leaving it disabled on others,
> >     which
> >     feels a little unclean.
> >   
> >   - Your warning above triggers when a shared interrupt has the
> >   IRQ_NOAUTOEN
> >   
> >     flag set. I can see why your warning makes sense if another driver has
> >     already enabled the shared interrupt, which would make IRQ_NOAUTOEN
> >     ineffective. I'm not sure I follow your comment above the warning
> >     though -
> >     it sounds like you're trying to describe something else?
> > > 
> > > +			/*
> > > +			 * Shared interrupts do not go well with disabling
> > > +			 * auto enable. The sharing interrupt might request
> > > +			 * it while it's still disabled and then wait for
> > > +			 * interrupts forever.
> > > +			 */
> 
> Assume the following:
> 
>        request_irq(X, handler1, NOAUTOEN|SHARED, dev1);
> 
> now the second device does:
> 
>        request_irq(X, handler2, SHARED, dev2):
> 
> which will see the first handler installed, so it wont run into the code
> path which starts up the interrupt. That means as long as dev1 does not
> explicitely enable the interrupt dev2 will wait for it forever.

Ok, makes sense.

> > For my interrupts which are both per-CPU & shared the combination of these
> > 2> 
> > facts mean I end up triggering your warning. My current ideas include:
> >   - I could clear the IRQ_NOAUTOEN flag before calling setup_percpu_irq().
> >   In
> >   
> >     my cases that should be fine - we call enable_percpu_irq() anyway, and
> >     would just enable the IRQ slightly earlier on the CPU which calls
> >     setup_percpu_irq() which wouldn't be a problem. It feels a bit yucky
> >     though.
> 
> What's the problem with IRQ_NOAUTOEN and do
> 
>        setup_percpu_irq();
>        enable_percpu_irq();
> 
> on the boot CPU and then later call it when the secondary CPUs come up in
> cpu bringup code or a hotplug state callback?

There's no problem with that at all, apart from that it triggers your warning 
when the boot CPU calls setup_percpu_irq().

Thanks,
    Paul

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-09-06 14:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-31  9:58 [patch 0/2] genirq: Handle NOAUTOEN interrupts correctly Thomas Gleixner
2017-05-31  9:58 ` [patch 1/2] genirq: Handle NOAUTOEN interrupt setup proper Thomas Gleixner
2017-05-31 13:54   ` Marc Zyngier
2017-05-31 15:18     ` Thomas Gleixner
2017-06-04 12:47   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2017-05-31  9:58 ` [patch 2/2] genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts Thomas Gleixner
2017-06-04 12:48   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2017-09-06  6:00   ` [2/2] " Paul Burton
2017-09-06  8:16     ` Thomas Gleixner
2017-09-06 14:01       ` Paul Burton [this message]
2017-09-06 14:14         ` Thomas Gleixner
2017-09-07  1:18           ` Paul Burton
2017-09-07 23:25             ` [RFC PATCH v1 0/9] Support shared percpu interrupts; clean up MIPS hacks Paul Burton
2017-09-07 23:25               ` [RFC PATCH v1 1/9] genirq: Allow shared interrupt users to opt into IRQ_NOAUTOEN Paul Burton
2017-09-07 23:25               ` [RFC PATCH v1 2/9] genirq: Support shared per_cpu_devid interrupts Paul Burton
2017-09-25 21:06                 ` Thomas Gleixner
2017-09-26 12:00                   ` Thomas Gleixner
2017-10-19 14:08                     ` Thomas Gleixner
2017-09-07 23:25               ` [RFC PATCH v1 3/9] genirq: Introduce irq_is_percpu_devid() Paul Burton
2017-09-07 23:25               ` [RFC PATCH v1 4/9] MIPS: Remove perf_irq interrupt sharing fallback Paul Burton
2017-09-07 23:25               ` [RFC PATCH v1 5/9] MIPS: Remove perf_irq Paul Burton
2017-09-07 23:25               ` [RFC PATCH v1 6/9] MIPS: perf: percpu_devid interrupt support Paul Burton
2017-10-19 14:12                 ` Thomas Gleixner
2017-09-07 23:25               ` [RFC PATCH v1 7/9] MIPS: cevt-r4k: " Paul Burton
2017-09-07 23:25               ` [RFC PATCH v1 8/9] irqchip: mips-cpu: Set timer, FDC & perf interrupts percpu_devid Paul Burton
2017-09-07 23:25               ` [RFC PATCH v1 9/9] irqchip: mips-gic: Remove gic_all_vpes_local_irq_controller Paul Burton

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=2582391.E0BmZJ6Wil@np-p-burton \
    --to=paul.burton@imgtec.com \
    --cc=briannorris@chromium.org \
    --cc=dianders@chromium.org \
    --cc=james.hogan@imgtec.com \
    --cc=jeffy.chen@rock-chips.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=tfiga@chromium.org \
    --cc=tglx@linutronix.de \
    /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®