lkml.org 
[lkml]   [2021]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] genirq/irqdesc: Add state node to show if IRQ is enabled
From
Date


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);
>

\
 
 \ /
  Last update: 2021-11-16 13:48    [W:0.041 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site