lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211116123447.23902-1-srinivas.kandagatla@linaro.org>
Date:   Tue, 16 Nov 2021 12:34:47 +0000
From:   Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
To:     tglx@...utronix.de
Cc:     linux-kernel@...r.kernel.org,
        Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Subject: [PATCH] genirq/irqdesc: Add state node to show if IRQ is enabled

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@...aro.org>
---

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@...ux.intel.com>
 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@...aro.org>
+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);
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