2018-03-27 16:20:46

by Palmer Dabbelt

[permalink] [raw]
Subject: Make set_handle_irq and handle_arch_irq generic, v4

This is my third version of this patch set, but the original cover
letter is still the most relevant description I can come up with.

This patch set has been sitting around for a while, but it got a bit lost
in the shuffle. In RISC-V land we currently couple do_IRQ (the C entry
point for interrupt handling) to our first-level interrupt controller.
While this isn't completely crazy (as the first-level interrupt controller
is specified by the ISA), it is a bit awkward.

This patch set decouples our trap handler from our first-level IRQ chip
driver by copying what a handful of other architectures are doing. This
does add an additional load to the interrupt handling path, but there's a
handful of performance problems in there that I've been meaning to look at
so I don't mind adding another one for now. The advantage is that our
irqchip driver is decoupled from our arch port, at least at compile time.

Hopefully this time I've managed to produce a properly bisectable patch
set. There were two big bugs in the last version:

* I missed the generic irqchip drivers that set MULTI_IRQ_HANDLER. This
caused all sorts of non-defconfig ARM builds to fail.
* MULTI_IRQ_HANDLER and GENERIC_IRQ_MULTI_HANDLER could both get set by
randconfig builds. This caused the patch set to be non-bisectable.

I've gone through a bit of a song-and-dance to work around these, but I
think it's sound. The patch set works as follows (the order is
important):

* MULTI_IRQ_HANDLER is added to the arm64 and openriscv ports,
forced to true. Nothing in these ports actually looks at
CONFIG_MULTI_IRQ_HANDLER (it's forced to true anyway, so there's no
point in looking), it's just there to indicate that set_handle_irq()
is defined by these ports.
* Every generic irqchip driver is modified to set
GENERIC_IRQ_MULTI_HANDLER, but only if MULTI_IRQ_HANDLER is false.
These generic drivers depend on set_handle_irq() so they need one of
these symbols to be set, but the two Kconfig symbols are mutually
exclusive so I can't just select both (I just found out that select
ignores dependencies :)).
* GENERIC_IRQ_MULTI_HANDLER is added to all ports, with a dependency on
!MULTI_IRQ_HANDLER as they define the same symbols.
* Support for GENERIC_IRQ_MULTI_HANDLER is added to the RISC-V, arm,
arm64, and openrisc ports. This is a pretty mechanical change for
the other ports (just changing the #ifdefs), and a simple one for the
RISC-V port.

This patch set assumes that the two patches currently on tip are
dropped, but if that's not OK then I can create another patch set based
on those two. Of course, it won't be fully bisectable (arm randconfig
will still be broken somewhere in the middle).

I built this patch set after patches 3, 7, and 8 on arm, arm64, and
openrisc defconfigs as well as an arm randconfig that broke my v3 patch
set.

Sorry for breaking things, hopefully it works this time!

Changes since v3:

* There's now three new patches: #1 and #2 add MULTI_IRQ_HANDLER on
arm64 and openrisc so they match ARM, while #8 removes all
MULTI_IRQ_HANDLER references.
* All the generic irqchip drivers have been converted from
MULTI_IRQ_HANDLER to GENERIC_IRQ_MULTI_HANDLER.
* A handful of commit messages have been cleaned up.

Changes since v2:

* This is now called CONFIG_GENERIC_IRQ_MULTI_HANDLER instead of
MULTI_IRQ_HANDLER.
* Rather than converting the ARM code to generic code, this adds new
generic code (based on the ARM implementation) and then provides
separate patches to convert each architecture over to use
CONFIG_GENERIC_IRQ_MULTI_HANDLER.

Changes since v1:

* I based this on arm instead of arm64, which means we guard the selection of
these routines with CONFIG_MULTI_IRQ_HANDLER.
* The changes are in kernel/irq/handle.c and include/linux/irq.h instead of
lib.
* I've converted the arm, arm64, and openrisc ports to use the generic versions
of these routines.

