From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Alexandre Belloni <alexandre.belloni@free-electrons.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Nicolas Ferre <nicolas.ferre@atmel.com>,
LAK <linux-arm-kernel@lists.infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
David Dueck <davidcdueck@googlemail.com>,
Sebastian Sewior <bigeasy@linutronix.de>
Subject: Re: [PATCH 1/3] clocksource: atmel-st: Remove irq handler when clock event is unused
Date: Mon, 3 Aug 2015 15:30:04 +0200 [thread overview]
Message-ID: <20150803153004.4a74d99a@bbrezillon> (raw)
In-Reply-To: <20150802094028.GN12596@twins.programming.kicks-ass.net>
Peter, Thomas,
On Sun, 2 Aug 2015 11:40:28 +0200
Peter Zijlstra <peterz@infradead.org> wrote:
> On Sun, Aug 02, 2015 at 11:10:21AM +0200, Thomas Gleixner wrote:
> > I think Boris Brezillon had implemented it at some point, but it was
> > shot down for reasons I can't remember.
>
> You weren't around at the time.. DT people didn't like it, said they
> didn't like having to make up fake hardware in their DT crap.
I don't know who was right, but the fact is they won't be inclined to
take such an approach unless the virtual demuxer is not exposed in the
DT, which is almost impossible since irq users are identifying their
irq lines with a phandle to the interrupt controller and an interrupt
id (usually extracted from the datasheet).
Anyway, below is a solution providing a way to disable specific
handlers without reworking the way we are modeling shared interrupts.
Thomas, I know you were not in favor of the proposed approach, but,
AFAICT, it does not add any conditional path to the interrupt handling
path (which, IIRC, was one of your requirements), and is simple enough
to be used by people really needing it.
There's probably other drawback I haven't noticed, so please don't
hesitate to share your thoughts.
Thanks,
Boris
--- >8 ---
>From 3add0dceff714d94748106eba9867ea9aa3cd6a8 Mon Sep 17 00:00:00 2001
From: Boris Brezillon <boris.brezillon@free-electrons.com>
Date: Mon, 3 Aug 2015 15:18:08 +0200
Subject: [PATCH] irq: add disable_irq_handler()/enable_irq_handler() functions
Sometime we need to disable a specific handler on a shared irq line.
Currently, the only way this can be achieved is by freeing the irq handler
when we want to disable the irq and creating a new one when we want to
enable it.
This is not only adding some overhead to the disable/enable operations, but
the request_irq function cannot be called in atomic context, which means
it prevents disabling the interrupt in such situation.
This patch introduces three new functions: disable_irq_handler(),
disable_irq_handler_nosync() and enable_irq_handler() to allow disabling
a specific handler on a shared irq line.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
include/linux/irqdesc.h | 1 +
kernel/irq/manage.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
index fcea4e4..c8bd055 100644
--- a/include/linux/irqdesc.h
+++ b/include/linux/irqdesc.h
@@ -52,6 +52,7 @@ struct irq_desc {
irq_preflow_handler_t preflow_handler;
#endif
struct irqaction *action; /* IRQ action list */
+ struct irqaction *disabled_actions; /* IRQ disabled action list */
unsigned int status_use_accessors;
unsigned int core_internal_state__do_not_mess_with_it;
unsigned int depth; /* nested irq disables */
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index f974485..4690ab4 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -458,6 +458,47 @@ void disable_irq_nosync(unsigned int irq)
}
EXPORT_SYMBOL(disable_irq_nosync);
+static int __disable_irq_handler_nosync(unsigned int irq, void *dev_id)
+{
+ unsigned long flags;
+ struct irqaction *action, **prev;
+ struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
+ int ret = 0;
+
+ if (!desc)
+ return -EINVAL;
+
+ for (action = desc->action, prev = &desc->action; action; action = action->next) {
+ if (action->dev_id == dev_id)
+ break;
+
+ prev = &action->next;
+ }
+
+ if (!action)
+ goto out;
+
+ *prev = action->next;
+
+ action->next = desc->disabled_actions;
+ desc->disabled_actions = action;
+ if (!desc->action) {
+ __disable_irq(desc, irq);
+ ret = 1;
+ }
+
+out:
+ irq_put_desc_busunlock(desc, flags);
+ return ret;
+}
+
+static void disable_irq_handler_nosync(unsigned int irq, void *dev_id)
+{
+ __disable_irq_handler_nosync(irq, dev_id);
+}
+EXPORT_SYMBOL(disable_irq_handler_nosync);
+
+
/**
* disable_irq - disable an irq and wait for completion
* @irq: Interrupt to disable
@@ -477,6 +518,13 @@ void disable_irq(unsigned int irq)
}
EXPORT_SYMBOL(disable_irq);
+void disable_irq_handler(unsigned int irq, )
+{
+ if (__disable_irq_handler_nosync(irq) > 0)
+ synchronize_irq(irq);
+}
+EXPORT_SYMBOL(disable_irq);
+
/**
* disable_hardirq - disables an irq and waits for hardirq completion
* @irq: Interrupt to disable
@@ -552,6 +600,40 @@ out:
}
EXPORT_SYMBOL(enable_irq);
+void enable_irq_handler(unsigned int irq, void *dev_id)
+{
+ unsigned long flags;
+ struct irqaction *action, **prev;
+ struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
+
+ if (!desc)
+ return -EINVAL;
+
+ for (action = desc->disabled_actions, prev = &desc->action; action;
+ action = action->next) {
+ if (action->dev_id == dev_id)
+ break;
+
+ prev = &action->next;
+ }
+
+ if (!action)
+ goto out;
+
+ *prev = action->next;
+
+ action->next = desc->action;
+ desc->action = action;
+
+ if (!action->next)
+ __enable_irq(desc, irq);
+
+out:
+ irq_put_desc_busunlock(desc, flags);
+
+}
+EXPORT_SYMBOL(enable_irq_handler);
+
static int set_irq_wake_real(unsigned int irq, unsigned int on)
{
struct irq_desc *desc = irq_to_desc(irq);
--
1.9.1
next prev parent reply other threads:[~2015-08-03 13:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-17 19:33 [PATCH 0/3] clocksource: at91: Remove irq handler when clock event is unused Alexandre Belloni
2015-07-17 19:33 ` [PATCH 1/3] clocksource: atmel-st: " Alexandre Belloni
2015-07-18 8:12 ` Thomas Gleixner
2015-07-18 22:23 ` Alexandre Belloni
2015-07-20 9:04 ` Thomas Gleixner
2015-07-20 19:37 ` Alexandre Belloni
2015-07-20 20:46 ` Thomas Gleixner
2015-08-02 9:10 ` Thomas Gleixner
2015-08-02 9:40 ` Peter Zijlstra
2015-08-03 13:30 ` Boris Brezillon [this message]
2015-08-03 14:36 ` Thomas Gleixner
2015-08-03 20:07 ` Boris Brezillon
2015-07-17 19:33 ` [PATCH 2/3] clocksource: atmel-pit: drop at91sam926x_pit_common_init Alexandre Belloni
2015-07-17 19:33 ` [PATCH 3/3] clocksource: atmel-pit: Remove irq handler when clock event is unused Alexandre Belloni
2015-07-18 8:20 ` Thomas Gleixner
2015-07-18 22:18 ` Alexandre Belloni
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=20150803153004.4a74d99a@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=alexandre.belloni@free-electrons.com \
--cc=bigeasy@linutronix.de \
--cc=daniel.lezcano@linaro.org \
--cc=davidcdueck@googlemail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.ferre@atmel.com \
--cc=peterz@infradead.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