From: Marc Zyngier <maz@kernel.org> To: LAK <linux-arm-kernel@lists.infradead.org>, linux-kernel <linux-kernel@vger.kernel.org> Cc: Will Deacon <will@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Thomas Gleixner <tglx@linutronix.de>, Valentin Schneider <Valentin.Schneider@arm.com>, Peter Zijlstra <peterz@infradead.org>, Mark Rutland <mark.rutland@arm.com>, Russell King <linux@arm.linux.org.uk>, Android Kernel Team <kernel-team@android.com> Subject: [PATCH v2 2/6] genirq: Allow an interrupt to be marked as 'raw' Date: Tue, 24 Nov 2020 14:14:45 +0000 [thread overview] Message-ID: <20201124141449.572446-3-maz@kernel.org> (raw) In-Reply-To: <20201124141449.572446-1-maz@kernel.org> Some interrupts (such as the rescheduling IPI) rely on not going through the irq_enter()/irq_exit() calls. To distinguish such interrupts, add a new IRQ flag that allows the low-level handling code to sidestep the enter()/exit() calls. Only the architecture code is expected to use this. It will do the wrong thing on normal interrupts. Note that this is a band-aid until we can move to some more correct infrastructure (such as kernel/entry/common.c). Signed-off-by: Marc Zyngier <maz@kernel.org> --- include/linux/irq.h | 2 ++ kernel/irq/Kconfig | 3 +++ kernel/irq/debugfs.c | 1 + kernel/irq/irqdesc.c | 17 ++++++++++++----- kernel/irq/settings.h | 15 +++++++++++++++ 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index c55f218d5b61..605ba5949255 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -72,6 +72,7 @@ enum irqchip_irq_state; * mechanism and from core side polling. * IRQ_DISABLE_UNLAZY - Disable lazy irq disable * IRQ_HIDDEN - Don't show up in /proc/interrupts + * IRQ_RAW - Skip tick management and irqtime accounting */ enum { IRQ_TYPE_NONE = 0x00000000, @@ -99,6 +100,7 @@ enum { IRQ_IS_POLLED = (1 << 18), IRQ_DISABLE_UNLAZY = (1 << 19), IRQ_HIDDEN = (1 << 20), + IRQ_RAW = (1 << 21), }; #define IRQF_MODIFY_MASK \ diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig index 164a031cfdb6..ae9b13d5ee91 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig @@ -109,6 +109,9 @@ config GENERIC_IRQ_MATRIX_ALLOCATOR config GENERIC_IRQ_RESERVATION_MODE bool +config ARCH_WANTS_IRQ_RAW + bool + # Support forced irq threading config IRQ_FORCED_THREADING bool diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c index e4cff358b437..f53475d88072 100644 --- a/kernel/irq/debugfs.c +++ b/kernel/irq/debugfs.c @@ -140,6 +140,7 @@ static const struct irq_bit_descr irqdesc_states[] = { BIT_MASK_DESCR(_IRQ_IS_POLLED), BIT_MASK_DESCR(_IRQ_DISABLE_UNLAZY), BIT_MASK_DESCR(_IRQ_HIDDEN), + BIT_MASK_DESCR(_IRQ_RAW), }; static const struct irq_bit_descr irqdesc_istates[] = { diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 1a7723604399..f5beee546a6f 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -667,10 +667,9 @@ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, { struct pt_regs *old_regs = set_irq_regs(regs); unsigned int irq = hwirq; + struct irq_desc *desc; int ret = 0; - irq_enter(); - #ifdef CONFIG_IRQ_DOMAIN if (lookup) irq = irq_find_mapping(domain, hwirq); @@ -680,14 +679,22 @@ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, * Some hardware gives randomly wrong interrupts. Rather * than crashing, do something sensible. */ - if (unlikely(!irq || irq >= nr_irqs)) { + if (unlikely(!irq || irq >= nr_irqs || !(desc = irq_to_desc(irq)))) { ack_bad_irq(irq); ret = -EINVAL; + goto out; + } + + if (IS_ENABLED(CONFIG_ARCH_WANTS_IRQ_RAW) && + unlikely(irq_settings_is_raw(desc))) { + generic_handle_irq_desc(desc); } else { - generic_handle_irq(irq); + irq_enter(); + generic_handle_irq_desc(desc); + irq_exit(); } - irq_exit(); +out: set_irq_regs(old_regs); return ret; } diff --git a/kernel/irq/settings.h b/kernel/irq/settings.h index 51acdf43eadc..0033d459fdac 100644 --- a/kernel/irq/settings.h +++ b/kernel/irq/settings.h @@ -18,6 +18,7 @@ enum { _IRQ_IS_POLLED = IRQ_IS_POLLED, _IRQ_DISABLE_UNLAZY = IRQ_DISABLE_UNLAZY, _IRQ_HIDDEN = IRQ_HIDDEN, + _IRQ_RAW = IRQ_RAW, _IRQF_MODIFY_MASK = IRQF_MODIFY_MASK, }; @@ -33,6 +34,7 @@ enum { #define IRQ_IS_POLLED GOT_YOU_MORON #define IRQ_DISABLE_UNLAZY GOT_YOU_MORON #define IRQ_HIDDEN GOT_YOU_MORON +#define IRQ_RAW GOT_YOU_MORON #undef IRQF_MODIFY_MASK #define IRQF_MODIFY_MASK GOT_YOU_MORON @@ -180,3 +182,16 @@ static inline bool irq_settings_is_hidden(struct irq_desc *desc) { return desc->status_use_accessors & _IRQ_HIDDEN; } + +static inline bool irq_settings_is_raw(struct irq_desc *desc) +{ + if (IS_ENABLED(CONFIG_ARCH_WANTS_IRQ_RAW)) + return desc->status_use_accessors & _IRQ_RAW; + + /* + * Using IRQ_RAW on architectures that don't expect it is + * likely to be wrong. + */ + WARN_ON_ONCE(1); + return false; +} -- 2.28.0
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org> To: LAK <linux-arm-kernel@lists.infradead.org>, linux-kernel <linux-kernel@vger.kernel.org> Cc: Mark Rutland <mark.rutland@arm.com>, Android Kernel Team <kernel-team@android.com>, Russell King <linux@arm.linux.org.uk>, Peter Zijlstra <peterz@infradead.org>, Catalin Marinas <catalin.marinas@arm.com>, Thomas Gleixner <tglx@linutronix.de>, Will Deacon <will@kernel.org>, Valentin Schneider <Valentin.Schneider@arm.com> Subject: [PATCH v2 2/6] genirq: Allow an interrupt to be marked as 'raw' Date: Tue, 24 Nov 2020 14:14:45 +0000 [thread overview] Message-ID: <20201124141449.572446-3-maz@kernel.org> (raw) In-Reply-To: <20201124141449.572446-1-maz@kernel.org> Some interrupts (such as the rescheduling IPI) rely on not going through the irq_enter()/irq_exit() calls. To distinguish such interrupts, add a new IRQ flag that allows the low-level handling code to sidestep the enter()/exit() calls. Only the architecture code is expected to use this. It will do the wrong thing on normal interrupts. Note that this is a band-aid until we can move to some more correct infrastructure (such as kernel/entry/common.c). Signed-off-by: Marc Zyngier <maz@kernel.org> --- include/linux/irq.h | 2 ++ kernel/irq/Kconfig | 3 +++ kernel/irq/debugfs.c | 1 + kernel/irq/irqdesc.c | 17 ++++++++++++----- kernel/irq/settings.h | 15 +++++++++++++++ 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index c55f218d5b61..605ba5949255 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -72,6 +72,7 @@ enum irqchip_irq_state; * mechanism and from core side polling. * IRQ_DISABLE_UNLAZY - Disable lazy irq disable * IRQ_HIDDEN - Don't show up in /proc/interrupts + * IRQ_RAW - Skip tick management and irqtime accounting */ enum { IRQ_TYPE_NONE = 0x00000000, @@ -99,6 +100,7 @@ enum { IRQ_IS_POLLED = (1 << 18), IRQ_DISABLE_UNLAZY = (1 << 19), IRQ_HIDDEN = (1 << 20), + IRQ_RAW = (1 << 21), }; #define IRQF_MODIFY_MASK \ diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig index 164a031cfdb6..ae9b13d5ee91 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig @@ -109,6 +109,9 @@ config GENERIC_IRQ_MATRIX_ALLOCATOR config GENERIC_IRQ_RESERVATION_MODE bool +config ARCH_WANTS_IRQ_RAW + bool + # Support forced irq threading config IRQ_FORCED_THREADING bool diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c index e4cff358b437..f53475d88072 100644 --- a/kernel/irq/debugfs.c +++ b/kernel/irq/debugfs.c @@ -140,6 +140,7 @@ static const struct irq_bit_descr irqdesc_states[] = { BIT_MASK_DESCR(_IRQ_IS_POLLED), BIT_MASK_DESCR(_IRQ_DISABLE_UNLAZY), BIT_MASK_DESCR(_IRQ_HIDDEN), + BIT_MASK_DESCR(_IRQ_RAW), }; static const struct irq_bit_descr irqdesc_istates[] = { diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 1a7723604399..f5beee546a6f 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -667,10 +667,9 @@ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, { struct pt_regs *old_regs = set_irq_regs(regs); unsigned int irq = hwirq; + struct irq_desc *desc; int ret = 0; - irq_enter(); - #ifdef CONFIG_IRQ_DOMAIN if (lookup) irq = irq_find_mapping(domain, hwirq); @@ -680,14 +679,22 @@ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, * Some hardware gives randomly wrong interrupts. Rather * than crashing, do something sensible. */ - if (unlikely(!irq || irq >= nr_irqs)) { + if (unlikely(!irq || irq >= nr_irqs || !(desc = irq_to_desc(irq)))) { ack_bad_irq(irq); ret = -EINVAL; + goto out; + } + + if (IS_ENABLED(CONFIG_ARCH_WANTS_IRQ_RAW) && + unlikely(irq_settings_is_raw(desc))) { + generic_handle_irq_desc(desc); } else { - generic_handle_irq(irq); + irq_enter(); + generic_handle_irq_desc(desc); + irq_exit(); } - irq_exit(); +out: set_irq_regs(old_regs); return ret; } diff --git a/kernel/irq/settings.h b/kernel/irq/settings.h index 51acdf43eadc..0033d459fdac 100644 --- a/kernel/irq/settings.h +++ b/kernel/irq/settings.h @@ -18,6 +18,7 @@ enum { _IRQ_IS_POLLED = IRQ_IS_POLLED, _IRQ_DISABLE_UNLAZY = IRQ_DISABLE_UNLAZY, _IRQ_HIDDEN = IRQ_HIDDEN, + _IRQ_RAW = IRQ_RAW, _IRQF_MODIFY_MASK = IRQF_MODIFY_MASK, }; @@ -33,6 +34,7 @@ enum { #define IRQ_IS_POLLED GOT_YOU_MORON #define IRQ_DISABLE_UNLAZY GOT_YOU_MORON #define IRQ_HIDDEN GOT_YOU_MORON +#define IRQ_RAW GOT_YOU_MORON #undef IRQF_MODIFY_MASK #define IRQF_MODIFY_MASK GOT_YOU_MORON @@ -180,3 +182,16 @@ static inline bool irq_settings_is_hidden(struct irq_desc *desc) { return desc->status_use_accessors & _IRQ_HIDDEN; } + +static inline bool irq_settings_is_raw(struct irq_desc *desc) +{ + if (IS_ENABLED(CONFIG_ARCH_WANTS_IRQ_RAW)) + return desc->status_use_accessors & _IRQ_RAW; + + /* + * Using IRQ_RAW on architectures that don't expect it is + * likely to be wrong. + */ + WARN_ON_ONCE(1); + return false; +} -- 2.28.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-11-24 14:15 UTC|newest] Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-24 14:14 [PATCH v2 0/6] arm/arm64: Allow the rescheduling IPI to bypass irq_enter/exit Marc Zyngier 2020-11-24 14:14 ` Marc Zyngier 2020-11-24 14:14 ` [PATCH v2 1/6] genirq: Add __irq_modify_status() helper to clear/set special flags Marc Zyngier 2020-11-24 14:14 ` Marc Zyngier 2020-11-24 14:14 ` Marc Zyngier [this message] 2020-11-24 14:14 ` [PATCH v2 2/6] genirq: Allow an interrupt to be marked as 'raw' Marc Zyngier 2020-11-24 16:26 ` Peter Zijlstra 2020-11-24 16:26 ` Peter Zijlstra 2020-11-24 16:56 ` Marc Zyngier 2020-11-24 16:56 ` Marc Zyngier 2020-11-26 18:18 ` Valentin Schneider 2020-11-26 18:18 ` Valentin Schneider 2020-12-03 13:03 ` Peter Zijlstra 2020-12-03 13:03 ` Peter Zijlstra 2020-12-03 15:52 ` Valentin Schneider 2020-12-03 15:52 ` Valentin Schneider 2020-12-05 19:24 ` Valentin Schneider 2020-12-05 19:24 ` Valentin Schneider 2020-12-10 15:07 ` Will Deacon 2020-12-10 15:07 ` Will Deacon 2021-06-23 17:28 ` Todd Kjos 2021-06-23 17:28 ` Todd Kjos 2020-11-24 14:14 ` [PATCH v2 3/6] arm64: Mark the recheduling IPI as raw interrupt Marc Zyngier 2020-11-24 14:14 ` Marc Zyngier 2020-12-10 15:15 ` Will Deacon 2020-12-10 15:15 ` Will Deacon 2020-11-24 14:14 ` [PATCH v2 4/6] arm: " Marc Zyngier 2020-11-24 14:14 ` Marc Zyngier 2020-11-24 14:14 ` [PATCH v2 5/6] genirq: Drop IRQ_HIDDEN from IRQF_MODIFY_MASK Marc Zyngier 2020-11-24 14:14 ` Marc Zyngier 2020-11-24 14:14 ` [PATCH v2 6/6] genirq: Rename IRQ_HIDDEN to IRQ_IPI Marc Zyngier 2020-11-24 14:14 ` Marc Zyngier 2020-11-26 18:18 ` Valentin Schneider 2020-11-26 18:18 ` Valentin Schneider 2021-03-01 0:39 ` [PATCH v2 0/6] arm/arm64: Allow the rescheduling IPI to bypass irq_enter/exit ito-yuichi 2021-03-01 0:39 ` ito-yuichi 2021-03-01 9:22 ` Marc Zyngier 2021-03-01 9:22 ` Marc Zyngier 2021-03-09 6:20 ` Yuichi Ito 2021-03-09 6:20 ` Yuichi Ito 2021-06-18 19:30 ` Abhijeet Dharmapurikar
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=20201124141449.572446-3-maz@kernel.org \ --to=maz@kernel.org \ --cc=Valentin.Schneider@arm.com \ --cc=catalin.marinas@arm.com \ --cc=kernel-team@android.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@arm.linux.org.uk \ --cc=mark.rutland@arm.com \ --cc=peterz@infradead.org \ --cc=tglx@linutronix.de \ --cc=will@kernel.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.