From: Palmer Dabbelt <palmer@sifive.com>
To: Arnd Bergmann <arnd@arndb.de>,
Christoph Hellwig <hch@infradead.org>,
linux-kernel@vger.kernel.org
Cc: patches@groups.riscv.org, Palmer Dabbelt <palmer@dabbelt.com>
Subject: [PATCH 1/2] asm-generic: Add a generic set_handle_irq
Date: Thu, 18 Jan 2018 07:40:04 -0800 [thread overview]
Message-ID: <20180118154005.24994-2-palmer@sifive.com> (raw)
In-Reply-To: <20180118154005.24994-1-palmer@sifive.com>
From: Palmer Dabbelt <palmer@dabbelt.com>
I've copied this from arm64, but it appears to be the same code that's
in arm and openrisc. I wanted to use it for RISC-V's interrupt handler
as well, so despite this only being a handful of lines of code it seems
worth having a generic version -- if it existed when we created our
interrupt controller then maybe we would have just started with the
generic version.
This patch alone is just dead code, further patches actually use this
infrastructure.
Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
---
include/asm-generic/handle_irq.h | 28 ++++++++++++++++++++++++++++
lib/Kconfig | 3 +++
lib/Makefile | 2 ++
lib/handle_irq.c | 26 ++++++++++++++++++++++++++
4 files changed, 59 insertions(+)
create mode 100644 include/asm-generic/handle_irq.h
create mode 100644 lib/handle_irq.c
diff --git a/include/asm-generic/handle_irq.h b/include/asm-generic/handle_irq.h
new file mode 100644
index 000000000000..2865fa12993a
--- /dev/null
+++ b/include/asm-generic/handle_irq.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 1992 Linus Torvalds
+ * Modifications for ARM processor Copyright (C) 1995-2000 Russell King.
+ * Support for Dynamic Tick Timer Copyright (C) 2004-2005 Nokia Corporation.
+ * Dynamic Tick Timer written by Tony Lindgren <tony@atomide.com> and
+ * Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>.
+ * Copyright (C) 2012 ARM Ltd.
+ * Copyright (C) 2017 SiFive, Inc
+ */
+
+#ifndef __ASM_GENERIC_IRQ_HANDLER_H
+#define __ASM_GENERIC_IRQ_HANDLER_H
+
+#include <asm/ptrace.h>
+#include <linux/module.h>
+
+/*
+ * Registers a generic IRQ handling function as the top-level IRQ handler in
+ * the system, which is generally the first C code called from an assembly
+ * architecture-specific interrupt handler.
+ *
+ * Returns 0 on success, or -EBUSY if an IRQ handler has already been
+ * registered.
+ */
+int __init set_handle_irq(void (*handle_irq)(struct pt_regs *));
+
+#endif
diff --git a/lib/Kconfig b/lib/Kconfig
index c5e84fbcb30b..c74469d44fdc 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -601,3 +601,6 @@ config GENERIC_CMPDI2
config GENERIC_UCMPDI2
bool
+
+config GENERIC_HANDLE_IRQ
+ bool
diff --git a/lib/Makefile b/lib/Makefile
index d11c48ec8ffd..57ae58fde821 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -258,3 +258,5 @@ obj-$(CONFIG_GENERIC_LSHRDI3) += lshrdi3.o
obj-$(CONFIG_GENERIC_MULDI3) += muldi3.o
obj-$(CONFIG_GENERIC_CMPDI2) += cmpdi2.o
obj-$(CONFIG_GENERIC_UCMPDI2) += ucmpdi2.o
+
+obj-$(CONFIG_GENERIC_HANDLE_IRQ) += handle_irq.o
diff --git a/lib/handle_irq.c b/lib/handle_irq.c
new file mode 100644
index 000000000000..e732147537f4
--- /dev/null
+++ b/lib/handle_irq.c
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 1992 Linus Torvalds
+ * Modifications for ARM processor Copyright (C) 1995-2000 Russell King.
+ * Support for Dynamic Tick Timer Copyright (C) 2004-2005 Nokia Corporation.
+ * Dynamic Tick Timer written by Tony Lindgren <tony@atomide.com> and
+ * Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>.
+ * Copyright (C) 2012 ARM Ltd.
+ * Copyright (C) 2017 SiFive, Inc
+ */
+
+#include <asm-generic/handle_irq.h>
+
+void (*handle_arch_irq)(struct pt_regs *) = NULL;
+
+int __init set_handle_irq(void (*handle_irq)(struct pt_regs *))
+{
+ if (!handle_arch_irq)
+ handle_arch_irq = handle_irq;
+
+ if (handle_arch_irq != handle_irq)
+ return -EBUSY;
+
+ return 0;
+}
+
--
2.13.6
next prev parent reply other threads:[~2018-01-18 16:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-18 15:40 Use arm64's scheme for registering first-level IRQ handlers on RISC-V Palmer Dabbelt
2018-01-18 15:40 ` Palmer Dabbelt [this message]
2018-01-18 15:45 ` [PATCH 1/2] asm-generic: Add a generic set_handle_irq Christoph Hellwig
2018-01-25 3:08 ` [patches] " Palmer Dabbelt
2018-01-18 15:40 ` [PATCH 2/2] RISC-V: Move to the new asm-generic IRQ handler Palmer Dabbelt
2018-01-18 16:43 ` Use arm64's scheme for registering first-level IRQ handlers on RISC-V Arnd Bergmann
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=20180118154005.24994-2-palmer@sifive.com \
--to=palmer@sifive.com \
--cc=arnd@arndb.de \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=palmer@dabbelt.com \
--cc=patches@groups.riscv.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
Powered by JetHome