Skip to contentSkip to conversation

target/openrisc: Call cpu_openrisc_clock_init() in cpu_realize()

RFC PATCH In review Philippe Mathieu-Daudé 2 participants 3 messages Jan 14, 2025 – Mar 6, 2025

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 target/openrisc: Call cpu_openrisc_clock_init() in cpu_realize()

OpenRISC timer is architecturally tied to the CPU.

It doesn't belong to the machine init() code to instanciate it: move its creation when a vCPU is realized (after being created).

---
 hw/openrisc/openrisc_sim.c | 2 --
 hw/openrisc/virt.c         | 2 --
 target/openrisc/cpu.c      | 2 ++
 3 files changed, 2 insertions(+), 4 deletions(-)
hw/openrisc/openrisc_sim.c +0 -2
index e0da4067ba3..d7f97d19913 100644
@@ -306,8 +306,6 @@ static void openrisc_sim_init(MachineState *machine)
             exit(1);
         }
 
-        cpu_openrisc_clock_init(cpus[n]);
-
         qemu_register_reset(main_cpu_reset, cpus[n]);
     }
 
hw/openrisc/virt.c +0 -2
index 7b60bf85094..676cf8d692d 100644
@@ -487,8 +487,6 @@ static void openrisc_virt_init(MachineState *machine)
             exit(1);
         }
 
-        cpu_openrisc_clock_init(cpus[n]);
-
         qemu_register_reset(main_cpu_reset, cpus[n]);
     }
 
target/openrisc/cpu.c +2 -0
index b7bab0d7abf..291fec04fda 100644
@@ -165,6 +165,8 @@ static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp)
     qemu_init_vcpu(cs);
     cpu_reset(cs);
 
+    cpu_openrisc_clock_init(OPENRISC_CPU(dev));
+
     occ->parent_realize(dev, errp);
 }
 
Signature · 1 line
2.47.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Philippe Mathieu-Daudé

OpenRISC timer is architecturally tied to the CPU.

It doesn't belong to the machine init() code to instanciate it: move its creation when a vCPU is realized (after being created).

Quoted 7 lines
---
  hw/openrisc/openrisc_sim.c | 2 --
  hw/openrisc/virt.c         | 2 --
  target/openrisc/cpu.c      | 2 ++
  3 files changed, 2 insertions(+), 4 deletions(-)

r~

Quoted 40 lines
hw/openrisc/openrisc_sim.c +0 -2
index e0da4067ba3..d7f97d19913 100644
@@ -306,8 +306,6 @@ static void openrisc_sim_init(MachineState *machine)
              exit(1);
          }
 
-        cpu_openrisc_clock_init(cpus[n]);
-
          qemu_register_reset(main_cpu_reset, cpus[n]);
      }
 
hw/openrisc/virt.c +0 -2
index 7b60bf85094..676cf8d692d 100644
@@ -487,8 +487,6 @@ static void openrisc_virt_init(MachineState *machine)
              exit(1);
          }
 
-        cpu_openrisc_clock_init(cpus[n]);
-
          qemu_register_reset(main_cpu_reset, cpus[n]);
      }
 
target/openrisc/cpu.c +2 -0
index b7bab0d7abf..291fec04fda 100644
@@ -165,6 +165,8 @@ static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp)
      qemu_init_vcpu(cs);
      cpu_reset(cs);
 
+    cpu_openrisc_clock_init(OPENRISC_CPU(dev));
+
      occ->parent_realize(dev, errp);
  }
 
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

OpenRISC timer is architecturally tied to the CPU.

It doesn't belong to the machine init() code to instanciate it: move its creation when a vCPU is realized (after being created).

Quoted 7 lines
---
  hw/openrisc/openrisc_sim.c | 2 --
  hw/openrisc/virt.c         | 2 --
  target/openrisc/cpu.c      | 2 ++
  3 files changed, 2 insertions(+), 4 deletions(-)

Patch queued, thanks.