public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>, Jiri Slaby <jirislaby@kernel.org>
Subject: [patch 11/46] genirq/chip: Prepare for code reduction
Date: Thu, 13 Mar 2025 17:00:00 +0100 (CET)	[thread overview]
Message-ID: <20250313155914.608834932@linutronix.de> (raw)
In-Reply-To: 20250313154615.860723120@linutronix.de

The interrupt flow handlers have similar patterns to decide whether to
handle an interrupt or not.

Provide common helper functions to allow removal of duplicated code.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/irq/chip.c |   37 ++++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)

--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -499,7 +499,7 @@ static bool irq_check_poll(struct irq_de
 	return irq_wait_for_poll(desc);
 }
 
-static bool irq_may_run(struct irq_desc *desc)
+static bool irq_can_handle_pm(struct irq_desc *desc)
 {
 	unsigned int mask = IRQD_IRQ_INPROGRESS | IRQD_WAKEUP_ARMED;
 
@@ -524,6 +524,25 @@ static bool irq_may_run(struct irq_desc
 	return irq_check_poll(desc);
 }
 
+static inline bool irq_can_handle_actions(struct irq_desc *desc)
+{
+	desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
+
+	if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) {
+		desc->istate |= IRQS_PENDING;
+		return false;
+	}
+	return true;
+}
+
+static inline bool irq_can_handle(struct irq_desc *desc)
+{
+	if (!irq_can_handle_pm(desc))
+		return false;
+
+	return irq_can_handle_actions(desc);
+}
+
 /**
  *	handle_simple_irq - Simple and software-decoded IRQs.
  *	@desc:	the interrupt description structure for this irq
@@ -539,7 +558,7 @@ void handle_simple_irq(struct irq_desc *
 {
 	raw_spin_lock(&desc->lock);
 
-	if (!irq_may_run(desc))
+	if (!irq_can_handle_pm(desc))
 		goto out_unlock;
 
 	desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
@@ -574,7 +593,7 @@ void handle_untracked_irq(struct irq_des
 {
 	raw_spin_lock(&desc->lock);
 
-	if (!irq_may_run(desc))
+	if (!irq_can_handle_pm(desc))
 		goto out_unlock;
 
 	desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
@@ -630,7 +649,7 @@ void handle_level_irq(struct irq_desc *d
 	raw_spin_lock(&desc->lock);
 	mask_ack_irq(desc);
 
-	if (!irq_may_run(desc))
+	if (!irq_can_handle_pm(desc))
 		goto out_unlock;
 
 	desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
@@ -695,7 +714,7 @@ void handle_fasteoi_irq(struct irq_desc
 	 * can arrive on the new CPU before the original CPU has completed
 	 * handling the previous one - it may need to be resent.
 	 */