[PATCH v4 1/8] arm64: Set CONFIG_MULTI_IRQ_HANDLER
[PATCH v4 2/8] openrisc: Set CONFIG_MULTI_IRQ_HANDLER
[PATCH v4 3/8] irq: Add CONFIG_GENERIC_IRQ_MULTI_HANDLER
[PATCH v4 4/8] RISC-V: Move to the new GENERIC_IRQ_MULTI_HANDLER
[PATCH v4 5/8] arm: Convert to GENERIC_IRQ_MULTI_HANDLER
[PATCH v4 6/8] arm64: Use the new GENERIC_IRQ_MULTI_HANDLER
[PATCH v4 7/8] openrisc: Use the new GENERIC_IRQ_MULTI_HANDLER
[PATCH v4 8/8] irq: Remove MULTI_IRQ_HANDLER as it's now obselete


2018-03-27 16:20:52

by Palmer Dabbelt

[permalink] [raw]
Subject: [PATCH v4 1/8] arm64: Set CONFIG_MULTI_IRQ_HANDLER

arm has an optional MULTI_IRQ_HANDLER, which arm64 copied but didn't
make optional. I'm converting this to generic code, but in order to
ensure everything stays bisectable I want this defined on arm64 for now.
This will go away by the end of the patch set.

Signed-off-by: Palmer Dabbelt <[email protected]>
---
arch/arm64/Kconfig | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7381eeb7ef8e..302d0b681676 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -132,6 +132,7 @@ config ARM64
select IRQ_DOMAIN
select IRQ_FORCED_THREADING
select MODULES_USE_ELF_RELA
+ select MULTI_IRQ_HANDLER
select NO_BOOTMEM
select OF
select OF_EARLY_FLATTREE
@@ -275,6 +276,9 @@ config ARCH_SUPPORTS_UPROBES
config ARCH_PROC_KCORE_TEXT
def_bool y

+config MULTI_IRQ_HANDLER
+ def_bool y
+
source "init/Kconfig"

source "kernel/Kconfig.freezer"
--
2.16.1


2018-03-27 16:21:14

by Palmer Dabbelt

[permalink] [raw]
Subject: [PATCH v4 3/8] irq: Add CONFIG_GENERIC_IRQ_MULTI_HANDLER

It looks like the arm irqchip registration mechanism has been copied
into a handful of ports, including arm64 and openrisc. I want to use
this in the RISC-V port, so I thought it would be good to make this
generic instead.

This patch copies the arm definition of CONFIG_MULTI_IRQ_HANDLER into
kernel/irq under CONFIG_GENERIC_IRQ_MULTI_HANDLER. This patch is
currently all dead code, but it will be enabled in the various other
architectures in subsequent patches.

GENERIC_IRQ_MULTI_HANDLER is incompatible with MULTI_IRQ_HANDLER because
they define the same symbols. Multiple generic irqchip drivers select
MULTI_IRQ_HANDLER, which is now defined on all architectures that
provide set_handle_irq(). This patch selects GENERIC_IRQ_MULTI_HANDLER
for all drivers that used to select MULTI_IRQ_HANDLER, but only when
MULTI_IRQ_HANDLER doesn't exist. I'll then convert every architecture
over from MULTI_IRQ_HANDLER to GENERIC_IRQ_MULTI_HANDLER before removing
the extra MULTI_IRQ_HANDLER scaffolding.

CC: Shea Levy <[email protected]>
CC: Arnd Bergmann <[email protected]>
Signed-off-by: Palmer Dabbelt <[email protected]>
---
drivers/irqchip/Kconfig | 8 ++++++++
include/linux/irq.h | 18 ++++++++++++++++++
kernel/irq/Kconfig | 6 ++++++
kernel/irq/handle.c | 15 +++++++++++++++
4 files changed, 47 insertions(+)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index d913aec85109..5af28ac6ce35 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -9,6 +9,7 @@ config ARM_GIC
select IRQ_DOMAIN
select IRQ_DOMAIN_HIERARCHY
select MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
select GENERIC_IRQ_EFFECTIVE_AFF_MASK

config ARM_GIC_PM
@@ -35,6 +36,7 @@ config ARM_GIC_V3
bool
select IRQ_DOMAIN
select MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
select IRQ_DOMAIN_HIERARCHY
select PARTITION_PERCPU
select GENERIC_IRQ_EFFECTIVE_AFF_MASK
@@ -61,6 +63,7 @@ config ARM_VIC
bool
select IRQ_DOMAIN
select MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER

