Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ledtrig-cpu: Handle CPU hot(un)plugging

When CPU is hot(un)plugged, no syscore notification is being
generated, nor is cpuidle involved. This leaves the CPU LED
turned on, because the dying thread is doing some work (LED on)
and than it is... well, dying (LED still on :-)

Added notifier block for hot(un)plugging operations, generating
existing trigger events.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>

authored by

Pawel Moll and committed by
Bryan Wu
fba14ae8 cfbf8d48

+24
+24
drivers/leds/trigger/ledtrig-cpu.c
··· 26 26 #include <linux/percpu.h> 27 27 #include <linux/syscore_ops.h> 28 28 #include <linux/rwsem.h> 29 + #include <linux/cpu.h> 29 30 #include "../leds.h" 30 31 31 32 #define MAX_NAME_LEN 8 ··· 93 92 .resume = ledtrig_cpu_syscore_resume, 94 93 }; 95 94 95 + static int ledtrig_cpu_notify(struct notifier_block *self, 96 + unsigned long action, void *hcpu) 97 + { 98 + switch (action & ~CPU_TASKS_FROZEN) { 99 + case CPU_STARTING: 100 + ledtrig_cpu(CPU_LED_START); 101 + break; 102 + case CPU_DYING: 103 + ledtrig_cpu(CPU_LED_STOP); 104 + break; 105 + } 106 + 107 + return NOTIFY_OK; 108 + } 109 + 110 + 111 + static struct notifier_block ledtrig_cpu_nb = { 112 + .notifier_call = ledtrig_cpu_notify, 113 + }; 114 + 96 115 static int __init ledtrig_cpu_init(void) 97 116 { 98 117 int cpu; ··· 134 113 } 135 114 136 115 register_syscore_ops(&ledtrig_cpu_syscore_ops); 116 + register_cpu_notifier(&ledtrig_cpu_nb); 137 117 138 118 pr_info("ledtrig-cpu: registered to indicate activity on CPUs\n"); 139 119 ··· 145 123 static void __exit ledtrig_cpu_exit(void) 146 124 { 147 125 int cpu; 126 + 127 + unregister_cpu_notifier(&ledtrig_cpu_nb); 148 128 149 129 for_each_possible_cpu(cpu) { 150 130 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);