LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] genirq/irqdesc: Add state node to show if IRQ is enabled
@ 2021-11-16 12:34 Srinivas Kandagatla
  2021-11-16 12:47 ` Srinivas Kandagatla
  2021-11-24 19:16 ` Thomas Gleixner
  0 siblings, 2 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2021-11-16 12:34 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, Srinivas Kandagatla

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@linaro.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@linux.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@linaro.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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] genirq/irqdesc: Add state node to show if IRQ is enabled
  2021-11-16 12:34 [PATCH] genirq/irqdesc: Add state node to show if IRQ is enabled Srinivas Kandagatla
@ 2021-11-16 12:47 ` Srinivas Kandagatla
  2021-11-24 19:16 ` Thomas Gleixner
  1 sibling, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2021-11-16 12:47 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel



On 16/11/2021 12:34, Srinivas Kandagatla wrote:
> 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@linaro.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


Please ignore this patch! It will not work for every case.

--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@linux.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@linaro.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);
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] genirq/irqdesc: Add state node to show if IRQ is enabled
  2021-11-16 12:34 [PATCH] genirq/irqdesc: Add state node to show if IRQ is enabled Srinivas Kandagatla
  2021-11-16 12:47 ` Srinivas Kandagatla
@ 2021-11-24 19:16 ` Thomas Gleixner
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Gleixner @ 2021-11-24 19:16 UTC (permalink / raw)
  To: Srinivas Kandagatla; +Cc: linux-kernel, Srinivas Kandagatla

On Tue, Nov 16 2021 at 12:34, Srinivas Kandagatla wrote:
> 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.

You can find this information along with more details when you enable
CONFIG_GENERIC_IRQ_DEBUGFS. Dig into /sys/kernel/debug/irq/

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-24 19:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 12:34 [PATCH] genirq/irqdesc: Add state node to show if IRQ is enabled Srinivas Kandagatla
2021-11-16 12:47 ` Srinivas Kandagatla
2021-11-24 19:16 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).