Skip to contentSkip to conversation

hw/arm/bcm2836: Wire up CPU timer interrupts correctly

PATCH In review Peter Maydell 3 participants 5 messages Mar 17, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm/bcm2836: Wire up CPU timer interrupts correctly

Wire up the CPU timer interrupts in the right order, with the nonsecure physical timer on cntpnsirq, the hyp timer on cnthpirq, and the secure physical timer on cntpsirq. (We did get the virt timer right, at least.)

---
 hw/arm/bcm2836.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/arm/bcm2836.c +5 -1
index 89a6b35..1cefe41 100644
@@ -136,9 +136,13 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
 
         /* Connect timers from the CPU to the interrupt controller */
         qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_PHYS,
-                qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq", n));
+                qdev_get_gpio_in_named(DEVICE(&s->control), "cntpnsirq", n));
         qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_VIRT,
                 qdev_get_gpio_in_named(DEVICE(&s->control), "cntvirq", n));
+        qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_HYP,
+                qdev_get_gpio_in_named(DEVICE(&s->control), "cnthpirq", n));
+        qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_SEC,
+                qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq", n));
     }
 }
 
Signature · 1 line
1.9.1
#1 lore raw

hw/arm/bcm2836.c static void bcm2836_realize(DeviceState *dev, Error

Quoted 17 lines · Peter Maydell

Wire up the CPU timer interrupts in the right order, with the nonsecure physical timer on cntpnsirq, the hyp timer on cnthpirq, and the secure physical timer on cntpsirq. (We did get the virt timer right, at least.)

---
 hw/arm/bcm2836.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/arm/bcm2836.c +0 -0
index 89a6b35..1cefe41 100644
@@ -136,9 +136,13 @@ static void bcm2836_realize(DeviceState *dev, Error

**errp)

hw/arm/bcm2836.c static void bcm2836_realize(DeviceState *dev, Error **errp)

Quoted 4 lines
hw/arm/bcm2836.c +0 -1
         /* Connect timers from the CPU to the interrupt controller */
         qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_PHYS,
-                qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq",

n));

hw/arm/bcm2836.c static void bcm2836_realize(DeviceState *dev, Error · line 138

Quoted 1 line
hw/arm/bcm2836.c +1 -0
+                qdev_get_gpio_in_named(DEVICE(&s->control), "cntpnsirq",

n));

hw/arm/bcm2836.c static void bcm2836_realize(DeviceState *dev, Error · line 140

Quoted 2 lines
hw/arm/bcm2836.c +0 -0
         qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_VIRT,
                 qdev_get_gpio_in_named(DEVICE(&s->control), "cntvirq",

n));

hw/arm/bcm2836.c static void bcm2836_realize(DeviceState *dev, Error · line 142

Quoted 2 lines
hw/arm/bcm2836.c +2 -0
+        qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_HYP,
+                qdev_get_gpio_in_named(DEVICE(&s->control), "cnthpirq",

n));

hw/arm/bcm2836.c static void bcm2836_realize(DeviceState *dev, Error · line 144

Quoted 2 lines
hw/arm/bcm2836.c +2 -0
+        qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_SEC,
+                qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq",

n));

Quoted 7 lines
hw/arm/bcm2836.c +0 -1
     }
 }
 
--

1.9.1

What drives the order?

#2 lore raw
Quoted 9 lines · Thomas Hanson
Quoted 5 lines · Peter Maydell

Wire up the CPU timer interrupts in the right order, with the nonsecure physical timer on cntpnsirq, the hyp timer on cnthpirq, and the secure physical timer on cntpsirq. (We did get the virt timer right, at least.)

What drives the order?

This is modelling the hardware:
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/README.md

The interrupt controller has 4 lines named CNTPSIRQ, CNTPNSIRQ, etc, and we need to hook the lines from the CPU up to the interrupt controller appropriately. The names we ended up with in QEMU's CPU model (GTIMER_PHYS, etc) don't match the signal names that a hardware A7 uses, which is slightly irritating, but not a big deal.

The A7 TRM lists which timer is which signal:
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0464f/BABBABDJ.html
(though you can pretty much guess from the signal names).

thanks
-- PMM

#3 lore raw
Quoted 20 lines · Peter Maydell
Quoted 9 lines · Thomas Hanson
Quoted 5 lines · Peter Maydell

Wire up the CPU timer interrupts in the right order, with the nonsecure physical timer on cntpnsirq, the hyp timer on cnthpirq, and the secure physical timer on cntpsirq. (We did get the virt timer right, at least.)

What drives the order?

This is modelling the hardware:
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/README.md

The interrupt controller has 4 lines named CNTPSIRQ, CNTPNSIRQ, etc, and we need to hook the lines from the CPU up to the interrupt controller appropriately. The names we ended up with in QEMU's CPU model (GTIMER_PHYS, etc) don't match the signal names that a hardware A7 uses, which is slightly irritating, but not a big deal.

Quoted 6 lines

The A7 TRM lists which timer is which signal:
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0464f/BABBABDJ.html
(though you can pretty much guess from the signal names).

thanks
-- PMM

Ah, thanks. I was thinking time-order. It's still early...

Reviewed-by on v1 1/1
#4 lore raw
In reply to Peter Maydell
Quoted 10 lines

From: Peter Maydell [mailto:[email protected]]
Sent: Thursday, 17 March 2016 3:33 AM

Wire up the CPU timer interrupts in the right order, with the nonsecure physical timer on cntpnsirq, the hyp timer on cnthpirq, and the secure physical timer on cntpsirq. (We did get the virt timer right, at least.)

Thanks Peter!
Andrew