config ARM_VIC_NR
int
@@ -88,6 +91,7 @@ config ATMEL_AIC_IRQ
select GENERIC_IRQ_CHIP
select IRQ_DOMAIN
select MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
select SPARSE_IRQ

config ATMEL_AIC5_IRQ
@@ -95,6 +99,7 @@ config ATMEL_AIC5_IRQ
select GENERIC_IRQ_CHIP
select IRQ_DOMAIN
select MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
select SPARSE_IRQ

config I8259
@@ -132,6 +137,7 @@ config FARADAY_FTINTC010
bool
select IRQ_DOMAIN
select MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
select SPARSE_IRQ

config HISILICON_IRQ_MBIGEN
@@ -157,6 +163,7 @@ config CLPS711X_IRQCHIP
depends on ARCH_CLPS711X
select IRQ_DOMAIN
select MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
select SPARSE_IRQ
default y

@@ -176,6 +183,7 @@ config ORION_IRQCHIP
bool
select IRQ_DOMAIN
select MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER

config PIC32_EVIC
bool
diff --git a/include/linux/irq.h b/include/linux/irq.h
index a0231e96a578..77e97872a13e 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -1170,4 +1170,22 @@ int __ipi_send_mask(struct irq_desc *desc, const struct cpumask *dest);
int ipi_send_single(unsigned int virq, unsigned int cpu);
int ipi_send_mask(unsigned int virq, const struct cpumask *dest);

+#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
+/*
+ * 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 *));
+
+/*
+ * Allows interrupt handlers to find the irqchip that's been registered as the
+ * top-level IRQ handler.
+ */
+extern void (*handle_arch_irq)(struct pt_regs *) __ro_after_init;
+#endif
+
#endif /* _LINUX_IRQ_H */
diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 6fc87ccda1d7..8596baa8e53d 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -132,3 +132,9 @@ config GENERIC_IRQ_DEBUGFS
If you don't know what to do here, say N.

endmenu
+
+config GENERIC_IRQ_MULTI_HANDLER
+ depends on !MULTI_IRQ_HANDLER
+ bool
+ help
+ Allow each machine to specify it's own IRQ handler at run time.
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 79f987b942b8..3570c715c3e7 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -20,6 +20,10 @@

#include "internals.h"

