Skip to contentSkip to conversation

hw/arm/virt: mark timer in fdt as v8-compatible

PATCH Applied [email protected] 3 participants 5 messages Sep 26, 2014 – Oct 10, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm/virt: mark timer in fdt as v8-compatible

From: Claudio Fontana <[email protected]>

check if the first cpu is an armv8 cpu, and if so, put arm,armv8-timer in the compatible string list.

Note that due to this check, this patch moves the creation of the timer fdt node to after the cpu creation loop.

---
 hw/arm/virt.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
hw/arm/virt.c +12 -3
index 8c6b171..eeb3105 100644
@@ -239,14 +239,23 @@ static void fdt_add_timer_nodes(const VirtBoardInfo *vbi)
      * but for the GIC implementation provided by both QEMU and KVM
      * they are edge-triggered.
      */
+    ARMCPU *armcpu;
     uint32_t irqflags = GIC_FDT_IRQ_FLAGS_EDGE_LO_HI;
 
     irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
                          GIC_FDT_IRQ_PPI_CPU_WIDTH, (1 << vbi->smp_cpus) - 1);
 
     qemu_fdt_add_subnode(vbi->fdt, "/timer");
-    qemu_fdt_setprop_string(vbi->fdt, "/timer",
-                                "compatible", "arm,armv7-timer");
+
+    armcpu = ARM_CPU(qemu_get_cpu(0));
+    if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) {
+        const char compat[] = "arm,armv7-timer\0arm,armv8-timer";
+        qemu_fdt_setprop(vbi->fdt, "/timer", "compatible",
+                         compat, sizeof(compat));
+    } else {
+        qemu_fdt_setprop_string(vbi->fdt, "/timer", "compatible",
+                                "arm,armv7-timer");
+    }
     qemu_fdt_setprop_cells(vbi->fdt, "/timer", "interrupts",
                                GIC_FDT_IRQ_TYPE_PPI, 13, irqflags,
                                GIC_FDT_IRQ_TYPE_PPI, 14, irqflags,
@@ -553,7 +562,6 @@ static void machvirt_init(MachineState *machine)
     }
 
     create_fdt(vbi);
-    fdt_add_timer_nodes(vbi);
 
     for (n = 0; n < smp_cpus; n++) {
         ObjectClass *oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);
@@ -577,6 +585,7 @@ static void machvirt_init(MachineState *machine)
 
         object_property_set_bool(cpuobj, true, "realized", NULL);
     }
+    fdt_add_timer_nodes(vbi);
     fdt_add_cpu_nodes(vbi);
     fdt_add_psci_node(vbi);
 
Signature · 1 line
1.8.5.3
#1 lore raw

Hello Peter,

are you ok with this one?

Thanks,

Claudio

Quoted 62 lines · On 26 September 2014 15:09, <[email protected]> wrote:

From: Claudio Fontana <[email protected]>

check if the first cpu is an armv8 cpu, and if so, put arm,armv8-timer in the compatible string list.

Note that due to this check, this patch moves the creation of the timer fdt node to after the cpu creation loop.

---
 hw/arm/virt.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
hw/arm/virt.c +12 -4
index 8c6b171..eeb3105 100644
@@ -239,14 +239,23 @@ static void fdt_add_timer_nodes(const VirtBoardInfo *vbi)
      * but for the GIC implementation provided by both QEMU and KVM
      * they are edge-triggered.
      */
+    ARMCPU *armcpu;
     uint32_t irqflags = GIC_FDT_IRQ_FLAGS_EDGE_LO_HI;
 
     irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
                          GIC_FDT_IRQ_PPI_CPU_WIDTH, (1 << vbi->smp_cpus) - 1);
 
     qemu_fdt_add_subnode(vbi->fdt, "/timer");
-    qemu_fdt_setprop_string(vbi->fdt, "/timer",
-                                "compatible", "arm,armv7-timer");
+
+    armcpu = ARM_CPU(qemu_get_cpu(0));
+    if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) {
+        const char compat[] = "arm,armv7-timer\0arm,armv8-timer";
+        qemu_fdt_setprop(vbi->fdt, "/timer", "compatible",
+                         compat, sizeof(compat));
+    } else {
+        qemu_fdt_setprop_string(vbi->fdt, "/timer", "compatible",
+                                "arm,armv7-timer");
+    }
     qemu_fdt_setprop_cells(vbi->fdt, "/timer", "interrupts",
                                GIC_FDT_IRQ_TYPE_PPI, 13, irqflags,
                                GIC_FDT_IRQ_TYPE_PPI, 14, irqflags,
@@ -553,7 +562,6 @@ static void machvirt_init(MachineState *machine)
     }
 
     create_fdt(vbi);
-    fdt_add_timer_nodes(vbi);
 
     for (n = 0; n < smp_cpus; n++) {
         ObjectClass *oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);
@@ -577,6 +585,7 @@ static void machvirt_init(MachineState *machine)
 
         object_property_set_bool(cpuobj, true, "realized", NULL);
     }
+    fdt_add_timer_nodes(vbi);
     fdt_add_cpu_nodes(vbi);
     fdt_add_psci_node(vbi);
 
--

1.8.5.3

#2 lore raw
In reply to [email protected]
Quoted 9 lines · On 26 September 2014 14:09, <[email protected]> wrote:

From: Claudio Fontana <[email protected]>

check if the first cpu is an armv8 cpu, and if so, put arm,armv8-timer in the compatible string list.

Note that due to this check, this patch moves the creation of the timer fdt node to after the cpu creation loop.

Applied to target-arm.next, thanks.

-- PMM

#3 lore raw
Quoted 6 lines · Peter Maydell
Quoted 5 lines · On 26 September 2014 14:09, <[email protected]> wrote:

From: Claudio Fontana <[email protected]>

check if the first cpu is an armv8 cpu, and if so, put arm,armv8-timer in the compatible string list.

Quoted 6 lines
Quoted 4 lines

Note that due to this check, this patch moves the creation of the timer fdt node to after the cpu creation loop.

Applied to target-arm.next, thanks.

...except that on advice from one of our kernel folk I've swapped the v8 compat string round so it reads
"arm,armv8-timer\0arm,armv7-timer"
to advertise the more specific compat first for v8.

-- PMM

#4 lore raw
Quoted 12 lines · Peter Maydell
Quoted 11 lines · Peter Maydell
Quoted 9 lines · On 26 September 2014 14:09, <[email protected]> wrote:

From: Claudio Fontana <[email protected]>

check if the first cpu is an armv8 cpu, and if so, put arm,armv8-timer in the compatible string list.

Note that due to this check, this patch moves the creation of the timer fdt node to after the cpu creation loop.

Quoted 9 lines
Quoted 1 line

Applied to target-arm.next, thanks.

...except that on advice from one of our kernel folk I've swapped the v8 compat string round so it reads
"arm,armv8-timer\0arm,armv7-timer"
to advertise the more specific compat first for v8.

-- PMM

Ok, thanks!

Claudio