-	if (!irq_may_run(desc)) {
+	if (!irq_can_handle_pm(desc)) {
 		if (irqd_needs_resend_when_in_progress(&desc->irq_data))
 			desc->istate |= IRQS_PENDING;
 		goto out;
@@ -790,7 +809,7 @@ void handle_edge_irq(struct irq_desc *de
 
 	desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
 
-	if (!irq_may_run(desc)) {
+	if (!irq_can_handle_pm(desc)) {
 		desc->istate |= IRQS_PENDING;
 		mask_ack_irq(desc);
 		goto out_unlock;
@@ -854,7 +873,7 @@ void handle_edge_eoi_irq(struct irq_desc
 
 	desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
 
-	if (!irq_may_run(desc)) {
+	if (!irq_can_handle_pm(desc)) {
 		desc->istate |= IRQS_PENDING;
 		goto out_eoi;
 	}
@@ -1213,7 +1232,7 @@ void handle_fasteoi_ack_irq(struct irq_d
 
 	raw_spin_lock(&desc->lock);
 
-	if (!irq_may_run(desc))
+	if (!irq_can_handle_pm(desc))
 		goto out;
 
 	desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
@@ -1265,7 +1284,7 @@ void handle_fasteoi_mask_irq(struct irq_
 	raw_spin_lock(&desc->lock);
 	mask_ack_irq(desc);
 
-	if (!irq_may_run(desc))
+	if (!irq_can_handle_pm(desc))
 		goto out;
 
 	desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);


  parent reply	other threads:[~2025-03-13 16:00 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-13 15:59 [patch 00/46] genirq: Cleanups and conversion to lock guards Thomas Gleixner
2025-03-13 15:59 ` [patch 01/46] genirq: Provide conditional " Thomas Gleixner
2025-03-13 15:59 ` [patch 02/46] genirq/irqdesc: Switch to " Thomas Gleixner
2025-03-14 10:57   ` Jiri Slaby
2025-03-13 15:59 ` [patch 03/46] genirq/autoprobe: " Thomas Gleixner
2025-03-13 15:59 ` [patch 04/46] genirq/pm: " Thomas Gleixner
2025-03-13 15:59 ` [patch 05/46] genirq/resend: " Thomas Gleixner
2025-03-17  8:22   ` Shrikanth Hegde
2025-03-13 15:59 ` [patch 06/46] genirq/proc: " Thomas Gleixner
2025-03-13 15:59 ` [patch 07/46] genirq/spurious: Cleanup code Thomas Gleixner
2025-03-13 15:59 ` [patch 08/46] genirq/spurious: Switch to lock guards Thomas Gleixner
2025-03-13 15:59 ` [patch 09/46] genirq/cpuhotplug: Convert " Thomas Gleixner
2025-03-13 15:59 ` [patch 10/46] genirq/debugfs: " Thomas Gleixner
2025-03-13 16:00 ` Thomas Gleixner [this message]
2025-03-13 16:00 ` [patch 12/46] genirq/chip: Rework handle_nested_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 13/46] genirq/chip: Rework handle_simple_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 14/46] genirq/chip: Rework handle_untracked_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 15/46] genirq/chip: Rework handle_level_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 16/46] genirq/chip: Rework handle_eoi_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 17/46] genirq/chip: Rework handle_edge_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 18/46] genirq/chip: Rework handle_edge_eoi_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 19/46] genirq/chip: Rework handle_fasteoi_ack_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 20/46] genirq/chip: Rework handle_fasteoi_mask_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 21/46] genirq/chip: Use lock guards where applicable Thomas Gleixner
2025-03-13 16:00 ` [patch 22/46] genirq/chip: Rework irq_set_chip() Thomas Gleixner
2025-03-13 16:00 ` [patch 23/46] genirq/chip: Rework irq_set_irq_type() Thomas Gleixner
2025-03-13 16:00 ` [patch 24/46] genirq/chip: Rework irq_set_handler_data() Thomas Gleixner
2025-03-13 16:00 ` [patch 25/46] genirq/chip: Rework irq_set_msi_desc_off() Thomas Gleixner
2025-03-13 16:00 ` [patch 26/46] genirq/chip: Rework irq_set_chip_data() Thomas Gleixner
2025-03-13 16:00 ` [patch 27/46] genirq/chip: Rework irq_set_handler() variants Thomas Gleixner
2025-03-13 16:00 ` [patch 28/46] genirq/chip: Rework irq_modify_status() Thomas Gleixner
2025-03-13 16:00 ` [patch 29/46] genirq/manage: Cleanup kernel doc comments Thomas Gleixner
2025-03-13 16:00 ` [patch 30/46] genirq/manage: Convert to lock guards Thomas Gleixner
2025-03-13 16:00 ` [patch 31/46] genirq/manage: Rework irq_update_affinity_desc() Thomas Gleixner
2025-03-13 16:00 ` [patch 32/46] genirq/manage: Rework __irq_apply_affinity_hint() Thomas Gleixner
2025-03-13 16:00 ` [patch 33/46] genirq/manage: Rework irq_set_vcpu_affinity() Thomas Gleixner
2025-03-13 16:00 ` [patch 34/46] genirq/manage: Rework __disable_irq_nosync() Thomas Gleixner
2025-03-13 16:00 ` [patch 35/46] genirq/manage: Rework enable_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 36/46] genirq/manage: Rework irq_set_irq_wake() Thomas Gleixner
2025-03-13 16:00 ` [patch 37/46] genirq/manage: Rework can_request_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 38/46] genirq/manage: Rework irq_set_parent() Thomas Gleixner
2025-03-13 16:00 ` [patch 39/46] genirq/manage: Rework enable_percpu_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 40/46] genirq/manage: Rework irq_percpu_is_enabled() Thomas Gleixner
2025-03-13 16:00 ` [patch 41/46] genirq/manage: Rework disable_percpu_irq() Thomas Gleixner
2025-03-13 16:00 ` [patch 42/46] genirq/manage: Rework prepare_percpu_nmi() Thomas Gleixner
2025-03-13 16:00 ` [patch 43/46] genirq/manage: Rework teardown_percpu_nmi() Thomas Gleixner
2025-03-13 16:00 ` [patch 44/46] genirq/manage: Rework irq_get_irqchip_state() Thomas Gleixner
2025-03-13 16:01 ` [patch 45/46] genirq/manage: Rework irq_set_irqchip_state() Thomas Gleixner
2025-03-13 16:01 ` [patch 46/46] genirq: Remove irq_[get|put]_desc*() Thomas Gleixner
2025-03-14  9:04 ` [patch 00/46] genirq: Cleanups and conversion to lock guards Peter Zijlstra

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=20250313155914.608834932@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.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