+#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
+void (*handle_arch_irq)(struct pt_regs *) __ro_after_init;
+#endif
+
/**
* handle_bad_irq - handle spurious and unhandled irqs
* @desc: description of the interrupt
@@ -207,3 +211,14 @@ irqreturn_t handle_irq_event(struct irq_desc *desc)
irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS);
return ret;
}
+
+#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
+int __init set_handle_irq(void (*handle_irq)(struct pt_regs *))
+{
+ if (handle_arch_irq)
+ return -EBUSY;
+
+ handle_arch_irq = handle_irq;
+ return 0;
+}
+#endif
--
2.16.1


2018-03-27 16:22:06

by Palmer Dabbelt

[permalink] [raw]
Subject: [PATCH v4 8/8] irq: Remove MULTI_IRQ_HANDLER as it's now obselete

Now that every user of MULTI_IRQ_HANDLER has been convereted over to use
GENERIC_IRQ_MULTI_HANDLER we can remove the references to
MULTI_IRQ_HANDLER.

Signed-off-by: Palmer Dabbelt <[email protected]>
---
drivers/irqchip/Kconfig | 24 ++++++++----------------
kernel/irq/Kconfig | 1 -
2 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 5af28ac6ce35..70157a257ce0 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -8,8 +8,7 @@ config ARM_GIC
bool
select IRQ_DOMAIN
select IRQ_DOMAIN_HIERARCHY
- select MULTI_IRQ_HANDLER
- select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER
select GENERIC_IRQ_EFFECTIVE_AFF_MASK

config ARM_GIC_PM
@@ -35,8 +34,7 @@ config GIC_NON_BANKED
config ARM_GIC_V3
bool
select IRQ_DOMAIN
- select MULTI_IRQ_HANDLER
- select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER
select IRQ_DOMAIN_HIERARCHY
select PARTITION_PERCPU
select GENERIC_IRQ_EFFECTIVE_AFF_MASK
@@ -62,8 +60,7 @@ config ARM_NVIC
config ARM_VIC
bool
select IRQ_DOMAIN
- select MULTI_IRQ_HANDLER
- select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER

config ARM_VIC_NR
int
@@ -90,16 +87,14 @@ config ATMEL_AIC_IRQ
bool
select GENERIC_IRQ_CHIP
select IRQ_DOMAIN
- select MULTI_IRQ_HANDLER
- select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER
select SPARSE_IRQ

config ATMEL_AIC5_IRQ
bool
select GENERIC_IRQ_CHIP
select IRQ_DOMAIN
- select MULTI_IRQ_HANDLER
- select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER
select SPARSE_IRQ

config I8259
@@ -136,8 +131,7 @@ config DW_APB_ICTL
config FARADAY_FTINTC010
bool
select IRQ_DOMAIN
- select MULTI_IRQ_HANDLER
- select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER
select SPARSE_IRQ

config HISILICON_IRQ_MBIGEN
@@ -162,8 +156,7 @@ config CLPS711X_IRQCHIP
bool
depends on ARCH_CLPS711X
select IRQ_DOMAIN
- select MULTI_IRQ_HANDLER
- select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER
select SPARSE_IRQ
default y

@@ -182,8 +175,7 @@ config OMAP_IRQCHIP
config ORION_IRQCHIP
bool
select IRQ_DOMAIN
- select MULTI_IRQ_HANDLER
- select GENERIC_IRQ_MULTI_HANDLER if !MULTI_IRQ_HANDLER
+ select GENERIC_IRQ_MULTI_HANDLER

config PIC32_EVIC
bool
diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 8596baa8e53d..116a6972f124 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -134,7 +134,6 @@ config GENERIC_IRQ_DEBUGFS
endmenu

config GENERIC_IRQ_MULTI_HANDLER
- depends on !MULTI_IRQ_HANDLER
bool
help
Allow each machine to specify it's own IRQ handler at run time.
--
2.16.1


2018-03-27 16:22:07

by Palmer Dabbelt

[permalink] [raw]
Subject: [PATCH v4 4/8] RISC-V: Move to the new GENERIC_IRQ_MULTI_HANDLER handler

The old mechanism for handling IRQs on RISC-V was pretty ugly: the arch
code looked at the Kconfig entry for our first-level irqchip driver and
called into it directly.

This patch uses the new generic IRQ handling infastructure, which
essentially just deletes a bunch of code. This does add an additional
load to the interrupt latency, but there's a lot of tuning left to be
done there on RISC-V so I think it's OK for now.

Reviewed-by: Christoph Hellwig <[email protected]>
Acked-by: Stafford Horne <[email protected]>
Signed-off-by: Palmer Dabbelt <[email protected]>
---
arch/riscv/Kconfig | 1 +
arch/riscv/include/asm/Kbuild | 1 +
arch/riscv/kernel/entry.S | 7 +++----
arch/riscv/kernel/irq.c | 13 -------------
4 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 04807c7f64cc..148865de1692 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -33,6 +33,7 @@ config RISCV
select MODULES_USE_ELF_RELA if MODULES
select THREAD_INFO_IN_TASK
select RISCV_TIMER
+ select GENERIC_IRQ_MULTI_HANDLER

config MMU
def_bool y
diff --git a/arch/riscv/include/asm/Kbuild b/arch/riscv/include/asm/Kbuild
index 4286a5f83876..1e5fd280fb4d 100644
--- a/arch/riscv/include/asm/Kbuild
+++ b/arch/riscv/include/asm/Kbuild
@@ -15,6 +15,7 @@ generic-y += fcntl.h
generic-y += futex.h
generic-y += hardirq.h
generic-y += hash.h
+generic-y += handle_irq.h
generic-y += hw_irq.h
generic-y += ioctl.h
generic-y += ioctls.h
diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S
index 56fa592cfa34..9aaf6c986771 100644
--- a/arch/riscv/kernel/entry.S
+++ b/arch/riscv/kernel/entry.S
@@ -167,10 +167,9 @@ ENTRY(handle_exception)
bge s4, zero, 1f

/* Handle interrupts */
- slli a0, s4, 1
- srli a0, a0, 1
- move a1, sp /* pt_regs */
- tail do_IRQ
+ move a0, sp /* pt_regs */
+ REG_L a1, handle_arch_irq
+ jr a1
1:
/* Exceptions run with interrupts enabled */
csrs sstatus, SR_SIE
diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c
index 328718e8026e..b74cbfbce2d0 100644
--- a/arch/riscv/kernel/irq.c
+++ b/arch/riscv/kernel/irq.c
@@ -24,16 +24,3 @@ void __init init_IRQ(void)
{
irqchip_init();
}
-
-asmlinkage void __irq_entry do_IRQ(unsigned int cause, struct pt_regs *regs)
-{
-#ifdef CONFIG_RISCV_INTC
- /*
- * FIXME: We don't want a direct call to riscv_intc_irq here. The plan
- * is to put an IRQ domain here and let the interrupt controller
- * register with that, but I poked around the arm64 code a bit and
- * there might be a better way to do it (ie, something fully generic).
- */
- riscv_intc_irq(cause, regs);
-#endif
-}
--
2.16.1


