Updated from Linux LTS 3.10.22 to 3.10.23
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
#include <linux/hrtimer.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/smp.h>
|
||||
|
||||
#include "tick-internal.h"
|
||||
@@ -23,10 +22,6 @@
|
||||
/* The registered clock event devices */
|
||||
static LIST_HEAD(clockevent_devices);
|
||||
static LIST_HEAD(clockevents_released);
|
||||
|
||||
/* Notification for clock events */
|
||||
static RAW_NOTIFIER_HEAD(clockevents_chain);
|
||||
|
||||
/* Protection for the above */
|
||||
static DEFINE_RAW_SPINLOCK(clockevents_lock);
|
||||
|
||||
@@ -267,30 +262,6 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires,
|
||||
return (rc && force) ? clockevents_program_min_delta(dev) : rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* clockevents_register_notifier - register a clock events change listener
|
||||
*/
|
||||
int clockevents_register_notifier(struct notifier_block *nb)
|
||||
{
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
|
||||
raw_spin_lock_irqsave(&clockevents_lock, flags);
|
||||
ret = raw_notifier_chain_register(&clockevents_chain, nb);
|
||||
raw_spin_unlock_irqrestore(&clockevents_lock, flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Notify about a clock event change. Called with clockevents_lock
|
||||
* held.
|
||||
*/
|
||||
static void clockevents_do_notify(unsigned long reason, void *dev)
|
||||
{
|
||||
raw_notifier_call_chain(&clockevents_chain, reason, dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called after a notify add to make devices available which were
|
||||
* released from the notifier call.
|
||||
@@ -304,7 +275,7 @@ static void clockevents_notify_released(void)
|
||||
struct clock_event_device, list);
|
||||
list_del(&dev->list);
|
||||
list_add(&dev->list, &clockevent_devices);
|
||||
clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev);
|
||||
tick_check_new_device(dev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +296,7 @@ void clockevents_register_device(struct clock_event_device *dev)
|
||||
raw_spin_lock_irqsave(&clockevents_lock, flags);
|
||||
|
||||
list_add(&dev->list, &clockevent_devices);
|
||||
clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev);
|
||||
tick_check_new_device(dev);
|
||||
clockevents_notify_released();
|
||||
|
||||
raw_spin_unlock_irqrestore(&clockevents_lock, flags);
|
||||
@@ -421,6 +392,7 @@ void clockevents_exchange_device(struct clock_event_device *old,
|
||||
* released list and do a notify add later.
|
||||
*/
|
||||
if (old) {
|
||||
module_put(old->owner);
|
||||
clockevents_set_mode(old, CLOCK_EVT_MODE_UNUSED);
|
||||
list_del(&old->list);
|
||||
list_add(&old->list, &clockevents_released);
|
||||
@@ -468,7 +440,7 @@ void clockevents_notify(unsigned long reason, void *arg)
|
||||
int cpu;
|
||||
|
||||
raw_spin_lock_irqsave(&clockevents_lock, flags);
|
||||
clockevents_do_notify(reason, arg);
|
||||
tick_notify(reason, arg);
|
||||
|
||||
switch (reason) {
|
||||
case CLOCK_EVT_NOTIFY_CPU_DEAD:
|
||||
|
||||
@@ -475,6 +475,7 @@ static void sync_cmos_clock(struct work_struct *work)
|
||||
* called as close as possible to 500 ms before the new second starts.
|
||||
* This code is run on a timer. If the clock is set, that timer
|
||||
* may not expire at the correct time. Thus, we adjust...
|
||||
* We want the clock to be within a couple of ticks from the target.
|
||||
*/
|
||||
if (!ntp_synced()) {
|
||||
/*
|
||||
@@ -485,7 +486,7 @@ static void sync_cmos_clock(struct work_struct *work)
|
||||
}
|
||||
|
||||
getnstimeofday(&now);
|
||||
if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec / 2) {
|
||||
if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec * 5) {
|
||||
struct timespec adjust = now;
|
||||
|
||||
fail = -ENODEV;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <linux/profile.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/smp.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include "tick-internal.h"
|
||||
|
||||
@@ -65,17 +66,34 @@ static void tick_broadcast_start_periodic(struct clock_event_device *bc)
|
||||
/*
|
||||
* Check, if the device can be utilized as broadcast device:
|
||||
*/
|
||||
int tick_check_broadcast_device(struct clock_event_device *dev)
|
||||
static bool tick_check_broadcast_device(struct clock_event_device *curdev,
|
||||
struct clock_event_device *newdev)
|
||||
{
|
||||
if ((newdev->features & CLOCK_EVT_FEAT_DUMMY) ||
|
||||
(newdev->features & CLOCK_EVT_FEAT_C3STOP))
|
||||
return false;
|
||||
|
||||
if (tick_broadcast_device.mode == TICKDEV_MODE_ONESHOT &&
|
||||
!(newdev->features & CLOCK_EVT_FEAT_ONESHOT))
|
||||
return false;
|
||||
|
||||
return !curdev || newdev->rating > curdev->rating;
|
||||
}
|
||||
|
||||
/*
|
||||
* Conditionally install/replace broadcast device
|
||||
*/
|
||||
void tick_install_broadcast_device(struct clock_event_device *dev)
|
||||
{
|
||||
struct clock_event_device *cur = tick_broadcast_device.evtdev;
|
||||
|
||||
if ((dev->features & CLOCK_EVT_FEAT_DUMMY) ||
|
||||
(tick_broadcast_device.evtdev &&
|
||||
tick_broadcast_device.evtdev->rating >= dev->rating) ||
|
||||
(dev->features & CLOCK_EVT_FEAT_C3STOP))
|
||||
return 0;
|
||||
if (!tick_check_broadcast_device(cur, dev))
|
||||
return;
|
||||
|
||||
clockevents_exchange_device(tick_broadcast_device.evtdev, dev);
|
||||
if (!try_module_get(dev->owner))
|
||||
return;
|
||||
|
||||
clockevents_exchange_device(cur, dev);
|
||||
if (cur)
|
||||
cur->event_handler = clockevents_handle_noop;
|
||||
tick_broadcast_device.evtdev = dev;
|
||||
@@ -91,7 +109,6 @@ int tick_check_broadcast_device(struct clock_event_device *dev)
|
||||
*/
|
||||
if (dev->features & CLOCK_EVT_FEAT_ONESHOT)
|
||||
tick_clock_notify();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <linux/percpu.h>
|
||||
#include <linux/profile.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <asm/irq_regs.h>
|
||||
|
||||
@@ -206,14 +207,50 @@ static void tick_setup_device(struct tick_device *td,
|
||||
tick_setup_oneshot(newdev, handler, next_event);
|
||||
}
|
||||
|
||||
static bool tick_check_percpu(struct clock_event_device *curdev,
|
||||
struct clock_event_device *newdev, int cpu)
|
||||
{
|
||||
if (!cpumask_test_cpu(cpu, newdev->cpumask))
|
||||
return false;
|
||||
if (cpumask_equal(newdev->cpumask, cpumask_of(cpu)))
|
||||
return true;
|
||||
/* Check if irq affinity can be set */
|
||||
if (newdev->irq >= 0 && !irq_can_set_affinity(newdev->irq))
|
||||
return false;
|
||||
/* Prefer an existing cpu local device */
|
||||
if (curdev && cpumask_equal(curdev->cpumask, cpumask_of(cpu)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool tick_check_preferred(struct clock_event_device *curdev,
|
||||
struct clock_event_device *newdev)
|
||||
{
|
||||
/* Prefer oneshot capable device */
|
||||
if (!(newdev->features & CLOCK_EVT_FEAT_ONESHOT)) {
|
||||
if (curdev && (curdev->features & CLOCK_EVT_FEAT_ONESHOT))
|
||||
return false;
|
||||
if (tick_oneshot_mode_active())
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Use the higher rated one, but prefer a CPU local device with a lower
|
||||
* rating than a non-CPU local device
|
||||
*/
|
||||
return !curdev ||
|
||||
newdev->rating > curdev->rating ||
|
||||
!cpumask_equal(curdev->cpumask, newdev->cpumask);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check, if the new registered device should be used.
|
||||
*/
|
||||
static int tick_check_new_device(struct clock_event_device *newdev)
|
||||
void tick_check_new_device(struct clock_event_device *newdev)
|
||||
{
|
||||
struct clock_event_device *curdev;
|
||||
struct tick_device *td;
|
||||
int cpu, ret = NOTIFY_OK;
|
||||
int cpu;
|
||||
unsigned long flags;
|
||||
|
||||
raw_spin_lock_irqsave(&tick_device_lock, flags);
|
||||
@@ -226,40 +263,15 @@ static int tick_check_new_device(struct clock_event_device *newdev)
|
||||
curdev = td->evtdev;
|
||||
|
||||
/* cpu local device ? */
|
||||
if (!cpumask_equal(newdev->cpumask, cpumask_of(cpu))) {
|
||||
if (!tick_check_percpu(curdev, newdev, cpu))
|
||||
goto out_bc;
|
||||
|
||||
/*
|
||||
* If the cpu affinity of the device interrupt can not
|
||||
* be set, ignore it.
|
||||
*/
|
||||
if (!irq_can_set_affinity(newdev->irq))
|
||||
goto out_bc;
|
||||
/* Preference decision */
|
||||
if (!tick_check_preferred(curdev, newdev))
|
||||
goto out_bc;
|
||||
|
||||
/*
|
||||
* If we have a cpu local device already, do not replace it
|
||||
* by a non cpu local device
|
||||
*/
|
||||
if (curdev && cpumask_equal(curdev->cpumask, cpumask_of(cpu)))
|
||||
goto out_bc;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we have an active device, then check the rating and the oneshot
|
||||
* feature.
|
||||
*/
|
||||
if (curdev) {
|
||||
/*
|
||||
* Prefer one shot capable devices !
|
||||
*/
|
||||
if ((curdev->features & CLOCK_EVT_FEAT_ONESHOT) &&
|
||||
!(newdev->features & CLOCK_EVT_FEAT_ONESHOT))
|
||||
goto out_bc;
|
||||
/*
|
||||
* Check the rating
|
||||
*/
|
||||
if (curdev->rating >= newdev->rating)
|
||||
goto out_bc;
|
||||
}
|
||||
if (!try_module_get(newdev->owner))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Replace the eventually existing device by the new
|
||||
@@ -276,18 +288,14 @@ static int tick_check_new_device(struct clock_event_device *newdev)
|
||||
tick_oneshot_notify();
|
||||
|
||||
raw_spin_unlock_irqrestore(&tick_device_lock, flags);
|
||||
return NOTIFY_STOP;
|
||||
return;
|
||||
|
||||
out_bc:
|
||||
/*
|
||||
* Can the new device be used as a broadcast device ?
|
||||
*/
|
||||
if (tick_check_broadcast_device(newdev))
|
||||
ret = NOTIFY_STOP;
|
||||
|
||||
tick_install_broadcast_device(newdev);
|
||||
raw_spin_unlock_irqrestore(&tick_device_lock, flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -361,17 +369,10 @@ static void tick_resume(void)
|
||||
raw_spin_unlock_irqrestore(&tick_device_lock, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* Notification about clock event devices
|
||||
*/
|
||||
static int tick_notify(struct notifier_block *nb, unsigned long reason,
|
||||
void *dev)
|
||||
void tick_notify(unsigned long reason, void *dev)
|
||||
{
|
||||
switch (reason) {
|
||||
|
||||
case CLOCK_EVT_NOTIFY_ADD:
|
||||
return tick_check_new_device(dev);
|
||||
|
||||
case CLOCK_EVT_NOTIFY_BROADCAST_ON:
|
||||
case CLOCK_EVT_NOTIFY_BROADCAST_OFF:
|
||||
case CLOCK_EVT_NOTIFY_BROADCAST_FORCE:
|
||||
@@ -405,21 +406,12 @@ static int tick_notify(struct notifier_block *nb, unsigned long reason,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
|
||||
static struct notifier_block tick_notifier = {
|
||||
.notifier_call = tick_notify,
|
||||
};
|
||||
|
||||
/**
|
||||
* tick_init - initialize the tick control
|
||||
*
|
||||
* Register the notifier with the clockevents framework
|
||||
*/
|
||||
void __init tick_init(void)
|
||||
{
|
||||
clockevents_register_notifier(&tick_notifier);
|
||||
tick_broadcast_init();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ extern int tick_do_timer_cpu __read_mostly;
|
||||
|
||||
extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
|
||||
extern void tick_handle_periodic(struct clock_event_device *dev);
|
||||
extern void tick_notify(unsigned long reason, void *dev);
|
||||
extern void tick_check_new_device(struct clock_event_device *dev);
|
||||
|
||||
extern void clockevents_shutdown(struct clock_event_device *dev);
|
||||
|
||||
@@ -90,7 +92,7 @@ static inline bool tick_broadcast_oneshot_available(void) { return false; }
|
||||
*/
|
||||
#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
|
||||
extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
|
||||
extern int tick_check_broadcast_device(struct clock_event_device *dev);
|
||||
extern void tick_install_broadcast_device(struct clock_event_device *dev);
|
||||
extern int tick_is_broadcast_device(struct clock_event_device *dev);
|
||||
extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
|
||||
extern void tick_shutdown_broadcast(unsigned int *cpup);
|
||||
@@ -102,9 +104,8 @@ tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
|
||||
|
||||
#else /* !BROADCAST */
|
||||
|
||||
static inline int tick_check_broadcast_device(struct clock_event_device *dev)
|
||||
static inline void tick_install_broadcast_device(struct clock_event_device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int tick_is_broadcast_device(struct clock_event_device *dev)
|
||||
|
||||
Reference in New Issue
Block a user