diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2015-09-10 10:08:56 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-09-11 16:32:37 +1000 |
commit | b5f05ac337b3495cf506f5492fd053e90ae0bda3 (patch) | |
tree | 13430c290a130c3f777736abec56173f987416b2 | |
parent | ebf9084d8a4d2f70e4e7d2c6a35cac2c7f6e2681 (diff) | |
download | skiboot-b5f05ac337b3495cf506f5492fd053e90ae0bda3.zip skiboot-b5f05ac337b3495cf506f5492fd053e90ae0bda3.tar.gz skiboot-b5f05ac337b3495cf506f5492fd053e90ae0bda3.tar.bz2 |
timer: Pass current timer to timer callbacks
The caller usually has it and it avoids additional mftb() which
can be expensive.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[stewart@linux.vnet.ibm.com: fix run-timer unit test]
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r-- | core/test/run-timer.c | 3 | ||||
-rw-r--r-- | core/timer.c | 8 | ||||
-rw-r--r-- | hw/bt.c | 13 | ||||
-rw-r--r-- | hw/ipmi/ipmi-watchdog.c | 3 | ||||
-rw-r--r-- | hw/p8-i2c.c | 17 | ||||
-rw-r--r-- | include/timer.h | 2 |
6 files changed, 25 insertions, 21 deletions
diff --git a/core/test/run-timer.c b/core/test/run-timer.c index 8452ee0..13b175e 100644 --- a/core/test/run-timer.c +++ b/core/test/run-timer.c @@ -31,9 +31,10 @@ static void init_rand(void) } } -static void expiry(struct timer *t, void *data) +static void expiry(struct timer *t, void *data, uint64_t now) { (void)data; + (void)now; assert(t->target >= last); count--; } diff --git a/core/timer.c b/core/timer.c index 737fb78..d5a3477 100644 --- a/core/timer.c +++ b/core/timer.c @@ -109,7 +109,7 @@ uint64_t schedule_timer(struct timer *t, uint64_t how_long) return now; } -static void __check_poll_timers(void) +static void __check_poll_timers(uint64_t now) { struct timer *t; @@ -153,7 +153,7 @@ static void __check_poll_timers(void) /* Now we can unlock and call it's expiry */ unlock(&timer_lock); - t->expiry(t, t->user_data); + t->expiry(t, t->user_data, now); /* Re-lock and mark not running */ lock(&timer_lock); @@ -187,7 +187,7 @@ static void __check_timers(uint64_t now) /* Now we can unlock and call it's expiry */ unlock(&timer_lock); - t->expiry(t, t->user_data); + t->expiry(t, t->user_data, now); /* Re-lock and mark not running */ lock(&timer_lock); @@ -216,7 +216,7 @@ void check_timers(bool from_interrupt) /* Take lock and try again */ lock(&timer_lock); if (!from_interrupt) - __check_poll_timers(); + __check_poll_timers(now); __check_timers(now); unlock(&timer_lock); } @@ -293,12 +293,10 @@ static void bt_get_resp(void) return; } -static void bt_expire_old_msg(void) +static void bt_expire_old_msg(uint64_t tb) { - unsigned long tb; struct bt_msg *bt_msg; - tb = mftb(); bt_msg = list_top(&bt.msgq, struct bt_msg, link); if (bt_msg && bt_msg->tb > 0 && (bt_msg->tb + BT_MSG_TIMEOUT) < tb) { @@ -309,7 +307,7 @@ static void bt_expire_old_msg(void) FIFO so just reset the flag.*/ BT_ERR(bt_msg, "Retry sending message"); bt_msg->retry_count++; - bt_msg->tb = mftb(); + bt_msg->tb = tb; bt_outb(BT_CTRL_H2B_ATN, BT_CTRL); } else { BT_ERR(bt_msg, "Timeout sending message"); @@ -356,7 +354,8 @@ static void bt_send_and_unlock(void) return; } -static void bt_poll(struct timer *t __unused, void *data __unused) +static void bt_poll(struct timer *t __unused, void *data __unused, + uint64_t now) { uint8_t bt_ctrl; @@ -369,7 +368,7 @@ static void bt_poll(struct timer *t __unused, void *data __unused) lock(&bt.lock); print_debug_queue_info(); - bt_expire_old_msg(); + bt_expire_old_msg(now); bt_ctrl = bt_inb(BT_CTRL); @@ -447,7 +446,7 @@ static void bt_irq(uint32_t chip_id __unused, uint32_t irq_mask __unused) bt.irq_ok = true; if (ireg & BT_INTMASK_B2H_IRQ) { bt_outb(BT_INTMASK_B2H_IRQ | BT_INTMASK_B2H_IRQEN, BT_INTMASK); - bt_poll(NULL, NULL); + bt_poll(NULL, NULL, mftb()); } } diff --git a/hw/ipmi/ipmi-watchdog.c b/hw/ipmi/ipmi-watchdog.c index 7dfb0c0..55c3bf5 100644 --- a/hw/ipmi/ipmi-watchdog.c +++ b/hw/ipmi/ipmi-watchdog.c @@ -100,7 +100,8 @@ static void sync_reset_wdt(void) ipmi_queue_msg_sync(ipmi_msg); } -static void reset_wdt(struct timer *t __unused, void *data __unused) +static void reset_wdt(struct timer *t __unused, void *data __unused, + uint64_t now __unused) { struct ipmi_msg *ipmi_msg; diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index dfb26d4..848d400 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -1048,7 +1048,7 @@ static inline uint64_t p8_i2c_get_poll_interval(uint32_t bus_speed) return usecs_to_tb(usec); } -static void p8_i2c_timeout(struct timer *t __unused, void *data) +static void p8_i2c_timeout(struct timer *t __unused, void *data, uint64_t now) { struct p8_i2c_master_port *port; struct p8_i2c_master *master = data; @@ -1073,7 +1073,7 @@ static void p8_i2c_timeout(struct timer *t __unused, void *data) goto exit; } request = container_of(req, struct p8_i2c_request, req); - if (tb_compare(mftb(), request->timeout) == TB_ABEFOREB) { + if (tb_compare(now, request->timeout) == TB_ABEFOREB) { DBG("I2C: Timeout with request not expired\n"); goto exit; } @@ -1094,12 +1094,14 @@ static void p8_i2c_timeout(struct timer *t __unused, void *data) unlock(&master->lock); } -static void p8_i2c_recover(struct timer *t __unused, void *data) +static void p8_i2c_recover(struct timer *t __unused, void *data, + uint64_t now __unused) { struct p8_i2c_master *master = data; lock(&master->lock); - assert(master->state == state_recovery || master->state == state_occache_dis); + assert(master->state == state_recovery || + master->state == state_occache_dis); master->state = state_idle; /* We may or may not still have work pending, re-enable the sensor cache @@ -1117,7 +1119,8 @@ static void p8_i2c_recover(struct timer *t __unused, void *data) unlock(&master->lock); } -static void p8_i2c_enable_scache(struct timer *t __unused, void *data) +static void p8_i2c_enable_scache(struct timer *t __unused, void *data, + uint64_t now __unused) { struct p8_i2c_master *master = data; @@ -1132,7 +1135,7 @@ static void p8_i2c_enable_scache(struct timer *t __unused, void *data) unlock(&master->lock); } -static void p8_i2c_poll(struct timer *t __unused, void *data) +static void p8_i2c_poll(struct timer *t __unused, void *data, uint64_t now) { struct p8_i2c_master *master = data; @@ -1149,7 +1152,7 @@ static void p8_i2c_poll(struct timer *t __unused, void *data) lock(&master->lock); p8_i2c_check_status(master); if (master->state != state_idle) - schedule_timer(&master->poller, master->poll_interval); + schedule_timer_at(&master->poller, now + master->poll_interval); p8_i2c_check_work(master); unlock(&master->lock); } diff --git a/include/timer.h b/include/timer.h index a1132e0..116b9ac 100644 --- a/include/timer.h +++ b/include/timer.h @@ -6,7 +6,7 @@ struct timer; -typedef void (*timer_func_t)(struct timer *t, void *data); +typedef void (*timer_func_t)(struct timer *t, void *data, uint64_t now); /* Structure exposed in order to be able to allocate it * statically but otherwise, use accessors, don't access |