2018-03-27 16:22:09

by Palmer Dabbelt

[permalink] [raw]
Subject: [PATCH v4 7/8] openrisc: Use the new GENERIC_IRQ_MULTI_HANDLER

It appears that openrisc copied arm64's GENERIC_IRQ_MULTI_HANDLER code
(which came from arm). I wanted to make this generic so I could use it
in the RISC-V port. This patch converts the openrisc code to use the
generic version.

Acked-by: Stafford Horne <[email protected]>
Signed-off-by: Palmer Dabbelt <[email protected]>
---
arch/openrisc/Kconfig | 5 +----
arch/openrisc/include/asm/irq.h | 2 --
arch/openrisc/kernel/irq.c | 7 -------
3 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 9ecad05bfc73..dfb6a79ba7ff 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -27,7 +27,6 @@ config OPENRISC
select GENERIC_STRNLEN_USER
select GENERIC_SMP_IDLE_THREAD
select MODULES_USE_ELF_RELA
- select MULTI_IRQ_HANDLER
select HAVE_DEBUG_STACKOVERFLOW
select OR1K_PIC
select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1
@@ -36,6 +35,7 @@ config OPENRISC
select ARCH_USE_QUEUED_RWLOCKS
select OMPIC if SMP
select ARCH_WANT_FRAME_POINTERS
+ select GENERIC_IRQ_MULTI_HANDLER

config CPU_BIG_ENDIAN
def_bool y
@@ -69,9 +69,6 @@ config STACKTRACE_SUPPORT
config LOCKDEP_SUPPORT
def_bool y

-config MULTI_IRQ_HANDLER
- def_bool y
-
source "init/Kconfig"

source "kernel/Kconfig.freezer"
diff --git a/arch/openrisc/include/asm/irq.h b/arch/openrisc/include/asm/irq.h
index d9eee0a2b7b4..eb612b1865d2 100644
--- a/arch/openrisc/include/asm/irq.h
+++ b/arch/openrisc/include/asm/irq.h
@@ -24,6 +24,4 @@

#define NO_IRQ (-1)

-extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
-
#endif /* __ASM_OPENRISC_IRQ_H__ */
diff --git a/arch/openrisc/kernel/irq.c b/arch/openrisc/kernel/irq.c
index 35e478a93116..5f9445effaf8 100644
--- a/arch/openrisc/kernel/irq.c
+++ b/arch/openrisc/kernel/irq.c
@@ -41,13 +41,6 @@ void __init init_IRQ(void)
irqchip_init();
}

