Skip to content

Commit

Permalink
sched: idle: Add support to print wake irqs during s2idle
Browse files Browse the repository at this point in the history
syscore ops prints wake irq during "deep" suspend exit however
syscore ops do not execute for "s2idle" suspend.

Add changes to print wakeup irq during "s2idle" mode exit.

The change prints wakeup irq from the first cpu waking up from s2idle
during which local irqs on the cpu is disabled.

Change-Id: Idd05d42f30b97cc5f9d62627339e21731f131673
Signed-off-by: Maulik Shah <[email protected]>
  • Loading branch information
mkshahc authored and jerpelea committed Nov 16, 2022
1 parent 22f0921 commit c4343d6
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/irqchip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ config ARM_GIC_V3
select IRQ_DOMAIN_HIERARCHY
select PARTITION_PERCPU
select GENERIC_IRQ_EFFECTIVE_AFF_MASK
select QGKI_SHOW_S2IDLE_WAKE_IRQ if QGKI

config ARM_GIC_V3_ITS
bool
Expand Down Expand Up @@ -516,4 +517,11 @@ config SIFIVE_PLIC

If you don't know what to do here, say Y.

config QGKI_SHOW_S2IDLE_WAKE_IRQ
bool "Qualcomm Technologies, Inc. (QTI) SHOW S2IDLE WAKE IRQ"
depends on ARM_GIC_V3
help
When this option is selected, first cpu waking up from s2idle
prints the interrupts pending and enabled at GIC.

endmenu
8 changes: 8 additions & 0 deletions drivers/irqchip/irq-gic-v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/percpu.h>
#include <linux/refcount.h>
#include <linux/slab.h>
#include <linux/suspend.h>
#include <linux/msm_rtb.h>
#include <linux/wakeup_reason.h>

Expand Down Expand Up @@ -1244,6 +1245,13 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
#define gic_smp_init() do { } while(0)
#endif

#ifdef CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ
void gic_s2idle_wake(void)
{
gic_resume_one(&gic_data);
}
#endif /* CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ */

#ifdef CONFIG_CPU_PM
static int gic_cpu_pm_notifier(struct notifier_block *self,
unsigned long cmd, void *v)
Expand Down
4 changes: 4 additions & 0 deletions include/linux/irqchip/arm-gic-v3.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,10 @@ static inline bool gic_enable_sre(void)
return !!(val & ICC_SRE_EL1_SRE);
}

#ifdef CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ
void gic_s2idle_wake(void);
#endif /* CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ */

#endif

#endif
25 changes: 25 additions & 0 deletions kernel/sched/idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*/
#include "sched.h"

#ifdef CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ
#include <linux/irqchip/arm-gic-v3.h>
#endif /* CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ */
#include <trace/events/power.h>

/* Linker adds these: start and end of __cpuidle functions */
Expand Down Expand Up @@ -128,6 +131,11 @@ static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev,
* set, and it returns with polling set. If it ever stops polling, it
* must clear the polling bit.
*/

#ifdef CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ
static cpumask_t cpu_state;
#endif /* CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ */

static void cpuidle_idle_call(void)
{
struct cpuidle_device *dev = cpuidle_get_device();
Expand Down Expand Up @@ -169,9 +177,26 @@ static void cpuidle_idle_call(void)

if (idle_should_enter_s2idle() || dev->use_deepest_state) {
if (idle_should_enter_s2idle()) {

#ifdef CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ
bool print_wake_irq;

cpumask_set_cpu(dev->cpu, &cpu_state);
#endif /* CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ */

rcu_idle_enter();

entered_state = cpuidle_enter_s2idle(drv, dev);

#ifdef CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ
print_wake_irq = cpumask_weight(&cpu_state) ==
cpumask_weight(cpu_online_mask) ?
true : false;
cpumask_clear_cpu(dev->cpu, &cpu_state);
if (print_wake_irq)
gic_s2idle_wake();
#endif /* CONFIG_QGKI_SHOW_S2IDLE_WAKE_IRQ */

if (entered_state > 0) {
local_irq_enable();
goto exit_idle;
Expand Down

0 comments on commit c4343d6

Please sign in to comment.