From: Paul Burton <paul.burton@imgtec.com>
To: Thomas Gleixner <tglx@linutronix.de>, Ralf Baechle <ralf@linux-mips.org>
Cc: dianders@chromium.org, James Hogan <james.hogan@imgtec.com>,
Brian Norris <briannorris@chromium.org>,
Jason Cooper <jason@lakedaemon.net>,
jeffy.chen@rock-chips.com, Marc Zyngier <marc.zyngier@arm.com>,
linux-kernel@vger.kernel.org, linux-mips@linux-mips.org,
tfiga@chromium.org, Paul Burton <paul.burton@imgtec.com>
Subject: [RFC PATCH v1 7/9] MIPS: cevt-r4k: percpu_devid interrupt support
Date: Thu, 7 Sep 2017 16:25:40 -0700 [thread overview]
Message-ID: <20170907232542.20589-8-paul.burton@imgtec.com> (raw)
Message-ID: <20170907232540.jumcqIBQyC5F9iH36tpwQIhr_Ne3YvJvk4-LoLZPTeA@z> (raw)
In-Reply-To: <20170907232542.20589-1-paul.burton@imgtec.com>
The MIPS coprocessor 0 count/compare interrupt, used by the cevt-r4k
driver, is really a percpu interrupt but up until now we have not used
the percpu interrupt APIs to configure & control it. In preparation for
doing so, introduce support for percpu_devid interrupts in cevt-r4k.
We switch from using request_irq() to using either setup_irq() or
setup_percpu_irq() with an explicit struct irqaction such that we can
set the flags, handler & name for that struct irqaction once rather than
needing to duplicate them in calls to request_irq() and
request_percpu_irq().
The IRQF_NOAUTOEN flag is passed because percpu interrupts
automatically get IRQ_NOAUTOEN set by irq_set_percpu_devid_flags(). We
opt into accepting this behaviour & explicitly enable the interrupt in
r4k_clockevent_init() which is called on all CPUs during bringup.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
---
arch/mips/kernel/cevt-r4k.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index 893aa32759d9..0021fc1226f3 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -8,6 +8,7 @@
*/
#include <linux/clockchips.h>
#include <linux/interrupt.h>
+#include <linux/once.h>
#include <linux/percpu.h>
#include <linux/smp.h>
#include <linux/irq.h>
@@ -106,7 +107,6 @@ static unsigned int calculate_min_delta(void)
}
DEFINE_PER_CPU(struct clock_event_device, mips_clockevent_device);
-int cp0_timer_irq_installed;
irqreturn_t c0_compare_interrupt(int irq, void *dev_id)
{
@@ -136,8 +136,9 @@ struct irqaction c0_compare_irqaction = {
* IRQF_SHARED: The timer interrupt may be shared with other interrupts
* such as perf counter and FDC interrupts.
*/
- .flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED,
+ .flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED | IRQF_NOAUTOEN,
.name = "timer",
+ .percpu_dev_id = &mips_clockevent_device,
};
@@ -222,11 +223,20 @@ unsigned int __weak get_c0_compare_int(void)
return MIPS_CPU_IRQ_BASE + cp0_compare_irq;
}
+static void setup_c0_compare_int(int irq, int *err)
+{
+ if (irq_is_percpu_devid(irq))
+ *err = setup_percpu_irq(irq, &c0_compare_irqaction);
+ else
+ *err = setup_irq(irq, &c0_compare_irqaction);
+}
+
int r4k_clockevent_init(void)
{
unsigned int cpu = smp_processor_id();
struct clock_event_device *cd;
unsigned int irq, min_delta;
+ int err;
if (!cpu_has_counter || !mips_hpt_frequency)
return -ENXIO;
@@ -258,12 +268,17 @@ int r4k_clockevent_init(void)
clockevents_config_and_register(cd, mips_hpt_frequency, min_delta, 0x7fffffff);
- if (cp0_timer_irq_installed)
- return 0;
-
- cp0_timer_irq_installed = 1;
+ err = 0;
+ DO_ONCE(setup_c0_compare_int, irq, &err);
+ if (err) {
+ pr_err("Unable to setup timer IRQ %d: %d\n", irq, err);
+ return err;
+ }
- setup_irq(irq, &c0_compare_irqaction);
+ if (irq_is_percpu_devid(irq))
+ enable_percpu_irq(irq, IRQ_TYPE_NONE);
+ else
+ enable_irq(irq);
return 0;
}
--
2.14.1
next prev parent reply other threads:[~2017-09-07 23:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1682867.tATABVWsV9@np-p-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 ` 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 ` Paul Burton
2017-09-07 23:25 ` [RFC PATCH v1 2/9] genirq: Support shared per_cpu_devid interrupts Paul Burton
2017-09-07 23:25 ` 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 ` 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 ` Paul Burton
2017-09-07 23:25 ` [RFC PATCH v1 5/9] MIPS: Remove perf_irq Paul Burton
2017-09-07 23:25 ` Paul Burton
2017-09-07 23:25 ` [RFC PATCH v1 6/9] MIPS: perf: percpu_devid interrupt support Paul Burton
2017-09-07 23:25 ` Paul Burton
2017-10-19 14:12 ` Thomas Gleixner
2017-09-07 23:25 ` Paul Burton [this message]
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 ` Paul Burton
2017-09-07 23:25 ` [RFC PATCH v1 9/9] irqchip: mips-gic: Remove gic_all_vpes_local_irq_controller Paul Burton
2017-09-07 23:25 ` 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=20170907232542.20589-8-paul.burton@imgtec.com \
--to=paul.burton@imgtec.com \
--cc=briannorris@chromium.org \
--cc=dianders@chromium.org \
--cc=james.hogan@imgtec.com \
--cc=jason@lakedaemon.net \
--cc=jeffy.chen@rock-chips.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=marc.zyngier@arm.com \
--cc=ralf@linux-mips.org \
--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;
as well as URLs for NNTP newsgroup(s).