From: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
To: Peter Rosin <peda-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Hartmut Knaack <knaack.h-Mmb7MZpHnFY@public.gmane.org>,
Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>,
Peter Meerwald-Stadler
<pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Daniel Baluta
<daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Slawomir Stepien <sst-IjDXvh/HVVUAvxtiuMwx3w@public.gmane.org>,
linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v4 8/8] iio: envelope-detector: ADC driver based on a DAC and a comparator
Date: Tue, 8 Nov 2016 22:47:00 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.20.1611082146560.3501@nanos> (raw)
In-Reply-To: <1c104a31-6c66-9537-9b90-ede58c8e1a92-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
On Tue, 8 Nov 2016, Peter Rosin wrote:
> So, to sum up, in order for this to work with threaded oneshot
> interrupts, I still need to either keep the enable/sync/enable-dance
> or tweak the irq core to handle my case better. The only gain would
> be that I could fire the next step of the search from the threaded
> irq handler directly (but it needs some new race-killing code).
> Or am I missing something? If not, there's no pressing reason to
> switch to threaded oneshot interrupts, right?
There is no pressing reason, but that misfire prevention dance looks
fragile and overly complex to me.
The completely untested patch below should block the replay for edge
interrupts from the core code. It also makes sure that the edge interrupt
is masked until the thread handler returns. All you have to do is
requesting your threaded handler with IRQF_ONESHOT | IRQF_NO_REPLAY.
I don't think you need extra race handling with that, but I might be wrong
as usual.
Thanks,
tglx
8<------------------
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -74,6 +74,7 @@
#define IRQF_NO_THREAD 0x00010000
#define IRQF_EARLY_RESUME 0x00020000
#define IRQF_COND_SUSPEND 0x00040000
+#define IRQF_NO_REPLAY 0x00080000
#define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -57,6 +57,7 @@ enum {
IRQS_WAITING = 0x00000080,
IRQS_PENDING = 0x00000200,
IRQS_SUSPENDED = 0x00000800,
+ IRQS_NO_REPLAY = 0x00001000,
};
#include "debug.h"
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1212,7 +1212,8 @@ static int
*/
if (!((old->flags & new->flags) & IRQF_SHARED) ||
((old->flags ^ new->flags) & IRQF_TRIGGER_MASK) ||
- ((old->flags ^ new->flags) & IRQF_ONESHOT))
+ ((old->flags ^ new->flags) & IRQF_ONESHOT) ||
+ ((old->flags ^ new->flags) & IRQF_NO_REPLAY))
goto mismatch;
/* All handlers must agree on per-cpuness */
@@ -1324,6 +1325,9 @@ static int
if (new->flags & IRQF_ONESHOT)
desc->istate |= IRQS_ONESHOT;
+ if (new->flags & IRQF_NO_REPLAY)
+ desc->istate |= IRQS_NO_REPLAY;
+
if (irq_settings_can_autoenable(desc))
irq_startup(desc, true);
else
--- a/kernel/irq/resend.c
+++ b/kernel/irq/resend.c
@@ -56,12 +56,12 @@ static DECLARE_TASKLET(resend_tasklet, r
void check_irq_resend(struct irq_desc *desc)
{
/*
- * We do not resend level type interrupts. Level type
- * interrupts are resent by hardware when they are still
- * active. Clear the pending bit so suspend/resume does not
- * get confused.
+ * We do not resend level type interrupts. Level type interrupts
+ * are resent by hardware when they are still active. Also prevent
+ * resend when the user requested so. Clear the pending bit so
+ * suspend/resume does not get confused.
*/
- if (irq_settings_is_level(desc)) {
+ if (irq_settings_is_level(desc) || (desc->istate & IRQS_NO_REPLAY)) {
desc->istate &= ~IRQS_PENDING;
return;
}
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -643,7 +643,10 @@ void handle_edge_irq(struct irq_desc *de
kstat_incr_irqs_this_cpu(desc);
/* Start handling the irq */
- desc->irq_data.chip->irq_ack(&desc->irq_data);
+ if (!(desc->istate & (IRQS_NO_REPLAY | IRQS_ONESHOT))
+ desc->irq_data.chip->irq_ack(&desc->irq_data);
+ else
+ mask_ack_irq(desc);
do {
if (unlikely(!desc->action)) {
next prev parent reply other threads:[~2016-11-08 21:47 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-08 11:58 [PATCH v4 0/8] IIO wrapper drivers, dpot-dac and envelope-detector Peter Rosin
2016-11-08 11:58 ` [PATCH v4 1/8] iio:core: add a callback to allow drivers to provide _available attributes Peter Rosin
[not found] ` <1478606339-31253-2-git-send-email-peda-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2016-11-12 17:17 ` Jonathan Cameron
2016-11-08 11:58 ` [PATCH v4 2/8] iio: inkern: add helpers to query available values from channels Peter Rosin
2016-11-12 17:17 ` Jonathan Cameron
[not found] ` <1478606339-31253-1-git-send-email-peda-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2016-11-08 11:58 ` [PATCH v4 3/8] iio: mcp4531: provide range of available raw values Peter Rosin
[not found] ` <1478606339-31253-4-git-send-email-peda-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2016-11-12 17:22 ` Jonathan Cameron
2016-11-08 11:58 ` [PATCH v4 4/8] dt-bindings: add axentia to vendor-prefixes Peter Rosin
[not found] ` <1478606339-31253-5-git-send-email-peda-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2016-11-12 17:23 ` Jonathan Cameron
2016-11-12 17:15 ` [PATCH v4 0/8] IIO wrapper drivers, dpot-dac and envelope-detector Jonathan Cameron
2016-11-15 14:03 ` Peter Rosin
2016-11-08 11:58 ` [PATCH v4 5/8] dt-bindings: iio: document dpot-dac bindings Peter Rosin
2016-11-08 11:58 ` [PATCH v4 6/8] iio: dpot-dac: DAC driver based on a digital potentiometer Peter Rosin
[not found] ` <1478606339-31253-7-git-send-email-peda-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2016-11-12 17:24 ` Jonathan Cameron
2016-11-08 11:58 ` [PATCH v4 7/8] dt-bindings: iio: document envelope-detector bindings Peter Rosin
2016-11-12 17:25 ` Jonathan Cameron
2016-11-08 11:58 ` [PATCH v4 8/8] iio: envelope-detector: ADC driver based on a DAC and a comparator Peter Rosin
[not found] ` <1478606339-31253-9-git-send-email-peda-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2016-11-08 15:59 ` Thomas Gleixner
2016-11-08 17:03 ` Peter Rosin
2016-11-08 18:38 ` Thomas Gleixner
2016-11-08 20:44 ` Peter Rosin
[not found] ` <1c104a31-6c66-9537-9b90-ede58c8e1a92-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2016-11-08 21:47 ` Thomas Gleixner [this message]
2016-11-09 15:01 ` Peter Rosin
2016-11-09 15:06 ` Thomas Gleixner
2016-11-11 11:37 ` Peter Rosin
[not found] ` <9fa01d3d-74ba-a048-52bf-4df959153354-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2016-11-12 17:29 ` Jonathan Cameron
[not found] ` <d8237286-d2ff-3146-d718-f54d05b0101d-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2016-11-12 17:27 ` Jonathan Cameron
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=alpine.DEB.2.20.1611082146560.3501@nanos \
--to=tglx-hfztesqfncyowbw4kg4ksq@public.gmane.org \
--cc=daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=knaack.h-Mmb7MZpHnFY@public.gmane.org \
--cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=peda-koto5C5qi+TLoDKTGw+V6w@public.gmane.org \
--cc=pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=sst-IjDXvh/HVVUAvxtiuMwx3w@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