Commit 3a6e55cb authored by Thomas Gleixner's avatar Thomas Gleixner

clockevents: Convert clockevents / tick device locks to atomic_spinlock

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 4b064e4f
...@@ -28,7 +28,7 @@ static LIST_HEAD(clockevents_released); ...@@ -28,7 +28,7 @@ static LIST_HEAD(clockevents_released);
static RAW_NOTIFIER_HEAD(clockevents_chain); static RAW_NOTIFIER_HEAD(clockevents_chain);
/* Protection for the above */ /* Protection for the above */
static DEFINE_SPINLOCK(clockevents_lock); static DEFINE_ATOMIC_SPINLOCK(clockevents_lock);
/** /**
* clockevents_delta2ns - Convert a latch value (device ticks) to nanoseconds * clockevents_delta2ns - Convert a latch value (device ticks) to nanoseconds
...@@ -139,9 +139,9 @@ int clockevents_register_notifier(struct notifier_block *nb) ...@@ -139,9 +139,9 @@ int clockevents_register_notifier(struct notifier_block *nb)
{ {
int ret; int ret;
spin_lock(&clockevents_lock); atomic_spin_lock(&clockevents_lock);
ret = raw_notifier_chain_register(&clockevents_chain, nb); ret = raw_notifier_chain_register(&clockevents_chain, nb);
spin_unlock(&clockevents_lock); atomic_spin_unlock(&clockevents_lock);
return ret; return ret;
} }
...@@ -181,13 +181,13 @@ void clockevents_register_device(struct clock_event_device *dev) ...@@ -181,13 +181,13 @@ void clockevents_register_device(struct clock_event_device *dev)
BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
BUG_ON(!dev->cpumask); BUG_ON(!dev->cpumask);
spin_lock(&clockevents_lock); atomic_spin_lock(&clockevents_lock);
list_add(&dev->list, &clockevent_devices); list_add(&dev->list, &clockevent_devices);
clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev); clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev);
clockevents_notify_released(); clockevents_notify_released();
spin_unlock(&clockevents_lock); atomic_spin_unlock(&clockevents_lock);
} }
EXPORT_SYMBOL_GPL(clockevents_register_device); EXPORT_SYMBOL_GPL(clockevents_register_device);
...@@ -236,7 +236,7 @@ void clockevents_notify(unsigned long reason, void *arg) ...@@ -236,7 +236,7 @@ void clockevents_notify(unsigned long reason, void *arg)
{ {
struct list_head *node, *tmp; struct list_head *node, *tmp;
spin_lock(&clockevents_lock); atomic_spin_lock(&clockevents_lock);
clockevents_do_notify(reason, arg); clockevents_do_notify(reason, arg);
switch (reason) { switch (reason) {
...@@ -251,7 +251,7 @@ void clockevents_notify(unsigned long reason, void *arg) ...@@ -251,7 +251,7 @@ void clockevents_notify(unsigned long reason, void *arg)
default: default:
break; break;
} }
spin_unlock(&clockevents_lock); atomic_spin_unlock(&clockevents_lock);
} }
EXPORT_SYMBOL_GPL(clockevents_notify); EXPORT_SYMBOL_GPL(clockevents_notify);
#endif #endif
...@@ -31,7 +31,7 @@ static struct tick_device tick_broadcast_device; ...@@ -31,7 +31,7 @@ static struct tick_device tick_broadcast_device;
/* FIXME: Use cpumask_var_t. */ /* FIXME: Use cpumask_var_t. */
static DECLARE_BITMAP(tick_broadcast_mask, NR_CPUS); static DECLARE_BITMAP(tick_broadcast_mask, NR_CPUS);
static DECLARE_BITMAP(tmpmask, NR_CPUS); static DECLARE_BITMAP(tmpmask, NR_CPUS);
static DEFINE_SPINLOCK(tick_broadcast_lock); static DEFINE_ATOMIC_SPINLOCK(tick_broadcast_lock);
static int tick_broadcast_force; static int tick_broadcast_force;
#ifdef CONFIG_TICK_ONESHOT #ifdef CONFIG_TICK_ONESHOT
...@@ -96,7 +96,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu) ...@@ -96,7 +96,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
unsigned long flags; unsigned long flags;
int ret = 0; int ret = 0;
spin_lock_irqsave(&tick_broadcast_lock, flags); atomic_spin_lock_irqsave(&tick_broadcast_lock, flags);
/* /*
* Devices might be registered with both periodic and oneshot * Devices might be registered with both periodic and oneshot
...@@ -122,7 +122,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu) ...@@ -122,7 +122,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
tick_broadcast_clear_oneshot(cpu); tick_broadcast_clear_oneshot(cpu);
} }
} }
spin_unlock_irqrestore(&tick_broadcast_lock, flags); atomic_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
return ret; return ret;
} }
...@@ -161,13 +161,13 @@ static void tick_do_broadcast(struct cpumask *mask) ...@@ -161,13 +161,13 @@ static void tick_do_broadcast(struct cpumask *mask)
*/ */
static void tick_do_periodic_broadcast(void) static void tick_do_periodic_broadcast(void)
{ {
spin_lock(&tick_broadcast_lock); atomic_spin_lock(&tick_broadcast_lock);
cpumask_and(to_cpumask(tmpmask), cpumask_and(to_cpumask(tmpmask),
cpu_online_mask, tick_get_broadcast_mask()); cpu_online_mask, tick_get_broadcast_mask());
tick_do_broadcast(to_cpumask(tmpmask)); tick_do_broadcast(to_cpumask(tmpmask));
spin_unlock(&tick_broadcast_lock); atomic_spin_unlock(&tick_broadcast_lock);
} }
/* /*
...@@ -212,7 +212,7 @@ static void tick_do_broadcast_on_off(void *why) ...@@ -212,7 +212,7 @@ static void tick_do_broadcast_on_off(void *why)
unsigned long flags, *reason = why; unsigned long flags, *reason = why;
int cpu, bc_stopped; int cpu, bc_stopped;
spin_lock_irqsave(&tick_broadcast_lock, flags); atomic_spin_lock_irqsave(&tick_broadcast_lock, flags);
cpu = smp_processor_id(); cpu = smp_processor_id();
td = &per_cpu(tick_cpu_device, cpu); td = &per_cpu(tick_cpu_device, cpu);
...@@ -263,7 +263,7 @@ static void tick_do_broadcast_on_off(void *why) ...@@ -263,7 +263,7 @@ static void tick_do_broadcast_on_off(void *why)
tick_broadcast_setup_oneshot(bc); tick_broadcast_setup_oneshot(bc);
} }
out: out:
spin_unlock_irqrestore(&tick_broadcast_lock, flags); atomic_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
} }
/* /*
...@@ -300,7 +300,7 @@ void tick_shutdown_broadcast(unsigned int *cpup) ...@@ -300,7 +300,7 @@ void tick_shutdown_broadcast(unsigned int *cpup)
unsigned long flags; unsigned long flags;
unsigned int cpu = *cpup; unsigned int cpu = *cpup;
spin_lock_irqsave(&tick_broadcast_lock, flags); atomic_spin_lock_irqsave(&tick_broadcast_lock, flags);
bc = tick_broadcast_device.evtdev; bc = tick_broadcast_device.evtdev;
cpumask_clear_cpu(cpu, tick_get_broadcast_mask()); cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
...@@ -310,7 +310,7 @@ void tick_shutdown_broadcast(unsigned int *cpup) ...@@ -310,7 +310,7 @@ void tick_shutdown_broadcast(unsigned int *cpup)
clockevents_shutdown(bc); clockevents_shutdown(bc);
} }
spin_unlock_irqrestore(&tick_broadcast_lock, flags); atomic_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
} }
void tick_suspend_broadcast(void) void tick_suspend_broadcast(void)
...@@ -318,13 +318,13 @@ void tick_suspend_broadcast(void) ...@@ -318,13 +318,13 @@ void tick_suspend_broadcast(void)
struct clock_event_device *bc; struct clock_event_device *bc;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&tick_broadcast_lock, flags); atomic_spin_lock_irqsave(&tick_broadcast_lock, flags);
bc = tick_broadcast_device.evtdev; bc = tick_broadcast_device.evtdev;
if (bc) if (bc)
clockevents_shutdown(bc); clockevents_shutdown(bc);
spin_unlock_irqrestore(&tick_broadcast_lock, flags); atomic_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
} }
int tick_resume_broadcast(void) int tick_resume_broadcast(void)
...@@ -333,7 +333,7 @@ int tick_resume_broadcast(void) ...@@ -333,7 +333,7 @@ int tick_resume_broadcast(void)
unsigned long flags; unsigned long flags;
int broadcast = 0; int broadcast = 0;
spin_lock_irqsave(&tick_broadcast_lock, flags); atomic_spin_lock_irqsave(&tick_broadcast_lock, flags);
bc = tick_broadcast_device.evtdev; bc = tick_broadcast_device.evtdev;
...@@ -352,7 +352,7 @@ int tick_resume_broadcast(void) ...@@ -352,7 +352,7 @@ int tick_resume_broadcast(void)
break; break;
} }
} }
spin_unlock_irqrestore(&tick_broadcast_lock, flags); atomic_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
return broadcast; return broadcast;
} }
...@@ -406,7 +406,7 @@ static void tick_handle_oneshot_broadcast(struct clock_event_device *dev) ...@@ -406,7 +406,7 @@ static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
ktime_t now, next_event; ktime_t now, next_event;
int cpu; int cpu;
spin_lock(&tick_broadcast_lock); atomic_spin_lock(&tick_broadcast_lock);
again: again:
dev->next_event.tv64 = KTIME_MAX; dev->next_event.tv64 = KTIME_MAX;
next_event.tv64 = KTIME_MAX; next_event.tv64 = KTIME_MAX;
...@@ -444,7 +444,7 @@ again: ...@@ -444,7 +444,7 @@ again:
if (tick_broadcast_set_event(next_event, 0)) if (tick_broadcast_set_event(next_event, 0))
goto again; goto again;
} }
spin_unlock(&tick_broadcast_lock); atomic_spin_unlock(&tick_broadcast_lock);
} }
/* /*
...@@ -458,7 +458,7 @@ void tick_broadcast_oneshot_control(unsigned long reason) ...@@ -458,7 +458,7 @@ void tick_broadcast_oneshot_control(unsigned long reason)
unsigned long flags; unsigned long flags;
int cpu; int cpu;
spin_lock_irqsave(&tick_broadcast_lock, flags); atomic_spin_lock_irqsave(&tick_broadcast_lock, flags);
/* /*
* Periodic mode does not care about the enter/exit of power * Periodic mode does not care about the enter/exit of power
...@@ -493,7 +493,7 @@ void tick_broadcast_oneshot_control(unsigned long reason) ...@@ -493,7 +493,7 @@ void tick_broadcast_oneshot_control(unsigned long reason)
} }
out: out:
spin_unlock_irqrestore(&tick_broadcast_lock, flags); atomic_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
} }
/* /*
...@@ -564,13 +564,13 @@ void tick_broadcast_switch_to_oneshot(void) ...@@ -564,13 +564,13 @@ void tick_broadcast_switch_to_oneshot(void)
struct clock_event_device *bc; struct clock_event_device *bc;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&tick_broadcast_lock, flags); atomic_spin_lock_irqsave(&tick_broadcast_lock, flags);
tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT; tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT;
bc = tick_broadcast_device.evtdev; bc = tick_broadcast_device.evtdev;
if (bc) if (bc)
tick_broadcast_setup_oneshot(bc); tick_broadcast_setup_oneshot(bc);
spin_unlock_irqrestore(&tick_broadcast_lock, flags); atomic_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
} }
...@@ -582,7 +582,7 @@ void tick_shutdown_broadcast_oneshot(unsigned int *cpup) ...@@ -582,7 +582,7 @@ void tick_shutdown_broadcast_oneshot(unsigned int *cpup)
unsigned long flags; unsigned long flags;
unsigned int cpu = *cpup; unsigned int cpu = *cpup;
spin_lock_irqsave(&tick_broadcast_lock, flags); atomic_spin_lock_irqsave(&tick_broadcast_lock, flags);
/* /*
* Clear the broadcast mask flag for the dead cpu, but do not * Clear the broadcast mask flag for the dead cpu, but do not
...@@ -590,7 +590,7 @@ void tick_shutdown_broadcast_oneshot(unsigned int *cpup) ...@@ -590,7 +590,7 @@ void tick_shutdown_broadcast_oneshot(unsigned int *cpup)
*/ */
cpumask_clear_cpu(cpu, tick_get_broadcast_oneshot_mask()); cpumask_clear_cpu(cpu, tick_get_broadcast_oneshot_mask());
spin_unlock_irqrestore(&tick_broadcast_lock, flags); atomic_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
} }
/* /*
......
...@@ -34,7 +34,7 @@ DEFINE_PER_CPU(struct tick_device, tick_cpu_device); ...@@ -34,7 +34,7 @@ DEFINE_PER_CPU(struct tick_device, tick_cpu_device);
ktime_t tick_next_period; ktime_t tick_next_period;
ktime_t tick_period; ktime_t tick_period;
int tick_do_timer_cpu __read_mostly = TICK_DO_TIMER_BOOT; int tick_do_timer_cpu __read_mostly = TICK_DO_TIMER_BOOT;
DEFINE_SPINLOCK(tick_device_lock); DEFINE_ATOMIC_SPINLOCK(tick_device_lock);
/* /*
* Debugging: see timer_list.c * Debugging: see timer_list.c
...@@ -209,7 +209,7 @@ static int tick_check_new_device(struct clock_event_device *newdev) ...@@ -209,7 +209,7 @@ static int tick_check_new_device(struct clock_event_device *newdev)
int cpu, ret = NOTIFY_OK; int cpu, ret = NOTIFY_OK;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&tick_device_lock, flags); atomic_spin_lock_irqsave(&tick_device_lock, flags);
cpu = smp_processor_id(); cpu = smp_processor_id();
if (!cpumask_test_cpu(cpu, newdev->cpumask)) if (!cpumask_test_cpu(cpu, newdev->cpumask))
...@@ -268,7 +268,7 @@ static int tick_check_new_device(struct clock_event_device *newdev) ...@@ -268,7 +268,7 @@ static int tick_check_new_device(struct clock_event_device *newdev)
if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) if (newdev->features & CLOCK_EVT_FEAT_ONESHOT)
tick_oneshot_notify(); tick_oneshot_notify();
spin_unlock_irqrestore(&tick_device_lock, flags); atomic_spin_unlock_irqrestore(&tick_device_lock, flags);
return NOTIFY_STOP; return NOTIFY_STOP;
out_bc: out_bc:
...@@ -278,7 +278,7 @@ out_bc: ...@@ -278,7 +278,7 @@ out_bc:
if (tick_check_broadcast_device(newdev)) if (tick_check_broadcast_device(newdev))
ret = NOTIFY_STOP; ret = NOTIFY_STOP;
spin_unlock_irqrestore(&tick_device_lock, flags); atomic_spin_unlock_irqrestore(&tick_device_lock, flags);
return ret; return ret;
} }
...@@ -311,7 +311,7 @@ static void tick_shutdown(unsigned int *cpup) ...@@ -311,7 +311,7 @@ static void tick_shutdown(unsigned int *cpup)
struct clock_event_device *dev = td->evtdev; struct clock_event_device *dev = td->evtdev;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&tick_device_lock, flags); atomic_spin_lock_irqsave(&tick_device_lock, flags);
td->mode = TICKDEV_MODE_PERIODIC; td->mode = TICKDEV_MODE_PERIODIC;
if (dev) { if (dev) {
/* /*
...@@ -322,7 +322,7 @@ static void tick_shutdown(unsigned int *cpup) ...@@ -322,7 +322,7 @@ static void tick_shutdown(unsigned int *cpup)
clockevents_exchange_device(dev, NULL); clockevents_exchange_device(dev, NULL);
td->evtdev = NULL; td->evtdev = NULL;
} }
spin_unlock_irqrestore(&tick_device_lock, flags); atomic_spin_unlock_irqrestore(&tick_device_lock, flags);
} }
static void tick_suspend(void) static void tick_suspend(void)
...@@ -330,9 +330,9 @@ static void tick_suspend(void) ...@@ -330,9 +330,9 @@ static void tick_suspend(void)
struct tick_device *td = &__get_cpu_var(tick_cpu_device); struct tick_device *td = &__get_cpu_var(tick_cpu_device);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&tick_device_lock, flags); atomic_spin_lock_irqsave(&tick_device_lock, flags);
clockevents_shutdown(td->evtdev); clockevents_shutdown(td->evtdev);
spin_unlock_irqrestore(&tick_device_lock, flags); atomic_spin_unlock_irqrestore(&tick_device_lock, flags);
} }
static void tick_resume(void) static void tick_resume(void)
...@@ -341,7 +341,7 @@ static void tick_resume(void) ...@@ -341,7 +341,7 @@ static void tick_resume(void)
unsigned long flags; unsigned long flags;
int broadcast = tick_resume_broadcast(); int broadcast = tick_resume_broadcast();
spin_lock_irqsave(&tick_device_lock, flags); atomic_spin_lock_irqsave(&tick_device_lock, flags);
clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_RESUME); clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_RESUME);
if (!broadcast) { if (!broadcast) {
...@@ -350,7 +350,7 @@ static void tick_resume(void) ...@@ -350,7 +350,7 @@ static void tick_resume(void)
else else
tick_resume_oneshot(); tick_resume_oneshot();
} }
spin_unlock_irqrestore(&tick_device_lock, flags); atomic_spin_unlock_irqrestore(&tick_device_lock, flags);
} }
/* /*
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define TICK_DO_TIMER_BOOT -2 #define TICK_DO_TIMER_BOOT -2
DECLARE_PER_CPU(struct tick_device, tick_cpu_device); DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
extern spinlock_t tick_device_lock; extern atomic_spinlock_t tick_device_lock;
extern ktime_t tick_next_period; extern ktime_t tick_next_period;
extern ktime_t tick_period; extern ktime_t tick_period;
extern int tick_do_timer_cpu __read_mostly; extern int tick_do_timer_cpu __read_mostly;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment