* [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic
@ 2024-09-18 6:54 Bibo Mao
2024-09-18 6:54 ` [PATCH v2 1/8] include: Add loongarch_pic_common header file Bibo Mao
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Bibo Mao @ 2024-09-18 6:54 UTC (permalink / raw)
To: Song Gao, Philippe Mathieu-Daudé; +Cc: Jiaxun Yang, qemu-devel
In order to support irqchip_in_kenrel method, split loongarch pch pic
driver into two parts, pic common and pic TCG driver. LoongArch pic common
driver includes vmstate and property interface, also vmstate load and
store interface is defined in pic common driver.
In future LoongArch pic kvm driver can inherit from pic common driver.
---
v1 ... v2:
1. Reorganize the patchset, put macro and structure moving patch as
first one
2. Split the patchset with smaller patch, so that it is easier to
review
---
Bibo Mao (8):
include: Add loongarch_pic_common header file
include: Move struct LoongArchPCHPIC to loongarch_pic_common header
file
hw/intc/loongarch_pch: Merge instance_init() into realize()
hw/intc/loongarch_pch: Rename LoongArchPCHPIC with
LoongArchPICCommonState
hw/intc/loongarch_pch: Move some functions to file
loongarch_pic_common
hw/intc/loongarch_pch: Inherit from loongarch_pic_common
hw/intc/loongarch_pch: Add pre_save and post_load interfaces
hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic
hw/intc/loongarch_pch_pic.c | 106 ++++++++-----------------
hw/intc/loongarch_pic_common.c | 97 ++++++++++++++++++++++
hw/intc/meson.build | 2 +-
hw/loongarch/virt.c | 2 +-
include/hw/intc/loongarch_pch_pic.h | 70 ++++------------
include/hw/intc/loongarch_pic_common.h | 82 +++++++++++++++++++
6 files changed, 230 insertions(+), 129 deletions(-)
create mode 100644 hw/intc/loongarch_pic_common.c
create mode 100644 include/hw/intc/loongarch_pic_common.h
base-commit: 2b81c046252fbfb375ad30632362fc16e6e22bd5
--
2.39.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/8] include: Add loongarch_pic_common header file
2024-09-18 6:54 [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic Bibo Mao
@ 2024-09-18 6:54 ` Bibo Mao
2024-09-18 6:54 ` [PATCH v2 2/8] include: Move struct LoongArchPCHPIC to " Bibo Mao
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Bibo Mao @ 2024-09-18 6:54 UTC (permalink / raw)
To: Song Gao, Philippe Mathieu-Daudé; +Cc: Jiaxun Yang, qemu-devel
Add common header file hw/intc/loongarch_pic_common.h, and move
some macro definition from hw/intc/loongarch_pch_pic.h to the common
header file.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
include/hw/intc/loongarch_pch_pic.h | 36 +++-------------------
include/hw/intc/loongarch_pic_common.h | 42 ++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 31 deletions(-)
create mode 100644 include/hw/intc/loongarch_pic_common.h
diff --git a/include/hw/intc/loongarch_pch_pic.h b/include/hw/intc/loongarch_pch_pic.h
index d5437e88f2..861b32313b 100644
--- a/include/hw/intc/loongarch_pch_pic.h
+++ b/include/hw/intc/loongarch_pch_pic.h
@@ -5,42 +5,15 @@
* Copyright (c) 2021 Loongson Technology Corporation Limited
*/
-#include "hw/sysbus.h"
+#ifndef HW_LOONGARCH_PCH_PIC_H
+#define HW_LOONGARCH_PCH_PIC_H
+
+#include "hw/intc/loongarch_pic_common.h"
#define TYPE_LOONGARCH_PCH_PIC "loongarch_pch_pic"
#define PCH_PIC_NAME(name) TYPE_LOONGARCH_PCH_PIC#name
OBJECT_DECLARE_SIMPLE_TYPE(LoongArchPCHPIC, LOONGARCH_PCH_PIC)
-#define PCH_PIC_INT_ID_VAL 0x7000000UL
-#define PCH_PIC_INT_ID_VER 0x1UL
-
-#define PCH_PIC_INT_ID_LO 0x00
-#define PCH_PIC_INT_ID_HI 0x04
-#define PCH_PIC_INT_MASK_LO 0x20
-#define PCH_PIC_INT_MASK_HI 0x24
-#define PCH_PIC_HTMSI_EN_LO 0x40
-#define PCH_PIC_HTMSI_EN_HI 0x44
-#define PCH_PIC_INT_EDGE_LO 0x60
-#define PCH_PIC_INT_EDGE_HI 0x64
-#define PCH_PIC_INT_CLEAR_LO 0x80
-#define PCH_PIC_INT_CLEAR_HI 0x84
-#define PCH_PIC_AUTO_CTRL0_LO 0xc0
-#define PCH_PIC_AUTO_CTRL0_HI 0xc4
-#define PCH_PIC_AUTO_CTRL1_LO 0xe0
-#define PCH_PIC_AUTO_CTRL1_HI 0xe4
-#define PCH_PIC_ROUTE_ENTRY_OFFSET 0x100
-#define PCH_PIC_ROUTE_ENTRY_END 0x13f
-#define PCH_PIC_HTMSI_VEC_OFFSET 0x200
-#define PCH_PIC_HTMSI_VEC_END 0x23f
-#define PCH_PIC_INT_STATUS_LO 0x3a0
-#define PCH_PIC_INT_STATUS_HI 0x3a4
-#define PCH_PIC_INT_POL_LO 0x3e0
-#define PCH_PIC_INT_POL_HI 0x3e4
-
-#define STATUS_LO_START 0
-#define STATUS_HI_START 0x4
-#define POL_LO_START 0x40
-#define POL_HI_START 0x44
struct LoongArchPCHPIC {
SysBusDevice parent_obj;
qemu_irq parent_irq[64];
@@ -67,3 +40,4 @@ struct LoongArchPCHPIC {
MemoryRegion iomem8;
unsigned int irq_num;
};
+#endif /* HW_LOONGARCH_PCH_PIC_H */
diff --git a/include/hw/intc/loongarch_pic_common.h b/include/hw/intc/loongarch_pic_common.h
new file mode 100644
index 0000000000..6d0e33e1ac
--- /dev/null
+++ b/include/hw/intc/loongarch_pic_common.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * LoongArch 7A1000 I/O interrupt controller definitions
+ * Copyright (c) 2024 Loongson Technology Corporation Limited
+ */
+
+#ifndef HW_LOONGARCH_PIC_COMMON_H
+#define HW_LOONGARCH_PIC_COMMON_H
+
+#include "hw/pci-host/ls7a.h"
+#include "hw/sysbus.h"
+
+#define PCH_PIC_INT_ID_VAL 0x7000000UL
+#define PCH_PIC_INT_ID_VER 0x1UL
+#define PCH_PIC_INT_ID_LO 0x00
+#define PCH_PIC_INT_ID_HI 0x04
+#define PCH_PIC_INT_MASK_LO 0x20
+#define PCH_PIC_INT_MASK_HI 0x24
+#define PCH_PIC_HTMSI_EN_LO 0x40
+#define PCH_PIC_HTMSI_EN_HI 0x44
+#define PCH_PIC_INT_EDGE_LO 0x60
+#define PCH_PIC_INT_EDGE_HI 0x64
+#define PCH_PIC_INT_CLEAR_LO 0x80
+#define PCH_PIC_INT_CLEAR_HI 0x84
+#define PCH_PIC_AUTO_CTRL0_LO 0xc0
+#define PCH_PIC_AUTO_CTRL0_HI 0xc4
+#define PCH_PIC_AUTO_CTRL1_LO 0xe0
+#define PCH_PIC_AUTO_CTRL1_HI 0xe4
+#define PCH_PIC_ROUTE_ENTRY_OFFSET 0x100
+#define PCH_PIC_ROUTE_ENTRY_END 0x13f
+#define PCH_PIC_HTMSI_VEC_OFFSET 0x200
+#define PCH_PIC_HTMSI_VEC_END 0x23f
+#define PCH_PIC_INT_STATUS_LO 0x3a0
+#define PCH_PIC_INT_STATUS_HI 0x3a4
+#define PCH_PIC_INT_POL_LO 0x3e0
+#define PCH_PIC_INT_POL_HI 0x3e4
+
+#define STATUS_LO_START 0
+#define STATUS_HI_START 0x4
+#define POL_LO_START 0x40
+#define POL_HI_START 0x44
+#endif /* HW_LOONGARCH_PIC_COMMON_H */
--
2.39.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/8] include: Move struct LoongArchPCHPIC to loongarch_pic_common header file
2024-09-18 6:54 [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic Bibo Mao
2024-09-18 6:54 ` [PATCH v2 1/8] include: Add loongarch_pic_common header file Bibo Mao
@ 2024-09-18 6:54 ` Bibo Mao
2024-09-18 6:54 ` [PATCH v2 3/8] hw/intc/loongarch_pch: Merge instance_init() into realize() Bibo Mao
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Bibo Mao @ 2024-09-18 6:54 UTC (permalink / raw)
To: Song Gao, Philippe Mathieu-Daudé; +Cc: Jiaxun Yang, qemu-devel
Move structure LoongArchPCHPIC from header file loongarch_pch_pic.h
to file loongarch_pic_common.h, and rename structure name with
LoongArchPICCommonState.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
include/hw/intc/loongarch_pch_pic.h | 27 +------------------------
include/hw/intc/loongarch_pic_common.h | 28 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 26 deletions(-)
diff --git a/include/hw/intc/loongarch_pch_pic.h b/include/hw/intc/loongarch_pch_pic.h
index 861b32313b..381accbf2b 100644
--- a/include/hw/intc/loongarch_pch_pic.h
+++ b/include/hw/intc/loongarch_pch_pic.h
@@ -10,34 +10,9 @@
#include "hw/intc/loongarch_pic_common.h"
+#define LoongArchPCHPIC LoongArchPICCommonState
#define TYPE_LOONGARCH_PCH_PIC "loongarch_pch_pic"
#define PCH_PIC_NAME(name) TYPE_LOONGARCH_PCH_PIC#name
OBJECT_DECLARE_SIMPLE_TYPE(LoongArchPCHPIC, LOONGARCH_PCH_PIC)
-struct LoongArchPCHPIC {
- SysBusDevice parent_obj;
- qemu_irq parent_irq[64];
- uint64_t int_mask; /*0x020 interrupt mask register*/
- uint64_t htmsi_en; /*0x040 1=msi*/
- uint64_t intedge; /*0x060 edge=1 level =0*/
- uint64_t intclr; /*0x080 for clean edge int,set 1 clean,set 0 is noused*/
- uint64_t auto_crtl0; /*0x0c0*/
- uint64_t auto_crtl1; /*0x0e0*/
- uint64_t last_intirr; /* edge detection */
- uint64_t intirr; /* 0x380 interrupt request register */
- uint64_t intisr; /* 0x3a0 interrupt service register */
- /*
- * 0x3e0 interrupt level polarity selection
- * register 0 for high level trigger
- */
- uint64_t int_polarity;
-
- uint8_t route_entry[64]; /*0x100 - 0x138*/
- uint8_t htmsi_vector[64]; /*0x200 - 0x238*/
-
- MemoryRegion iomem32_low;
- MemoryRegion iomem32_high;
- MemoryRegion iomem8;
- unsigned int irq_num;
-};
#endif /* HW_LOONGARCH_PCH_PIC_H */
diff --git a/include/hw/intc/loongarch_pic_common.h b/include/hw/intc/loongarch_pic_common.h
index 6d0e33e1ac..124bb7d226 100644
--- a/include/hw/intc/loongarch_pic_common.h
+++ b/include/hw/intc/loongarch_pic_common.h
@@ -39,4 +39,32 @@
#define STATUS_HI_START 0x4
#define POL_LO_START 0x40
#define POL_HI_START 0x44
+
+struct LoongArchPICCommonState {
+ SysBusDevice parent_obj;
+
+ qemu_irq parent_irq[64];
+ uint64_t int_mask; /* 0x020 interrupt mask register */
+ uint64_t htmsi_en; /* 0x040 1=msi */
+ uint64_t intedge; /* 0x060 edge=1 level=0 */
+ uint64_t intclr; /* 0x080 clean edge int, set 1 clean, 0 noused */
+ uint64_t auto_crtl0; /* 0x0c0 */
+ uint64_t auto_crtl1; /* 0x0e0 */
+ uint64_t last_intirr; /* edge detection */
+ uint64_t intirr; /* 0x380 interrupt request register */
+ uint64_t intisr; /* 0x3a0 interrupt service register */
+ /*
+ * 0x3e0 interrupt level polarity selection
+ * register 0 for high level trigger
+ */
+ uint64_t int_polarity;
+
+ uint8_t route_entry[64]; /* 0x100 - 0x138 */
+ uint8_t htmsi_vector[64]; /* 0x200 - 0x238 */
+
+ MemoryRegion iomem32_low;
+ MemoryRegion iomem32_high;
+ MemoryRegion iomem8;
+ unsigned int irq_num;
+};
#endif /* HW_LOONGARCH_PIC_COMMON_H */
--
2.39.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/8] hw/intc/loongarch_pch: Merge instance_init() into realize()
2024-09-18 6:54 [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic Bibo Mao
2024-09-18 6:54 ` [PATCH v2 1/8] include: Add loongarch_pic_common header file Bibo Mao
2024-09-18 6:54 ` [PATCH v2 2/8] include: Move struct LoongArchPCHPIC to " Bibo Mao
@ 2024-09-18 6:54 ` Bibo Mao
2024-09-18 6:54 ` [PATCH v2 4/8] hw/intc/loongarch_pch: Rename LoongArchPCHPIC with LoongArchPICCommonState Bibo Mao
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Bibo Mao @ 2024-09-18 6:54 UTC (permalink / raw)
To: Song Gao, Philippe Mathieu-Daudé; +Cc: Jiaxun Yang, qemu-devel
Memory region is created in instance_init(), merge it into function
realize(). There is no special class_init() for loongarch_pch object.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
hw/intc/loongarch_pch_pic.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c
index b958180591..96d0e9c16c 100644
--- a/hw/intc/loongarch_pch_pic.c
+++ b/hw/intc/loongarch_pch_pic.c
@@ -382,6 +382,7 @@ static void loongarch_pch_pic_reset(DeviceState *d)
static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp)
{
LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(dev);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) {
error_setg(errp, "Invalid 'pic_irq_num'");
@@ -390,19 +391,12 @@ static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp)
qdev_init_gpio_out(dev, s->parent_irq, s->irq_num);
qdev_init_gpio_in(dev, pch_pic_irq_handler, s->irq_num);
-}
-
-static void loongarch_pch_pic_init(Object *obj)
-{
- LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(obj);
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
-
- memory_region_init_io(&s->iomem32_low, obj,
+ memory_region_init_io(&s->iomem32_low, OBJECT(dev),
&loongarch_pch_pic_reg32_low_ops,
s, PCH_PIC_NAME(.reg32_part1), 0x100);
- memory_region_init_io(&s->iomem8, obj, &loongarch_pch_pic_reg8_ops,
+ memory_region_init_io(&s->iomem8, OBJECT(dev), &loongarch_pch_pic_reg8_ops,
s, PCH_PIC_NAME(.reg8), 0x2a0);
- memory_region_init_io(&s->iomem32_high, obj,
+ memory_region_init_io(&s->iomem32_high, OBJECT(dev),
&loongarch_pch_pic_reg32_high_ops,
s, PCH_PIC_NAME(.reg32_part2), 0xc60);
sysbus_init_mmio(sbd, &s->iomem32_low);
@@ -451,7 +445,6 @@ static const TypeInfo loongarch_pch_pic_info = {
.name = TYPE_LOONGARCH_PCH_PIC,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(LoongArchPCHPIC),
- .instance_init = loongarch_pch_pic_init,
.class_init = loongarch_pch_pic_class_init,
};
--
2.39.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 4/8] hw/intc/loongarch_pch: Rename LoongArchPCHPIC with LoongArchPICCommonState
2024-09-18 6:54 [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic Bibo Mao
` (2 preceding siblings ...)
2024-09-18 6:54 ` [PATCH v2 3/8] hw/intc/loongarch_pch: Merge instance_init() into realize() Bibo Mao
@ 2024-09-18 6:54 ` Bibo Mao
2024-09-18 6:54 ` [PATCH v2 5/8] hw/intc/loongarch_pch: Move some functions to file loongarch_pic_common Bibo Mao
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Bibo Mao @ 2024-09-18 6:54 UTC (permalink / raw)
To: Song Gao, Philippe Mathieu-Daudé; +Cc: Jiaxun Yang, qemu-devel
With pic vmstate, rename structure name vmstate_loongarch_pch_pic with
vmstate_loongarch_pic_common, and with pic property rename
loongarch_pch_pic_properties with loongarch_pic_common_properties.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
hw/intc/loongarch_pch_pic.c | 52 +++++++++++++++++++++++--------------
1 file changed, 32 insertions(+), 20 deletions(-)
diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c
index 96d0e9c16c..64f30d8916 100644
--- a/hw/intc/loongarch_pch_pic.c
+++ b/hw/intc/loongarch_pch_pic.c
@@ -379,13 +379,25 @@ static void loongarch_pch_pic_reset(DeviceState *d)
s->int_polarity = 0x0;
}
+static void loongarch_pic_common_realize(DeviceState *dev, Error **errp)
+{
+ LoongArchPICCommonState *s = LOONGARCH_PCH_PIC(dev);
+
+ if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) {
+ error_setg(errp, "Invalid 'pic_irq_num'");
+ return;
+ }
+}
+
static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp)
{
LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(dev);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+ Error *local_err = NULL;
- if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) {
- error_setg(errp, "Invalid 'pic_irq_num'");
+ loongarch_pic_common_realize(dev, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
return;
}
@@ -405,28 +417,28 @@ static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp)
}
-static Property loongarch_pch_pic_properties[] = {
- DEFINE_PROP_UINT32("pch_pic_irq_num", LoongArchPCHPIC, irq_num, 0),
+static Property loongarch_pic_common_properties[] = {
+ DEFINE_PROP_UINT32("pch_pic_irq_num", LoongArchPICCommonState, irq_num, 0),
DEFINE_PROP_END_OF_LIST(),
};
-static const VMStateDescription vmstate_loongarch_pch_pic = {
- .name = TYPE_LOONGARCH_PCH_PIC,
+static const VMStateDescription vmstate_loongarch_pic_common = {
+ .name = "loongarch_pch_pic",
.version_id = 1,
.minimum_version_id = 1,
.fields = (const VMStateField[]) {
- VMSTATE_UINT64(int_mask, LoongArchPCHPIC),
- VMSTATE_UINT64(htmsi_en, LoongArchPCHPIC),
- VMSTATE_UINT64(intedge, LoongArchPCHPIC),
- VMSTATE_UINT64(intclr, LoongArchPCHPIC),
- VMSTATE_UINT64(auto_crtl0, LoongArchPCHPIC),
- VMSTATE_UINT64(auto_crtl1, LoongArchPCHPIC),
- VMSTATE_UINT8_ARRAY(route_entry, LoongArchPCHPIC, 64),
- VMSTATE_UINT8_ARRAY(htmsi_vector, LoongArchPCHPIC, 64),
- VMSTATE_UINT64(last_intirr, LoongArchPCHPIC),
- VMSTATE_UINT64(intirr, LoongArchPCHPIC),
- VMSTATE_UINT64(intisr, LoongArchPCHPIC),
- VMSTATE_UINT64(int_polarity, LoongArchPCHPIC),
+ VMSTATE_UINT64(int_mask, LoongArchPICCommonState),
+ VMSTATE_UINT64(htmsi_en, LoongArchPICCommonState),
+ VMSTATE_UINT64(intedge, LoongArchPICCommonState),
+ VMSTATE_UINT64(intclr, LoongArchPICCommonState),
+ VMSTATE_UINT64(auto_crtl0, LoongArchPICCommonState),
+ VMSTATE_UINT64(auto_crtl1, LoongArchPICCommonState),
+ VMSTATE_UINT8_ARRAY(route_entry, LoongArchPICCommonState, 64),
+ VMSTATE_UINT8_ARRAY(htmsi_vector, LoongArchPICCommonState, 64),
+ VMSTATE_UINT64(last_intirr, LoongArchPICCommonState),
+ VMSTATE_UINT64(intirr, LoongArchPICCommonState),
+ VMSTATE_UINT64(intisr, LoongArchPICCommonState),
+ VMSTATE_UINT64(int_polarity, LoongArchPICCommonState),
VMSTATE_END_OF_LIST()
}
};
@@ -437,8 +449,8 @@ static void loongarch_pch_pic_class_init(ObjectClass *klass, void *data)
dc->realize = loongarch_pch_pic_realize;
device_class_set_legacy_reset(dc, loongarch_pch_pic_reset);
- dc->vmsd = &vmstate_loongarch_pch_pic;
- device_class_set_props(dc, loongarch_pch_pic_properties);
+ dc->vmsd = &vmstate_loongarch_pic_common;
+ device_class_set_props(dc, loongarch_pic_common_properties);
}
static const TypeInfo loongarch_pch_pic_info = {
--
2.39.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 5/8] hw/intc/loongarch_pch: Move some functions to file loongarch_pic_common
2024-09-18 6:54 [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic Bibo Mao
` (3 preceding siblings ...)
2024-09-18 6:54 ` [PATCH v2 4/8] hw/intc/loongarch_pch: Rename LoongArchPCHPIC with LoongArchPICCommonState Bibo Mao
@ 2024-09-18 6:54 ` Bibo Mao
2024-09-18 6:54 ` [PATCH v2 6/8] hw/intc/loongarch_pch: Inherit from loongarch_pic_common Bibo Mao
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Bibo Mao @ 2024-09-18 6:54 UTC (permalink / raw)
To: Song Gao, Philippe Mathieu-Daudé; +Cc: Jiaxun Yang, qemu-devel
Move some common functions to file loongarch_pic_common.c, the common
functions include loongarch_pic_common_realize(), property structure
loongarch_pic_common_properties and vmstate structure
vmstate_loongarch_pic_common.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
hw/intc/loongarch_pch_pic.c | 37 +-----------------------------
hw/intc/loongarch_pic_common.c | 41 ++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 36 deletions(-)
create mode 100644 hw/intc/loongarch_pic_common.c
diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c
index 64f30d8916..25c612b366 100644
--- a/hw/intc/loongarch_pch_pic.c
+++ b/hw/intc/loongarch_pch_pic.c
@@ -379,16 +379,7 @@ static void loongarch_pch_pic_reset(DeviceState *d)
s->int_polarity = 0x0;
}
-static void loongarch_pic_common_realize(DeviceState *dev, Error **errp)
-{
- LoongArchPICCommonState *s = LOONGARCH_PCH_PIC(dev);
-
- if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) {
- error_setg(errp, "Invalid 'pic_irq_num'");
- return;
- }
-}
-
+#include "loongarch_pic_common.c"
static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp)
{
LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(dev);
@@ -417,32 +408,6 @@ static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp)
}
-static Property loongarch_pic_common_properties[] = {
- DEFINE_PROP_UINT32("pch_pic_irq_num", LoongArchPICCommonState, irq_num, 0),
- DEFINE_PROP_END_OF_LIST(),
-};
-
-static const VMStateDescription vmstate_loongarch_pic_common = {
- .name = "loongarch_pch_pic",
- .version_id = 1,
- .minimum_version_id = 1,
- .fields = (const VMStateField[]) {
- VMSTATE_UINT64(int_mask, LoongArchPICCommonState),
- VMSTATE_UINT64(htmsi_en, LoongArchPICCommonState),
- VMSTATE_UINT64(intedge, LoongArchPICCommonState),
- VMSTATE_UINT64(intclr, LoongArchPICCommonState),
- VMSTATE_UINT64(auto_crtl0, LoongArchPICCommonState),
- VMSTATE_UINT64(auto_crtl1, LoongArchPICCommonState),
- VMSTATE_UINT8_ARRAY(route_entry, LoongArchPICCommonState, 64),
- VMSTATE_UINT8_ARRAY(htmsi_vector, LoongArchPICCommonState, 64),
- VMSTATE_UINT64(last_intirr, LoongArchPICCommonState),
- VMSTATE_UINT64(intirr, LoongArchPICCommonState),
- VMSTATE_UINT64(intisr, LoongArchPICCommonState),
- VMSTATE_UINT64(int_polarity, LoongArchPICCommonState),
- VMSTATE_END_OF_LIST()
- }
-};
-
static void loongarch_pch_pic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
diff --git a/hw/intc/loongarch_pic_common.c b/hw/intc/loongarch_pic_common.c
new file mode 100644
index 0000000000..c8e0490d40
--- /dev/null
+++ b/hw/intc/loongarch_pic_common.c
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * QEMU Loongson 7A1000 I/O interrupt controller.
+ * Copyright (C) 2024 Loongson Technology Corporation Limited
+ */
+
+static void loongarch_pic_common_realize(DeviceState *dev, Error **errp)
+{
+ LoongArchPICCommonState *s = LOONGARCH_PCH_PIC(dev);
+
+ if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) {
+ error_setg(errp, "Invalid 'pic_irq_num'");
+ return;
+ }
+}
+
+static Property loongarch_pic_common_properties[] = {
+ DEFINE_PROP_UINT32("pch_pic_irq_num", LoongArchPICCommonState, irq_num, 0),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static const VMStateDescription vmstate_loongarch_pic_common = {
+ .name = "loongarch_pch_pic",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (const VMStateField[]) {
+ VMSTATE_UINT64(int_mask, LoongArchPICCommonState),
+ VMSTATE_UINT64(htmsi_en, LoongArchPICCommonState),
+ VMSTATE_UINT64(intedge, LoongArchPICCommonState),
+ VMSTATE_UINT64(intclr, LoongArchPICCommonState),
+ VMSTATE_UINT64(auto_crtl0, LoongArchPICCommonState),
+ VMSTATE_UINT64(auto_crtl1, LoongArchPICCommonState),
+ VMSTATE_UINT8_ARRAY(route_entry, LoongArchPICCommonState, 64),
+ VMSTATE_UINT8_ARRAY(htmsi_vector, LoongArchPICCommonState, 64),
+ VMSTATE_UINT64(last_intirr, LoongArchPICCommonState),
+ VMSTATE_UINT64(intirr, LoongArchPICCommonState),
+ VMSTATE_UINT64(intisr, LoongArchPICCommonState),
+ VMSTATE_UINT64(int_polarity, LoongArchPICCommonState),
+ VMSTATE_END_OF_LIST()
+ }
+};
--
2.39.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 6/8] hw/intc/loongarch_pch: Inherit from loongarch_pic_common
2024-09-18 6:54 [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic Bibo Mao
` (4 preceding siblings ...)
2024-09-18 6:54 ` [PATCH v2 5/8] hw/intc/loongarch_pch: Move some functions to file loongarch_pic_common Bibo Mao
@ 2024-09-18 6:54 ` Bibo Mao
2024-09-18 6:54 ` [PATCH v2 7/8] hw/intc/loongarch_pch: Add pre_save and post_load interfaces Bibo Mao
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Bibo Mao @ 2024-09-18 6:54 UTC (permalink / raw)
To: Song Gao, Philippe Mathieu-Daudé; +Cc: Jiaxun Yang, qemu-devel
Set TYPE_LOONGARCH_PIC inherit from TYPE_LOONGARCH_PIC_COMMON object,
it shares vmsate and property of TYPE_LOONGARCH_PIC_COMMON, and has
its own realize() function.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
hw/intc/loongarch_pch_pic.c | 38 ++++++++++++--------------
hw/intc/loongarch_pic_common.c | 32 +++++++++++++++++++++-
hw/intc/meson.build | 2 +-
include/hw/intc/loongarch_pch_pic.h | 21 +++++++++++---
include/hw/intc/loongarch_pic_common.h | 10 +++++++
5 files changed, 77 insertions(+), 26 deletions(-)
diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c
index 25c612b366..11effd4cc9 100644
--- a/hw/intc/loongarch_pch_pic.c
+++ b/hw/intc/loongarch_pch_pic.c
@@ -379,14 +379,14 @@ static void loongarch_pch_pic_reset(DeviceState *d)
s->int_polarity = 0x0;
}
-#include "loongarch_pic_common.c"
-static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp)
+static void loongarch_pic_realize(DeviceState *dev, Error **errp)
{
- LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(dev);
- SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+ LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(dev);
+ LoongarchPICClass *lpc = LOONGARCH_PIC_GET_CLASS(dev);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
Error *local_err = NULL;
- loongarch_pic_common_realize(dev, &local_err);
+ lpc->parent_realize(dev, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -408,26 +408,24 @@ static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp)
}
-static void loongarch_pch_pic_class_init(ObjectClass *klass, void *data)
+static void loongarch_pic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
+ LoongarchPICClass *lpc = LOONGARCH_PIC_CLASS(klass);
- dc->realize = loongarch_pch_pic_realize;
device_class_set_legacy_reset(dc, loongarch_pch_pic_reset);
- dc->vmsd = &vmstate_loongarch_pic_common;
- device_class_set_props(dc, loongarch_pic_common_properties);
+ device_class_set_parent_realize(dc, loongarch_pic_realize,
+ &lpc->parent_realize);
}
-static const TypeInfo loongarch_pch_pic_info = {
- .name = TYPE_LOONGARCH_PCH_PIC,
- .parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(LoongArchPCHPIC),
- .class_init = loongarch_pch_pic_class_init,
+static const TypeInfo loongarch_pic_types[] = {
+ {
+ .name = TYPE_LOONGARCH_PIC,
+ .parent = TYPE_LOONGARCH_PIC_COMMON,
+ .instance_size = sizeof(LoongarchPICState),
+ .class_size = sizeof(LoongarchPICClass),
+ .class_init = loongarch_pic_class_init,
+ }
};
-static void loongarch_pch_pic_register_types(void)
-{
- type_register_static(&loongarch_pch_pic_info);
-}
-
-type_init(loongarch_pch_pic_register_types)
+DEFINE_TYPES(loongarch_pic_types)
diff --git a/hw/intc/loongarch_pic_common.c b/hw/intc/loongarch_pic_common.c
index c8e0490d40..28e9376557 100644
--- a/hw/intc/loongarch_pic_common.c
+++ b/hw/intc/loongarch_pic_common.c
@@ -4,9 +4,15 @@
* Copyright (C) 2024 Loongson Technology Corporation Limited
*/
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "hw/intc/loongarch_pic_common.h"
+#include "hw/qdev-properties.h"
+#include "migration/vmstate.h"
+
static void loongarch_pic_common_realize(DeviceState *dev, Error **errp)
{
- LoongArchPICCommonState *s = LOONGARCH_PCH_PIC(dev);
+ LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(dev);
if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) {
error_setg(errp, "Invalid 'pic_irq_num'");
@@ -39,3 +45,27 @@ static const VMStateDescription vmstate_loongarch_pic_common = {
VMSTATE_END_OF_LIST()
}
};
+
+static void loongarch_pic_common_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ LoongArchPICCommonClass *lpcc = LOONGARCH_PIC_COMMON_CLASS(klass);
+
+ device_class_set_parent_realize(dc, loongarch_pic_common_realize,
+ &lpcc->parent_realize);
+ device_class_set_props(dc, loongarch_pic_common_properties);
+ dc->vmsd = &vmstate_loongarch_pic_common;
+}
+
+static const TypeInfo loongarch_pic_common_types[] = {
+ {
+ .name = TYPE_LOONGARCH_PIC_COMMON,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(LoongArchPICCommonState),
+ .class_size = sizeof(LoongArchPICCommonClass),
+ .class_init = loongarch_pic_common_class_init,
+ .abstract = true,
+ }
+};
+
+DEFINE_TYPES(loongarch_pic_common_types)
diff --git a/hw/intc/meson.build b/hw/intc/meson.build
index 6bfdc4eb33..848cb6685e 100644
--- a/hw/intc/meson.build
+++ b/hw/intc/meson.build
@@ -71,6 +71,6 @@ 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', 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_PCH_PIC', if_true: files('loongarch_pch_pic.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_EXTIOI', if_true: files('loongarch_extioi.c'))
diff --git a/include/hw/intc/loongarch_pch_pic.h b/include/hw/intc/loongarch_pch_pic.h
index 381accbf2b..f84be0ac62 100644
--- a/include/hw/intc/loongarch_pch_pic.h
+++ b/include/hw/intc/loongarch_pch_pic.h
@@ -10,9 +10,22 @@
#include "hw/intc/loongarch_pic_common.h"
-#define LoongArchPCHPIC LoongArchPICCommonState
-#define TYPE_LOONGARCH_PCH_PIC "loongarch_pch_pic"
-#define PCH_PIC_NAME(name) TYPE_LOONGARCH_PCH_PIC#name
-OBJECT_DECLARE_SIMPLE_TYPE(LoongArchPCHPIC, LOONGARCH_PCH_PIC)
+#define TYPE_LOONGARCH_PIC "loongarch_pic"
+#define PCH_PIC_NAME(name) TYPE_LOONGARCH_PIC#name
+OBJECT_DECLARE_TYPE(LoongarchPICState, LoongarchPICClass, LOONGARCH_PIC)
+
+struct LoongarchPICState {
+ LoongArchPICCommonState parent_obj;
+};
+
+struct LoongarchPICClass {
+ LoongArchPICCommonClass parent_class;
+
+ DeviceRealize parent_realize;
+};
+
+#define TYPE_LOONGARCH_PCH_PIC TYPE_LOONGARCH_PIC
+typedef struct LoongArchPICCommonState LoongArchPCHPIC;
+#define LOONGARCH_PCH_PIC(obj) ((struct LoongArchPICCommonState *)(obj))
#endif /* HW_LOONGARCH_PCH_PIC_H */
diff --git a/include/hw/intc/loongarch_pic_common.h b/include/hw/intc/loongarch_pic_common.h
index 124bb7d226..0a1a28063c 100644
--- a/include/hw/intc/loongarch_pic_common.h
+++ b/include/hw/intc/loongarch_pic_common.h
@@ -40,6 +40,10 @@
#define POL_LO_START 0x40
#define POL_HI_START 0x44
+#define TYPE_LOONGARCH_PIC_COMMON "loongarch_pic_common"
+OBJECT_DECLARE_TYPE(LoongArchPICCommonState,
+ LoongArchPICCommonClass, LOONGARCH_PIC_COMMON)
+
struct LoongArchPICCommonState {
SysBusDevice parent_obj;
@@ -67,4 +71,10 @@ struct LoongArchPICCommonState {
MemoryRegion iomem8;
unsigned int irq_num;
};
+
+struct LoongArchPICCommonClass {
+ SysBusDeviceClass parent_class;
+
+ DeviceRealize parent_realize;
+};
#endif /* HW_LOONGARCH_PIC_COMMON_H */
--
2.39.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 7/8] hw/intc/loongarch_pch: Add pre_save and post_load interfaces
2024-09-18 6:54 [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic Bibo Mao
` (5 preceding siblings ...)
2024-09-18 6:54 ` [PATCH v2 6/8] hw/intc/loongarch_pch: Inherit from loongarch_pic_common Bibo Mao
@ 2024-09-18 6:54 ` Bibo Mao
2024-09-18 6:54 ` [PATCH v2 8/8] hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic Bibo Mao
2024-11-07 12:23 ` [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic gaosong
8 siblings, 0 replies; 10+ messages in thread
From: Bibo Mao @ 2024-09-18 6:54 UTC (permalink / raw)
To: Song Gao, Philippe Mathieu-Daudé; +Cc: Jiaxun Yang, qemu-devel
Add vmstate pre_save and post_load interfaces, which can be used
by pic kvm driver in future.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
hw/intc/loongarch_pic_common.c | 26 ++++++++++++++++++++++++++
include/hw/intc/loongarch_pic_common.h | 2 ++
2 files changed, 28 insertions(+)
diff --git a/hw/intc/loongarch_pic_common.c b/hw/intc/loongarch_pic_common.c
index 28e9376557..a74b6c7b44 100644
--- a/hw/intc/loongarch_pic_common.c
+++ b/hw/intc/loongarch_pic_common.c
@@ -10,6 +10,30 @@
#include "hw/qdev-properties.h"
#include "migration/vmstate.h"
+static int loongarch_pic_pre_save(void *opaque)
+{
+ LoongArchPICCommonState *s = (LoongArchPICCommonState *)opaque;
+ LoongArchPICCommonClass *lpcc = LOONGARCH_PIC_COMMON_GET_CLASS(s);
+
+ if (lpcc->pre_save) {
+ return lpcc->pre_save(s);
+ }
+
+ return 0;
+}
+
+static int loongarch_pic_post_load(void *opaque, int version_id)
+{
+ LoongArchPICCommonState *s = (LoongArchPICCommonState *)opaque;
+ LoongArchPICCommonClass *lpcc = LOONGARCH_PIC_COMMON_GET_CLASS(s);
+
+ if (lpcc->post_load) {
+ return lpcc->post_load(s, version_id);
+ }
+
+ return 0;
+}
+
static void loongarch_pic_common_realize(DeviceState *dev, Error **errp)
{
LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(dev);
@@ -29,6 +53,8 @@ static const VMStateDescription vmstate_loongarch_pic_common = {
.name = "loongarch_pch_pic",
.version_id = 1,
.minimum_version_id = 1,
+ .pre_save = loongarch_pic_pre_save,
+ .post_load = loongarch_pic_post_load,
.fields = (const VMStateField[]) {
VMSTATE_UINT64(int_mask, LoongArchPICCommonState),
VMSTATE_UINT64(htmsi_en, LoongArchPICCommonState),
diff --git a/include/hw/intc/loongarch_pic_common.h b/include/hw/intc/loongarch_pic_common.h
index 0a1a28063c..43cce48978 100644
--- a/include/hw/intc/loongarch_pic_common.h
+++ b/include/hw/intc/loongarch_pic_common.h
@@ -76,5 +76,7 @@ struct LoongArchPICCommonClass {
SysBusDeviceClass parent_class;
DeviceRealize parent_realize;
+ int (*pre_save)(LoongArchPICCommonState *s);
+ int (*post_load)(LoongArchPICCommonState *s, int version_id);
};
#endif /* HW_LOONGARCH_PIC_COMMON_H */
--
2.39.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 8/8] hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic
2024-09-18 6:54 [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic Bibo Mao
` (6 preceding siblings ...)
2024-09-18 6:54 ` [PATCH v2 7/8] hw/intc/loongarch_pch: Add pre_save and post_load interfaces Bibo Mao
@ 2024-09-18 6:54 ` Bibo Mao
2024-11-07 12:23 ` [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic gaosong
8 siblings, 0 replies; 10+ messages in thread
From: Bibo Mao @ 2024-09-18 6:54 UTC (permalink / raw)
To: Song Gao, Philippe Mathieu-Daudé; +Cc: Jiaxun Yang, qemu-devel
Remove definition about LoongArchPCHPIC and LOONGARCH_PCH_PIC, and
replace them with LoongArchPICCommonState and LOONGARCH_PIC_COMMON
separately. Also remove unnecessary header files.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
hw/intc/loongarch_pch_pic.c | 24 ++++++++++--------------
hw/loongarch/virt.c | 2 +-
include/hw/intc/loongarch_pch_pic.h | 4 ----
3 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c
index 11effd4cc9..acd75ccb0c 100644
--- a/hw/intc/loongarch_pch_pic.c
+++ b/hw/intc/loongarch_pch_pic.c
@@ -7,17 +7,13 @@
#include "qemu/osdep.h"
#include "qemu/bitops.h"
-#include "hw/sysbus.h"
-#include "hw/loongarch/virt.h"
-#include "hw/pci-host/ls7a.h"
#include "hw/irq.h"
#include "hw/intc/loongarch_pch_pic.h"
-#include "hw/qdev-properties.h"
-#include "migration/vmstate.h"
#include "trace.h"
#include "qapi/error.h"
-static void pch_pic_update_irq(LoongArchPCHPIC *s, uint64_t mask, int level)
+static void pch_pic_update_irq(LoongArchPICCommonState *s, uint64_t mask,
+ int level)
{
uint64_t val;
int irq;
@@ -45,7 +41,7 @@ static void pch_pic_update_irq(LoongArchPCHPIC *s, uint64_t mask, int level)
static void pch_pic_irq_handler(void *opaque, int irq, int level)
{
- LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque);
+ LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque);
uint64_t mask = 1ULL << irq;
assert(irq < s->irq_num);
@@ -78,7 +74,7 @@ static void pch_pic_irq_handler(void *opaque, int irq, int level)
static uint64_t loongarch_pch_pic_low_readw(void *opaque, hwaddr addr,
unsigned size)
{
- LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque);
+ LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque);
uint64_t val = 0;
uint32_t offset = addr & 0xfff;
@@ -136,7 +132,7 @@ static uint64_t get_writew_val(uint64_t value, uint32_t target, bool hi)
static void loongarch_pch_pic_low_writew(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
- LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque);
+ LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque);
uint32_t offset, old_valid, data = (uint32_t)value;
uint64_t old, int_mask;
offset = addr & 0xfff;
@@ -208,7 +204,7 @@ static void loongarch_pch_pic_low_writew(void *opaque, hwaddr addr,
static uint64_t loongarch_pch_pic_high_readw(void *opaque, hwaddr addr,
unsigned size)
{
- LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque);
+ LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque);
uint64_t val = 0;
uint32_t offset = addr & 0xfff;
@@ -236,7 +232,7 @@ static uint64_t loongarch_pch_pic_high_readw(void *opaque, hwaddr addr,
static void loongarch_pch_pic_high_writew(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
- LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque);
+ LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque);
uint32_t offset, data = (uint32_t)value;
offset = addr & 0xfff;
@@ -263,7 +259,7 @@ static void loongarch_pch_pic_high_writew(void *opaque, hwaddr addr,
static uint64_t loongarch_pch_pic_readb(void *opaque, hwaddr addr,
unsigned size)
{
- LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque);
+ LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque);
uint64_t val = 0;
uint32_t offset = (addr & 0xfff) + PCH_PIC_ROUTE_ENTRY_OFFSET;
int64_t offset_tmp;
@@ -292,7 +288,7 @@ static uint64_t loongarch_pch_pic_readb(void *opaque, hwaddr addr,
static void loongarch_pch_pic_writeb(void *opaque, hwaddr addr,
uint64_t data, unsigned size)
{
- LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque);
+ LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque);
int32_t offset_tmp;
uint32_t offset = (addr & 0xfff) + PCH_PIC_ROUTE_ENTRY_OFFSET;
@@ -360,7 +356,7 @@ static const MemoryRegionOps loongarch_pch_pic_reg8_ops = {
static void loongarch_pch_pic_reset(DeviceState *d)
{
- LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(d);
+ LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(d);
int i;
s->int_mask = -1;
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index 81b1f9486f..4471a9eb05 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -855,7 +855,7 @@ static void virt_irq_init(LoongArchVirtMachineState *lvms)
/* Add Extend I/O Interrupt Controller node */
fdt_add_eiointc_node(lvms, &cpuintc_phandle, &eiointc_phandle);
- pch_pic = qdev_new(TYPE_LOONGARCH_PCH_PIC);
+ pch_pic = qdev_new(TYPE_LOONGARCH_PIC);
num = VIRT_PCH_PIC_IRQ_NUM;
qdev_prop_set_uint32(pch_pic, "pch_pic_irq_num", num);
d = SYS_BUS_DEVICE(pch_pic);
diff --git a/include/hw/intc/loongarch_pch_pic.h b/include/hw/intc/loongarch_pch_pic.h
index f84be0ac62..481cc58aed 100644
--- a/include/hw/intc/loongarch_pch_pic.h
+++ b/include/hw/intc/loongarch_pch_pic.h
@@ -24,8 +24,4 @@ struct LoongarchPICClass {
DeviceRealize parent_realize;
};
-#define TYPE_LOONGARCH_PCH_PIC TYPE_LOONGARCH_PIC
-typedef struct LoongArchPICCommonState LoongArchPCHPIC;
-#define LOONGARCH_PCH_PIC(obj) ((struct LoongArchPICCommonState *)(obj))
-
#endif /* HW_LOONGARCH_PCH_PIC_H */
--
2.39.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic
2024-09-18 6:54 [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic Bibo Mao
` (7 preceding siblings ...)
2024-09-18 6:54 ` [PATCH v2 8/8] hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic Bibo Mao
@ 2024-11-07 12:23 ` gaosong
8 siblings, 0 replies; 10+ messages in thread
From: gaosong @ 2024-11-07 12:23 UTC (permalink / raw)
To: Bibo Mao; +Cc: Philippe Mathieu-Daudé, Jiaxun Yang, qemu-devel
在 2024/9/18 下午2:54, Bibo Mao 写道:
> In order to support irqchip_in_kenrel method, split loongarch pch pic
> driver into two parts, pic common and pic TCG driver. LoongArch pic common
> driver includes vmstate and property interface, also vmstate load and
> store interface is defined in pic common driver.
>
> In future LoongArch pic kvm driver can inherit from pic common driver.
>
> ---
> v1 ... v2:
> 1. Reorganize the patchset, put macro and structure moving patch as
> first one
> 2. Split the patchset with smaller patch, so that it is easier to
> review
> ---
> Bibo Mao (8):
> include: Add loongarch_pic_common header file
> include: Move struct LoongArchPCHPIC to loongarch_pic_common header
> file
> hw/intc/loongarch_pch: Merge instance_init() into realize()
> hw/intc/loongarch_pch: Rename LoongArchPCHPIC with
> LoongArchPICCommonState
> hw/intc/loongarch_pch: Move some functions to file
> loongarch_pic_common
> hw/intc/loongarch_pch: Inherit from loongarch_pic_common
> hw/intc/loongarch_pch: Add pre_save and post_load interfaces
> hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic
>
> hw/intc/loongarch_pch_pic.c | 106 ++++++++-----------------
> hw/intc/loongarch_pic_common.c | 97 ++++++++++++++++++++++
> hw/intc/meson.build | 2 +-
> hw/loongarch/virt.c | 2 +-
> include/hw/intc/loongarch_pch_pic.h | 70 ++++------------
> include/hw/intc/loongarch_pic_common.h | 82 +++++++++++++++++++
> 6 files changed, 230 insertions(+), 129 deletions(-)
> create mode 100644 hw/intc/loongarch_pic_common.c
> create mode 100644 include/hw/intc/loongarch_pic_common.h
>
>
> base-commit: 2b81c046252fbfb375ad30632362fc16e6e22bd5
Reviewed-by: Song Gao <gaosong@loongson.cn>
Thanks.
Song Gao
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-11-07 12:22 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-18 6:54 [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic Bibo Mao
2024-09-18 6:54 ` [PATCH v2 1/8] include: Add loongarch_pic_common header file Bibo Mao
2024-09-18 6:54 ` [PATCH v2 2/8] include: Move struct LoongArchPCHPIC to " Bibo Mao
2024-09-18 6:54 ` [PATCH v2 3/8] hw/intc/loongarch_pch: Merge instance_init() into realize() Bibo Mao
2024-09-18 6:54 ` [PATCH v2 4/8] hw/intc/loongarch_pch: Rename LoongArchPCHPIC with LoongArchPICCommonState Bibo Mao
2024-09-18 6:54 ` [PATCH v2 5/8] hw/intc/loongarch_pch: Move some functions to file loongarch_pic_common Bibo Mao
2024-09-18 6:54 ` [PATCH v2 6/8] hw/intc/loongarch_pch: Inherit from loongarch_pic_common Bibo Mao
2024-09-18 6:54 ` [PATCH v2 7/8] hw/intc/loongarch_pch: Add pre_save and post_load interfaces Bibo Mao
2024-09-18 6:54 ` [PATCH v2 8/8] hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic Bibo Mao
2024-11-07 12:23 ` [PATCH v2 0/8] hw/intc/loongarch_pch: Split into pic common and pic gaosong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).