@@ -17,49 +17,24 @@ static AddressSpace *get_iocsr_as(CPUState *cpu)
return LOONGARCH_CPU(cpu)->env.address_space_iocsr;
}
-static int archid_cmp(const void *a, const void *b)
-{
- CPUArchId *archid_a = (CPUArchId *)a;
- CPUArchId *archid_b = (CPUArchId *)b;
-
- return archid_a->arch_id - archid_b->arch_id;
-}
-
-static CPUArchId *find_cpu_by_archid(MachineState *ms, uint32_t id)
-{
- CPUArchId apic_id, *found_cpu;
-
- apic_id.arch_id = id;
- found_cpu = bsearch(&apic_id, ms->possible_cpus->cpus,
- ms->possible_cpus->len,
- sizeof(*ms->possible_cpus->cpus),
- archid_cmp);
-
- return found_cpu;
-}
-
static int loongarch_cpu_by_arch_id(LoongsonIPICommonState *lics,
int64_t arch_id, int *index, CPUState **pcs)
{
- MachineState *machine = MACHINE(qdev_get_machine());
- CPUArchId *archid;
- CPUState *cs;
-
- archid = find_cpu_by_archid(machine, arch_id);
- if (archid && archid->cpu) {
- cs = archid->cpu;
- if (index) {
- *index = cs->cpu_index;
- }
+ LoongarchIPIState *lis = LOONGARCH_IPI(lics);
- if (pcs) {
- *pcs = cs;
- }
+ if ((arch_id >= MAX_PHY_ID) || (lis->cs[arch_id] == NULL)) {
+ return MEMTX_ERROR;
+ }
+
+ if (index) {
+ *index = lis->present_cpu[arch_id];
+ }
- return MEMTX_OK;
+ if (pcs) {
+ *pcs = lis->cs[arch_id];
}
- return MEMTX_ERROR;
+ return MEMTX_OK;
}
static void loongarch_cpu_plug(HotplugHandler *hotplug_dev,
There is cpu mapping from physical cpu id inside, cpu_by_arch_id can be optimized from cpu mapping table. Signed-off-by: Bibo Mao <maobibo@loongson.cn> --- hw/intc/loongarch_ipi.c | 47 ++++++++++------------------------------- 1 file changed, 11 insertions(+), 36 deletions(-)