mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-14 21:52:18 -06:00
hw/intc/loongarch_ipi: Add kernel irqchip realize function
Function kvm_ipi_realize() is added if kvm_irqchip_in_kernel() return true. It is to create and initialize IPI device in kernel mode. Reviewed-by: Song Gao <gaosong@loongson.cn> Signed-off-by: Bibo Mao <maobibo@loongson.cn> Message-ID: <20250606063033.2557365-4-maobibo@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn>
This commit is contained in:
parent
228c5413fb
commit
412f655566
5 changed files with 42 additions and 0 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "hw/intc/loongarch_ipi.h"
|
#include "hw/intc/loongarch_ipi.h"
|
||||||
#include "hw/qdev-properties.h"
|
#include "hw/qdev-properties.h"
|
||||||
|
#include "system/kvm.h"
|
||||||
#include "target/loongarch/cpu.h"
|
#include "target/loongarch/cpu.h"
|
||||||
|
|
||||||
static AddressSpace *get_iocsr_as(CPUState *cpu)
|
static AddressSpace *get_iocsr_as(CPUState *cpu)
|
||||||
|
@ -91,6 +92,10 @@ static void loongarch_ipi_realize(DeviceState *dev, Error **errp)
|
||||||
lics->cpu[i].ipi = lics;
|
lics->cpu[i].ipi = lics;
|
||||||
qdev_init_gpio_out(dev, &lics->cpu[i].irq, 1);
|
qdev_init_gpio_out(dev, &lics->cpu[i].irq, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (kvm_irqchip_in_kernel()) {
|
||||||
|
kvm_ipi_realize(dev, errp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loongarch_ipi_reset_hold(Object *obj, ResetType type)
|
static void loongarch_ipi_reset_hold(Object *obj, ResetType type)
|
||||||
|
|
27
hw/intc/loongarch_ipi_kvm.c
Normal file
27
hw/intc/loongarch_ipi_kvm.c
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
/*
|
||||||
|
* LoongArch IPI interrupt KVM support
|
||||||
|
*
|
||||||
|
* Copyright (C) 2025 Loongson Technology Corporation Limited
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "qapi/error.h"
|
||||||
|
#include "hw/intc/loongarch_ipi.h"
|
||||||
|
#include "system/kvm.h"
|
||||||
|
#include "target/loongarch/cpu.h"
|
||||||
|
|
||||||
|
void kvm_ipi_realize(DeviceState *dev, Error **errp)
|
||||||
|
{
|
||||||
|
LoongarchIPIState *lis = LOONGARCH_IPI(dev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = kvm_create_device(kvm_state, KVM_DEV_TYPE_LOONGARCH_IPI, false);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "IPI KVM_CREATE_DEVICE failed: %s\n",
|
||||||
|
strerror(-ret));
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
lis->dev_fd = ret;
|
||||||
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
#include "hw/irq.h"
|
#include "hw/irq.h"
|
||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
|
#include "system/kvm.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
MemTxResult loongson_ipi_core_readl(void *opaque, hwaddr addr, uint64_t *data,
|
MemTxResult loongson_ipi_core_readl(void *opaque, hwaddr addr, uint64_t *data,
|
||||||
|
@ -255,6 +256,10 @@ static void loongson_ipi_common_realize(DeviceState *dev, Error **errp)
|
||||||
LoongsonIPICommonState *s = LOONGSON_IPI_COMMON(dev);
|
LoongsonIPICommonState *s = LOONGSON_IPI_COMMON(dev);
|
||||||
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
|
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
|
||||||
|
|
||||||
|
if (kvm_irqchip_in_kernel()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
memory_region_init_io(&s->ipi_iocsr_mem, OBJECT(dev),
|
memory_region_init_io(&s->ipi_iocsr_mem, OBJECT(dev),
|
||||||
&loongson_ipi_iocsr_ops,
|
&loongson_ipi_iocsr_ops,
|
||||||
s, "loongson_ipi_iocsr", 0x48);
|
s, "loongson_ipi_iocsr", 0x48);
|
||||||
|
|
|
@ -71,6 +71,8 @@ specific_ss.add(when: 'CONFIG_M68K_IRQC', if_true: files('m68k_irqc.c'))
|
||||||
specific_ss.add(when: 'CONFIG_LOONGSON_IPI_COMMON', if_true: files('loongson_ipi_common.c'))
|
specific_ss.add(when: 'CONFIG_LOONGSON_IPI_COMMON', if_true: files('loongson_ipi_common.c'))
|
||||||
specific_ss.add(when: 'CONFIG_LOONGSON_IPI', if_true: files('loongson_ipi.c'))
|
specific_ss.add(when: 'CONFIG_LOONGSON_IPI', if_true: files('loongson_ipi.c'))
|
||||||
specific_ss.add(when: 'CONFIG_LOONGARCH_IPI', if_true: files('loongarch_ipi.c'))
|
specific_ss.add(when: 'CONFIG_LOONGARCH_IPI', if_true: files('loongarch_ipi.c'))
|
||||||
|
specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_LOONGARCH_IPI'],
|
||||||
|
if_true: files('loongarch_ipi_kvm.c'))
|
||||||
specific_ss.add(when: 'CONFIG_LOONGARCH_PCH_PIC', if_true: files('loongarch_pch_pic.c', 'loongarch_pic_common.c'))
|
specific_ss.add(when: 'CONFIG_LOONGARCH_PCH_PIC', if_true: files('loongarch_pch_pic.c', 'loongarch_pic_common.c'))
|
||||||
specific_ss.add(when: 'CONFIG_LOONGARCH_PCH_MSI', if_true: files('loongarch_pch_msi.c'))
|
specific_ss.add(when: 'CONFIG_LOONGARCH_PCH_MSI', if_true: files('loongarch_pch_msi.c'))
|
||||||
specific_ss.add(when: 'CONFIG_LOONGARCH_EXTIOI', if_true: files('loongarch_extioi.c', 'loongarch_extioi_common.c'))
|
specific_ss.add(when: 'CONFIG_LOONGARCH_EXTIOI', if_true: files('loongarch_extioi.c', 'loongarch_extioi_common.c'))
|
||||||
|
|
|
@ -16,6 +16,7 @@ OBJECT_DECLARE_TYPE(LoongarchIPIState, LoongarchIPIClass, LOONGARCH_IPI)
|
||||||
|
|
||||||
struct LoongarchIPIState {
|
struct LoongarchIPIState {
|
||||||
LoongsonIPICommonState parent_obj;
|
LoongsonIPICommonState parent_obj;
|
||||||
|
int dev_fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LoongarchIPIClass {
|
struct LoongarchIPIClass {
|
||||||
|
@ -24,4 +25,6 @@ struct LoongarchIPIClass {
|
||||||
ResettablePhases parent_phases;
|
ResettablePhases parent_phases;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void kvm_ipi_realize(DeviceState *dev, Error **errp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue