Reconstruct loongson ipi driver
v4 cover Reconstruct loongson ipi driver
Since v3:
- Use DEFINE_TYPES() macro (unreviewed patch #1)
- Update MAINTAINERS
- Added Bibo's tags
Song, since Bibo reviewed/tested, if you provide your Acked-by I can queue that to my next hw-misc PR (pending Jiaxun testing).
Thanks,
Phil.
Bibo Mao (16):
hw/intc/loongson_ipi: Access memory in little endian hw/intc/loongson_ipi: Rename LoongsonIPI -> LoongsonIPIState hw/intc/loongson_ipi: Extract loongson_ipi_common_finalize() hw/intc/loongson_ipi: Extract loongson_ipi_common_realize() hw/intc/loongson_ipi: Add TYPE_LOONGSON_IPI_COMMON stub hw/intc/loongson_ipi: Move common definitions to loongson_ipi_common.h hw/intc/loongson_ipi: Move IPICore::mmio_mem to LoongsonIPIState hw/intc/loongson_ipi: Move IPICore structure to loongson_ipi_common.h hw/intc/loongson_ipi: Pass LoongsonIPICommonState to send_ipi_data() hw/intc/loongson_ipi: Add LoongsonIPICommonClass::get_iocsr_as handler hw/intc/loongson_ipi: Add LoongsonIPICommonClass::cpu_by_arch_id
handler
hw/intc/loongson_ipi: Expose loongson_ipi_core_read/write helpers hw/intc/loongson_ipi: Move common code to loongson_ipi_common.c hw/intc/loongarch_ipi: Add loongarch IPI support hw/loongarch/virt: Replace loongson IPI with loongarch IPI hw/intc/loongson_ipi: Restrict to MIPS
Philippe Mathieu-Daudé (2):
hw/intc/loongson_ipi: Declare QOM types using DEFINE_TYPES() macro hw/intc/loongson_ipi: Remove unused headers
MAINTAINERS | 6 +- include/hw/intc/loongarch_ipi.h | 25 ++ include/hw/intc/loongson_ipi.h | 50 +--- include/hw/intc/loongson_ipi_common.h | 72 ++++++ include/hw/loongarch/virt.h | 1 - hw/intc/loongarch_ipi.c | 68 +++++ hw/intc/loongson_ipi.c | 355 +++----------------------- hw/intc/loongson_ipi_common.c | 344 +++++++++++++++++++++++++ hw/loongarch/virt.c | 4 +- hw/intc/Kconfig | 8 + hw/intc/meson.build | 2 + hw/loongarch/Kconfig | 2 +- 12 files changed, 568 insertions(+), 369 deletions(-) create mode 100644 include/hw/intc/loongarch_ipi.h create mode 100644 include/hw/intc/loongson_ipi_common.h create mode 100644 hw/intc/loongarch_ipi.c create mode 100644 hw/intc/loongson_ipi_common.c
Signature · 1 line
2.41.0
PATCH v4 1/18 hw/intc/loongson_ipi: Declare QOM types using DEFINE_TYPES() macro
When multiple QOM types are registered in the same file, it is simpler to use the the DEFINE_TYPES() macro. Replace the type_init() / type_register_static() combination.
--- hw/intc/loongson_ipi.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
hw/intc/loongson_ipi.c +9 -12
@@ -363,17 +363,14 @@ static void loongson_ipi_finalize(Object *obj)g_free (s->cpu); } -static const TypeInfo loongson_ipi_info = { - .name =TYPE_LOONGSON_IPI , - .parent =TYPE_SYS_BUS_DEVICE , - .instance_size =sizeof (LoongsonIPI), - .class_init = loongson_ipi_class_init, - .instance_finalize = loongson_ipi_finalize, +static const TypeInfo loongson_ipi_types[] = { + { + .name =TYPE_LOONGSON_IPI , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (LoongsonIPI), + .class_init = loongson_ipi_class_init, + .instance_finalize = loongson_ipi_finalize, + } }; -static void loongson_ipi_register_types (void ) -{ -type_register_static (&loongson_ipi_info); -} - -type_init (loongson_ipi_register_types) +DEFINE_TYPES (loongson_ipi_types)
Signature · 1 line
2.41.0
Re: [PATCH v4 01/18] hw/intc/loongson_ipi: Declare QOM types using DEFINE_TYPES() macro
Quoted 8 lines · Philippe Mathieu-Daudé
When multiple QOM types are registered in the same file, it is simpler to use the the
DEFINE_TYPES()macro. Replace thetype_init()/type_register_static()combination.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/intc/loongson_ipi.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
r~
PATCH v4 2/18 hw/intc/loongson_ipi: Access memory in little endian
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
Loongson IPI is only available in little-endian,
so use that to access the guest memory (in case
we run on a big-endian host).
--- hw/intc/loongson_ipi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/intc/loongson_ipi.c +3 -2
@@ -14,6 +14,7 @@#include "qapi/error.h" #include "qemu/log.h" #include "exec/address-spaces.h" +#include "exec/memory.h" #include "migration/vmstate.h" #ifdef TARGET_LOONGARCH64 #include "target/loongarch/cpu.h"
@@ -102,7 +103,7 @@ static MemTxResult send_ipi_data(CPUState *cpu, uint64_t val, hwaddr addr,* if the mask is 0, we need not to do anything. */ if ((val >>27 ) &0xf ) { - data =address_space_ldl (iocsr_as, addr, attrs,NULL ); + data =address_space_ldl_le (iocsr_as, addr, attrs,NULL );for (i =0 ; i <4 ; i++) {/* get mask for byte writing */ if (val & (0x1 << (27 + i))) {
@@ -113,7 +114,7 @@ static MemTxResult send_ipi_data(CPUState *cpu, uint64_t val, hwaddr addr, data &= mask; data |= (val >>32 ) & ~mask; -address_space_stl (iocsr_as, addr, data, attrs,NULL ); +address_space_stl_le (iocsr_as, addr, data, attrs,NULL );return MEMTX_OK ; }
Signature · 1 line
2.41.0
PATCH v4 3/18 hw/intc/loongson_ipi: Rename LoongsonIPI -> LoongsonIPIState
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
We'll have to add LoongsonIPIClass in few commits, so rename LoongsonIPI as LoongsonIPIState for clarity.
--- include/hw/intc/loongson_ipi.h | 6 +++--- hw/intc/loongson_ipi.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-)
include/hw/intc/loongson_ipi.h +3 -3
@@ -31,10 +31,10 @@#define IPI_MBX_NUM 4#define TYPE_LOONGSON_IPI "loongson_ipi" -OBJECT_DECLARE_SIMPLE_TYPE(LoongsonIPI, LOONGSON_IPI) +OBJECT_DECLARE_SIMPLE_TYPE(LoongsonIPIState, LOONGSON_IPI) typedef struct IPICore { - LoongsonIPI *ipi; + LoongsonIPIState *ipi; MemoryRegion *ipi_mmio_mem; uint32_t status; uint32_t en;
@@ -45,7 +45,7 @@ typedef struct IPICore {qemu_irq irq; } IPICore; -struct LoongsonIPI { +struct LoongsonIPIState {SysBusDevice parent_obj;MemoryRegion ipi_iocsr_mem;MemoryRegion ipi64_iocsr_mem;
hw/intc/loongson_ipi.c +8 -8
@@ -64,7 +64,7 @@ static MemTxResult loongson_ipi_iocsr_readl(void *opaque, hwaddr addr,uint64_t *data, unsigned size, MemTxAttrs attrs) { - LoongsonIPI *ipi = opaque; + LoongsonIPIState *ipi = opaque;IPICore *s;if (attrs.requester_id >= ipi->num_cpu) {
@@ -160,7 +160,7 @@ static MemTxResult loongson_ipi_core_writel(void *opaque, hwaddr addr, MemTxAttrs attrs) {IPICore *s = opaque; -LoongsonIPI *ipi = s->ipi; +LoongsonIPIState *ipi = s->ipi;int index =0 ;uint32_t cpuid;uint8_t vector;
@@ -214,7 +214,7 @@ static MemTxResult loongson_ipi_iocsr_writel(void *opaque, hwaddr addr, uint64_t val, unsigned size, MemTxAttrs attrs) { - LoongsonIPI *ipi = opaque; + LoongsonIPIState *ipi = opaque;IPICore *s;if (attrs.requester_id >= ipi->num_cpu) {
@@ -277,7 +277,7 @@ static const MemoryRegionOps loongson_ipi64_ops = {static void loongson_ipi_realize (DeviceState *dev,Error **errp) { -LoongsonIPI *s =LOONGSON_IPI (dev); +LoongsonIPIState *s =LOONGSON_IPI (dev);SysBusDevice *sbd =SYS_BUS_DEVICE (dev);int i;
@@ -337,14 +337,14 @@ static const VMStateDescription vmstate_loongson_ipi = { .version_id = 2, .minimum_version_id = 2, .fields = (const VMStateField []) { -VMSTATE_STRUCT_VARRAY_POINTER_UINT32 (cpu, LoongsonIPI, num_cpu, +VMSTATE_STRUCT_VARRAY_POINTER_UINT32 (cpu, LoongsonIPIState, num_cpu, vmstate_ipi_core, IPICore),VMSTATE_END_OF_LIST () } };static Property ipi_properties[] = { -DEFINE_PROP_UINT32 ("num-cpu" , LoongsonIPI, num_cpu,1 ), +DEFINE_PROP_UINT32 ("num-cpu" , LoongsonIPIState, num_cpu,1 ),DEFINE_PROP_END_OF_LIST (), };
@@ -359,7 +359,7 @@ static void loongson_ipi_class_init(ObjectClass *klass, void *data)static void loongson_ipi_finalize (Object *obj) { -LoongsonIPI *s =LOONGSON_IPI (obj); +LoongsonIPIState *s =LOONGSON_IPI (obj);g_free (s->cpu); }
@@ -368,7 +368,7 @@ static const TypeInfo loongson_ipi_types[] = { { .name = TYPE_LOONGSON_IPI, .parent = TYPE_SYS_BUS_DEVICE, - .instance_size = sizeof(LoongsonIPI), + .instance_size = sizeof(LoongsonIPIState), .class_init = loongson_ipi_class_init, .instance_finalize = loongson_ipi_finalize, }
Signature · 1 line
2.41.0
Re: [PATCH v4 03/18] hw/intc/loongson_ipi: Rename LoongsonIPI -> LoongsonIPIState
Quoted 11 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
We'll have to add LoongsonIPIClass in few commits, so rename LoongsonIPI as LoongsonIPIState for clarity.
Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 4 lines
--- include/hw/intc/loongson_ipi.h | 6 +++--- hw/intc/loongson_ipi.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-)
r~
PATCH v4 4/18 hw/intc/loongson_ipi: Extract loongson_ipi_common_finalize()
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
In preparation to extract common IPI code in few commits, extract loongson_ipi_common_finalize().
--- hw/intc/loongson_ipi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
hw/intc/loongson_ipi.c +6 -1
@@ -357,13 +357,18 @@ static void loongson_ipi_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_loongson_ipi; } -static void loongson_ipi_finalize (Object *obj) +static void loongson_ipi_common_finalize (Object *obj) {LoongsonIPIState *s =LOONGSON_IPI (obj);g_free (s->cpu); } +static void loongson_ipi_finalize (Object *obj) +{ +loongson_ipi_common_finalize (obj); +} +static const TypeInfo loongson_ipi_types[] = { { .name =TYPE_LOONGSON_IPI ,
Signature · 1 line
2.41.0
Re: [PATCH v4 04/18] hw/intc/loongson_ipi: Extract loongson_ipi_common_finalize()
Quoted 11 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
In preparation to extract common IPI code in few commits, extract
loongson_ipi_common_finalize().Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 3 lines
--- hw/intc/loongson_ipi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
r~
PATCH v4 5/18 hw/intc/loongson_ipi: Extract loongson_ipi_common_realize()
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
In preparation to extract common IPI code in few commits, extract loongson_ipi_common_realize().
--- hw/intc/loongson_ipi.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
hw/intc/loongson_ipi.c +18 -7
@@ -275,7 +275,7 @@ static const MemoryRegionOps loongson_ipi64_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; -static void loongson_ipi_realize (DeviceState *dev,Error **errp) +static void loongson_ipi_common_realize (DeviceState *dev,Error **errp) {LoongsonIPIState *s =LOONGSON_IPI (dev);SysBusDevice *sbd =SYS_BUS_DEVICE (dev);
@@ -301,20 +301,31 @@ static void loongson_ipi_realize(DeviceState *dev, Error **errp)sysbus_init_mmio (sbd, &s->ipi64_iocsr_mem); s->cpu =g_new0 (IPICore, s->num_cpu); -if (s->cpu ==NULL ) { -error_setg (errp,"Memory allocation for IPICore faile" ); +for (i =0 ; i < s->num_cpu; i++) { + s->cpu[i].ipi = s; + +qdev_init_gpio_out (dev, &s->cpu[i].irq,1 ); + } +} + +static void loongson_ipi_realize (DeviceState *dev,Error **errp) +{ +LoongsonIPIState *s =LOONGSON_IPI (dev); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); +Error *local_err =NULL ; + +loongson_ipi_common_realize (dev, &local_err); +if (local_err) { +error_propagate (errp, local_err);return ; } -for (i =0 ; i < s->num_cpu; i++) { - s->cpu[i].ipi = s; +for (unsigned i =0 ; i < s->num_cpu; i++) { s->cpu[i].ipi_mmio_mem =g_new0 (MemoryRegion,1 ); g_autofree char *name = g_strdup_printf("loongson_ipi_cpu%d_mmio", i);memory_region_init_io (s->cpu[i].ipi_mmio_mem,OBJECT (dev), &loongson_ipi_core_ops, &s->cpu[i], name,0x48 );sysbus_init_mmio (sbd, s->cpu[i].ipi_mmio_mem); - -qdev_init_gpio_out (dev, &s->cpu[i].irq,1 ); } }
Signature · 1 line
2.41.0
Re: [PATCH v4 05/18] hw/intc/loongson_ipi: Extract loongson_ipi_common_realize()
Quoted 11 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
In preparation to extract common IPI code in few commits, extract
loongson_ipi_common_realize().Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 3 lines
--- hw/intc/loongson_ipi.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
r~
PATCH v4 6/18 hw/intc/loongson_ipi: Add TYPE_LOONGSON_IPI_COMMON stub
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
Introduce LOONGSON_IPI_COMMON stubs, QDev parent of LOONGSON_IPI.
--- MAINTAINERS | 4 ++++ include/hw/intc/loongson_ipi.h | 13 +++++++++++-- include/hw/intc/loongson_ipi_common.h | 26 ++++++++++++++++++++++++++ hw/intc/loongson_ipi.c | 7 ++++--- hw/intc/loongson_ipi_common.c | 22 ++++++++++++++++++++++ hw/intc/Kconfig | 4 ++++ hw/intc/meson.build | 1 + 7 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 include/hw/intc/loongson_ipi_common.h create mode 100644 hw/intc/loongson_ipi_common.c
MAINTAINERS +4 -0
@@ -1249,8 +1249,10 @@ F: configs/devices/loongarch64-softmmu/default.mak F: hw/loongarch/ F: include/hw/loongarch/virt.h F: include/hw/intc/loongarch_*.h +F: include/hw/intc/loongson_ipi_common.h F: include/hw/intc/loongson_ipi.h F: hw/intc/loongarch_*.c +F: hw/intc/loongson_ipi_common.c F: hw/intc/loongson_ipi.c F: include/hw/pci-host/ls7a.h F: hw/rtc/ls7a_rtc.c
@@ -1385,11 +1387,13 @@ Loongson-3 virtual platforms M: Huacai Chen <[email protected]> R: Jiaxun Yang <[email protected]> S: Maintained +F: hw/intc/loongson_ipi_common.c F: hw/intc/loongson_ipi.c F: hw/intc/loongson_liointc.c F: hw/mips/loongson3_bootp.c F: hw/mips/loongson3_bootp.h F: hw/mips/loongson3_virt.c +F: include/hw/intc/loongson_ipi_common.h F: include/hw/intc/loongson_ipi.h F: include/hw/intc/loongson_liointc.h F: tests/avocado/machine_mips_loongson3v.py
include/hw/intc/loongson_ipi.h +11 -2
@@ -8,6 +8,8 @@#ifndef HW_LOONGSON_IPI_H #define HW_LOONGSON_IPI_H +#include "qom/object.h" +#include "hw/intc/loongson_ipi_common.h" #include "hw/sysbus.h" /* Mainy used by iocsr read and write */
@@ -31,7 +33,7 @@#define IPI_MBX_NUM 4#define TYPE_LOONGSON_IPI "loongson_ipi" -OBJECT_DECLARE_SIMPLE_TYPE(LoongsonIPIState, LOONGSON_IPI) +OBJECT_DECLARE_TYPE(LoongsonIPIState, LoongsonIPIClass, LOONGSON_IPI) typedef struct IPICore { LoongsonIPIState *ipi;
@@ -45,8 +47,15 @@ typedef struct IPICore {qemu_irq irq; } IPICore; +struct LoongsonIPIClass { +LoongsonIPICommonClass parent_class; + +DeviceRealize parent_realize; +}; +struct LoongsonIPIState { -SysBusDevice parent_obj; +LoongsonIPICommonState parent_obj; +MemoryRegion ipi_iocsr_mem;MemoryRegion ipi64_iocsr_mem;uint32_t num_cpu;
include/hw/intc/loongson_ipi_common.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Loongson ipi interrupt header files +* +* Copyright (C) 2021 Loongson Technology Corporation Limited +*/ + +#ifndef HW_LOONGSON_IPI_COMMON_H +#define HW_LOONGSON_IPI_COMMON_H + +#include "qom/object.h" +#include "hw/sysbus.h" + +#define TYPE_LOONGSON_IPI_COMMON "loongson_ipi_common" +OBJECT_DECLARE_TYPE (LoongsonIPICommonState, + LoongsonIPICommonClass, LOONGSON_IPI_COMMON) + +struct LoongsonIPICommonState { +SysBusDevice parent_obj; +}; + +struct LoongsonIPICommonClass { +SysBusDeviceClass parent_class; +}; + +#endif
hw/intc/loongson_ipi.c +4 -3
@@ -362,8 +362,10 @@ static Property ipi_properties[] = {static void loongson_ipi_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +LoongsonIPIClass *lic =LOONGSON_IPI_CLASS (klass); - dc->realize = loongson_ipi_realize; +device_class_set_parent_realize (dc, loongson_ipi_realize, + &lic->parent_realize);device_class_set_props (dc, ipi_properties); dc->vmsd = &vmstate_loongson_ipi; }
@@ -383,8 +385,7 @@ static void loongson_ipi_finalize(Object *obj)static const TypeInfo loongson_ipi_types[] = { { .name =TYPE_LOONGSON_IPI , - .parent =TYPE_SYS_BUS_DEVICE , - .instance_size =sizeof (LoongsonIPIState), + .parent =TYPE_LOONGSON_IPI_COMMON , .class_init = loongson_ipi_class_init, .instance_finalize = loongson_ipi_finalize, }
hw/intc/loongson_ipi_common.c new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Loongson ipi interrupt common support +* +* Copyright (C) 2021 Loongson Technology Corporation Limited +*/ + +#include "qemu/osdep.h" +#include "hw/sysbus.h" +#include "hw/intc/loongson_ipi_common.h" + +static const TypeInfo loongarch_ipi_types[] = { + { + .name =TYPE_LOONGSON_IPI_COMMON , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (LoongsonIPICommonState), + .class_size =sizeof (LoongsonIPICommonClass), + .abstract = true, + } +}; + +DEFINE_TYPES (loongarch_ipi_types)
hw/intc/Kconfig +4 -0
@@ -87,8 +87,12 @@ config GOLDFISH_PIC config M68K_IRQC bool +config LOONGSON_IPI_COMMON + bool + config LOONGSON_IPI bool + select LOONGSON_IPI_COMMON config LOONGARCH_PCH_PIC bool
hw/intc/meson.build +1 -0
@@ -69,6 +69,7 @@ specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c')) specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], if_true: files('spapr_xive_kvm.c')) 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_PCH_PIC', if_true: files('loongarch_pch_pic.c')) specific_ss.add(when: 'CONFIG_LOONGARCH_PCH_MSI', if_true: files('loongarch_pch_msi.c'))
Signature · 1 line
2.41.0
Re: [PATCH v4 06/18] hw/intc/loongson_ipi: Add TYPE_LOONGSON_IPI_COMMON stub
Quoted 19 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
Introduce
LOONGSON_IPI_COMMONstubs, QDev parent ofLOONGSON_IPI.Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>--- MAINTAINERS | 4 ++++ include/hw/intc/loongson_ipi.h | 13 +++++++++++-- include/hw/intc/loongson_ipi_common.h | 26 ++++++++++++++++++++++++++ hw/intc/loongson_ipi.c | 7 ++++--- hw/intc/loongson_ipi_common.c | 22 ++++++++++++++++++++++ hw/intc/Kconfig | 4 ++++ hw/intc/meson.build | 1 + 7 files changed, 72 insertions(+), 5 deletions(-)
Quoted 2 lines
create mode 100644
include/hw/intc/loongson_ipi_common.hcreate mode 100644hw/intc/loongson_ipi_common.c
r~
PATCH v4 7/18 hw/intc/loongson_ipi: Move common definitions to loongson_ipi_common.h
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
--- include/hw/intc/loongson_ipi.h | 18 ------------------ include/hw/intc/loongson_ipi_common.h | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 18 deletions(-)
include/hw/intc/loongson_ipi.h +0 -18
@@ -12,24 +12,6 @@#include "hw/intc/loongson_ipi_common.h" #include "hw/sysbus.h" -/* Mainy used by iocsr read and write */ -#define SMP_IPI_MAILBOX 0x1000ULL -#define CORE_STATUS_OFF 0x0 -#define CORE_EN_OFF 0x4 -#define CORE_SET_OFF 0x8 -#define CORE_CLEAR_OFF 0xc -#define CORE_BUF_20 0x20 -#define CORE_BUF_28 0x28 -#define CORE_BUF_30 0x30 -#define CORE_BUF_38 0x38 -#define IOCSR_IPI_SEND 0x40 -#define IOCSR_MAIL_SEND 0x48 -#define IOCSR_ANY_SEND 0x158 - -#define MAIL_SEND_ADDR (SMP_IPI_MAILBOX + IOCSR_MAIL_SEND) -#define MAIL_SEND_OFFSET 0 -#define ANY_SEND_OFFSET (IOCSR_ANY_SEND - IOCSR_MAIL_SEND) -#define IPI_MBX_NUM 4#define TYPE_LOONGSON_IPI "loongson_ipi"
include/hw/intc/loongson_ipi_common.h +19 -0
@@ -23,4 +23,23 @@ struct LoongsonIPICommonClass { SysBusDeviceClass parent_class; }; +/* Mainy used by iocsr read and write */ +#define SMP_IPI_MAILBOX 0x1000ULL + +#define CORE_STATUS_OFF 0x0 +#define CORE_EN_OFF 0x4 +#define CORE_SET_OFF 0x8 +#define CORE_CLEAR_OFF 0xc +#define CORE_BUF_20 0x20 +#define CORE_BUF_28 0x28 +#define CORE_BUF_30 0x30 +#define CORE_BUF_38 0x38 +#define IOCSR_IPI_SEND 0x40 +#define IOCSR_MAIL_SEND 0x48 +#define IOCSR_ANY_SEND 0x158 + +#define MAIL_SEND_ADDR (SMP_IPI_MAILBOX + IOCSR_MAIL_SEND) +#define MAIL_SEND_OFFSET 0 +#define ANY_SEND_OFFSET (IOCSR_ANY_SEND - IOCSR_MAIL_SEND) +#endif
Signature · 1 line
2.41.0
Re: [PATCH v4 07/18] hw/intc/loongson_ipi: Move common definitions to loongson_ipi_common.h
Quoted 8 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 4 lines
--- include/hw/intc/loongson_ipi.h | 18 ------------------ include/hw/intc/loongson_ipi_common.h | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 18 deletions(-)
r~
PATCH v4 8/18 hw/intc/loongson_ipi: Move IPICore::mmio_mem to LoongsonIPIState
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
It is easier to manage one array of MMIO MR rather than one per vCPU.
--- include/hw/intc/loongson_ipi.h | 2 +- hw/intc/loongson_ipi.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-)
include/hw/intc/loongson_ipi.h +1 -1
@@ -19,7 +19,6 @@ OBJECT_DECLARE_TYPE(LoongsonIPIState, LoongsonIPIClass, LOONGSON_IPI) typedef struct IPICore { LoongsonIPIState *ipi; - MemoryRegion *ipi_mmio_mem; uint32_t status; uint32_t en; uint32_t set;
@@ -38,6 +37,7 @@ struct LoongsonIPIClass {struct LoongsonIPIState {LoongsonIPICommonState parent_obj; +MemoryRegion *ipi_mmio_mem;MemoryRegion ipi_iocsr_mem;MemoryRegion ipi64_iocsr_mem;uint32_t num_cpu;
hw/intc/loongson_ipi.c +6 -3
@@ -320,12 +320,12 @@ static void loongson_ipi_realize(DeviceState *dev, Error **errp)return ; } + s->ipi_mmio_mem =g_new0 (MemoryRegion, s->num_cpu);for (unsigned i =0 ; i < s->num_cpu; i++) { - s->cpu[i].ipi_mmio_mem =g_new0 (MemoryRegion,1 ); g_autofree char *name = g_strdup_printf("loongson_ipi_cpu%d_mmio", i); -memory_region_init_io (s->cpu[i].ipi_mmio_mem,OBJECT (dev), +memory_region_init_io (&s->ipi_mmio_mem[i],OBJECT (dev), &loongson_ipi_core_ops, &s->cpu[i], name,0x48 ); -sysbus_init_mmio (sbd, s->cpu[i].ipi_mmio_mem); +sysbus_init_mmio (sbd, &s->ipi_mmio_mem[i]); } }
@@ -379,6 +379,9 @@ static void loongson_ipi_common_finalize(Object *obj)static void loongson_ipi_finalize (Object *obj) { +LoongsonIPIState *s =LOONGSON_IPI (obj); + +g_free (s->ipi_mmio_mem);loongson_ipi_common_finalize (obj); }
Signature · 1 line
2.41.0
Re: [PATCH v4 08/18] hw/intc/loongson_ipi: Move IPICore::mmio_mem to LoongsonIPIState
Quoted 11 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
It is easier to manage one array of MMIO MR rather than one per vCPU.
Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 4 lines
--- include/hw/intc/loongson_ipi.h | 2 +- hw/intc/loongson_ipi.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-)
r~
PATCH v4 9/18 hw/intc/loongson_ipi: Move IPICore structure to loongson_ipi_common.h
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
Move the IPICore structure and corresponding common fields of LoongsonIPICommonState to "hw/intc/loongson_ipi_common.h".
--- include/hw/intc/loongson_ipi.h | 17 -------- include/hw/intc/loongson_ipi_common.h | 18 +++++++++ hw/intc/loongson_ipi.c | 56 +++++---------------------- hw/intc/loongson_ipi_common.c | 50 ++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 64 deletions(-)
include/hw/intc/loongson_ipi.h +0 -17
@@ -12,22 +12,9 @@#include "hw/intc/loongson_ipi_common.h" #include "hw/sysbus.h" -#define IPI_MBX_NUM 4 -#define TYPE_LOONGSON_IPI "loongson_ipi" OBJECT_DECLARE_TYPE(LoongsonIPIState, LoongsonIPIClass, LOONGSON_IPI) -typedef struct IPICore { -LoongsonIPIState *ipi; -uint32_t status; -uint32_t en; -uint32_t set; -uint32_t clear; -/* 64bit buf divide into 2 32bit buf */ -uint32_t buf[IPI_MBX_NUM *2 ]; -qemu_irq irq; -}IPICore ; -struct LoongsonIPIClass {LoongsonIPICommonClass parent_class;
@@ -38,10 +25,6 @@ struct LoongsonIPIState {LoongsonIPICommonState parent_obj; MemoryRegion *ipi_mmio_mem; -MemoryRegion ipi_iocsr_mem; -MemoryRegion ipi64_iocsr_mem; -uint32_t num_cpu; - IPICore *cpu; };#endif
include/hw/intc/loongson_ipi_common.h +18 -0
@@ -11,12 +11,30 @@#include "qom/object.h" #include "hw/sysbus.h" +#define IPI_MBX_NUM 4 +#define TYPE_LOONGSON_IPI_COMMON "loongson_ipi_common"OBJECT_DECLARE_TYPE (LoongsonIPICommonState, LoongsonIPICommonClass, LOONGSON_IPI_COMMON) +typedef struct IPICore { +LoongsonIPICommonState *ipi; +uint32_t status; +uint32_t en; +uint32_t set; +uint32_t clear; +/* 64bit buf divide into 2 32bit buf */ +uint32_t buf[IPI_MBX_NUM *2 ]; +qemu_irq irq; +}IPICore ; +struct LoongsonIPICommonState {SysBusDevice parent_obj; + +MemoryRegion ipi_iocsr_mem; +MemoryRegion ipi64_iocsr_mem; +uint32_t num_cpu; +IPICore *cpu; };struct LoongsonIPICommonClass {
hw/intc/loongson_ipi.c +9 -47
110 lines not on this page · raw message
hw/intc/loongson_ipi_common.c +50 -0
62 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH v4 09/18] hw/intc/loongson_ipi: Move IPICore structure to loongson_ipi_common.h
Quoted 11 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
Move the IPICore structure and corresponding common fields of LoongsonIPICommonState to "
hw/intc/loongson_ipi_common.h".Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 6 lines
--- include/hw/intc/loongson_ipi.h | 17 -------- include/hw/intc/loongson_ipi_common.h | 18 +++++++++ hw/intc/loongson_ipi.c | 56 +++++---------------------- hw/intc/loongson_ipi_common.c | 50 ++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 64 deletions(-)
r~
PATCH v4 10/18 hw/intc/loongson_ipi: Pass LoongsonIPICommonState to send_ipi_data()
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
In order to get LoongsonIPICommonClass in send_ipi_data() in the next commit, propagate LoongsonIPICommonState.
--- hw/intc/loongson_ipi.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
hw/intc/loongson_ipi.c +11 -8
@@ -88,8 +88,8 @@ static AddressSpace *get_cpu_iocsr_as(CPUState *cpu)return NULL ; } -static MemTxResult send_ipi_data (CPUState *cpu,uint64_t val,hwaddr addr, -MemTxAttrs attrs) +static MemTxResult send_ipi_data (LoongsonIPICommonState *ipi,CPUState *cpu, +uint64_t val,hwaddr addr,MemTxAttrs attrs) {int i, mask =0 , data =0 ;AddressSpace *iocsr_as =get_cpu_iocsr_as (cpu);
@@ -119,7 +119,8 @@ static MemTxResult send_ipi_data(CPUState *cpu, uint64_t val, hwaddr addr,return MEMTX_OK ; } -static MemTxResult mail_send (uint64_t val,MemTxAttrs attrs) +static MemTxResult mail_send (LoongsonIPICommonState *ipi, +uint64_t val,MemTxAttrs attrs) {uint32_t cpuid;hwaddr addr;
@@ -134,10 +135,11 @@ static MemTxResult mail_send(uint64_t val, MemTxAttrs attrs)/* override requester_id */ addr =SMP_IPI_MAILBOX +CORE_BUF_20 + (val &0x1c ); attrs.requester_id = cs->cpu_index; -return send_ipi_data (cs, val, addr, attrs); +return send_ipi_data (ipi, cs, val, addr, attrs); } -static MemTxResult any_send (uint64_t val,MemTxAttrs attrs) +static MemTxResult any_send (LoongsonIPICommonState *ipi, +uint64_t val,MemTxAttrs attrs) {uint32_t cpuid;hwaddr addr;
@@ -152,7 +154,7 @@ static MemTxResult any_send(uint64_t val, MemTxAttrs attrs)/* override requester_id */ addr = val &0xffff ; attrs.requester_id = cs->cpu_index; -return send_ipi_data (cs, val, addr, attrs); +return send_ipi_data (ipi, cs, val, addr, attrs); } static MemTxResult loongson_ipi_core_writel(void *opaque, hwaddr addr,
@@ -249,15 +251,16 @@ static const MemoryRegionOps loongson_ipi_iocsr_ops = {static MemTxResult loongson_ipi_writeq (void *opaque,hwaddr addr,uint64_t val,unsigned size,MemTxAttrs attrs) { +LoongsonIPICommonState *ipi = opaque;MemTxResult ret =MEMTX_OK ; addr &=0xfff ;switch (addr) {case MAIL_SEND_OFFSET : - ret =mail_send (val, attrs); + ret =mail_send (ipi, val, attrs);break ;case ANY_SEND_OFFSET : - ret =any_send (val, attrs); + ret =any_send (ipi, val, attrs);break ;default :break ;
Signature · 1 line
2.41.0
Re: [PATCH v4 10/18] hw/intc/loongson_ipi: Pass LoongsonIPICommonState to send_ipi_data()
Quoted 11 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
In order to get LoongsonIPICommonClass in
send_ipi_data()in the next commit, propagate LoongsonIPICommonState.Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 3 lines
--- hw/intc/loongson_ipi.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
r~
PATCH v4 11/18 hw/intc/loongson_ipi: Add LoongsonIPICommonClass::get_iocsr_as handler
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
Allow Loongson IPI implementations to have their own get_iocsr_as() handler.
--- include/hw/intc/loongson_ipi_common.h | 2 ++ hw/intc/loongson_ipi.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
include/hw/intc/loongson_ipi_common.h +2 -0
@@ -39,6 +39,8 @@ struct LoongsonIPICommonState {struct LoongsonIPICommonClass {SysBusDeviceClass parent_class; + +AddressSpace *(*get_iocsr_as)(CPUState *cpu); };/* Mainy used by iocsr read and write */
hw/intc/loongson_ipi.c +12 -4
@@ -75,24 +75,30 @@ static MemTxResult loongson_ipi_iocsr_readl(void *opaque, hwaddr addr,return loongson_ipi_core_readl (s, addr, data, size, attrs); } -static AddressSpace *get_cpu_iocsr_as (CPUState *cpu) -{#ifdef TARGET_LOONGARCH64 +static AddressSpace *get_iocsr_as (CPUState *cpu) +{return LOONGARCH_CPU (cpu)->env.address_space_iocsr; +}#endif +#ifdef TARGET_MIPS +static AddressSpace *get_iocsr_as (CPUState *cpu) +{if (ase_lcsr_available (&MIPS_CPU (cpu)->env)) {return &MIPS_CPU (cpu)->env.iocsr.as; } -#endif +return NULL ; } +#endif static MemTxResult send_ipi_data (LoongsonIPICommonState *ipi,CPUState *cpu,uint64_t val,hwaddr addr,MemTxAttrs attrs) { +LoongsonIPICommonClass *licc =LOONGSON_IPI_COMMON_GET_CLASS (ipi);int i, mask =0 , data =0 ; -AddressSpace *iocsr_as =get_cpu_iocsr_as (cpu); +AddressSpace *iocsr_as = licc->get_iocsr_as (cpu);if (!iocsr_as) {return MEMTX_DECODE_ERROR ;
@@ -338,9 +344,11 @@ static void loongson_ipi_class_init(ObjectClass *klass, void *data) {DeviceClass *dc =DEVICE_CLASS (klass);LoongsonIPIClass *lic =LOONGSON_IPI_CLASS (klass); +LoongsonIPICommonClass *licc =LOONGSON_IPI_COMMON_CLASS (klass);device_class_set_parent_realize (dc, loongson_ipi_realize, &lic->parent_realize); + licc->get_iocsr_as = get_iocsr_as; }static void loongson_ipi_finalize (Object *obj)
Signature · 1 line
2.41.0
Re: [PATCH v4 11/18] hw/intc/loongson_ipi: Add LoongsonIPICommonClass::get_iocsr_as handler
Quoted 11 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
Allow Loongson IPI implementations to have their own
get_iocsr_as()handler.Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 4 lines
--- include/hw/intc/loongson_ipi_common.h | 2 ++ hw/intc/loongson_ipi.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
r~
PATCH v4 12/18 hw/intc/loongson_ipi: Add LoongsonIPICommonClass::cpu_by_arch_id handler
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
Allow Loongson IPI implementations to have their own cpu_by_arch_id() handler.
--- include/hw/intc/loongson_ipi_common.h | 1 + hw/intc/loongson_ipi.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-)
include/hw/intc/loongson_ipi_common.h +1 -0
@@ -41,6 +41,7 @@ struct LoongsonIPICommonClass {SysBusDeviceClass parent_class; AddressSpace *(*get_iocsr_as)(CPUState *cpu); +CPUState *(*cpu_by_arch_id)(int64_t id); };/* Mainy used by iocsr read and write */
hw/intc/loongson_ipi.c +7 -3
@@ -128,12 +128,13 @@ static MemTxResult send_ipi_data(LoongsonIPICommonState *ipi, CPUState *cpu,static MemTxResult mail_send (LoongsonIPICommonState *ipi,uint64_t val,MemTxAttrs attrs) { +LoongsonIPICommonClass *licc =LOONGSON_IPI_COMMON_GET_CLASS (ipi);uint32_t cpuid;hwaddr addr;CPUState *cs; cpuid =extract32 (val,16 ,10 ); - cs =cpu_by_arch_id (cpuid); + cs = licc->cpu_by_arch_id (cpuid);if (cs ==NULL ) {return MEMTX_DECODE_ERROR ; }
@@ -147,12 +148,13 @@ static MemTxResult mail_send(LoongsonIPICommonState *ipi,static MemTxResult any_send (LoongsonIPICommonState *ipi,uint64_t val,MemTxAttrs attrs) { +LoongsonIPICommonClass *licc =LOONGSON_IPI_COMMON_GET_CLASS (ipi);uint32_t cpuid;hwaddr addr;CPUState *cs; cpuid =extract32 (val,16 ,10 ); - cs =cpu_by_arch_id (cpuid); + cs = licc->cpu_by_arch_id (cpuid);if (cs ==NULL ) {return MEMTX_DECODE_ERROR ; }
@@ -169,6 +171,7 @@ static MemTxResult loongson_ipi_core_writel(void *opaque, hwaddr addr, {IPICore *s = opaque;LoongsonIPICommonState *ipi = s->ipi; +LoongsonIPICommonClass *licc =LOONGSON_IPI_COMMON_GET_CLASS (ipi);int index =0 ;uint32_t cpuid;uint8_t vector;
@@ -203,7 +206,7 @@ static MemTxResult loongson_ipi_core_writel(void *opaque, hwaddr addr, cpuid =extract32 (val,16 ,10 );/* IPI status vector */ vector =extract8 (val,0 ,5 ); - cs =cpu_by_arch_id (cpuid); + cs = licc->cpu_by_arch_id (cpuid);if (cs ==NULL || cs->cpu_index >= ipi->num_cpu) {return MEMTX_DECODE_ERROR ; }
@@ -349,6 +352,7 @@ static void loongson_ipi_class_init(ObjectClass *klass, void *data)device_class_set_parent_realize (dc, loongson_ipi_realize, &lic->parent_realize); licc->get_iocsr_as = get_iocsr_as; + licc->cpu_by_arch_id = cpu_by_arch_id; }static void loongson_ipi_finalize (Object *obj)
Signature · 1 line
2.41.0
Re: [PATCH v4 12/18] hw/intc/loongson_ipi: Add LoongsonIPICommonClass::cpu_by_arch_id handler
Quoted 11 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
Allow Loongson IPI implementations to have their own
cpu_by_arch_id()handler.Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 4 lines
--- include/hw/intc/loongson_ipi_common.h | 1 + hw/intc/loongson_ipi.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-)
r~
PATCH v4 13/18 hw/intc/loongson_ipi: Expose loongson_ipi_core_read/write helpers
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
In order to access loongson_ipi_core_read/write helpers from loongson_ipi_common.c in the next commit, make their prototype declaration public.
--- include/hw/intc/loongson_ipi_common.h | 6 ++++++ hw/intc/loongson_ipi.c | 10 ++++------ 2 files changed, 10 insertions(+), 6 deletions(-)
include/hw/intc/loongson_ipi_common.h +6 -0
@@ -10,6 +10,7 @@#include "qom/object.h" #include "hw/sysbus.h" +#include "exec/memattrs.h" #define IPI_MBX_NUM 4
@@ -44,6 +45,11 @@ struct LoongsonIPICommonClass {CPUState *(*cpu_by_arch_id)(int64_t id); }; +MemTxResult loongson_ipi_core_readl (void *opaque,hwaddr addr,uint64_t *data, +unsigned size,MemTxAttrs attrs); +MemTxResult loongson_ipi_core_writel (void *opaque,hwaddr addr,uint64_t val, +unsigned size,MemTxAttrs attrs); +/* Mainy used by iocsr read and write */ #define SMP_IPI_MAILBOX 0x1000ULL
hw/intc/loongson_ipi.c +4 -6
@@ -24,9 +24,8 @@#endif #include "trace.h" -static MemTxResult loongson_ipi_core_readl (void *opaque,hwaddr addr, -uint64_t *data, -unsigned size,MemTxAttrs attrs) +MemTxResult loongson_ipi_core_readl (void *opaque,hwaddr addr,uint64_t *data, +unsigned size,MemTxAttrs attrs) {IPICore *s = opaque;uint64_t ret =0 ;
@@ -165,9 +164,8 @@ static MemTxResult any_send(LoongsonIPICommonState *ipi,return send_ipi_data (ipi, cs, val, addr, attrs); } -static MemTxResult loongson_ipi_core_writel (void *opaque,hwaddr addr, -uint64_t val,unsigned size, -MemTxAttrs attrs) +MemTxResult loongson_ipi_core_writel (void *opaque,hwaddr addr,uint64_t val, +unsigned size,MemTxAttrs attrs) {IPICore *s = opaque;LoongsonIPICommonState *ipi = s->ipi;
Signature · 1 line
2.41.0
Re: [PATCH v4 13/18] hw/intc/loongson_ipi: Expose loongson_ipi_core_read/write helpers
Quoted 12 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
In order to access loongson_ipi_core_read/write helpers from
loongson_ipi_common.cin the next commit, make their prototype declaration public.Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 4 lines
--- include/hw/intc/loongson_ipi_common.h | 6 ++++++ hw/intc/loongson_ipi.c | 10 ++++------ 2 files changed, 10 insertions(+), 6 deletions(-)
r~
PATCH v4 14/18 hw/intc/loongson_ipi: Move common code to loongson_ipi_common.c
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
Move the common code from loongson_ipi.c to loongson_ipi_common.c, call parent_realize() instead of loongson_ipi_common_realize() in loongson_ipi_realize().
--- hw/intc/loongson_ipi.c | 269 +-------------------------------- hw/intc/loongson_ipi_common.c | 272 ++++++++++++++++++++++++++++++++++ 2 files changed, 274 insertions(+), 267 deletions(-)
hw/intc/loongson_ipi.c +2 -267
@@ -24,56 +24,6 @@#endif #include "trace.h" -MemTxResult loongson_ipi_core_readl (void *opaque,hwaddr addr,uint64_t *data, -unsigned size,MemTxAttrs attrs) -{ -IPICore *s = opaque; -uint64_t ret =0 ; -int index =0 ; - - addr &=0xff ; -switch (addr) { -case CORE_STATUS_OFF : - ret = s->status; -break ; -case CORE_EN_OFF : - ret = s->en; -break ; -case CORE_SET_OFF : - ret =0 ; -break ; -case CORE_CLEAR_OFF : - ret =0 ; -break ; - case CORE_BUF_20 ... CORE_BUF_38 + 4: - index = (addr -CORE_BUF_20 ) >>2 ; - ret = s->buf[index]; -break ; -default : -qemu_log_mask (LOG_UNIMP ,"invalid read: %x" , (uint32_t )addr); -break ; - } - -trace_loongson_ipi_read (size, (uint64_t )addr, ret); - *data = ret; -return MEMTX_OK ; -} - -static MemTxResult loongson_ipi_iocsr_readl (void *opaque,hwaddr addr, -uint64_t *data, -unsigned size,MemTxAttrs attrs) -{ -LoongsonIPICommonState *ipi = opaque; -IPICore *s; - -if (attrs.requester_id >= ipi->num_cpu) { -return MEMTX_DECODE_ERROR ; - } - - s = &ipi->cpu[attrs.requester_id]; -return loongson_ipi_core_readl (s, addr, data, size, attrs); -} -#ifdef TARGET_LOONGARCH64 static AddressSpace *get_iocsr_as (CPUState *cpu) {
@@ -92,148 +42,6 @@ static AddressSpace *get_iocsr_as(CPUState *cpu) }#endif -static MemTxResult send_ipi_data (LoongsonIPICommonState *ipi,CPUState *cpu, -uint64_t val,hwaddr addr,MemTxAttrs attrs) -{ -LoongsonIPICommonClass *licc =LOONGSON_IPI_COMMON_GET_CLASS (ipi); -int i, mask =0 , data =0 ; -AddressSpace *iocsr_as = licc->get_iocsr_as (cpu); - -if (!iocsr_as) { -return MEMTX_DECODE_ERROR ; - } - -/* -* bit 27-30 is mask for byte writing, -* if the mask is 0, we need not to do anything. -*/ -if ((val >>27 ) &0xf ) { - data =address_space_ldl_le (iocsr_as, addr, attrs,NULL ); -for (i =0 ; i <4 ; i++) { -/* get mask for byte writing */ -if (val & (0x1 << (27 + i))) { - mask |=0xff << (i *8 ); - } - } - } - - data &= mask; - data |= (val >>32 ) & ~mask; -address_space_stl_le (iocsr_as, addr, data, attrs,NULL ); - -return MEMTX_OK ; -} - -static MemTxResult mail_send (LoongsonIPICommonState *ipi, -uint64_t val,MemTxAttrs attrs) -{ -LoongsonIPICommonClass *licc =LOONGSON_IPI_COMMON_GET_CLASS (ipi); -uint32_t cpuid; -hwaddr addr; -CPUState *cs; - - cpuid =extract32 (val,16 ,10 ); - cs = licc->cpu_by_arch_id (cpuid); -if (cs ==NULL ) { -return MEMTX_DECODE_ERROR ; - } - -/* override requester_id */ - addr =SMP_IPI_MAILBOX +CORE_BUF_20 + (val &0x1c ); - attrs.requester_id = cs->cpu_index; -return send_ipi_data (ipi, cs, val, addr, attrs); -} - -static MemTxResult any_send (LoongsonIPICommonState *ipi, -uint64_t val,MemTxAttrs attrs) -{ -LoongsonIPICommonClass *licc =LOONGSON_IPI_COMMON_GET_CLASS (ipi); -uint32_t cpuid; -hwaddr addr; -CPUState *cs; - - cpuid =extract32 (val,16 ,10 ); - cs = licc->cpu_by_arch_id (cpuid); -if (cs ==NULL ) { -return MEMTX_DECODE_ERROR ; - } - -/* override requester_id */ - addr = val &0xffff ; - attrs.requester_id = cs->cpu_index; -return send_ipi_data (ipi, cs, val, addr, attrs); -} - -MemTxResult loongson_ipi_core_writel (void *opaque,hwaddr addr,uint64_t val, -unsigned size,MemTxAttrs attrs) -{ -IPICore *s = opaque; -LoongsonIPICommonState *ipi = s->ipi; -LoongsonIPICommonClass *licc =LOONGSON_IPI_COMMON_GET_CLASS (ipi); -int index =0 ; -uint32_t cpuid; -uint8_t vector; -CPUState *cs; - - addr &=0xff ; -trace_loongson_ipi_write (size, (uint64_t )addr, val); -switch (addr) { -case CORE_STATUS_OFF : -qemu_log_mask (LOG_GUEST_ERROR ,"can not be written" ); -break ; -case CORE_EN_OFF : - s->en = val; -break ; -case CORE_SET_OFF : - s->status |= val; -if (s->status !=0 && (s->status & s->en) !=0 ) { -qemu_irq_raise (s->irq); - } -break ; -case CORE_CLEAR_OFF : - s->status &= ~val; -if (s->status ==0 && s->en !=0 ) { -qemu_irq_lower (s->irq); - } -break ; - case CORE_BUF_20 ... CORE_BUF_38 + 4: - index = (addr -CORE_BUF_20 ) >>2 ; - s->buf[index] = val; -break ; -case IOCSR_IPI_SEND : - cpuid =extract32 (val,16 ,10 ); -/* IPI status vector */ - vector =extract8 (val,0 ,5 ); - cs = licc->cpu_by_arch_id (cpuid); -if (cs ==NULL || cs->cpu_index >= ipi->num_cpu) { -return MEMTX_DECODE_ERROR ; - } -loongson_ipi_core_writel (&ipi->cpu[cs->cpu_index],CORE_SET_OFF , -BIT (vector),4 , attrs); -break ; -default : -qemu_log_mask (LOG_UNIMP ,"invalid write: %x" , (uint32_t )addr); -break ; - } - -return MEMTX_OK ; -} - -static MemTxResult loongson_ipi_iocsr_writel (void *opaque,hwaddr addr, -uint64_t val,unsigned size, -MemTxAttrs attrs) -{ -LoongsonIPICommonState *ipi = opaque; -IPICore *s; - -if (attrs.requester_id >= ipi->num_cpu) { -return MEMTX_DECODE_ERROR ; - } - - s = &ipi->cpu[attrs.requester_id]; -return loongson_ipi_core_writel (s, addr, val, size, attrs); -} -static const MemoryRegionOps loongson_ipi_core_ops = { .read_with_attrs = loongson_ipi_core_readl, .write_with_attrs = loongson_ipi_core_writel,
@@ -244,88 +52,15 @@ static const MemoryRegionOps loongson_ipi_core_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; -static const MemoryRegionOps loongson_ipi_iocsr_ops = { - .read_with_attrs = loongson_ipi_iocsr_readl, - .write_with_attrs = loongson_ipi_iocsr_writel, - .impl.min_access_size =4 , - .impl.max_access_size =4 , - .valid.min_access_size =4 , - .valid.max_access_size =8 , - .endianness =DEVICE_LITTLE_ENDIAN , -}; - -/* mail send and any send only support writeq */ -static MemTxResult loongson_ipi_writeq (void *opaque,hwaddr addr,uint64_t val, -unsigned size,MemTxAttrs attrs) -{ -LoongsonIPICommonState *ipi = opaque; -MemTxResult ret =MEMTX_OK ; - - addr &=0xfff ; -switch (addr) { -case MAIL_SEND_OFFSET : - ret =mail_send (ipi, val, attrs); -break ; -case ANY_SEND_OFFSET : - ret =any_send (ipi, val, attrs); -break ; -default : -break ; - } - -return ret; -} - -static const MemoryRegionOps loongson_ipi64_ops = { - .write_with_attrs = loongson_ipi_writeq, - .impl.min_access_size =8 , - .impl.max_access_size =8 , - .valid.min_access_size =8 , - .valid.max_access_size =8 , - .endianness =DEVICE_LITTLE_ENDIAN , -}; - -static void loongson_ipi_common_realize (DeviceState *dev,Error **errp) -{ -LoongsonIPICommonState *s =LOONGSON_IPI_COMMON (dev); -SysBusDevice *sbd =SYS_BUS_DEVICE (dev); -int i; - -if (s->num_cpu ==0 ) { -error_setg (errp,"num-cpu must be at least 1" ); -return ; - } - -memory_region_init_io (&s->ipi_iocsr_mem,OBJECT (dev), - &loongson_ipi_iocsr_ops, - s,"loongson_ipi_iocsr" ,0x48 ); - -/* loongson_ipi_iocsr performs re-entrant IO through ipi_send */ - s->ipi_iocsr_mem.disable_reentrancy_guard = true; - -sysbus_init_mmio (sbd, &s->ipi_iocsr_mem); - -memory_region_init_io (&s->ipi64_iocsr_mem,OBJECT (dev), - &loongson_ipi64_ops, - s,"loongson_ipi64_iocsr" ,0x118 ); -sysbus_init_mmio (sbd, &s->ipi64_iocsr_mem); - - s->cpu =g_new0 (IPICore, s->num_cpu); -for (i =0 ; i < s->num_cpu; i++) { - s->cpu[i].ipi = s; - -qdev_init_gpio_out (dev, &s->cpu[i].irq,1 ); - } -} -static void loongson_ipi_realize (DeviceState *dev,Error **errp) {LoongsonIPICommonState *sc =LOONGSON_IPI_COMMON (dev);LoongsonIPIState *s =LOONGSON_IPI (dev); +LoongsonIPIClass *lic =LOONGSON_IPI_GET_CLASS (dev);SysBusDevice *sbd =SYS_BUS_DEVICE (dev);Error *local_err =NULL ; -loongson_ipi_common_realize (dev, &local_err); + lic->parent_realize (dev, &local_err);if (local_err) {error_propagate (errp, local_err);return ;
hw/intc/loongson_ipi_common.c +272 -0
286 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH v4 14/18] hw/intc/loongson_ipi: Move common code to loongson_ipi_common.c
Quoted 12 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
Move the common code from
loongson_ipi.ctoloongson_ipi_common.c, callparent_realize()instead ofloongson_ipi_common_realize()inloongson_ipi_realize().Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 4 lines
--- hw/intc/loongson_ipi.c | 269 +-------------------------------- hw/intc/loongson_ipi_common.c | 272 ++++++++++++++++++++++++++++++++++ 2 files changed, 274 insertions(+), 267 deletions(-)
r~
PATCH v4 15/18 hw/intc/loongarch_ipi: Add loongarch IPI support
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
Loongarch IPI is added here, it inherits from class TYPE_LOONGSON_IPI_COMMON, and two interfaces get_iocsr_as() and cpu_by_arch_id() are added for Loongarch 3A5000 machine. It can be used when ipi is emulated in userspace with KVM mode.
--- include/hw/intc/loongarch_ipi.h | 25 ++++++++++++ hw/intc/loongarch_ipi.c | 68 +++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 4 ++ hw/intc/meson.build | 1 + 4 files changed, 98 insertions(+) create mode 100644 include/hw/intc/loongarch_ipi.h create mode 100644 hw/intc/loongarch_ipi.c
include/hw/intc/loongarch_ipi.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Loongarch ipi interrupt header files +* +* Copyright (C) 2024 Loongson Technology Corporation Limited +*/ + +#ifndef HW_LOONGARCH_IPI_H +#define HW_LOONGARCH_IPI_H + +#include "qom/object.h" +#include "hw/intc/loongson_ipi_common.h" + +#define TYPE_LOONGARCH_IPI "loongarch_ipi" +OBJECT_DECLARE_TYPE(LoongarchIPIState, LoongarchIPIClass, LOONGARCH_IPI) + +struct LoongarchIPIState { +LoongsonIPICommonState parent_obj; +}; + +struct LoongarchIPIClass { +LoongsonIPICommonClass parent_class; +}; + +#endif
hw/intc/loongarch_ipi.c new file +68 -0
68 lines not on this page · raw message
hw/intc/Kconfig +4 -0
@@ -94,6 +94,10 @@ config LOONGSON_IPI bool select LOONGSON_IPI_COMMON +config LOONGARCH_IPI + bool + select LOONGSON_IPI_COMMON + config LOONGARCH_PCH_PIC bool select UNIMP
hw/intc/meson.build +1 -0
@@ -71,6 +71,7 @@ specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], 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_MSI', if_true: files('loongarch_pch_msi.c')) specific_ss.add(when: 'CONFIG_LOONGARCH_EXTIOI', if_true: files('loongarch_extioi.c'))
Signature · 1 line
2.41.0
Re: [PATCH v4 15/18] hw/intc/loongarch_ipi: Add loongarch IPI support
Quoted 113 lines · Philippe Mathieu-Daudé
From: Bibo Mao <[email protected]>
Loongarch IPI is added here, it inherits from class
TYPE_LOONGSON_IPI_COMMON, and two interfacesget_iocsr_as()andcpu_by_arch_id()are added for Loongarch 3A5000 machine. It can be used when ipi is emulated in userspace with KVM mode.Signed-off-by Bibo Mao <[email protected]>[PMD: Rebased and simplified]Co-Developed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Bibo Mao <[email protected]>Tested-by Bibo Mao <[email protected]>--- include/hw/intc/loongarch_ipi.h | 25 ++++++++++++ hw/intc/loongarch_ipi.c | 68 +++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 4 ++ hw/intc/meson.build | 1 + 4 files changed, 98 insertions(+)create mode 100644
include/hw/intc/loongarch_ipi.hcreate mode 100644hw/intc/loongarch_ipi.cinclude/hw/intc/loongarch_ipi.h new file +25
-0@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Loongarch ipi interrupt header files +* +* Copyright (C) 2024 Loongson Technology Corporation Limited +*/ + +#ifndef HW_LOONGARCH_IPI_H +#define HW_LOONGARCH_IPI_H + +#include "qom/object.h" +#include "hw/intc/loongson_ipi_common.h" + +#define TYPE_LOONGARCH_IPI "loongarch_ipi" +OBJECT_DECLARE_TYPE(LoongarchIPIState, LoongarchIPIClass, LOONGARCH_IPI) + +struct LoongarchIPIState { +LoongsonIPICommonState parent_obj; +}; + +struct LoongarchIPIClass { +LoongsonIPICommonClass parent_class; +}; + +#endif hw/intc/loongarch_ipi.c new file +54
-0@@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Loongarch ipi interrupt support +* +* Copyright (C) 2024 Loongson Technology Corporation Limited +*/ + +#include "qemu/osdep.h" +#include "hw/boards.h" +#include "hw/intc/loongarch_ipi.h" +#include "target/loongarch/cpu.h" + +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 CPUState *loongarch_cpu_by_arch_id (int64_t arch_id) +{ +MachineState *machine =MACHINE (qdev_get_machine ()); +CPUArchId *archid; + + archid =find_cpu_by_archid (machine, arch_id); +if (archid) { +return CPU (archid->cpu); + } + +return NULL ; +} + +static void loongarch_ipi_class_init (ObjectClass *klass,void *data) +{ +LoongsonIPICommonClass *licc =LOONGSON_IPI_COMMON_CLASS (klass);
hw/intc/loongarch_ipi.c line 64
Quoted 10 lines
hw/intc/loongarch_ipi.c new file +10
-0+ + licc->get_iocsr_as = get_iocsr_as; + licc->cpu_by_arch_id = loongarch_cpu_by_arch_id; +} + +static const TypeInfo loongarch_ipi_types[] = { + { + .name =TYPE_LOONGARCH_IPI , + .parent =TYPE_LOONGSON_IPI_COMMON , + .class_init = loongson_ipi_class_init,
loongarch_ipi_class_init.
Thanks.
Song Gao
Quoted 31 lines
hw/intc/loongarch_ipi.c new file +4
-0+ } +}; + +DEFINE_TYPES (loongarch_ipi_types)hw/intc/Kconfig +4
-0@@ -94,6 +94,10 @@ config LOONGSON_IPI bool select LOONGSON_IPI_COMMON +config LOONGARCH_IPI + bool + select LOONGSON_IPI_COMMON + config LOONGARCH_PCH_PIC bool select UNIMPhw/intc/meson.build +1
-0@@ -71,6 +71,7 @@ specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], 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_MSI', if_true: files('loongarch_pch_msi.c')) specific_ss.add(when: 'CONFIG_LOONGARCH_EXTIOI', if_true: files('loongarch_extioi.c'))
PATCH v4 16/18 hw/loongarch/virt: Replace loongson IPI with loongarch IPI
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
Loongarch IPI inherits from class LoongsonIPICommonClass, and it only contains Loongarch 3A5000 virt machine specific interfaces, rather than mix different machine implementations together.
--- include/hw/loongarch/virt.h | 1 - hw/loongarch/virt.c | 4 ++-- hw/loongarch/Kconfig | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-)
include/hw/loongarch/virt.h +0 -1
@@ -11,7 +11,6 @@#include "target/loongarch/cpu.h" #include "hw/boards.h" #include "qemu/queue.h" -#include "hw/intc/loongson_ipi.h" #include "hw/block/flash.h" #include "hw/loongarch/boot.h"
hw/loongarch/virt.c +2 -2
@@ -23,7 +23,7 @@#include "net/net.h" #include "hw/loader.h" #include "elf.h" -#include "hw/intc/loongson_ipi.h" +#include "hw/intc/loongarch_ipi.h" #include "hw/intc/loongarch_extioi.h" #include "hw/intc/loongarch_pch_pic.h" #include "hw/intc/loongarch_pch_msi.h"
@@ -788,7 +788,7 @@ static void virt_irq_init(LoongArchVirtMachineState *lvms)*/ /* Create IPI device */ - ipi =qdev_new (TYPE_LOONGSON_IPI ); + ipi =qdev_new (TYPE_LOONGARCH_IPI );qdev_prop_set_uint32 (ipi,"num-cpu" , ms->smp.cpus);sysbus_realize_and_unref (SYS_BUS_DEVICE (ipi), &error_fatal);
hw/loongarch/Kconfig +1 -1
@@ -12,7 +12,7 @@ config LOONGARCH_VIRT select SERIAL select VIRTIO_PCI select PLATFORM_BUS - select LOONGSON_IPI + select LOONGARCH_IPI select LOONGARCH_PCH_PIC select LOONGARCH_PCH_MSI select LOONGARCH_EXTIOI
Signature · 1 line
2.41.0
Re: [PATCH v4 16/18] hw/loongarch/virt: Replace loongson IPI with loongarch IPI
Quoted 12 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
Loongarch IPI inherits from class LoongsonIPICommonClass, and it only contains Loongarch 3A5000 virt machine specific interfaces, rather than mix different machine implementations together.
Signed-off-by Bibo Mao<[email protected]>[PMD: Rebased]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 5 lines
--- include/hw/loongarch/virt.h | 1 - hw/loongarch/virt.c | 4 ++-- hw/loongarch/Kconfig | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-)
r~
PATCH v4 17/18 hw/intc/loongson_ipi: Restrict to MIPS
In reply to Philippe Mathieu-DaudéFrom: Bibo Mao <[email protected]>
Now than LoongArch target can use the TYPE_LOONGARCH_IPI model, restrict TYPE_LOONGSON_IPI to MIPS.
--- MAINTAINERS | 2 -- hw/intc/loongson_ipi.c | 14 -------------- 2 files changed, 16 deletions(-)
MAINTAINERS +0 -2
@@ -1250,10 +1250,8 @@ F: hw/loongarch/ F: include/hw/loongarch/virt.h F: include/hw/intc/loongarch_*.h F: include/hw/intc/loongson_ipi_common.h -F: include/hw/intc/loongson_ipi.h F: hw/intc/loongarch_*.c F: hw/intc/loongson_ipi_common.c -F: hw/intc/loongson_ipi.c F: include/hw/pci-host/ls7a.h F: hw/rtc/ls7a_rtc.c F: gdb-xml/loongarch*.xml
hw/intc/loongson_ipi.c +0 -14
@@ -16,22 +16,9 @@#include "exec/address-spaces.h" #include "exec/memory.h" #include "migration/vmstate.h" -#ifdef TARGET_LOONGARCH64 -#include "target/loongarch/cpu.h" -#endif -#ifdef TARGET_MIPS #include "target/mips/cpu.h" -#endif #include "trace.h" -#ifdef TARGET_LOONGARCH64 -static AddressSpace *get_iocsr_as (CPUState *cpu) -{ -return LOONGARCH_CPU (cpu)->env.address_space_iocsr; -} -#endif - -#ifdef TARGET_MIPS static AddressSpace *get_iocsr_as (CPUState *cpu) {if (ase_lcsr_available (&MIPS_CPU (cpu)->env)) {
@@ -40,7 +27,6 @@ static AddressSpace *get_iocsr_as(CPUState *cpu)return NULL ; } -#endif static const MemoryRegionOps loongson_ipi_core_ops = { .read_with_attrs = loongson_ipi_core_readl,
Signature · 1 line
2.41.0
Re: [PATCH v4 17/18] hw/intc/loongson_ipi: Restrict to MIPS
Quoted 11 lines · Philippe Mathieu-Daudé
From: Bibo Mao<[email protected]>
Now than LoongArch target can use the
TYPE_LOONGARCH_IPImodel, restrictTYPE_LOONGSON_IPIto MIPS.Signed-off-by Bibo Mao<[email protected]>[PMD: Extracted from bigger commit, added commit description]Co-Developed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>
Quoted 4 lines
--- MAINTAINERS | 2 -- hw/intc/loongson_ipi.c | 14 -------------- 2 files changed, 16 deletions(-)
r~
PATCH v4 18/18 hw/intc/loongson_ipi: Remove unused headers
In reply to Philippe Mathieu-Daudé--- hw/intc/loongson_ipi.c | 9 --------- 1 file changed, 9 deletions(-)
hw/intc/loongson_ipi.c +0 -9
@@ -6,18 +6,9 @@*/ #include "qemu/osdep.h" -#include "hw/boards.h" -#include "hw/sysbus.h" #include "hw/intc/loongson_ipi.h" -#include "hw/irq.h" -#include "hw/qdev-properties.h" #include "qapi/error.h" -#include "qemu/log.h" -#include "exec/address-spaces.h" -#include "exec/memory.h" -#include "migration/vmstate.h" #include "target/mips/cpu.h" -#include "trace.h" static AddressSpace *get_iocsr_as (CPUState *cpu) {
Signature · 1 line
2.41.0
Re: [PATCH v4 18/18] hw/intc/loongson_ipi: Remove unused headers
Quoted 6 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Bibo Mao<[email protected]>Tested-by Bibo Mao<[email protected]>--- hw/intc/loongson_ipi.c | 9 --------- 1 file changed, 9 deletions(-)
r~
Quoted 49 lines · Philippe Mathieu-Daudé
Since v3:
- UseDEFINE_TYPES()macro (unreviewed patch #1)
- UpdateMAINTAINERS
- Added Bibo's tagsSong, since Bibo reviewed/tested, if you provide your Acked-by I can queue that to my next hw-misc PR (pending Jiaxun testing).
Thanks,
Phil.
Bibo Mao (16):
hw/intc/loongson_ipi: Access memory in little endian hw/intc/loongson_ipi: Rename LoongsonIPI -> LoongsonIPIState hw/intc/loongson_ipi: Extractloongson_ipi_common_finalize()hw/intc/loongson_ipi: Extractloongson_ipi_common_realize()hw/intc/loongson_ipi: AddTYPE_LOONGSON_IPI_COMMONstub hw/intc/loongson_ipi: Move common definitions toloongson_ipi_common.hhw/intc/loongson_ipi: MoveIPICore::mmio_memto LoongsonIPIState hw/intc/loongson_ipi: Move IPICore structure toloongson_ipi_common.hhw/intc/loongson_ipi: Pass LoongsonIPICommonState tosend_ipi_data()hw/intc/loongson_ipi: AddLoongsonIPICommonClass::get_iocsr_ashandler hw/intc/loongson_ipi: AddLoongsonIPICommonClass::cpu_by_arch_id
handler
hw/intc/loongson_ipi: Expose loongson_ipi_core_read/write helpers hw/intc/loongson_ipi: Move common code toloongson_ipi_common.chw/intc/loongarch_ipi: Add loongarch IPI support hw/loongarch/virt: Replace loongson IPI with loongarch IPI hw/intc/loongson_ipi: Restrict to MIPSPhilippe Mathieu-Daudé (2):
hw/intc/loongson_ipi: Declare QOM types usingDEFINE_TYPES()macro hw/intc/loongson_ipi: Remove unused headersMAINTAINERS | 6 +- include/hw/intc/loongarch_ipi.h | 25 ++ include/hw/intc/loongson_ipi.h | 50 +--- include/hw/intc/loongson_ipi_common.h | 72 ++++++ include/hw/loongarch/virt.h | 1 - hw/intc/loongarch_ipi.c | 68 +++++ hw/intc/loongson_ipi.c | 355 +++----------------------- hw/intc/loongson_ipi_common.c | 344 +++++++++++++++++++++++++ hw/loongarch/virt.c | 4 +- hw/intc/Kconfig | 8 + hw/intc/meson.build | 2 + hw/loongarch/Kconfig | 2 +- 12 files changed, 568 insertions(+), 369 deletions(-)
Quoted 5 lines
create mode 100644
include/hw/intc/loongarch_ipi.hcreate mode 100644include/hw/intc/loongson_ipi_common.hcreate mode 100644hw/intc/loongarch_ipi.ccreate mode 100644hw/intc/loongson_ipi_common.c
A build error occurred with patch 15.
sed -i g/Loongarch/LoongArch/g *.c and *.h
For this series:
Thanks.
Song Gao
Quoted 55 lines · gaosong
Quoted 48 lines · Philippe Mathieu-Daudé
Since v3:
- UseDEFINE_TYPES()macro (unreviewed patch #1)
- UpdateMAINTAINERS
- Added Bibo's tagsSong, since Bibo reviewed/tested, if you provide your Acked-by I can queue that to my next hw-misc PR (pending Jiaxun testing).
Thanks,
Phil.
Bibo Mao (16):
hw/intc/loongson_ipi: Access memory in little endian hw/intc/loongson_ipi: Rename LoongsonIPI -> LoongsonIPIState hw/intc/loongson_ipi: Extractloongson_ipi_common_finalize()hw/intc/loongson_ipi: Extractloongson_ipi_common_realize()hw/intc/loongson_ipi: AddTYPE_LOONGSON_IPI_COMMONstub hw/intc/loongson_ipi: Move common definitions toloongson_ipi_common.hhw/intc/loongson_ipi: MoveIPICore::mmio_memto LoongsonIPIState hw/intc/loongson_ipi: Move IPICore structure toloongson_ipi_common.hhw/intc/loongson_ipi: Pass LoongsonIPICommonState tosend_ipi_data()hw/intc/loongson_ipi: AddLoongsonIPICommonClass::get_iocsr_ashandler hw/intc/loongson_ipi: AddLoongsonIPICommonClass::cpu_by_arch_idhandler
hw/intc/loongson_ipi: Expose loongson_ipi_core_read/write helpers hw/intc/loongson_ipi: Move common code toloongson_ipi_common.chw/intc/loongarch_ipi: Add loongarch IPI support hw/loongarch/virt: Replace loongson IPI with loongarch IPI hw/intc/loongson_ipi: Restrict to MIPSPhilippe Mathieu-Daudé (2):
hw/intc/loongson_ipi: Declare QOM types usingDEFINE_TYPES()macro hw/intc/loongson_ipi: Remove unused headersMAINTAINERS | 6 +- include/hw/intc/loongarch_ipi.h | 25 ++ include/hw/intc/loongson_ipi.h | 50 +---
include/hw/intc/loongson_ipi_common.h| 72 ++++++ include/hw/loongarch/virt.h | 1 - hw/intc/loongarch_ipi.c | 68 +++++ hw/intc/loongson_ipi.c | 355 +++----------------------- hw/intc/loongson_ipi_common.c | 344 +++++++++++++++++++++++++ hw/loongarch/virt.c | 4 +- hw/intc/Kconfig | 8 + hw/intc/meson.build | 2 + hw/loongarch/Kconfig | 2 +-Quoted 6 lines
12 files changed, 568 insertions(+), 369 deletions(-)create mode 100644
include/hw/intc/loongarch_ipi.hcreate mode 100644include/hw/intc/loongson_ipi_common.hcreate mode 100644hw/intc/loongarch_ipi.ccreate mode 100644hw/intc/loongson_ipi_common.c
Quoted 1 line
A build error occurred with patch 15.
Oops, introduced when adding patch 1 :/ Will fix.
Quoted 1 line
sed -i g/Loongarch/LoongArch/g *.c and *.h
OK.
Quoted 2 lines
For this series:
Acked-by Song Gao <[email protected]>
Thanks!