-static void (*handle_arch_irq)(struct pt_regs *);
-
-void __init set_handle_irq(void (*handle_irq)(struct pt_regs *))
-{
- handle_arch_irq = handle_irq;
-}
-
void __irq_entry do_IRQ(struct pt_regs *regs)
{
handle_arch_irq(regs);
--
2.16.1


2018-03-27 16:22:59

by Palmer Dabbelt

[permalink] [raw]
Subject: [PATCH v4 2/8] openrisc: Set CONFIG_MULTI_IRQ_HANDLER

arm has an optional MULTI_IRQ_HANDLER, which openrisc copied but didn't
make optional. I'm converting this to generic code, but in order to
ensure everything stays bisectable I want this defined on openrisc for
now. This will go away by the end of the patch set.

Signed-off-by: Palmer Dabbelt <[email protected]>
---
arch/openrisc/Kconfig | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 339df7324e9c..9ecad05bfc73 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -27,6 +27,7 @@ config OPENRISC
select GENERIC_STRNLEN_USER
select GENERIC_SMP_IDLE_THREAD
select MODULES_USE_ELF_RELA
+ select MULTI_IRQ_HANDLER
select HAVE_DEBUG_STACKOVERFLOW
select OR1K_PIC
select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1
@@ -68,6 +69,9 @@ config STACKTRACE_SUPPORT
config LOCKDEP_SUPPORT
def_bool y

+config MULTI_IRQ_HANDLER
+ def_bool y
+
source "init/Kconfig"

source "kernel/Kconfig.freezer"
--
2.16.1


2018-03-27 16:23:08

by Palmer Dabbelt

[permalink] [raw]
Subject: [PATCH v4 5/8] arm: Convert to GENERIC_IRQ_MULTI_HANDLER

This converts the ARM port to use the recently added
GENERIC_IRQ_MULTI_HANDLER, which is essentially just a copy of ARM's
existhing MULTI_IRQ_HANDLER. The only changes are:

* handle_arch_irq is now defined in a generic C file instead of an
arm-specific assembly file.
* handle_arch_irq is now marked as __ro_after_init.

Signed-off-by: Palmer Dabbelt <[email protected]>
---
arch/arm/Kconfig | 19 +++++++------------
arch/arm/include/asm/irq.h | 5 -----
arch/arm/include/asm/mach/arch.h | 2 +-
arch/arm/kernel/entry-armv.S | 10 ++--------
arch/arm/kernel/irq.c | 10 ----------
arch/arm/kernel/setup.c | 2 +-
6 files changed, 11 insertions(+), 37 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7e3d53575486..3f972e83909b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -339,8 +339,8 @@ config ARCH_MULTIPLATFORM
select TIMER_OF
select COMMON_CLK
select GENERIC_CLOCKEVENTS
+ select GENERIC_IRQ_MULTI_HANDLER
select MIGHT_HAVE_PCI
- select MULTI_IRQ_HANDLER
select PCI_DOMAINS if PCI
select SPARSE_IRQ
select USE_OF
@@ -467,9 +467,9 @@ config ARCH_DOVE
bool "Marvell Dove"
select CPU_PJ4
select GENERIC_CLOCKEVENTS
+ select GENERIC_IRQ_MULTI_HANDLER
select GPIOLIB
select MIGHT_HAVE_PCI
- select MULTI_IRQ_HANDLER
select MVEBU_MBUS
select PINCTRL
select PINCTRL_DOVE
@@ -514,8 +514,8 @@ config ARCH_LPC32XX
select COMMON_CLK
select CPU_ARM926T
select GENERIC_CLOCKEVENTS
+ select GENERIC_IRQ_MULTI_HANDLER
select GPIOLIB
- select MULTI_IRQ_HANDLER
select SPARSE_IRQ
select USE_OF
help
@@ -534,11 +534,11 @@ config ARCH_PXA
select TIMER_OF
select CPU_XSCALE if !CPU_XSC3
select GENERIC_CLOCKEVENTS
+ select GENERIC_IRQ_MULTI_HANDLER
select GPIO_PXA
select GPIOLIB
select HAVE_IDE
select IRQ_DOMAIN
- select MULTI_IRQ_HANDLER
select PLAT_PXA
select SPARSE_IRQ
help
@@ -574,11 +574,11 @@ config ARCH_SA1100
select CPU_FREQ
select CPU_SA1100
select GENERIC_CLOCKEVENTS
+ select GENERIC_IRQ_MULTI_HANDLER
select GPIOLIB
select HAVE_IDE
select IRQ_DOMAIN
select ISA
- select MULTI_IRQ_HANDLER
select NEED_MACH_MEMORY_H
select SPARSE_IRQ
help
@@ -592,10 +592,10 @@ config ARCH_S3C24XX
select GENERIC_CLOCKEVENTS
select GPIO_SAMSUNG
select GPIOLIB
+ select GENERIC_IRQ_MULTI_HANDLER
select HAVE_S3C2410_I2C if I2C
select HAVE_S3C2410_WATCHDOG if WATCHDOG
select HAVE_S3C_RTC if RTC_CLASS
- select MULTI_IRQ_HANDLER
select NEED_MACH_IO_H
select SAMSUNG_ATAGS
select USE_OF
@@ -629,10 +629,10 @@ config ARCH_OMAP1
select CLKSRC_MMIO
select GENERIC_CLOCKEVENTS
select GENERIC_IRQ_CHIP
+ select GENERIC_IRQ_MULTI_HANDLER
select GPIOLIB
select HAVE_IDE
select IRQ_DOMAIN
- select MULTI_IRQ_HANDLER
select NEED_MACH_IO_H if PCCARD
select NEED_MACH_MEMORY_H
select SPARSE_IRQ
@@ -921,11 +921,6 @@ config IWMMXT
Enable support for iWMMXt context switching at run time if
running on a CPU that supports it.

-config MULTI_IRQ_HANDLER
- bool
- help
- Allow each machine to specify it's own IRQ handler at run time.
-
if !MMU
source "arch/arm/Kconfig-nommu"
endif
diff --git a/arch/arm/include/asm/irq.h b/arch/arm/include/asm/irq.h
index b6f319606e30..c883fcbe93b6 100644
--- a/arch/arm/include/asm/irq.h
+++ b/arch/arm/include/asm/irq.h
@@ -31,11 +31,6 @@ extern void asm_do_IRQ(unsigned int, struct pt_regs *);
void handle_IRQ(unsigned int, struct pt_regs *);
void init_IRQ(void);

-#ifdef CONFIG_MULTI_IRQ_HANDLER
-extern void (*handle_arch_irq)(struct pt_regs *);
-extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
-#endif
-
#ifdef CONFIG_SMP
extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask,
bool exclude_self);
diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
index 5c1ad11aa392..bb8851208e17 100644
--- a/arch/arm/include/asm/mach/arch.h
+++ b/arch/arm/include/asm/mach/arch.h
@@ -59,7 +59,7 @@ struct machine_desc {
void (*init_time)(void);
void (*init_machine)(void);
void (*init_late)(void);
-#ifdef CONFIG_MULTI_IRQ_HANDLER
+#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
void (*handle_irq)(struct pt_regs *);
#endif
void (*restart)(enum reboot_mode, const char *);
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 1752033b0070..7eeb1f57fa20 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -22,7 +22,7 @@
#include <asm/glue-df.h>
#include <asm/glue-pf.h>
#include <asm/vfpmacros.h>
-#ifndef CONFIG_MULTI_IRQ_HANDLER
+#ifndef CONFIG_GENERIC_IRQ_MULTI_HANDLER
#include <mach/entry-macro.S>
#endif
#include <asm/thread_notify.h>
@@ -39,7 +39,7 @@
* Interrupt handling.
*/
.macro irq_handler
-#ifdef CONFIG_MULTI_IRQ_HANDLER
+#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
ldr r1, =handle_arch_irq
mov r0, sp
badr lr, 9997f
@@ -1226,9 +1226,3 @@ vector_addrexcptn:
.globl cr_alignment
cr_alignment:
.space 4
-
-#ifdef CONFIG_MULTI_IRQ_HANDLER
- .globl handle_arch_irq
-handle_arch_irq:
- .space 4
-#endif
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index ece04a457486..9908dacf9229 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -102,16 +102,6 @@ void __init init_IRQ(void)
uniphier_cache_init();
}

