qemu/hw/timer
Andrew Jeffery 77a132ea7e aspeed/timer: Provide back-pressure information for short periods
First up: This is not the way the hardware behaves.

However, it helps resolve real-world problems with short periods being
used under Linux. Commit 4451d3f59f2a ("clocksource/drivers/fttmr010:
Fix set_next_event handler") in Linux fixed the timer driver to
correctly schedule the next event for the Aspeed controller, and in
combination with 5daa8212c08e ("ARM: dts: aspeed: Describe random number
device") Linux will now set a timer with a period as low as 1us.

Configuring a qemu timer with such a short period results in spending
time handling the interrupt in the model rather than executing guest
code, leading to noticeable "sticky" behaviour in the guest.

The behaviour of Linux is correct with respect to the hardware, so we
need to improve our handling under emulation. The approach chosen is to
provide back-pressure information by calculating an acceptable minimum
number of ticks to be set on the model. Under Linux an additional read
is added in the timer configuration path to detect back-pressure, which
will never occur on hardware. However if back-pressure is observed, the
driver alerts the clock event subsystem, which then performs its own
next event dilation via a config option - d1748302f70b ("clockevents:
Make minimum delay adjustments configurable")

A minimum period of 5us was experimentally determined on a Lenovo
T480s, which I've increased to 20us for "safety".

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-id: 20190704055150.4899-1-clg@kaod.org
[clg: - changed the computation of min_ticks to be done each time the
        timer value is reloaded. It removes the ordering issue of the
        timer and scu reset handlers but is slightly slower ]
      - introduced TIMER_MIN_NS
      - introduced calculate_min_ticks() ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2019-09-03 16:20:34 +01:00
..
a9gtimer.c hw/core: Move cpu.c, cpu.h from qom/ to hw/core/ 2019-08-21 13:24:01 +02:00
allwinner-a10-pit.c Clean up inclusion of sysemu/sysemu.h 2019-08-16 13:31:53 +02:00
altera_timer.c Clean up inclusion of sysemu/sysemu.h 2019-08-16 13:31:53 +02:00
arm_mptimer.c hw/core: Move cpu.c, cpu.h from qom/ to hw/core/ 2019-08-21 13:24:01 +02:00
arm_timer.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
armv7m_systick.c
aspeed_rtc.c
aspeed_timer.c aspeed/timer: Provide back-pressure information for short periods 2019-09-03 16:20:34 +01:00
cadence_ttc.c
cmsdk-apb-dualtimer.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
cmsdk-apb-timer.c
digic-timer.c
ds1338.c
etraxfs_timer.c sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
exynos4210_mct.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
exynos4210_pwm.c
exynos4210_rtc.c Clean up inclusion of sysemu/sysemu.h 2019-08-16 13:31:53 +02:00
grlib_gptimer.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
hpet.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
i8254_common.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
i8254.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
imx_epit.c
imx_gpt.c
Kconfig hw/Kconfig: Move the generic XLNX_ZYNQMP to the root hw/Kconfig 2019-08-19 21:28:25 +02:00
lm32_timer.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
m41t80.c
m48t59-internal.h
m48t59-isa.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
m48t59.c sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
Makefile.objs
mc146818rtc.c mc146818rtc: Remove reset notifiers 2019-08-20 17:26:20 +02:00
milkymist-sysctl.c sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
mips_gictimer.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
mss-timer.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
nrf51_timer.c
omap_gptimer.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
omap_synctimer.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
pl031.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
puv3_ost.c
pxa2xx_timer.c sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
sh_timer.c
slavio_timer.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
stm32f2xx_timer.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
sun4v-rtc.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
trace-events
twl92230.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
xilinx_timer.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
xlnx-zynqmp-rtc.c