Add reset support with LoongArch pci irqchip, and register reset
callback support with new API resettable_class_set_parent_phases().
Clear internal HW registers and SW state when virt machine resets.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
hw/intc/loongarch_pic_common.c | 25 +++++++++++++++++++++++++
include/hw/intc/loongarch_pic_common.h | 1 +
2 files changed, 26 insertions(+)
diff --git a/hw/intc/loongarch_pic_common.c b/hw/intc/loongarch_pic_common.c
index e7f541db4b..08ef97fcc4 100644
--- a/hw/intc/loongarch_pic_common.c
+++ b/hw/intc/loongarch_pic_common.c
@@ -44,6 +44,27 @@ static void loongarch_pic_common_realize(DeviceState *dev, Error **errp)
}
}
+static void loongarch_pic_common_reset_hold(Object *obj, ResetType type)
+{
+ LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(obj);
+ int i;
+
+ s->int_mask = -1;
+ s->htmsi_en = 0x0;
+ s->intedge = 0x0;
+ s->intclr = 0x0;
+ s->auto_crtl0 = 0x0;
+ s->auto_crtl1 = 0x0;
+ for (i = 0; i < 64; i++) {
+ s->route_entry[i] = 0x1;
+ s->htmsi_vector[i] = 0x0;
+ }
+ s->intirr = 0x0;
+ s->intisr = 0x0;
+ s->last_intirr = 0x0;
+ s->int_polarity = 0x0;
+}
+
static const Property loongarch_pic_common_properties[] = {
DEFINE_PROP_UINT32("pch_pic_irq_num", LoongArchPICCommonState, irq_num, 0),
};
@@ -75,9 +96,13 @@ static void loongarch_pic_common_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
LoongArchPICCommonClass *lpcc = LOONGARCH_PIC_COMMON_CLASS(klass);
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
device_class_set_parent_realize(dc, loongarch_pic_common_realize,
&lpcc->parent_realize);
+ resettable_class_set_parent_phases(rc, NULL,
+ loongarch_pic_common_reset_hold,
+ NULL, &lpcc->parent_phases);
device_class_set_props(dc, loongarch_pic_common_properties);
dc->vmsd = &vmstate_loongarch_pic_common;
}
diff --git a/include/hw/intc/loongarch_pic_common.h b/include/hw/intc/loongarch_pic_common.h
index 43cce48978..d301377cd7 100644
--- a/include/hw/intc/loongarch_pic_common.h
+++ b/include/hw/intc/loongarch_pic_common.h
@@ -76,6 +76,7 @@ struct LoongArchPICCommonClass {
SysBusDeviceClass parent_class;
DeviceRealize parent_realize;
+ ResettablePhases parent_phases;
int (*pre_save)(LoongArchPICCommonState *s);
int (*post_load)(LoongArchPICCommonState *s, int version_id);
};
--
2.39.3
在 2025/3/7 下午3:13, Bibo Mao 写道:
> Add reset support with LoongArch pci irqchip, and register reset
> callback support with new API resettable_class_set_parent_phases().
> Clear internal HW registers and SW state when virt machine resets.
>
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
> hw/intc/loongarch_pic_common.c | 25 +++++++++++++++++++++++++
> include/hw/intc/loongarch_pic_common.h | 1 +
> 2 files changed, 26 insertions(+)
Reviewed-by: Song Gao <gaosong@loongson.cn>
thanks.
Song Gao
> diff --git a/hw/intc/loongarch_pic_common.c b/hw/intc/loongarch_pic_common.c
> index e7f541db4b..08ef97fcc4 100644
> --- a/hw/intc/loongarch_pic_common.c
> +++ b/hw/intc/loongarch_pic_common.c
> @@ -44,6 +44,27 @@ static void loongarch_pic_common_realize(DeviceState *dev, Error **errp)
> }
> }
>
> +static void loongarch_pic_common_reset_hold(Object *obj, ResetType type)
> +{
> + LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(obj);
> + int i;
> +
> + s->int_mask = -1;
> + s->htmsi_en = 0x0;
> + s->intedge = 0x0;
> + s->intclr = 0x0;
> + s->auto_crtl0 = 0x0;
> + s->auto_crtl1 = 0x0;
> + for (i = 0; i < 64; i++) {
> + s->route_entry[i] = 0x1;
> + s->htmsi_vector[i] = 0x0;
> + }
> + s->intirr = 0x0;
> + s->intisr = 0x0;
> + s->last_intirr = 0x0;
> + s->int_polarity = 0x0;
> +}
> +
> static const Property loongarch_pic_common_properties[] = {
> DEFINE_PROP_UINT32("pch_pic_irq_num", LoongArchPICCommonState, irq_num, 0),
> };
> @@ -75,9 +96,13 @@ static void loongarch_pic_common_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> LoongArchPICCommonClass *lpcc = LOONGARCH_PIC_COMMON_CLASS(klass);
> + ResettableClass *rc = RESETTABLE_CLASS(klass);
>
> device_class_set_parent_realize(dc, loongarch_pic_common_realize,
> &lpcc->parent_realize);
> + resettable_class_set_parent_phases(rc, NULL,
> + loongarch_pic_common_reset_hold,
> + NULL, &lpcc->parent_phases);
> device_class_set_props(dc, loongarch_pic_common_properties);
> dc->vmsd = &vmstate_loongarch_pic_common;
> }
> diff --git a/include/hw/intc/loongarch_pic_common.h b/include/hw/intc/loongarch_pic_common.h
> index 43cce48978..d301377cd7 100644
> --- a/include/hw/intc/loongarch_pic_common.h
> +++ b/include/hw/intc/loongarch_pic_common.h
> @@ -76,6 +76,7 @@ struct LoongArchPICCommonClass {
> SysBusDeviceClass parent_class;
>
> DeviceRealize parent_realize;
> + ResettablePhases parent_phases;
> int (*pre_save)(LoongArchPICCommonState *s);
> int (*post_load)(LoongArchPICCommonState *s, int version_id);
> };
© 2016 - 2025 Red Hat, Inc.