1 | The following changes since commit d29201ff34a135cdfc197f4413c1c5047e4f58bb: | 1 | The following changes since commit 848a6caa88b9f082c89c9b41afa975761262981d: |
---|---|---|---|
2 | 2 | ||
3 | Merge tag 'pull-hmp-20220915a' of https://gitlab.com/dagrh/qemu into staging (2022-09-17 10:31:11 -0400) | 3 | Merge tag 'migration-20230602-pull-request' of https://gitlab.com/juan.quintela/qemu into staging (2023-06-02 17:33:29 -0700) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://gitlab.com/gaosong/qemu.git tags/pull-loongarch-20220919 | 7 | https://gitlab.com/gaosong/qemu.git tags/pull-loongarch-20230605 |
8 | 8 | ||
9 | for you to fetch changes up to c06bc455a0ac03123548ac9a2a76e5887f9b9a89: | 9 | for you to fetch changes up to 8555ddc671203969b0e6eb651e538d02a9a79b3a: |
10 | 10 | ||
11 | hw/loongarch: Improve acpi dsdt table (2022-09-19 20:01:41 +0800) | 11 | hw/intc/loongarch_ipi: Bring back all 4 IPI mailboxes (2023-06-05 11:08:55 +0800) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | pull-loongarch | 14 | Fixes Coverity CID: 1512452, 1512453 |
15 | Fixes: 78464f023b54 ("hw/loongarch/virt: Modify ipi as percpu device") | ||
15 | 16 | ||
16 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
17 | Xiaojuan Yang (9): | 18 | Jiaxun Yang (1): |
18 | hw/loongarch: Remove vga device when loongarch init | 19 | hw/intc/loongarch_ipi: Bring back all 4 IPI mailboxes |
19 | hw/loongarch: Support fw_cfg dma function | ||
20 | hw/loongarch: Add interrupt information to FDT table | ||
21 | hw/loongarch: Add platform bus support | ||
22 | hw/loongarch: Add hotplug handler for machine | ||
23 | hw/loongarch: Add RAMFB to dynamic_sysbus_devices list | ||
24 | hw/loongarch: Fix acpi ged irq number in dsdt table | ||
25 | hw/loongarch: Support memory hotplug | ||
26 | hw/loongarch: Improve acpi dsdt table | ||
27 | 20 | ||
28 | hw/loongarch/Kconfig | 5 +- | 21 | hw/intc/loongarch_ipi.c | 6 +++--- |
29 | hw/loongarch/acpi-build.c | 191 ++++++++++------------------------------- | 22 | include/hw/intc/loongarch_ipi.h | 4 +++- |
30 | hw/loongarch/fw_cfg.c | 3 +- | 23 | 2 files changed, 6 insertions(+), 4 deletions(-) |
31 | hw/loongarch/virt.c | 205 +++++++++++++++++++++++++++++++++++++++++++- | ||
32 | include/hw/loongarch/virt.h | 2 + | ||
33 | include/hw/pci-host/ls7a.h | 5 ++ | ||
34 | 6 files changed, 259 insertions(+), 152 deletions(-) | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
2 | 1 | ||
3 | Remove the vga device when loongarch machine init and | ||
4 | we will support other display device in the future. | ||
5 | |||
6 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
7 | Acked-by: Song Gao <gaosong@loongson.cn> | ||
8 | Message-Id: <20220908094623.73051-2-yangxiaojuan@loongson.cn> | ||
9 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
10 | --- | ||
11 | hw/loongarch/Kconfig | 1 - | ||
12 | hw/loongarch/virt.c | 3 --- | ||
13 | 2 files changed, 4 deletions(-) | ||
14 | |||
15 | diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/loongarch/Kconfig | ||
18 | +++ b/hw/loongarch/Kconfig | ||
19 | @@ -XXX,XX +XXX,XX @@ config LOONGARCH_VIRT | ||
20 | bool | ||
21 | select PCI | ||
22 | select PCI_EXPRESS_GENERIC_BRIDGE | ||
23 | - imply VGA_PCI | ||
24 | imply VIRTIO_VGA | ||
25 | imply PCI_DEVICES | ||
26 | select ISA_BUS | ||
27 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/hw/loongarch/virt.c | ||
30 | +++ b/hw/loongarch/virt.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineState * | ||
32 | pci_nic_init_nofail(nd, pci_bus, nd->model, NULL); | ||
33 | } | ||
34 | |||
35 | - /* VGA setup */ | ||
36 | - pci_vga_init(pci_bus); | ||
37 | - | ||
38 | /* | ||
39 | * There are some invalid guest memory access. | ||
40 | * Create some unimplemented devices to emulate this. | ||
41 | -- | ||
42 | 2.31.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
2 | 1 | ||
3 | Support fw_cfg dma function for LoongArch virt machine. | ||
4 | |||
5 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
6 | Acked-by: Song Gao <gaosong@loongson.cn> | ||
7 | Message-Id: <20220908094623.73051-3-yangxiaojuan@loongson.cn> | ||
8 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
9 | --- | ||
10 | hw/loongarch/Kconfig | 1 + | ||
11 | hw/loongarch/fw_cfg.c | 3 ++- | ||
12 | hw/loongarch/virt.c | 2 +- | ||
13 | 3 files changed, 4 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/loongarch/Kconfig | ||
18 | +++ b/hw/loongarch/Kconfig | ||
19 | @@ -XXX,XX +XXX,XX @@ config LOONGARCH_VIRT | ||
20 | select SMBIOS | ||
21 | select ACPI_PCI | ||
22 | select ACPI_HW_REDUCED | ||
23 | + select FW_CFG_DMA | ||
24 | diff --git a/hw/loongarch/fw_cfg.c b/hw/loongarch/fw_cfg.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/loongarch/fw_cfg.c | ||
27 | +++ b/hw/loongarch/fw_cfg.c | ||
28 | @@ -XXX,XX +XXX,XX @@ FWCfgState *loongarch_fw_cfg_init(ram_addr_t ram_size, MachineState *ms) | ||
29 | int max_cpus = ms->smp.max_cpus; | ||
30 | int smp_cpus = ms->smp.cpus; | ||
31 | |||
32 | - fw_cfg = fw_cfg_init_mem_wide(VIRT_FWCFG_BASE + 8, VIRT_FWCFG_BASE, 8, 0, NULL); | ||
33 | + fw_cfg = fw_cfg_init_mem_wide(VIRT_FWCFG_BASE + 8, VIRT_FWCFG_BASE, 8, | ||
34 | + VIRT_FWCFG_BASE + 16, &address_space_memory); | ||
35 | fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); | ||
36 | fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); | ||
37 | fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); | ||
38 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/hw/loongarch/virt.c | ||
41 | +++ b/hw/loongarch/virt.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_fw_cfg_node(const LoongArchMachineState *lams) | ||
43 | qemu_fdt_setprop_string(ms->fdt, nodename, | ||
44 | "compatible", "qemu,fw-cfg-mmio"); | ||
45 | qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", | ||
46 | - 2, base, 2, 0x8); | ||
47 | + 2, base, 2, 0x18); | ||
48 | qemu_fdt_setprop(ms->fdt, nodename, "dma-coherent", NULL, 0); | ||
49 | g_free(nodename); | ||
50 | } | ||
51 | -- | ||
52 | 2.31.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
2 | 1 | ||
3 | Add interrupt information to FDT table, such as interrupt | ||
4 | controller info, compatiable info, etc. | ||
5 | |||
6 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
7 | Acked-by: Song Gao <gaosong@loongson.cn> | ||
8 | Message-Id: <20220908094623.73051-4-yangxiaojuan@loongson.cn> | ||
9 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
10 | --- | ||
11 | hw/loongarch/virt.c | 29 +++++++++++++++++++++++++++++ | ||
12 | 1 file changed, 29 insertions(+) | ||
13 | |||
14 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/loongarch/virt.c | ||
17 | +++ b/hw/loongarch/virt.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pcie_node(const LoongArchMachineState *lams) | ||
19 | qemu_fdt_dumpdtb(ms->fdt, lams->fdt_size); | ||
20 | } | ||
21 | |||
22 | +static void fdt_add_irqchip_node(LoongArchMachineState *lams) | ||
23 | +{ | ||
24 | + MachineState *ms = MACHINE(lams); | ||
25 | + char *nodename; | ||
26 | + uint32_t irqchip_phandle; | ||
27 | + | ||
28 | + irqchip_phandle = qemu_fdt_alloc_phandle(ms->fdt); | ||
29 | + qemu_fdt_setprop_cell(ms->fdt, "/", "interrupt-parent", irqchip_phandle); | ||
30 | + | ||
31 | + nodename = g_strdup_printf("/intc@%" PRIx64, | ||
32 | + VIRT_IOAPIC_REG_BASE); | ||
33 | + qemu_fdt_add_subnode(ms->fdt, nodename); | ||
34 | + qemu_fdt_setprop_cell(ms->fdt, nodename, "#interrupt-cells", 3); | ||
35 | + qemu_fdt_setprop(ms->fdt, nodename, "interrupt-controller", NULL, 0); | ||
36 | + qemu_fdt_setprop_cell(ms->fdt, nodename, "#address-cells", 0x2); | ||
37 | + qemu_fdt_setprop_cell(ms->fdt, nodename, "#size-cells", 0x2); | ||
38 | + qemu_fdt_setprop(ms->fdt, nodename, "ranges", NULL, 0); | ||
39 | + | ||
40 | + qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", | ||
41 | + "loongarch,ls7a"); | ||
42 | + | ||
43 | + qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", | ||
44 | + 2, VIRT_IOAPIC_REG_BASE, | ||
45 | + 2, PCH_PIC_ROUTE_ENTRY_OFFSET); | ||
46 | + | ||
47 | + qemu_fdt_setprop_cell(ms->fdt, nodename, "phandle", irqchip_phandle); | ||
48 | + g_free(nodename); | ||
49 | +} | ||
50 | |||
51 | #define PM_BASE 0x10080000 | ||
52 | #define PM_SIZE 0x100 | ||
53 | @@ -XXX,XX +XXX,XX @@ static void loongarch_init(MachineState *machine) | ||
54 | } | ||
55 | /* Initialize the IO interrupt subsystem */ | ||
56 | loongarch_irq_init(lams); | ||
57 | + fdt_add_irqchip_node(lams); | ||
58 | lams->machine_done.notify = virt_machine_done; | ||
59 | qemu_add_machine_init_done_notifier(&lams->machine_done); | ||
60 | fdt_add_pcie_node(lams); | ||
61 | -- | ||
62 | 2.31.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
2 | 1 | ||
3 | Add platform bus support and add the bus information such as address, | ||
4 | size, irq number to FDT table. | ||
5 | |||
6 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
7 | Acked-by: Song Gao <gaosong@loongson.cn> | ||
8 | Message-Id: <20220908094623.73051-5-yangxiaojuan@loongson.cn> | ||
9 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
10 | --- | ||
11 | hw/loongarch/Kconfig | 1 + | ||
12 | hw/loongarch/virt.c | 33 +++++++++++++++++++++++++++++++++ | ||
13 | include/hw/loongarch/virt.h | 1 + | ||
14 | include/hw/pci-host/ls7a.h | 5 +++++ | ||
15 | 4 files changed, 40 insertions(+) | ||
16 | |||
17 | diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/loongarch/Kconfig | ||
20 | +++ b/hw/loongarch/Kconfig | ||
21 | @@ -XXX,XX +XXX,XX @@ config LOONGARCH_VIRT | ||
22 | select SERIAL | ||
23 | select SERIAL_ISA | ||
24 | select VIRTIO_PCI | ||
25 | + select PLATFORM_BUS | ||
26 | select LOONGARCH_IPI | ||
27 | select LOONGARCH_PCH_PIC | ||
28 | select LOONGARCH_PCH_MSI | ||
29 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/loongarch/virt.c | ||
32 | +++ b/hw/loongarch/virt.c | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | #include "hw/mem/nvdimm.h" | ||
35 | #include "sysemu/device_tree.h" | ||
36 | #include <libfdt.h> | ||
37 | +#include "hw/core/sysbus-fdt.h" | ||
38 | +#include "hw/platform-bus.h" | ||
39 | |||
40 | static void create_fdt(LoongArchMachineState *lams) | ||
41 | { | ||
42 | @@ -XXX,XX +XXX,XX @@ static DeviceState *create_acpi_ged(DeviceState *pch_pic, LoongArchMachineState | ||
43 | return dev; | ||
44 | } | ||
45 | |||
46 | +static DeviceState *create_platform_bus(DeviceState *pch_pic) | ||
47 | +{ | ||
48 | + DeviceState *dev; | ||
49 | + SysBusDevice *sysbus; | ||
50 | + int i, irq; | ||
51 | + MemoryRegion *sysmem = get_system_memory(); | ||
52 | + | ||
53 | + dev = qdev_new(TYPE_PLATFORM_BUS_DEVICE); | ||
54 | + dev->id = g_strdup(TYPE_PLATFORM_BUS_DEVICE); | ||
55 | + qdev_prop_set_uint32(dev, "num_irqs", VIRT_PLATFORM_BUS_NUM_IRQS); | ||
56 | + qdev_prop_set_uint32(dev, "mmio_size", VIRT_PLATFORM_BUS_SIZE); | ||
57 | + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
58 | + | ||
59 | + sysbus = SYS_BUS_DEVICE(dev); | ||
60 | + for (i = 0; i < VIRT_PLATFORM_BUS_NUM_IRQS; i++) { | ||
61 | + irq = VIRT_PLATFORM_BUS_IRQ - PCH_PIC_IRQ_OFFSET + i; | ||
62 | + sysbus_connect_irq(sysbus, i, qdev_get_gpio_in(pch_pic, irq)); | ||
63 | + } | ||
64 | + | ||
65 | + memory_region_add_subregion(sysmem, | ||
66 | + VIRT_PLATFORM_BUS_BASEADDRESS, | ||
67 | + sysbus_mmio_get_region(sysbus, 0)); | ||
68 | + return dev; | ||
69 | +} | ||
70 | + | ||
71 | static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineState *lams) | ||
72 | { | ||
73 | DeviceState *gpex_dev; | ||
74 | @@ -XXX,XX +XXX,XX @@ static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineState * | ||
75 | memory_region_add_subregion(get_system_memory(), PM_BASE, pm_mem); | ||
76 | /* acpi ged */ | ||
77 | lams->acpi_ged = create_acpi_ged(pch_pic, lams); | ||
78 | + /* platform bus */ | ||
79 | + lams->platform_bus_dev = create_platform_bus(pch_pic); | ||
80 | } | ||
81 | |||
82 | static void loongarch_irq_init(LoongArchMachineState *lams) | ||
83 | @@ -XXX,XX +XXX,XX @@ static void loongarch_init(MachineState *machine) | ||
84 | /* Initialize the IO interrupt subsystem */ | ||
85 | loongarch_irq_init(lams); | ||
86 | fdt_add_irqchip_node(lams); | ||
87 | + platform_bus_add_all_fdt_nodes(machine->fdt, "/intc", | ||
88 | + VIRT_PLATFORM_BUS_BASEADDRESS, | ||
89 | + VIRT_PLATFORM_BUS_SIZE, | ||
90 | + VIRT_PLATFORM_BUS_IRQ); | ||
91 | lams->machine_done.notify = virt_machine_done; | ||
92 | qemu_add_machine_init_done_notifier(&lams->machine_done); | ||
93 | fdt_add_pcie_node(lams); | ||
94 | diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h | ||
95 | index XXXXXXX..XXXXXXX 100644 | ||
96 | --- a/include/hw/loongarch/virt.h | ||
97 | +++ b/include/hw/loongarch/virt.h | ||
98 | @@ -XXX,XX +XXX,XX @@ struct LoongArchMachineState { | ||
99 | char *oem_table_id; | ||
100 | DeviceState *acpi_ged; | ||
101 | int fdt_size; | ||
102 | + DeviceState *platform_bus_dev; | ||
103 | }; | ||
104 | |||
105 | #define TYPE_LOONGARCH_MACHINE MACHINE_TYPE_NAME("virt") | ||
106 | diff --git a/include/hw/pci-host/ls7a.h b/include/hw/pci-host/ls7a.h | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/include/hw/pci-host/ls7a.h | ||
109 | +++ b/include/hw/pci-host/ls7a.h | ||
110 | @@ -XXX,XX +XXX,XX @@ | ||
111 | #define VIRT_RTC_REG_BASE (VIRT_MISC_REG_BASE + 0x00050100) | ||
112 | #define VIRT_RTC_LEN 0x100 | ||
113 | #define VIRT_SCI_IRQ (PCH_PIC_IRQ_OFFSET + 4) | ||
114 | + | ||
115 | +#define VIRT_PLATFORM_BUS_BASEADDRESS 0x16000000 | ||
116 | +#define VIRT_PLATFORM_BUS_SIZE 0x2000000 | ||
117 | +#define VIRT_PLATFORM_BUS_NUM_IRQS 2 | ||
118 | +#define VIRT_PLATFORM_BUS_IRQ 69 | ||
119 | #endif | ||
120 | -- | ||
121 | 2.31.1 | diff view generated by jsdifflib |
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | 1 | From: Jiaxun Yang <jiaxun.yang@flygoat.com> |
---|---|---|---|
2 | 2 | ||
3 | Add hotplug handler for LoongArch virt machine and now only support | 3 | As per "Loongson 3A5000/3B5000 Processor Reference Manual", |
4 | the dynamic sysbus device. | 4 | Loongson 3A5000's IPI implementation have 4 mailboxes per |
5 | core. | ||
5 | 6 | ||
6 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | 7 | However, in 78464f023b54 ("hw/loongarch/virt: Modify ipi as |
7 | Acked-by: Song Gao <gaosong@loongson.cn> | 8 | percpu device"), the number of IPI mailboxes was reduced to |
8 | Message-Id: <20220908094623.73051-6-yangxiaojuan@loongson.cn> | 9 | one, which mismatches actual hardware. |
10 | |||
11 | It won't affect LoongArch based system as LoongArch boot code | ||
12 | only uses the first mailbox, however MIPS based Loongson boot | ||
13 | code uses all 4 mailboxes. | ||
14 | |||
15 | Fixes Coverity CID: 1512452, 1512453 | ||
16 | Fixes: 78464f023b54 ("hw/loongarch/virt: Modify ipi as percpu device") | ||
17 | Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> | ||
18 | Reviewed-by: Song Gao <gaosong@loongson.cn> | ||
19 | Message-Id: <20230521102307.87081-2-jiaxun.yang@flygoat.com> | ||
9 | Signed-off-by: Song Gao <gaosong@loongson.cn> | 20 | Signed-off-by: Song Gao <gaosong@loongson.cn> |
10 | --- | 21 | --- |
11 | hw/loongarch/virt.c | 32 ++++++++++++++++++++++++++++++++ | 22 | hw/intc/loongarch_ipi.c | 6 +++--- |
12 | 1 file changed, 32 insertions(+) | 23 | include/hw/intc/loongarch_ipi.h | 4 +++- |
24 | 2 files changed, 6 insertions(+), 4 deletions(-) | ||
13 | 25 | ||
14 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | 26 | diff --git a/hw/intc/loongarch_ipi.c b/hw/intc/loongarch_ipi.c |
15 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/loongarch/virt.c | 28 | --- a/hw/intc/loongarch_ipi.c |
17 | +++ b/hw/loongarch/virt.c | 29 | +++ b/hw/intc/loongarch_ipi.c |
18 | @@ -XXX,XX +XXX,XX @@ static void loongarch_machine_initfn(Object *obj) | 30 | @@ -XXX,XX +XXX,XX @@ static void loongarch_ipi_init(Object *obj) |
19 | lams->oem_table_id = g_strndup(ACPI_BUILD_APPNAME8, 8); | 31 | |
20 | } | 32 | static const VMStateDescription vmstate_ipi_core = { |
21 | 33 | .name = "ipi-single", | |
22 | +static void loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev, | 34 | - .version_id = 1, |
23 | + DeviceState *dev, Error **errp) | 35 | - .minimum_version_id = 1, |
24 | +{ | 36 | + .version_id = 2, |
25 | + LoongArchMachineState *lams = LOONGARCH_MACHINE(hotplug_dev); | 37 | + .minimum_version_id = 2, |
26 | + MachineClass *mc = MACHINE_GET_CLASS(lams); | 38 | .fields = (VMStateField[]) { |
27 | + | 39 | VMSTATE_UINT32(status, IPICore), |
28 | + if (device_is_dynamic_sysbus(mc, dev)) { | 40 | VMSTATE_UINT32(en, IPICore), |
29 | + if (lams->platform_bus_dev) { | 41 | VMSTATE_UINT32(set, IPICore), |
30 | + platform_bus_link_device(PLATFORM_BUS_DEVICE(lams->platform_bus_dev), | 42 | VMSTATE_UINT32(clear, IPICore), |
31 | + SYS_BUS_DEVICE(dev)); | 43 | - VMSTATE_UINT32_ARRAY(buf, IPICore, 2), |
32 | + } | 44 | + VMSTATE_UINT32_ARRAY(buf, IPICore, IPI_MBX_NUM * 2), |
33 | + } | 45 | VMSTATE_END_OF_LIST() |
34 | +} | ||
35 | + | ||
36 | +static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, | ||
37 | + DeviceState *dev) | ||
38 | +{ | ||
39 | + MachineClass *mc = MACHINE_GET_CLASS(machine); | ||
40 | + | ||
41 | + if (device_is_dynamic_sysbus(mc, dev)) { | ||
42 | + return HOTPLUG_HANDLER(machine); | ||
43 | + } | ||
44 | + return NULL; | ||
45 | +} | ||
46 | + | ||
47 | static void loongarch_class_init(ObjectClass *oc, void *data) | ||
48 | { | ||
49 | MachineClass *mc = MACHINE_CLASS(oc); | ||
50 | + HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc); | ||
51 | |||
52 | mc->desc = "Loongson-3A5000 LS7A1000 machine"; | ||
53 | mc->init = loongarch_init; | ||
54 | @@ -XXX,XX +XXX,XX @@ static void loongarch_class_init(ObjectClass *oc, void *data) | ||
55 | mc->block_default_type = IF_VIRTIO; | ||
56 | mc->default_boot_order = "c"; | ||
57 | mc->no_cdrom = 1; | ||
58 | + mc->get_hotplug_handler = virt_machine_get_hotplug_handler; | ||
59 | + hc->plug = loongarch_machine_device_plug_cb; | ||
60 | |||
61 | object_class_property_add(oc, "acpi", "OnOffAuto", | ||
62 | loongarch_get_acpi, loongarch_set_acpi, | ||
63 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo loongarch_machine_types[] = { | ||
64 | .instance_size = sizeof(LoongArchMachineState), | ||
65 | .class_init = loongarch_class_init, | ||
66 | .instance_init = loongarch_machine_initfn, | ||
67 | + .interfaces = (InterfaceInfo[]) { | ||
68 | + { TYPE_HOTPLUG_HANDLER }, | ||
69 | + { } | ||
70 | + }, | ||
71 | } | 46 | } |
72 | }; | 47 | }; |
48 | diff --git a/include/hw/intc/loongarch_ipi.h b/include/hw/intc/loongarch_ipi.h | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/include/hw/intc/loongarch_ipi.h | ||
51 | +++ b/include/hw/intc/loongarch_ipi.h | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | #define MAIL_SEND_OFFSET 0 | ||
54 | #define ANY_SEND_OFFSET (IOCSR_ANY_SEND - IOCSR_MAIL_SEND) | ||
55 | |||
56 | +#define IPI_MBX_NUM 4 | ||
57 | + | ||
58 | #define TYPE_LOONGARCH_IPI "loongarch_ipi" | ||
59 | OBJECT_DECLARE_SIMPLE_TYPE(LoongArchIPI, LOONGARCH_IPI) | ||
60 | |||
61 | @@ -XXX,XX +XXX,XX @@ typedef struct IPICore { | ||
62 | uint32_t set; | ||
63 | uint32_t clear; | ||
64 | /* 64bit buf divide into 2 32bit buf */ | ||
65 | - uint32_t buf[2]; | ||
66 | + uint32_t buf[IPI_MBX_NUM * 2]; | ||
67 | qemu_irq irq; | ||
68 | } IPICore; | ||
73 | 69 | ||
74 | -- | 70 | -- |
75 | 2.31.1 | 71 | 2.39.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
2 | 1 | ||
3 | Add RAMFB device to dynamic_sysbus_devices list so that it can be | ||
4 | hotpluged to the machine. | ||
5 | |||
6 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
7 | Acked-by: Song Gao <gaosong@loongson.cn> | ||
8 | Message-Id: <20220908094623.73051-7-yangxiaojuan@loongson.cn> | ||
9 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
10 | --- | ||
11 | hw/loongarch/virt.c | 2 ++ | ||
12 | 1 file changed, 2 insertions(+) | ||
13 | |||
14 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/loongarch/virt.c | ||
17 | +++ b/hw/loongarch/virt.c | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | #include <libfdt.h> | ||
20 | #include "hw/core/sysbus-fdt.h" | ||
21 | #include "hw/platform-bus.h" | ||
22 | +#include "hw/display/ramfb.h" | ||
23 | |||
24 | static void create_fdt(LoongArchMachineState *lams) | ||
25 | { | ||
26 | @@ -XXX,XX +XXX,XX @@ static void loongarch_class_init(ObjectClass *oc, void *data) | ||
27 | NULL, NULL); | ||
28 | object_class_property_set_description(oc, "acpi", | ||
29 | "Enable ACPI"); | ||
30 | + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE); | ||
31 | } | ||
32 | |||
33 | static const TypeInfo loongarch_machine_types[] = { | ||
34 | -- | ||
35 | 2.31.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
2 | 1 | ||
3 | In dsdt, acpi ged irq should use gsi number, and the | ||
4 | VIRT_SCI_IRQ means it. | ||
5 | |||
6 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
7 | Acked-by: Song Gao <gaosong@loongson.cn> | ||
8 | Message-Id: <20220908094623.73051-8-yangxiaojuan@loongson.cn> | ||
9 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
10 | --- | ||
11 | hw/loongarch/acpi-build.c | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/loongarch/acpi-build.c | ||
17 | +++ b/hw/loongarch/acpi-build.c | ||
18 | @@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine) | ||
19 | if (lams->acpi_ged) { | ||
20 | build_ged_aml(dsdt, "\\_SB."GED_DEVICE, | ||
21 | HOTPLUG_HANDLER(lams->acpi_ged), | ||
22 | - VIRT_SCI_IRQ - PCH_PIC_IRQ_OFFSET, AML_SYSTEM_MEMORY, | ||
23 | + VIRT_SCI_IRQ, AML_SYSTEM_MEMORY, | ||
24 | VIRT_GED_EVT_ADDR); | ||
25 | } | ||
26 | |||
27 | -- | ||
28 | 2.31.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
2 | 1 | ||
3 | Add hotplug/unplug interface for memory device. | ||
4 | |||
5 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
6 | Acked-by: Song Gao <gaosong@loongson.cn> | ||
7 | Message-Id: <20220908094623.73051-9-yangxiaojuan@loongson.cn> | ||
8 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
9 | --- | ||
10 | hw/loongarch/Kconfig | 2 + | ||
11 | hw/loongarch/acpi-build.c | 32 +++++++++--- | ||
12 | hw/loongarch/virt.c | 105 +++++++++++++++++++++++++++++++++++++- | ||
13 | 3 files changed, 132 insertions(+), 7 deletions(-) | ||
14 | |||
15 | diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/loongarch/Kconfig | ||
18 | +++ b/hw/loongarch/Kconfig | ||
19 | @@ -XXX,XX +XXX,XX @@ config LOONGARCH_VIRT | ||
20 | select PCI_EXPRESS_GENERIC_BRIDGE | ||
21 | imply VIRTIO_VGA | ||
22 | imply PCI_DEVICES | ||
23 | + imply NVDIMM | ||
24 | select ISA_BUS | ||
25 | select SERIAL | ||
26 | select SERIAL_ISA | ||
27 | @@ -XXX,XX +XXX,XX @@ config LOONGARCH_VIRT | ||
28 | select ACPI_PCI | ||
29 | select ACPI_HW_REDUCED | ||
30 | select FW_CFG_DMA | ||
31 | + select DIMM | ||
32 | diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/hw/loongarch/acpi-build.c | ||
35 | +++ b/hw/loongarch/acpi-build.c | ||
36 | @@ -XXX,XX +XXX,XX @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) | ||
37 | build_srat_memory(table_data, VIRT_HIGHMEM_BASE, machine->ram_size - VIRT_LOWMEM_SIZE, | ||
38 | 0, MEM_AFFINITY_ENABLED); | ||
39 | |||
40 | + if (ms->device_memory) { | ||
41 | + build_srat_memory(table_data, ms->device_memory->base, | ||
42 | + memory_region_size(&ms->device_memory->mr), | ||
43 | + 0, MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); | ||
44 | + } | ||
45 | + | ||
46 | acpi_table_end(linker, &table); | ||
47 | } | ||
48 | |||
49 | @@ -XXX,XX +XXX,XX @@ static void build_uart_device_aml(Aml *table) | ||
50 | aml_append(table, scope); | ||
51 | } | ||
52 | |||
53 | +static void | ||
54 | +build_la_ged_aml(Aml *dsdt, MachineState *machine) | ||
55 | +{ | ||
56 | + uint32_t event; | ||
57 | + LoongArchMachineState *lams = LOONGARCH_MACHINE(machine); | ||
58 | + | ||
59 | + build_ged_aml(dsdt, "\\_SB."GED_DEVICE, | ||
60 | + HOTPLUG_HANDLER(lams->acpi_ged), | ||
61 | + VIRT_SCI_IRQ, AML_SYSTEM_MEMORY, | ||
62 | + VIRT_GED_EVT_ADDR); | ||
63 | + event = object_property_get_uint(OBJECT(lams->acpi_ged), | ||
64 | + "ged-event", &error_abort); | ||
65 | + if (event & ACPI_GED_MEM_HOTPLUG_EVT) { | ||
66 | + build_memory_hotplug_aml(dsdt, machine->ram_slots, "\\_SB", NULL, | ||
67 | + AML_SYSTEM_MEMORY, | ||
68 | + VIRT_GED_MEM_ADDR); | ||
69 | + } | ||
70 | +} | ||
71 | + | ||
72 | /* build DSDT */ | ||
73 | static void | ||
74 | build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine) | ||
75 | @@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine) | ||
76 | |||
77 | build_gpex_pci0_int(dsdt); | ||
78 | build_uart_device_aml(dsdt); | ||
79 | - if (lams->acpi_ged) { | ||
80 | - build_ged_aml(dsdt, "\\_SB."GED_DEVICE, | ||
81 | - HOTPLUG_HANDLER(lams->acpi_ged), | ||
82 | - VIRT_SCI_IRQ, AML_SYSTEM_MEMORY, | ||
83 | - VIRT_GED_EVT_ADDR); | ||
84 | - } | ||
85 | + build_la_ged_aml(dsdt, machine); | ||
86 | |||
87 | scope = aml_scope("\\_SB.PCI0"); | ||
88 | /* Build PCI0._CRS */ | ||
89 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/hw/loongarch/virt.c | ||
92 | +++ b/hw/loongarch/virt.c | ||
93 | @@ -XXX,XX +XXX,XX @@ | ||
94 | #include "hw/core/sysbus-fdt.h" | ||
95 | #include "hw/platform-bus.h" | ||
96 | #include "hw/display/ramfb.h" | ||
97 | +#include "hw/mem/pc-dimm.h" | ||
98 | |||
99 | static void create_fdt(LoongArchMachineState *lams) | ||
100 | { | ||
101 | @@ -XXX,XX +XXX,XX @@ static void loongarch_init(MachineState *machine) | ||
102 | machine->ram, offset, highram_size); | ||
103 | memory_region_add_subregion(address_space_mem, 0x90000000, &lams->highmem); | ||
104 | memmap_add_entry(0x90000000, highram_size, 1); | ||
105 | + | ||
106 | + /* initialize device memory address space */ | ||
107 | + if (machine->ram_size < machine->maxram_size) { | ||
108 | + machine->device_memory = g_malloc0(sizeof(*machine->device_memory)); | ||
109 | + ram_addr_t device_mem_size = machine->maxram_size - machine->ram_size; | ||
110 | + | ||
111 | + if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) { | ||
112 | + error_report("unsupported amount of memory slots: %"PRIu64, | ||
113 | + machine->ram_slots); | ||
114 | + exit(EXIT_FAILURE); | ||
115 | + } | ||
116 | + | ||
117 | + if (QEMU_ALIGN_UP(machine->maxram_size, | ||
118 | + TARGET_PAGE_SIZE) != machine->maxram_size) { | ||
119 | + error_report("maximum memory size must by aligned to multiple of " | ||
120 | + "%d bytes", TARGET_PAGE_SIZE); | ||
121 | + exit(EXIT_FAILURE); | ||
122 | + } | ||
123 | + /* device memory base is the top of high memory address. */ | ||
124 | + machine->device_memory->base = 0x90000000 + highram_size; | ||
125 | + machine->device_memory->base = | ||
126 | + ROUND_UP(machine->device_memory->base, 1 * GiB); | ||
127 | + | ||
128 | + memory_region_init(&machine->device_memory->mr, OBJECT(lams), | ||
129 | + "device-memory", device_mem_size); | ||
130 | + memory_region_add_subregion(address_space_mem, machine->device_memory->base, | ||
131 | + &machine->device_memory->mr); | ||
132 | + } | ||
133 | + | ||
134 | /* Add isa io region */ | ||
135 | memory_region_init_alias(&lams->isa_io, NULL, "isa-io", | ||
136 | get_system_io(), 0, VIRT_ISA_IO_SIZE); | ||
137 | @@ -XXX,XX +XXX,XX @@ static void loongarch_machine_initfn(Object *obj) | ||
138 | lams->oem_table_id = g_strndup(ACPI_BUILD_APPNAME8, 8); | ||
139 | } | ||
140 | |||
141 | +static bool memhp_type_supported(DeviceState *dev) | ||
142 | +{ | ||
143 | + /* we only support pc dimm now */ | ||
144 | + return object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) && | ||
145 | + !object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); | ||
146 | +} | ||
147 | + | ||
148 | +static void virt_mem_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, | ||
149 | + Error **errp) | ||
150 | +{ | ||
151 | + pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); | ||
152 | +} | ||
153 | + | ||
154 | +static void virt_machine_device_pre_plug(HotplugHandler *hotplug_dev, | ||
155 | + DeviceState *dev, Error **errp) | ||
156 | +{ | ||
157 | + if (memhp_type_supported(dev)) { | ||
158 | + virt_mem_pre_plug(hotplug_dev, dev, errp); | ||
159 | + } | ||
160 | +} | ||
161 | + | ||
162 | +static void virt_mem_unplug_request(HotplugHandler *hotplug_dev, | ||
163 | + DeviceState *dev, Error **errp) | ||
164 | +{ | ||
165 | + LoongArchMachineState *lams = LOONGARCH_MACHINE(hotplug_dev); | ||
166 | + | ||
167 | + /* the acpi ged is always exist */ | ||
168 | + hotplug_handler_unplug_request(HOTPLUG_HANDLER(lams->acpi_ged), dev, | ||
169 | + errp); | ||
170 | +} | ||
171 | + | ||
172 | +static void virt_machine_device_unplug_request(HotplugHandler *hotplug_dev, | ||
173 | + DeviceState *dev, Error **errp) | ||
174 | +{ | ||
175 | + if (memhp_type_supported(dev)) { | ||
176 | + virt_mem_unplug_request(hotplug_dev, dev, errp); | ||
177 | + } | ||
178 | +} | ||
179 | + | ||
180 | +static void virt_mem_unplug(HotplugHandler *hotplug_dev, | ||
181 | + DeviceState *dev, Error **errp) | ||
182 | +{ | ||
183 | + LoongArchMachineState *lams = LOONGARCH_MACHINE(hotplug_dev); | ||
184 | + | ||
185 | + hotplug_handler_unplug(HOTPLUG_HANDLER(lams->acpi_ged), dev, errp); | ||
186 | + pc_dimm_unplug(PC_DIMM(dev), MACHINE(lams)); | ||
187 | + qdev_unrealize(dev); | ||
188 | +} | ||
189 | + | ||
190 | +static void virt_machine_device_unplug(HotplugHandler *hotplug_dev, | ||
191 | + DeviceState *dev, Error **errp) | ||
192 | +{ | ||
193 | + if (memhp_type_supported(dev)) { | ||
194 | + virt_mem_unplug(hotplug_dev, dev, errp); | ||
195 | + } | ||
196 | +} | ||
197 | + | ||
198 | +static void virt_mem_plug(HotplugHandler *hotplug_dev, | ||
199 | + DeviceState *dev, Error **errp) | ||
200 | +{ | ||
201 | + LoongArchMachineState *lams = LOONGARCH_MACHINE(hotplug_dev); | ||
202 | + | ||
203 | + pc_dimm_plug(PC_DIMM(dev), MACHINE(lams)); | ||
204 | + hotplug_handler_plug(HOTPLUG_HANDLER(lams->acpi_ged), | ||
205 | + dev, &error_abort); | ||
206 | +} | ||
207 | + | ||
208 | static void loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev, | ||
209 | DeviceState *dev, Error **errp) | ||
210 | { | ||
211 | @@ -XXX,XX +XXX,XX @@ static void loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev, | ||
212 | platform_bus_link_device(PLATFORM_BUS_DEVICE(lams->platform_bus_dev), | ||
213 | SYS_BUS_DEVICE(dev)); | ||
214 | } | ||
215 | + } else if (memhp_type_supported(dev)) { | ||
216 | + virt_mem_plug(hotplug_dev, dev, errp); | ||
217 | } | ||
218 | } | ||
219 | |||
220 | @@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, | ||
221 | { | ||
222 | MachineClass *mc = MACHINE_GET_CLASS(machine); | ||
223 | |||
224 | - if (device_is_dynamic_sysbus(mc, dev)) { | ||
225 | + if (device_is_dynamic_sysbus(mc, dev) || | ||
226 | + memhp_type_supported(dev)) { | ||
227 | return HOTPLUG_HANDLER(machine); | ||
228 | } | ||
229 | return NULL; | ||
230 | @@ -XXX,XX +XXX,XX @@ static void loongarch_class_init(ObjectClass *oc, void *data) | ||
231 | mc->no_cdrom = 1; | ||
232 | mc->get_hotplug_handler = virt_machine_get_hotplug_handler; | ||
233 | hc->plug = loongarch_machine_device_plug_cb; | ||
234 | + hc->pre_plug = virt_machine_device_pre_plug; | ||
235 | + hc->unplug_request = virt_machine_device_unplug_request; | ||
236 | + hc->unplug = virt_machine_device_unplug; | ||
237 | |||
238 | object_class_property_add(oc, "acpi", "OnOffAuto", | ||
239 | loongarch_get_acpi, loongarch_set_acpi, | ||
240 | -- | ||
241 | 2.31.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
2 | 1 | ||
3 | Cleanup the previous pci information in acpi dsdt table. | ||
4 | And using the common acpi_dsdt_add_gpex function to build | ||
5 | the gpex and pci information. | ||
6 | |||
7 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
8 | Acked-by: Song Gao <gaosong@loongson.cn> | ||
9 | Message-Id: <20220908094623.73051-10-yangxiaojuan@loongson.cn> | ||
10 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
11 | --- | ||
12 | hw/loongarch/acpi-build.c | 159 +++++------------------------------- | ||
13 | hw/loongarch/virt.c | 1 + | ||
14 | include/hw/loongarch/virt.h | 1 + | ||
15 | 3 files changed, 21 insertions(+), 140 deletions(-) | ||
16 | |||
17 | diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/loongarch/acpi-build.c | ||
20 | +++ b/hw/loongarch/acpi-build.c | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | #include "qom/qom-qobject.h" | ||
23 | |||
24 | #include "hw/acpi/generic_event_device.h" | ||
25 | +#include "hw/pci-host/gpex.h" | ||
26 | |||
27 | #define ACPI_BUILD_ALIGN_SIZE 0x1000 | ||
28 | #define ACPI_BUILD_TABLE_SIZE 0x20000 | ||
29 | @@ -XXX,XX +XXX,XX @@ struct AcpiBuildState { | ||
30 | MemoryRegion *linker_mr; | ||
31 | } AcpiBuildState; | ||
32 | |||
33 | -static void build_gpex_pci0_int(Aml *table) | ||
34 | -{ | ||
35 | - Aml *sb_scope = aml_scope("_SB"); | ||
36 | - Aml *pci0_scope = aml_scope("PCI0"); | ||
37 | - Aml *prt_pkg = aml_varpackage(128); | ||
38 | - int slot, pin; | ||
39 | - | ||
40 | - for (slot = 0; slot < PCI_SLOT_MAX; slot++) { | ||
41 | - for (pin = 0; pin < PCI_NUM_PINS; pin++) { | ||
42 | - Aml *pkg = aml_package(4); | ||
43 | - aml_append(pkg, aml_int((slot << 16) | 0xFFFF)); | ||
44 | - aml_append(pkg, aml_int(pin)); | ||
45 | - aml_append(pkg, aml_int(0)); | ||
46 | - aml_append(pkg, aml_int(80 + (slot + pin) % 4)); | ||
47 | - aml_append(prt_pkg, pkg); | ||
48 | - } | ||
49 | - } | ||
50 | - aml_append(pci0_scope, aml_name_decl("_PRT", prt_pkg)); | ||
51 | - aml_append(sb_scope, pci0_scope); | ||
52 | - aml_append(table, sb_scope); | ||
53 | -} | ||
54 | - | ||
55 | -static void build_dbg_aml(Aml *table) | ||
56 | -{ | ||
57 | - Aml *field; | ||
58 | - Aml *method; | ||
59 | - Aml *while_ctx; | ||
60 | - Aml *scope = aml_scope("\\"); | ||
61 | - Aml *buf = aml_local(0); | ||
62 | - Aml *len = aml_local(1); | ||
63 | - Aml *idx = aml_local(2); | ||
64 | - | ||
65 | - aml_append(scope, | ||
66 | - aml_operation_region("DBG", AML_SYSTEM_IO, aml_int(0x0402), 0x01)); | ||
67 | - field = aml_field("DBG", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE); | ||
68 | - aml_append(field, aml_named_field("DBGB", 8)); | ||
69 | - aml_append(scope, field); | ||
70 | - | ||
71 | - method = aml_method("DBUG", 1, AML_NOTSERIALIZED); | ||
72 | - | ||
73 | - aml_append(method, aml_to_hexstring(aml_arg(0), buf)); | ||
74 | - aml_append(method, aml_to_buffer(buf, buf)); | ||
75 | - aml_append(method, aml_subtract(aml_sizeof(buf), aml_int(1), len)); | ||
76 | - aml_append(method, aml_store(aml_int(0), idx)); | ||
77 | - | ||
78 | - while_ctx = aml_while(aml_lless(idx, len)); | ||
79 | - aml_append(while_ctx, | ||
80 | - aml_store(aml_derefof(aml_index(buf, idx)), aml_name("DBGB"))); | ||
81 | - aml_append(while_ctx, aml_increment(idx)); | ||
82 | - aml_append(method, while_ctx); | ||
83 | - aml_append(method, aml_store(aml_int(0x0A), aml_name("DBGB"))); | ||
84 | - aml_append(scope, method); | ||
85 | - aml_append(table, scope); | ||
86 | -} | ||
87 | - | ||
88 | -static Aml *build_osc_method(void) | ||
89 | -{ | ||
90 | - Aml *if_ctx; | ||
91 | - Aml *if_ctx2; | ||
92 | - Aml *else_ctx; | ||
93 | - Aml *method; | ||
94 | - Aml *a_cwd1 = aml_name("CDW1"); | ||
95 | - Aml *a_ctrl = aml_local(0); | ||
96 | - | ||
97 | - method = aml_method("_OSC", 4, AML_NOTSERIALIZED); | ||
98 | - aml_append(method, aml_create_dword_field(aml_arg(3), aml_int(0), "CDW1")); | ||
99 | - | ||
100 | - if_ctx = aml_if(aml_equal( | ||
101 | - aml_arg(0), aml_touuid("33DB4D5B-1FF7-401C-9657-7441C03DD766"))); | ||
102 | - aml_append(if_ctx, aml_create_dword_field(aml_arg(3), aml_int(4), "CDW2")); | ||
103 | - aml_append(if_ctx, aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3")); | ||
104 | - aml_append(if_ctx, aml_store(aml_name("CDW3"), a_ctrl)); | ||
105 | - | ||
106 | - /* | ||
107 | - * Always allow native PME, AER (no dependencies) | ||
108 | - * Allow SHPC (PCI bridges can have SHPC controller) | ||
109 | - */ | ||
110 | - aml_append(if_ctx, aml_and(a_ctrl, aml_int(0x1F), a_ctrl)); | ||
111 | - | ||
112 | - if_ctx2 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(1)))); | ||
113 | - /* Unknown revision */ | ||
114 | - aml_append(if_ctx2, aml_or(a_cwd1, aml_int(0x08), a_cwd1)); | ||
115 | - aml_append(if_ctx, if_ctx2); | ||
116 | - | ||
117 | - if_ctx2 = aml_if(aml_lnot(aml_equal(aml_name("CDW3"), a_ctrl))); | ||
118 | - /* Capabilities bits were masked */ | ||
119 | - aml_append(if_ctx2, aml_or(a_cwd1, aml_int(0x10), a_cwd1)); | ||
120 | - aml_append(if_ctx, if_ctx2); | ||
121 | - | ||
122 | - /* Update DWORD3 in the buffer */ | ||
123 | - aml_append(if_ctx, aml_store(a_ctrl, aml_name("CDW3"))); | ||
124 | - aml_append(method, if_ctx); | ||
125 | - | ||
126 | - else_ctx = aml_else(); | ||
127 | - /* Unrecognized UUID */ | ||
128 | - aml_append(else_ctx, aml_or(a_cwd1, aml_int(4), a_cwd1)); | ||
129 | - aml_append(method, else_ctx); | ||
130 | - | ||
131 | - aml_append(method, aml_return(aml_arg(3))); | ||
132 | - return method; | ||
133 | -} | ||
134 | - | ||
135 | static void build_uart_device_aml(Aml *table) | ||
136 | { | ||
137 | Aml *dev; | ||
138 | @@ -XXX,XX +XXX,XX @@ build_la_ged_aml(Aml *dsdt, MachineState *machine) | ||
139 | } | ||
140 | } | ||
141 | |||
142 | +static void build_pci_device_aml(Aml *scope, LoongArchMachineState *lams) | ||
143 | +{ | ||
144 | + struct GPEXConfig cfg = { | ||
145 | + .mmio64.base = VIRT_PCI_MEM_BASE, | ||
146 | + .mmio64.size = VIRT_PCI_MEM_SIZE, | ||
147 | + .pio.base = VIRT_PCI_IO_BASE, | ||
148 | + .pio.size = VIRT_PCI_IO_SIZE, | ||
149 | + .ecam.base = VIRT_PCI_CFG_BASE, | ||
150 | + .ecam.size = VIRT_PCI_CFG_SIZE, | ||
151 | + .irq = PCH_PIC_IRQ_OFFSET + VIRT_DEVICE_IRQS, | ||
152 | + .bus = lams->pci_bus, | ||
153 | + }; | ||
154 | + | ||
155 | + acpi_dsdt_add_gpex(scope, &cfg); | ||
156 | +} | ||
157 | + | ||
158 | /* build DSDT */ | ||
159 | static void | ||
160 | build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine) | ||
161 | { | ||
162 | - Aml *dsdt, *sb_scope, *scope, *dev, *crs, *pkg; | ||
163 | - int root_bus_limit = 0x7F; | ||
164 | + Aml *dsdt, *scope, *pkg; | ||
165 | LoongArchMachineState *lams = LOONGARCH_MACHINE(machine); | ||
166 | AcpiTable table = { .sig = "DSDT", .rev = 1, .oem_id = lams->oem_id, | ||
167 | .oem_table_id = lams->oem_table_id }; | ||
168 | |||
169 | acpi_table_begin(&table, table_data); | ||
170 | - | ||
171 | dsdt = init_aml_allocator(); | ||
172 | - | ||
173 | - build_dbg_aml(dsdt); | ||
174 | - | ||
175 | - sb_scope = aml_scope("_SB"); | ||
176 | - dev = aml_device("PCI0"); | ||
177 | - aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08"))); | ||
178 | - aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03"))); | ||
179 | - aml_append(dev, aml_name_decl("_ADR", aml_int(0))); | ||
180 | - aml_append(dev, aml_name_decl("_BBN", aml_int(0))); | ||
181 | - aml_append(dev, aml_name_decl("_UID", aml_int(1))); | ||
182 | - aml_append(dev, build_osc_method()); | ||
183 | - aml_append(sb_scope, dev); | ||
184 | - aml_append(dsdt, sb_scope); | ||
185 | - | ||
186 | - build_gpex_pci0_int(dsdt); | ||
187 | build_uart_device_aml(dsdt); | ||
188 | + build_pci_device_aml(dsdt, lams); | ||
189 | build_la_ged_aml(dsdt, machine); | ||
190 | |||
191 | - scope = aml_scope("\\_SB.PCI0"); | ||
192 | - /* Build PCI0._CRS */ | ||
193 | - crs = aml_resource_template(); | ||
194 | - aml_append(crs, | ||
195 | - aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE, | ||
196 | - 0x0000, 0x0, root_bus_limit, | ||
197 | - 0x0000, root_bus_limit + 1)); | ||
198 | - aml_append(crs, | ||
199 | - aml_dword_io(AML_MIN_FIXED, AML_MAX_FIXED, | ||
200 | - AML_POS_DECODE, AML_ENTIRE_RANGE, | ||
201 | - 0x0000, 0x0000, 0xFFFF, 0x18000000, 0x10000)); | ||
202 | - aml_append(crs, | ||
203 | - aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED, | ||
204 | - AML_CACHEABLE, AML_READ_WRITE, | ||
205 | - 0, VIRT_PCI_MEM_BASE, | ||
206 | - VIRT_PCI_MEM_BASE + VIRT_PCI_MEM_SIZE - 1, | ||
207 | - 0, VIRT_PCI_MEM_BASE)); | ||
208 | - aml_append(scope, aml_name_decl("_CRS", crs)); | ||
209 | - aml_append(dsdt, scope); | ||
210 | - | ||
211 | /* System State Package */ | ||
212 | scope = aml_scope("\\"); | ||
213 | pkg = aml_package(4); | ||
214 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | ||
215 | index XXXXXXX..XXXXXXX 100644 | ||
216 | --- a/hw/loongarch/virt.c | ||
217 | +++ b/hw/loongarch/virt.c | ||
218 | @@ -XXX,XX +XXX,XX @@ static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineState * | ||
219 | d = SYS_BUS_DEVICE(gpex_dev); | ||
220 | sysbus_realize_and_unref(d, &error_fatal); | ||
221 | pci_bus = PCI_HOST_BRIDGE(gpex_dev)->bus; | ||
222 | + lams->pci_bus = pci_bus; | ||
223 | |||
224 | /* Map only part size_ecam bytes of ECAM space */ | ||
225 | ecam_alias = g_new0(MemoryRegion, 1); | ||
226 | diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h | ||
227 | index XXXXXXX..XXXXXXX 100644 | ||
228 | --- a/include/hw/loongarch/virt.h | ||
229 | +++ b/include/hw/loongarch/virt.h | ||
230 | @@ -XXX,XX +XXX,XX @@ struct LoongArchMachineState { | ||
231 | DeviceState *acpi_ged; | ||
232 | int fdt_size; | ||
233 | DeviceState *platform_bus_dev; | ||
234 | + PCIBus *pci_bus; | ||
235 | }; | ||
236 | |||
237 | #define TYPE_LOONGARCH_MACHINE MACHINE_TYPE_NAME("virt") | ||
238 | -- | ||
239 | 2.31.1 | diff view generated by jsdifflib |