On 22 June 2018 at 21:32, Aaron Lindsay <alind...@codeaurora.org> wrote: > Setup a QEMUTimer to get a callback when we expect counters to next > overflow and trigger an interrupt at that time. > > Signed-off-by: Aaron Lindsay <alind...@codeaurora.org> > --- > target/arm/cpu.c | 11 +++++ > target/arm/cpu.h | 7 +++ > target/arm/helper.c | 132 > ++++++++++++++++++++++++++++++++++++++++++++++++---- > 3 files changed, 141 insertions(+), 9 deletions(-) > > diff --git a/target/arm/cpu.c b/target/arm/cpu.c > index 2f5b16a..7b3c137 100644 > --- a/target/arm/cpu.c > +++ b/target/arm/cpu.c > @@ -743,6 +743,12 @@ static void arm_cpu_finalizefn(Object *obj) > QLIST_REMOVE(hook, node); > g_free(hook); > } > +#ifndef CONFIG_USER_ONLY > + if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { > + timer_deinit(cpu->pmu_timer); > + timer_free(cpu->pmu_timer); > + } > +#endif > } > > static void arm_cpu_realizefn(DeviceState *dev, Error **errp) > @@ -937,6 +943,11 @@ static void arm_cpu_realizefn(DeviceState *dev, Error > **errp) > arm_register_pre_el_change_hook(cpu, &pmu_pre_el_change, 0); > arm_register_el_change_hook(cpu, &pmu_post_el_change, 0); > } > + > +#ifndef CONFIG_USER_ONLY > + cpu->pmu_timer = timer_new(QEMU_CLOCK_VIRTUAL, 1, arm_pmu_timer_cb, > + cpu);
This is a confusing way to write timer_new_ns(). > +#endif > #define SUPPORTED_EVENT_SENTINEL UINT16_MAX > static const pm_event pm_events[] = { > { .number = 0x000, /* SW_INCR */ > .supported = event_always_supported, > - .get_count = swinc_get_count > + .get_count = swinc_get_count, > + .ns_per_count = swinc_ns_per If you always put trailing commas on the end of the last line in a struct initializer, then you don't need to modify the preceding line in later patches which add a new line to the initializer. The meat of the patch is beyond me at this time of the afternoon :-) thanks -- PMM