With PCH PCI irqchip, property irqchip-in-kernel is added to indicate whether feature irqchip_in_kernel is supported or not. This property can be enabled only if it works in KVM mode.
Signed-off-by: Bibo Mao <maob...@loongson.cn> --- hw/intc/loongarch_pch_pic.c | 14 ++++++++++++++ include/hw/intc/loongarch_pch_pic.h | 1 + 2 files changed, 15 insertions(+) diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c index cbba2fc284..3729ab9700 100644 --- a/hw/intc/loongarch_pch_pic.c +++ b/hw/intc/loongarch_pch_pic.c @@ -10,6 +10,8 @@ #include "qemu/log.h" #include "hw/irq.h" #include "hw/intc/loongarch_pch_pic.h" +#include "hw/qdev-properties.h" +#include "system/kvm.h" #include "trace.h" #include "qapi/error.h" @@ -264,6 +266,7 @@ static void loongarch_pic_realize(DeviceState *dev, Error **errp) { LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(dev); LoongarchPICClass *lpc = LOONGARCH_PIC_GET_CLASS(dev); + LoongarchPICState *lps = LOONGARCH_PIC(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); Error *local_err = NULL; @@ -273,6 +276,11 @@ static void loongarch_pic_realize(DeviceState *dev, Error **errp) return; } + if (lps->irqchip_in_kernel && !kvm_enabled()) { + error_setg(errp, "PCH_PCI irqchip_in_kernel works only in kvm mode"); + return; + } + qdev_init_gpio_out(dev, s->parent_irq, s->irq_num); qdev_init_gpio_in(dev, pch_pic_irq_handler, s->irq_num); memory_region_init_io(&s->iomem, OBJECT(dev), @@ -281,6 +289,11 @@ static void loongarch_pic_realize(DeviceState *dev, Error **errp) sysbus_init_mmio(sbd, &s->iomem); } +static const Property loongarch_pic_properties[] = { + DEFINE_PROP_BOOL("irqchip-in-kernel", LoongarchPICState, + irqchip_in_kernel, false), +}; + static void loongarch_pic_class_init(ObjectClass *klass, const void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -291,6 +304,7 @@ static void loongarch_pic_class_init(ObjectClass *klass, const void *data) NULL, &lpc->parent_phases); device_class_set_parent_realize(dc, loongarch_pic_realize, &lpc->parent_realize); + device_class_set_props(dc, loongarch_pic_properties); } static const TypeInfo loongarch_pic_types[] = { diff --git a/include/hw/intc/loongarch_pch_pic.h b/include/hw/intc/loongarch_pch_pic.h index 839a59a43b..40fe550c0b 100644 --- a/include/hw/intc/loongarch_pch_pic.h +++ b/include/hw/intc/loongarch_pch_pic.h @@ -16,6 +16,7 @@ OBJECT_DECLARE_TYPE(LoongarchPICState, LoongarchPICClass, LOONGARCH_PIC) struct LoongarchPICState { LoongArchPICCommonState parent_obj; + bool irqchip_in_kernel; }; struct LoongarchPICClass { -- 2.39.3