*
* Copyright (c) 2007 CodeSourcery.
*
- * This code is licenced under the GNU LGPL.
+ * This code is licensed under the GNU LGPL.
*/
#include "hw.h"
#include "qemu-timer.h"
+#include "ptimer.h"
#include "host-utils.h"
struct ptimer_state
count = limit. */
void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload)
{
+ /*
+ * Artificially limit timeout rate to something
+ * achievable under QEMU. Otherwise, QEMU spends all
+ * its time generating timer interrupts, and there
+ * is no forward progress.
+ * About ten microseconds is the fastest that really works
+ * on the current generation of host machines.
+ */
+
+ if (limit * s->period < 10000 && s->period) {
+ limit = 10000 / s->period;
+ }
+
s->limit = limit;
if (reload)
s->delta = limit;
{
ptimer_state *s;
- s = (ptimer_state *)qemu_mallocz(sizeof(ptimer_state));
+ s = (ptimer_state *)g_malloc0(sizeof(ptimer_state));
s->bh = bh;
s->timer = qemu_new_timer_ns(vm_clock, ptimer_tick, s);
return s;