Report interrupt that caused system wakeup
Subsystems (5)
A message that is not in the archive (sent off-list or not yet received): [PATCH V10] Report interrupt that caused system wakeup
PATCH v10 1/1 Report interrupt that caused system wakeup
Add a sysfs attribute, /sys/power/pm_wakeup_irq, reporting the IRQ number of the first wakeup interrupt (that is, the first interrupt from an IRQ line armed for system wakeup) seen by the kernel during the most recent system suspend/resume cycle.
This feature will be useful for system wakeup diagnostics of spurious wakeup interrupts.
--- Documentation/ABI/testing/sysfs-power | 12 ++++++++++++ drivers/base/power/wakeup.c | 9 +++++++++ include/linux/suspend.h | 5 +++++ kernel/irq/pm.c | 3 ++- kernel/power/main.c | 18 ++++++++++++++++++ 5 files changed, 46 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-power +12 -0
@@ -256,3 +256,15 @@ Description: Writing a "1" enables this printing while writing a "0" disables it. The default value is "0". Reading from this file will display the current value. + +What: /sys/power/pm_wakeup_irq +Date: April 2015 +Contact: Alexandra Yates <[email protected]> +Description: + The /sys/power/pm_wakeup_irq file reports to user space the IRQ + number of the first wakeup interrupt (that is, the first + interrupt from an IRQ line armed for system wakeup) seen by the + kernel during the most recent system suspend/resume cycle. + + This output is useful for system wakeup diagnostics of spurious + wakeup interrupts.
drivers/base/power/wakeup.c +9 -0
@@ -868,6 +868,15 @@ EXPORT_SYMBOL_GPL(pm_system_wakeup);void pm_wakeup_clear (void ) { pm_abort_suspend = false; + wakeup_irq =0 ; +} + +void pm_system_irq_wakeup (unsigned int irq_number) +{ +if (wakeup_irq ==0 ) { + wakeup_irq = irq_number; +pm_system_wakeup (); + } }/**
include/linux/suspend.h +5 -0
@@ -371,6 +371,9 @@ static inline bool hibernation_available(void) { return false; }extern struct mutex pm_mutex; +/* IRQ number which causes system wakeup */ +extern unsigned int wakeup_irq; +#ifdef CONFIG_PM_SLEEP void save_processor_state (void );void restore_processor_state (void );
@@ -391,6 +394,7 @@ extern bool events_check_enabled;extern bool pm_wakeup_pending (void );extern void pm_system_wakeup (void );extern void pm_wakeup_clear (void ); +extern void pm_system_irq_wakeup (unsigned int );extern bool pm_get_wakeup_count (unsigned int *count,bool block);extern bool pm_save_wakeup_count (unsigned int count);extern void pm_wakep_autosleep_enabled (bool set);
@@ -440,6 +444,7 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)static inline bool pm_wakeup_pending (void ) {return false; }static inline void pm_system_wakeup (void ) {}static inline void pm_wakeup_clear (void ) {} +static inline void pm_system_irq_wakeup (unsigned int ) {}static inline void lock_system_sleep (void ) {}static inline void unlock_system_sleep (void ) {}
kernel/irq/pm.c +2 -1
@@ -21,7 +21,7 @@ bool irq_pm_check_wakeup(struct irq_desc *desc) desc->istate |=IRQS_SUSPENDED |IRQS_PENDING ; desc->depth++;irq_disable (desc); -pm_system_wakeup (); +pm_system_irq_wakeup (irq_desc_get_irq (desc));return true; }return false;
@@ -73,6 +73,7 @@ static bool suspend_device_irq(struct irq_desc *desc, int irq)if (!desc->action || desc->no_suspend_depth)return false; +if (irqd_is_wakeup_set (&desc->irq_data)) {irqd_set (&desc->irq_data,IRQD_WAKEUP_ARMED );/*
kernel/power/main.c +18 -0
@@ -272,6 +272,23 @@ static inline void pm_print_times_init(void) { pm_print_times_enabled = !!initcall_debug; } + +unsigned int wakeup_irq; +static ssize_t pm_wakeup_irq_show (struct kobject *kobj, +struct kobj_attribute *attr, +char *buf) +{ +return wakeup_irq ?sprintf (buf,"%u\n" , wakeup_irq) : -ENODATA ; +} + +static ssize_t pm_wakeup_irq_store (struct kobject *kobj, +struct kobj_attribute *attr, +const char *buf,size_t n) +{ +return -EINVAL ; +} +power_attr (pm_wakeup_irq); +#else /* !CONFIG_PM_SLEEP_DEBUG */ static inline void pm_print_times_init (void ) {}#endif /* CONFIG_PM_SLEEP_DEBUG */
@@ -604,6 +621,7 @@ static struct attribute * g[] = {#endif #ifdef CONFIG_PM_SLEEP_DEBUG &pm_print_times_attr.attr, + &pm_wakeup_irq_attr.attr,#endif #endif #ifdef CONFIG_FREEZER
Signature · 1 line
1.9.1
Quoted 9 lines · Alexandra Yates
Add a sysfs attribute,
/sys/power/pm_wakeup_irq, reporting the IRQ number of the first wakeup interrupt (that is, the first interrupt from an IRQ line armed for system wakeup) seen by the kernel during the most recent system suspend/resume cycle.This feature will be useful for system wakeup diagnostics of spurious wakeup interrupts.
Signed-off-by Alexandra Yates <[email protected]>
OK, looks good to me, one tiny nit below.
Quoted 83 lines
--- Documentation/ABI/testing/sysfs-power | 12 ++++++++++++ drivers/base/power/wakeup.c | 9 +++++++++ include/linux/suspend.h | 5 +++++ kernel/irq/pm.c | 3 ++- kernel/power/main.c | 18 ++++++++++++++++++ 5 files changed, 46 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-power +12
-0@@ -256,3 +256,15 @@ Description: Writing a "1" enables this printing while writing a "0" disables it. The default value is "0". Reading from this file will display the current value. + +What: /sys/power/pm_wakeup_irq +Date: April 2015 +Contact: Alexandra Yates <[email protected]> +Description: + The /sys/power/pm_wakeup_irq file reports to user space the IRQ + number of the first wakeup interrupt (that is, the first + interrupt from an IRQ line armed for system wakeup) seen by the + kernel during the most recent system suspend/resume cycle. + + This output is useful for system wakeup diagnostics of spurious + wakeup interrupts.drivers/base/power/wakeup.c +9
-0@@ -868,6 +868,15 @@ EXPORT_SYMBOL_GPL(pm_system_wakeup);void pm_wakeup_clear (void ) { pm_abort_suspend = false; + wakeup_irq =0 ; +} + +void pm_system_irq_wakeup (unsigned int irq_number) +{ +if (wakeup_irq ==0 ) { + wakeup_irq = irq_number; +pm_system_wakeup (); + } }/** include/linux/suspend.h +5
-0@@ -371,6 +371,9 @@ static inline bool hibernation_available(void) { return false; }extern struct mutex pm_mutex; +/* IRQ number which causes system wakeup */ +extern unsigned int wakeup_irq; +#ifdef CONFIG_PM_SLEEP void save_processor_state (void );void restore_processor_state (void );@@ -391,6 +394,7 @@ extern bool events_check_enabled;extern bool pm_wakeup_pending (void );extern void pm_system_wakeup (void );extern void pm_wakeup_clear (void ); +extern void pm_system_irq_wakeup (unsigned int );extern bool pm_get_wakeup_count (unsigned int *count,bool block);extern bool pm_save_wakeup_count (unsigned int count);extern void pm_wakep_autosleep_enabled (bool set);@@ -440,6 +444,7 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)static inline bool pm_wakeup_pending (void ) {return false; }static inline void pm_system_wakeup (void ) {}static inline void pm_wakeup_clear (void ) {} +static inline void pm_system_irq_wakeup (unsigned int ) {}static inline void lock_system_sleep (void ) {}static inline void unlock_system_sleep (void ) {}kernel/irq/pm.c +0
-0
kernel/irq/pm.c bool irq_pm_check_wakeup(struct irq_desc *desc) · line 26
Quoted 7 lines
kernel/irq/pm.c +1
-1@@ -21,7 +21,7 @@ bool irq_pm_check_wakeup(struct irq_desc *desc) desc->istate |=IRQS_SUSPENDED |IRQS_PENDING ; desc->depth++;irq_disable (desc); -pm_system_wakeup (); +pm_system_irq_wakeup (irq_desc_get_irq (desc));return true; }
Thomas, any objections agains the above?
kernel/irq/pm.c static bool suspend_device_irq(struct irq_desc *desc, int irq) · line 76
Quoted 6 lines
kernel/irq/pm.c +1
-0return false;@@ -73,6 +73,7 @@ static bool suspend_device_irq(struct irq_desc *desc, int irq)if (!desc->action || desc->no_suspend_depth)return false; +
A leftover from the previous versions of the patch?
Not useful anyway.
Quoted 33 lines
kernel/irq/pm.c +0
-0if (irqd_is_wakeup_set (&desc->irq_data)) {irqd_set (&desc->irq_data,IRQD_WAKEUP_ARMED );/* kernel/power/main.c +17
-0@@ -272,6 +272,23 @@ static inline void pm_print_times_init(void) { pm_print_times_enabled = !!initcall_debug; } + +unsigned int wakeup_irq; +static ssize_t pm_wakeup_irq_show (struct kobject *kobj, +struct kobj_attribute *attr, +char *buf) +{ +return wakeup_irq ?sprintf (buf,"%u\n" , wakeup_irq) : -ENODATA ; +} + +static ssize_t pm_wakeup_irq_store (struct kobject *kobj, +struct kobj_attribute *attr, +const char *buf,size_t n) +{ +return -EINVAL ; +} +power_attr (pm_wakeup_irq); +#else /* !CONFIG_PM_SLEEP_DEBUG */ static inline void pm_print_times_init (void ) {}#endif /* CONFIG_PM_SLEEP_DEBUG */
kernel/power/main.c static struct attribute * g[] = { · line 627
Quoted 7 lines
kernel/power/main.c +1
-0@@ -604,6 +621,7 @@ static struct attribute * g[] = {#endif #ifdef CONFIG_PM_SLEEP_DEBUG &pm_print_times_attr.attr, + &pm_wakeup_irq_attr.attr,#endif #endif #ifdef CONFIG_FREEZER
Thanks,
Rafael
Thomas Gleixner
Reviewed-byQuoted 6 lines · Rafael J. Wysocki
Quoted 6 lines
kernel/irq/pm.c +0
-0@@ -21,7 +21,7 @@ bool irq_pm_check_wakeup(struct irq_desc *desc) desc->istate |=IRQS_SUSPENDED |IRQS_PENDING ;
Quoted 8 lines
kernel/irq/pm.c bool irq_pm_check_wakeup(struct irq_desc *desc) · line 26
Quoted 6 lines
kernel/irq/pm.c +1
-1desc->depth++;irq_disable (desc); -pm_system_wakeup (); +pm_system_irq_wakeup (irq_desc_get_irq (desc));return true; }Thomas, any objections agains the above?
Quoted 10 lines
kernel/irq/pm.c static bool suspend_device_irq(struct irq_desc *desc, int irq) · line 76
Quoted 6 lines
kernel/irq/pm.c +1
-0return false;@@ -73,6 +73,7 @@ static bool suspend_device_irq(struct irq_desc *desc, int irq)if (!desc->action || desc->no_suspend_depth)return false; +A leftover from the previous versions of the patch?
Not useful anyway.
You said it way more polite than I would have :)
Thanks,
tglx
Quoted 23 lines · Thomas Gleixner
Quoted 6 lines · Rafael J. Wysocki
Quoted 6 lines
kernel/irq/pm.c +0
-0@@ -21,7 +21,7 @@ bool irq_pm_check_wakeup(struct irq_desc *desc) desc->istate |=IRQS_SUSPENDED |IRQS_PENDING ;Quoted 8 lines
kernel/irq/pm.c bool irq_pm_check_wakeup(struct irq_desc *desc) · line 26
Quoted 6 lines
kernel/irq/pm.c +1
-1desc->depth++;irq_disable (desc); -pm_system_wakeup (); +pm_system_irq_wakeup (irq_desc_get_irq (desc));return true; }Thomas, any objections agains the above?
Reviewed-by Thomas Gleixner <[email protected]>Quoted 5 lines
Quoted 5 lines
kernel/irq/pm.c +0
-0return false;@@ -73,6 +73,7 @@ static bool suspend_device_irq(struct irq_desc *desc, int irq)if (!desc->action || desc->no_suspend_depth)return false;
Quoted 7 lines
Quoted 5 lines
kernel/irq/pm.c static bool suspend_device_irq(struct irq_desc *desc, int irq) · line 76
Quoted 1 line
kernel/irq/pm.c +1
-0+A leftover from the previous versions of the patch?
Not useful anyway.
You said it way more polite than I would have :)
Heh
OK, I'll drop the pointless hunk from the patch and apply it then.
Thanks,
Rafael