|
@@ -95,6 +95,11 @@ static inline unsigned int tbase_get_deferrable(struct tvec_base *base)
|
|
return ((unsigned int)(unsigned long)base & TIMER_DEFERRABLE);
|
|
return ((unsigned int)(unsigned long)base & TIMER_DEFERRABLE);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static inline unsigned int tbase_get_irqsafe(struct tvec_base *base)
|
|
|
|
+{
|
|
|
|
+ return ((unsigned int)(unsigned long)base & TIMER_IRQSAFE);
|
|
|
|
+}
|
|
|
|
+
|
|
static inline struct tvec_base *tbase_get_base(struct tvec_base *base)
|
|
static inline struct tvec_base *tbase_get_base(struct tvec_base *base)
|
|
{
|
|
{
|
|
return ((struct tvec_base *)((unsigned long)base & ~TIMER_FLAG_MASK));
|
|
return ((struct tvec_base *)((unsigned long)base & ~TIMER_FLAG_MASK));
|
|
@@ -1002,14 +1007,14 @@ EXPORT_SYMBOL(try_to_del_timer_sync);
|
|
*
|
|
*
|
|
* Synchronization rules: Callers must prevent restarting of the timer,
|
|
* Synchronization rules: Callers must prevent restarting of the timer,
|
|
* otherwise this function is meaningless. It must not be called from
|
|
* otherwise this function is meaningless. It must not be called from
|
|
- * interrupt contexts. The caller must not hold locks which would prevent
|
|
|
|
- * completion of the timer's handler. The timer's handler must not call
|
|
|
|
- * add_timer_on(). Upon exit the timer is not queued and the handler is
|
|
|
|
- * not running on any CPU.
|
|
|
|
|
|
+ * interrupt contexts unless the timer is an irqsafe one. The caller must
|
|
|
|
+ * not hold locks which would prevent completion of the timer's
|
|
|
|
+ * handler. The timer's handler must not call add_timer_on(). Upon exit the
|
|
|
|
+ * timer is not queued and the handler is not running on any CPU.
|
|
*
|
|
*
|
|
- * Note: You must not hold locks that are held in interrupt context
|
|
|
|
- * while calling this function. Even if the lock has nothing to do
|
|
|
|
- * with the timer in question. Here's why:
|
|
|
|
|
|
+ * Note: For !irqsafe timers, you must not hold locks that are held in
|
|
|
|
+ * interrupt context while calling this function. Even if the lock has
|
|
|
|
+ * nothing to do with the timer in question. Here's why:
|
|
*
|
|
*
|
|
* CPU0 CPU1
|
|
* CPU0 CPU1
|
|
* ---- ----
|
|
* ---- ----
|
|
@@ -1046,7 +1051,7 @@ int del_timer_sync(struct timer_list *timer)
|
|
* don't use it in hardirq context, because it
|
|
* don't use it in hardirq context, because it
|
|
* could lead to deadlock.
|
|
* could lead to deadlock.
|
|
*/
|
|
*/
|
|
- WARN_ON(in_irq());
|
|
|
|
|
|
+ WARN_ON(in_irq() && !tbase_get_irqsafe(timer->base));
|
|
for (;;) {
|
|
for (;;) {
|
|
int ret = try_to_del_timer_sync(timer);
|
|
int ret = try_to_del_timer_sync(timer);
|
|
if (ret >= 0)
|
|
if (ret >= 0)
|
|
@@ -1153,19 +1158,27 @@ static inline void __run_timers(struct tvec_base *base)
|
|
while (!list_empty(head)) {
|
|
while (!list_empty(head)) {
|
|
void (*fn)(unsigned long);
|
|
void (*fn)(unsigned long);
|
|
unsigned long data;
|
|
unsigned long data;
|
|
|
|
+ bool irqsafe;
|
|
|
|
|
|
timer = list_first_entry(head, struct timer_list,entry);
|
|
timer = list_first_entry(head, struct timer_list,entry);
|
|
fn = timer->function;
|
|
fn = timer->function;
|
|
data = timer->data;
|
|
data = timer->data;
|
|
|
|
+ irqsafe = tbase_get_irqsafe(timer->base);
|
|
|
|
|
|
timer_stats_account_timer(timer);
|
|
timer_stats_account_timer(timer);
|
|
|
|
|
|
base->running_timer = timer;
|
|
base->running_timer = timer;
|
|
detach_expired_timer(timer, base);
|
|
detach_expired_timer(timer, base);
|
|
|
|
|
|
- spin_unlock_irq(&base->lock);
|
|
|
|
- call_timer_fn(timer, fn, data);
|
|
|
|
- spin_lock_irq(&base->lock);
|
|
|
|
|
|
+ if (irqsafe) {
|
|
|
|
+ spin_unlock(&base->lock);
|
|
|
|
+ call_timer_fn(timer, fn, data);
|
|
|
|
+ spin_lock(&base->lock);
|
|
|
|
+ } else {
|
|
|
|
+ spin_unlock_irq(&base->lock);
|
|
|
|
+ call_timer_fn(timer, fn, data);
|
|
|
|
+ spin_lock_irq(&base->lock);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
base->running_timer = NULL;
|
|
base->running_timer = NULL;
|