While debugging some issues with SoundWire WakeUp interrupt,
I did not find a way to figure out if the interrupt is really enabled
or disabled.
So I have added an new state entry in the sysfs to dump the current
interrupt state.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx>
---
While debugging I found this patch very useful, specially in SoundWire Wakeup
usecase where we dynamically enable Low Power Wakeup interrupt.
Sending this out, hoping that it will be useful for others as well.
--srini
Documentation/ABI/testing/sysfs-kernel-irq | 7 +++++++
kernel/irq/irqdesc.c | 16 ++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-kernel-irq b/Documentation/ABI/testing/sysfs-kernel-irq
index 8910d0c4bcd8..d858ed133ba2 100644
--- a/Documentation/ABI/testing/sysfs-kernel-irq
+++ b/Documentation/ABI/testing/sysfs-kernel-irq
@@ -58,3 +58,10 @@ KernelVersion: 4.17
Contact: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Description: The wakeup state of the interrupt. Either the string
'enabled' or 'disabled'.
+
+What: /sys/kernel/irq/<irq>/state
+Date: November 2021
+KernelVersion: 5.16
+Contact: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx>
+Description: The state of the interrupt. Either the string
+ 'enabled' or 'disabled'.
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 2267e6527db3..60c69978ea45 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -265,6 +265,21 @@ static ssize_t actions_show(struct kobject *kobj,
}
IRQ_ATTR_RO(actions);
+static ssize_t state_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ struct irq_desc *desc = container_of(kobj, struct irq_desc, kobj);
+ ssize_t ret;
+
+ raw_spin_lock_irq(&desc->lock);
+ ret = sprintf(buf, "%s\n",
+ irqd_irq_disabled(&desc->irq_data) ? "disabled" : "enabled");
+ raw_spin_unlock_irq(&desc->lock);
+
+ return ret;
+}
+IRQ_ATTR_RO(state);
+
static struct attribute *irq_attrs[] = {
&per_cpu_count_attr.attr,
&chip_name_attr.attr,
@@ -273,6 +288,7 @@ static struct attribute *irq_attrs[] = {
&wakeup_attr.attr,
&name_attr.attr,
&actions_attr.attr,
+ &state_attr.attr,
NULL
};
ATTRIBUTE_GROUPS(irq);