diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2013-04-25 16:31:49 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2013-05-16 05:09:17 -0400 |
commit | ccf33d6880f39a35158fff66db13000ae4943fac (patch) | |
tree | a39cb95e64c412b107c8640ae521bda78a7d1033 | |
parent | 8c53daf63f56791ed47fc585206ef3049489612f (diff) |
clockevents: Add module refcount
We want to be able to remove clockevent modules as well. Add a
refcount so we don't remove a module with an active clock event
device.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130425143436.307435149@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | include/linux/clockchips.h | 3 | ||||
-rw-r--r-- | kernel/time/clockevents.c | 1 | ||||
-rw-r--r-- | kernel/time/tick-broadcast.c | 3 | ||||
-rw-r--r-- | kernel/time/tick-common.c | 4 |
4 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h index 2f498f66c1bb..ae1193bcf074 100644 --- a/include/linux/clockchips.h +++ b/include/linux/clockchips.h | |||
@@ -30,6 +30,7 @@ enum clock_event_nofitiers { | |||
30 | #include <linux/notifier.h> | 30 | #include <linux/notifier.h> |
31 | 31 | ||
32 | struct clock_event_device; | 32 | struct clock_event_device; |
33 | struct module; | ||
33 | 34 | ||
34 | /* Clock event mode commands */ | 35 | /* Clock event mode commands */ |
35 | enum clock_event_mode { | 36 | enum clock_event_mode { |
@@ -83,6 +84,7 @@ enum clock_event_mode { | |||
83 | * @irq: IRQ number (only for non CPU local devices) | 84 | * @irq: IRQ number (only for non CPU local devices) |
84 | * @cpumask: cpumask to indicate for which CPUs this device works | 85 | * @cpumask: cpumask to indicate for which CPUs this device works |
85 | * @list: list head for the management code | 86 | * @list: list head for the management code |
87 | * @owner: module reference | ||
86 | */ | 88 | */ |
87 | struct clock_event_device { | 89 | struct clock_event_device { |
88 | void (*event_handler)(struct clock_event_device *); | 90 | void (*event_handler)(struct clock_event_device *); |
@@ -112,6 +114,7 @@ struct clock_event_device { | |||
112 | int irq; | 114 | int irq; |
113 | const struct cpumask *cpumask; | 115 | const struct cpumask *cpumask; |
114 | struct list_head list; | 116 | struct list_head list; |
117 | struct module *owner; | ||
115 | } ____cacheline_aligned; | 118 | } ____cacheline_aligned; |
116 | 119 | ||
117 | /* | 120 | /* |
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index 0e3a8448e115..89e394caa769 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c | |||
@@ -357,6 +357,7 @@ void clockevents_exchange_device(struct clock_event_device *old, | |||
357 | * released list and do a notify add later. | 357 | * released list and do a notify add later. |
358 | */ | 358 | */ |
359 | if (old) { | 359 | if (old) { |
360 | module_put(old->owner); | ||
360 | clockevents_set_mode(old, CLOCK_EVT_MODE_UNUSED); | 361 | clockevents_set_mode(old, CLOCK_EVT_MODE_UNUSED); |
361 | list_del(&old->list); | 362 | list_del(&old->list); |
362 | list_add(&old->list, &clockevents_released); | 363 | list_add(&old->list, &clockevents_released); |
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index 3500caaa0bfd..0e374cd2e0ef 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/profile.h> | 19 | #include <linux/profile.h> |
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
21 | #include <linux/smp.h> | 21 | #include <linux/smp.h> |
22 | #include <linux/module.h> | ||
22 | 23 | ||
23 | #include "tick-internal.h" | 24 | #include "tick-internal.h" |
24 | 25 | ||
@@ -73,6 +74,8 @@ void tick_install_broadcast_device(struct clock_event_device *dev) | |||
73 | tick_broadcast_device.evtdev->rating >= dev->rating) || | 74 | tick_broadcast_device.evtdev->rating >= dev->rating) || |
74 | (dev->features & CLOCK_EVT_FEAT_C3STOP)) | 75 | (dev->features & CLOCK_EVT_FEAT_C3STOP)) |
75 | return; | 76 | return; |
77 | if (!try_module_get(dev->owner)) | ||
78 | return; | ||
76 | 79 | ||
77 | clockevents_exchange_device(tick_broadcast_device.evtdev, dev); | 80 | clockevents_exchange_device(tick_broadcast_device.evtdev, dev); |
78 | if (cur) | 81 | if (cur) |
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c index 84c7cfca4d7d..433a1e11d13b 100644 --- a/kernel/time/tick-common.c +++ b/kernel/time/tick-common.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/percpu.h> | 18 | #include <linux/percpu.h> |
19 | #include <linux/profile.h> | 19 | #include <linux/profile.h> |
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
21 | #include <linux/module.h> | ||
21 | 22 | ||
22 | #include <asm/irq_regs.h> | 23 | #include <asm/irq_regs.h> |
23 | 24 | ||
@@ -257,6 +258,9 @@ void tick_check_new_device(struct clock_event_device *newdev) | |||
257 | goto out_bc; | 258 | goto out_bc; |
258 | } | 259 | } |
259 | 260 | ||
261 | if (!try_module_get(newdev->owner)) | ||
262 | return; | ||
263 | |||
260 | /* | 264 | /* |
261 | * Replace the eventually existing device by the new | 265 | * Replace the eventually existing device by the new |
262 | * device. If the current device is the broadcast device, do | 266 | * device. If the current device is the broadcast device, do |