aboutsummaryrefslogtreecommitdiff
path: root/include/timer.h
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-11-12 15:17:03 +1100
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-11-12 16:41:25 +1100
commiteec6e53ff88c0cb82f3624642390793cc0f8e3ce (patch)
treeb149be31c96ef55103116c5530da640bc689d2c6 /include/timer.h
parent2e47b392d69e17f5614ee7796710a69aa273a8c1 (diff)
downloadskiboot-eec6e53ff88c0cb82f3624642390793cc0f8e3ce.zip
skiboot-eec6e53ff88c0cb82f3624642390793cc0f8e3ce.tar.gz
skiboot-eec6e53ff88c0cb82f3624642390793cc0f8e3ce.tar.bz2
timer: Add "polling" timers
These have no expiry and get called whenever the opal pollers run, they are intended to replace most opal pollers and allow the same code in drivers to chose between a poller or a timer based on things like interrupt availability for example. The other advantage over existing pollers (which I hope to deprecate) is that they are protected against re-entrancy (while still running without locks held). Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'include/timer.h')
-rw-r--r--include/timer.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/timer.h b/include/timer.h
index 8770a95..1796508 100644
--- a/include/timer.h
+++ b/include/timer.h
@@ -24,6 +24,7 @@ struct timer {
timer_func_t expiry;
void * user_data;
void * running;
+ uint64_t gen;
};
extern void init_timer(struct timer *t, timer_func_t expiry, void *data);
@@ -33,8 +34,20 @@ extern void init_timer(struct timer *t, timer_func_t expiry, void *data);
* This doesn't synchronize so if the timer also reschedules itself there
* is no telling which one "wins". The advantage is that this can be called
* with any lock held or from the timer expiry itself.
+ *
+ * We support a magic expiry of TIMER_POLL which causes a given timer to
+ * be called whenever OPAL main polling loop is run, which is often during
+ * boot and occasionally while Linux is up. This can be used with both
+ * schedule_timer() and schedule_timer_at()
+ *
+ * This is useful for a number of interrupt driven drivers to have a way
+ * to crank their state machine at times when the interrupt isn't available
+ * such as during early boot.
+ *
+ * Note: For convenience, schedule_timer() returns the current TB value
*/
-extern void schedule_timer(struct timer *t, uint64_t how_long);
+#define TIMER_POLL ((uint64_t)-1)
+extern uint64_t schedule_timer(struct timer *t, uint64_t how_long);
extern void schedule_timer_at(struct timer *t, uint64_t when);
/* Synchronization point with the timer. If the callback has started before
@@ -67,4 +80,7 @@ extern void cancel_timer_async(struct timer *t);
/* Run the timers */
extern void check_timers(void);
+/* Core init */
+void late_init_timers(void);
+
#endif /* __TIMER_H */