-#ifdef CONFIG_MULTI_IRQ_HANDLER
-void __init set_handle_irq(void (*handle_irq)(struct pt_regs *))
-{
- if (handle_arch_irq)
- return;
-
- handle_arch_irq = handle_irq;
-}
-#endif
-
#ifdef CONFIG_SPARSE_IRQ
int __init arch_probe_nr_irqs(void)
{
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index fc40a2b40595..f6c26c370427 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -1145,7 +1145,7 @@ void __init setup_arch(char **cmdline_p)

reserve_crashkernel();

-#ifdef CONFIG_MULTI_IRQ_HANDLER
+#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
handle_arch_irq = mdesc->handle_irq;
#endif

--
2.16.1


2018-03-27 16:23:11

by Palmer Dabbelt

[permalink] [raw]
Subject: [PATCH v4 6/8] arm64: Use the new GENERIC_IRQ_MULTI_HANDLER

It appears arm64 copied arm's GENERIC_IRQ_MULTI_HANDLER code, but made
it unconditional. I wanted to make this generic so it could be used by
the RISC-V port. This patch converts the arm64 code to use the new
generic code, which simply consists of deleting the arm64 code and
setting MULTI_IRQ_HANDLER instead.

Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Palmer Dabbelt <[email protected]>
---
arch/arm64/Kconfig | 5 +----
arch/arm64/include/asm/irq.h | 2 --
arch/arm64/kernel/irq.c | 10 ----------
3 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 302d0b681676..e8f7ef1157ce 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -70,6 +70,7 @@ config ARM64
select GENERIC_CPU_AUTOPROBE
select GENERIC_EARLY_IOREMAP
select GENERIC_IDLE_POLL_SETUP
+ select GENERIC_IRQ_MULTI_HANDLER
select GENERIC_IRQ_PROBE
select GENERIC_IRQ_SHOW
select GENERIC_IRQ_SHOW_LEVEL
@@ -132,7 +133,6 @@ config ARM64
select IRQ_DOMAIN
select IRQ_FORCED_THREADING
select MODULES_USE_ELF_RELA
- select MULTI_IRQ_HANDLER
select NO_BOOTMEM
select OF
select OF_EARLY_FLATTREE
@@ -276,9 +276,6 @@ config ARCH_SUPPORTS_UPROBES
config ARCH_PROC_KCORE_TEXT
def_bool y

-config MULTI_IRQ_HANDLER
- def_bool y
-
source "init/Kconfig"

source "kernel/Kconfig.freezer"
diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h
index a0fee6985e6a..b2b0c6405eb0 100644
--- a/arch/arm64/include/asm/irq.h
+++ b/arch/arm64/include/asm/irq.h
@@ -8,8 +8,6 @@

struct pt_regs;

-extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
-
static inline int nr_legacy_irqs(void)
{
return 0;
diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
index 60e5fc661f74..780a12f59a8f 100644
--- a/arch/arm64/kernel/irq.c
+++ b/arch/arm64/kernel/irq.c
@@ -42,16 +42,6 @@ int arch_show_interrupts(struct seq_file *p, int prec)
return 0;
}

-void (*handle_arch_irq)(struct pt_regs *) = NULL;
-
-void __init set_handle_irq(void (*handle_irq)(struct pt_regs *))
-{
- if (handle_arch_irq)
- return;
-
- handle_arch_irq = handle_irq;
-}
-
#ifdef CONFIG_VMAP_STACK
static void init_irq_stacks(void)
{
--
2.16.1


2018-03-29 05:02:55

by Stafford Horne

[permalink] [raw]
Subject: Re: [PATCH v4 2/8] openrisc: Set CONFIG_MULTI_IRQ_HANDLER

On Tue, Mar 27, 2018 at 09:19:05AM -0700, Palmer Dabbelt wrote:
> arm has an optional MULTI_IRQ_HANDLER, which openrisc copied but didn't
> make optional. I'm converting this to generic code, but in order to
> ensure everything stays bisectable I want this defined on openrisc for
> now. This will go away by the end of the patch set.
>
> Signed-off-by: Palmer Dabbelt <[email protected]>

Hi Palmer,
Thanks for doing this work, its always nice to see generic code pulled out of
architecture ports.

Acked-by: Stafford Horne <[email protected]>

> ---
> arch/openrisc/Kconfig | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
> index 339df7324e9c..9ecad05bfc73 100644
> --- a/arch/openrisc/Kconfig
> +++ b/arch/openrisc/Kconfig
> @@ -27,6 +27,7 @@ config OPENRISC
> select GENERIC_STRNLEN_USER
> select GENERIC_SMP_IDLE_THREAD
> select MODULES_USE_ELF_RELA
> + select MULTI_IRQ_HANDLER
> select HAVE_DEBUG_STACKOVERFLOW
> select OR1K_PIC
> select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1
> @@ -68,6 +69,9 @@ config STACKTRACE_SUPPORT
> config LOCKDEP_SUPPORT
> def_bool y
>
> +config MULTI_IRQ_HANDLER
> + def_bool y
> +
> source "init/Kconfig"
>
> source "kernel/Kconfig.freezer"
> --
> 2.16.1
>