Re: [PATCH] PM / wakeirq: Add wakeup name to dedicated wake irqs

From: Andy Shevchenko
Date: Wed Feb 14 2018 - 06:23:47 EST


On Fri, Feb 9, 2018 at 6:14 PM, Tony Lindgren <tony@xxxxxxxxxxx> wrote:
> This makes it easy to grep :wakeup /proc/interrupts.

I used to have another patch (not published) to provide this
information via /sys/kernel/irq.

OK, here we are:


> + namelen = strlen(dev_name(dev)) + strlen(postfix) + 1;
> + wirq->name = kzalloc(namelen, GFP_KERNEL);

kasprintf()


--
With Best Regards,
Andy Shevchenko
From ef35d3fd789a32d85212b2bcb82f754ae244cd58 Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Date: Fri, 12 May 2017 20:19:32 +0300
Subject: [PATCH] genirq: Add wakeup sysfs node to show IRQ wakeup state

Surprisingly there is no simple way to see if the IRQ line in question
is wakeup source or not.

Note that wakeup might be an OOB (out-of-band) source like GPIO line
which makes things slightly more complicated.

Add a sysfs node to cover this case.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
Documentation/ABI/testing/sysfs-kernel-irq | 7 +++++++
kernel/irq/irqdesc.c | 17 +++++++++++++++++
2 files changed, 24 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-kernel-irq b/Documentation/ABI/testing/sysfs-kernel-irq
index eb074b100986..10ad998f9411 100644
--- a/Documentation/ABI/testing/sysfs-kernel-irq
+++ b/Documentation/ABI/testing/sysfs-kernel-irq
@@ -51,3 +51,10 @@ Date: September 2016
KernelVersion: 4.9
Contact: Craig Gallek <kraig@xxxxxxxxxx>
Description: The type of the interrupt. Either the string 'level' or 'edge'.
+
+What: /sys/kernel/irq/<irq>/wakeup
+Date: Jan 2018
+KernelVersion: 4.16
+Contact: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
+Description: The wakeup state of the interrupt. Either the string
+ 'enabled' or 'disabled'.
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 49b54e9979cc..d9ded088d336 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -210,6 +210,22 @@ static ssize_t type_show(struct kobject *kobj,
}
IRQ_ATTR_RO(type);

+static ssize_t wakeup_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ struct irq_desc *desc = container_of(kobj, struct irq_desc, kobj);
+ ssize_t ret = 0;
+
+ raw_spin_lock_irq(&desc->lock);
+ ret = sprintf(buf, "%s\n",
+ irqd_is_wakeup_set(&desc->irq_data) ? "enabled" : "disabled");
+ raw_spin_unlock_irq(&desc->lock);
+
+ return ret;
+
+}
+IRQ_ATTR_RO(wakeup);
+
static ssize_t name_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
@@ -253,6 +269,7 @@ static struct attribute *irq_attrs[] = {
&chip_name_attr.attr,
&hwirq_attr.attr,
&type_attr.attr,
+ &wakeup_attr.attr,
&name_attr.attr,
&actions_attr.attr,
NULL
--
2.15.1