mbox series

[v2,0/5] hw/arm/raspi: Fix SYS_timer to unbrick Linux kernels v3.7+

Message ID 20200921035257.434532-1-f4bug@amsat.org
Headers show
Series hw/arm/raspi: Fix SYS_timer to unbrick Linux kernels v3.7+ | expand

Message

Philippe Mathieu-Daudé Sept. 21, 2020, 3:52 a.m. UTC
In this series we implement the COMPARE registers of the
SYS_timer, since they are used by Linux.

This fixes the hang reported by Niek here:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg682090.html

Since v1:
- Extracted unrelated patches to previous series
  (which happened to be mis-rebased)

Based-on: <20200921034729.432931-1-f4bug@amsat.org>
Supersedes: <20200920175825.417680-1-f4bug@amsat.org>

Philippe Mathieu-Daudé (5):
  hw/intc/bcm2835_ic: Trace GPU/CPU IRQ handlers
  hw/timer/bcm2835: Introduce BCM2835_SYSTIMER_COUNT definition
  hw/timer/bcm2835: Rename variable holding CTRL_STATUS register
  hw/timer/bcm2835: Support the timer COMPARE registers
  hw/arm/bcm2835_peripherals: Correctly wire the SYS_timer IRQs

 include/hw/timer/bcm2835_systmr.h | 17 ++++++++---
 hw/arm/bcm2835_peripherals.c      | 13 ++++++--
 hw/intc/bcm2835_ic.c              |  4 ++-
 hw/timer/bcm2835_systmr.c         | 50 ++++++++++++++++++-------------
 hw/intc/trace-events              |  4 +++
 hw/timer/trace-events             |  4 ++-
 6 files changed, 64 insertions(+), 28 deletions(-)

Comments

Luc Michel Sept. 21, 2020, 7:50 p.m. UTC | #1
On 9/21/20 5:52 AM, Philippe Mathieu-Daudé wrote:
> The SYS_timer is not directly wired to the ARM core, but to the
> SoC (peripheral) interrupt controller.
> 
> Fixes: 0e5bbd74064 ("hw/arm/bcm2835_peripherals: Use the SYS_timer")
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Luc Michel <luc.michel@greensocs.com>

> ---
>   hw/arm/bcm2835_peripherals.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
> index 15c5c72e465..48909a43c32 100644
> --- a/hw/arm/bcm2835_peripherals.c
> +++ b/hw/arm/bcm2835_peripherals.c
> @@ -171,8 +171,17 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
>       memory_region_add_subregion(&s->peri_mr, ST_OFFSET,
>                   sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systmr), 0));
>       sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 0,
> -        qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_ARM_IRQ,
> -                               INTERRUPT_ARM_TIMER));
> +        qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
> +                               INTERRUPT_TIMER0));
> +    sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 1,
> +        qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
> +                               INTERRUPT_TIMER1));
> +    sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 2,
> +        qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
> +                               INTERRUPT_TIMER2));
> +    sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 3,
> +        qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
> +                               INTERRUPT_TIMER3));
>   
>       /* UART0 */
>       qdev_prop_set_chr(DEVICE(&s->uart0), "chardev", serial_hd(0));
>
Philippe Mathieu-Daudé Sept. 24, 2020, 11:21 a.m. UTC | #2
On 9/21/20 5:52 AM, Philippe Mathieu-Daudé wrote:
> In this series we implement the COMPARE registers of the
> SYS_timer, since they are used by Linux.
> 
> This fixes the hang reported by Niek here:
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg682090.html
> 
> Since v1:
> - Extracted unrelated patches to previous series
>   (which happened to be mis-rebased)
> 
> Based-on: <20200921034729.432931-1-f4bug@amsat.org>
> Supersedes: <20200920175825.417680-1-f4bug@amsat.org>
> 
> Philippe Mathieu-Daudé (5):
>   hw/intc/bcm2835_ic: Trace GPU/CPU IRQ handlers
>   hw/timer/bcm2835: Introduce BCM2835_SYSTIMER_COUNT definition
>   hw/timer/bcm2835: Rename variable holding CTRL_STATUS register
>   hw/timer/bcm2835: Support the timer COMPARE registers

I'll respin this series trying to address Luc's comments on patch 4.