[PATCH 1/2] genirq: Introduce a new flag IRQ_IS_CHAINED for chained interrupts

From: Mika Westerberg
Date: Fri Oct 02 2015 - 02:57:40 EST


In some cases it is useful to know if the interrupt in question has chained
handler installed. For example when a cpu is offlined the architecture code
needs to know if it has any users so that it can fixup affinity
accordingly.

To make this possible we introduce a new flag IRQ_IS_CHAINED that is set by
the core code when chained interrupt handler is installed. We also make it
possible for core and architecture code to check the flag by introducing
function irq_has_chained_handler() for this.

Signed-off-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>
---
include/linux/irq.h | 6 +++++-
kernel/irq/chip.c | 11 +++++++++++
kernel/irq/settings.h | 16 ++++++++++++++++
3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 6bcfe8ac7594..cefdb36eb3e9 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -72,6 +72,7 @@ enum irqchip_irq_state;
* IRQ_IS_POLLED - Always polled by another interrupt. Exclude
* it from the spurious interrupt detection
* mechanism and from core side polling.
+ * IRQ_IS_CHAINED - Interrupt has chained handler installed
*/
enum {
IRQ_TYPE_NONE = 0x00000000,
@@ -97,13 +98,14 @@ enum {
IRQ_NOTHREAD = (1 << 16),
IRQ_PER_CPU_DEVID = (1 << 17),
IRQ_IS_POLLED = (1 << 18),
+ IRQ_IS_CHAINED = (1 << 19),
};

#define IRQF_MODIFY_MASK \
(IRQ_TYPE_SENSE_MASK | IRQ_NOPROBE | IRQ_NOREQUEST | \
IRQ_NOAUTOEN | IRQ_MOVE_PCNTXT | IRQ_LEVEL | IRQ_NO_BALANCING | \
IRQ_PER_CPU | IRQ_NESTED_THREAD | IRQ_NOTHREAD | IRQ_PER_CPU_DEVID | \
- IRQ_IS_POLLED)
+ IRQ_IS_POLLED | IRQ_IS_CHAINED)

#define IRQ_NO_BALANCING_MASK (IRQ_PER_CPU | IRQ_NO_BALANCING)

@@ -544,6 +546,8 @@ void
irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t handle,
void *data);

+bool irq_has_chained_handler(unsigned int irq);
+
void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set);

static inline void irq_set_status_flags(unsigned int irq, unsigned long set)
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index e28169dd1c36..826adc1e2c3c 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -747,6 +747,7 @@ __irq_do_set_handler(struct irq_desc *desc, irq_flow_handler_t handle,
mask_ack_irq(desc);
irq_state_set_disabled(desc);
desc->depth = 1;
+ irq_settings_clr_chained(desc);
}
desc->handle_irq = handle;
desc->name = name;
@@ -755,6 +756,7 @@ __irq_do_set_handler(struct irq_desc *desc, irq_flow_handler_t handle,
irq_settings_set_noprobe(desc);
irq_settings_set_norequest(desc);
irq_settings_set_nothread(desc);
+ irq_settings_set_chained(desc);
irq_startup(desc, true);
}
}
@@ -791,6 +793,15 @@ irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t handle,
}
EXPORT_SYMBOL_GPL(irq_set_chained_handler_and_data);

+bool irq_has_chained_handler(unsigned int irq)
+{
+ struct irq_desc *desc = irq_to_desc(irq);
+
+ if (!desc)
+ return false;
+ return irq_settings_is_chained(desc);
+}
+
void
irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
irq_flow_handler_t handle, const char *name)
diff --git a/kernel/irq/settings.h b/kernel/irq/settings.h
index 3320b84cc60f..b364dc873314 100644
--- a/kernel/irq/settings.h
+++ b/kernel/irq/settings.h
@@ -15,6 +15,7 @@ enum {
_IRQ_NESTED_THREAD = IRQ_NESTED_THREAD,
_IRQ_PER_CPU_DEVID = IRQ_PER_CPU_DEVID,
_IRQ_IS_POLLED = IRQ_IS_POLLED,
+ _IRQ_IS_CHAINED = IRQ_IS_CHAINED,
_IRQF_MODIFY_MASK = IRQF_MODIFY_MASK,
};

@@ -154,3 +155,18 @@ static inline bool irq_settings_is_polled(struct irq_desc *desc)
{
return desc->status_use_accessors & _IRQ_IS_POLLED;
}
+
+static inline void irq_settings_set_chained(struct irq_desc *desc)
+{
+ desc->status_use_accessors |= _IRQ_IS_CHAINED;
+}
+
+static inline void irq_settings_clr_chained(struct irq_desc *desc)
+{
+ desc->status_use_accessors &= ~_IRQ_IS_CHAINED;
+}
+
+static inline bool irq_settings_is_chained(struct irq_desc *desc)
+{
+ return desc->status_use_accessors & _IRQ_IS_CHAINED;
+}
--
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/