- fix compile error on loongarch
- hw/loongarch: fix cpu hotplug reset
- hw/loongarch/boot: Use warn_report when no kernel filename
- hw/loongarch: clean code
- hw/loongarch: Add KVM pch msi device support
- hw/loongarch: Add KVM pch pic device support
- hw/loongarch: Add KVM extioi device support
- hw/loongarch: Add KVM IPI device support
- hw/loongarch/virt: Update the ACPI table for hotplug cpu
- hw/loongarch/virt: Add basic CPU plug support
- hw/loongarch/virt: Add CPU topology support
- accel/kvm/kvm-all: Fixes the missing break in vCPU unpark logic
- gdbstub: Add helper function to unregister GDB register space
- physmem: Add helper function to destroy CPU AddressSpace
- hw/acpi: Update CPUs AML with cpu-(ctrl)dev change
- hw/acpi: Update ACPI GED framework to support vCPU Hotplug
- hw/acpi: Move CPU ctrl-dev MMIO region len macro to common header file
- accel/kvm: Extract common KVM vCPU {creation,parking} code
- target/loongarch: Add steal time support on migration
- linux-headers: loongarch: Add kvm_para.h and unistd_64.h
- target/loongarch/kvm: Implement LoongArch PMU extension
- target/loongarch: Implement lbt registers save/restore function
- target/loongarch: Add loongson binary translation feature
- sync loongarch linux-headers
- target/loongarch: Avoid bits shift exceeding width of bool type
- target/loongarch: Use explicit little-endian LD/ST API
- target/loongarch: fix -Werror=maybe-uninitialized false-positive
- target/loongarch: Support QMP dump-guest-memory
- target/loongarch/kvm: Add vCPU reset function
- target/loongarch: Add compatible support about VM reboot
- target/loongarch: Fix cpu_reset set wrong CSR_CRMD
- target/loongarch: Set CSR_PRCFG1 and CSR_PRCFG2 values
- target/loongarch: Remove avail_64 in trans_srai_w() and simplify it
- target/loongarch/kvm: Add software breakpoint support
- target/loongarch: Add loongarch vector property unconditionally
- target/loongarch/kvm: Fix VM recovery from disk failures
- target/loongarch: Put cpucfg operation before CSR register
- target/loongarch: Add TCG macro in structure CPUArchState
- hw/arm/virt-acpi-build.c: Migrate SPCR creation to common location
- hw/loongarch/virt: Add FDT table support with acpi ged pm register
- hw/loongarch/virt: Add description for virt machine type
- hw/loongarch: Add acpi SPCR table support
- hw/loongarch: virt: pass random seed to fdt
- hw/loongarch: virt: support up to 4 serial ports
- hw/loongarch: Remove default enable with VIRTIO_VGA device
- hw/loongarch: Fix length for lowram in ACPI SRAT
- hw/loongarch/virt: Remove unused assignment
- hw/loongarch: Change the tpm support by default
- hw/loongarch/boot.c: fix out-of-bound reading
- hw/loongarch/virt: Use MemTxAttrs interface for misc ops
- tests/libqos: Add loongarch virt machine node
- hw/loongarch: Remove minimum and default memory size
- hw/loongarch: Refine system dram memory region
- hw/loongarch: Refine fwcfg memory map
- hw/loongarch: Refine fadt memory table for numa memory
- hw/loongarch: Refine acpi srat table for numa memory
- hw/loongarch: Add VM mode in IOCSR feature register in kvm mode
- hw/loongarch: Refine default numa id calculation
- hw/loongarch: Rename LoongArchMachineState with LoongArchVirtMachineState
- hw/loongarch: Rename LOONGARCH_MACHINE with LOONGARCH_VIRT_MACHINE
- hw/loongarch: move memory map to boot.c
- loongarch: switch boards to "default y"
- hw/loongarch: Add cells missing from rtc node
- hw/loongarch: Add cells missing from uart node
- hw/loongarch: fdt remove unused irqchip node
- hw/loongarch: fdt adds pcie irq_map node
- hw/loongarch: fdt adds pch_msi Controller
- hw/loongarch: fdt adds pch_pic Controller
- hw/loongarch: fdt adds Extend I/O Interrupt Controller
- hw/loongarch: fdt adds cpu interrupt controller node
- hw/loongarch: Init efi_fdt table
- hw/loongarch: Init efi_initrd table
- hw/loongarch: Init efi_boot_memmap table
- hw/loongarch: Init efi_system_table
- hw/loongarch: Add init_cmdline
- hw/loongarch: Add slave cpu boot_code
- hw/loongarch: Add load initrd
- hw/loongarch: Move boot functions to boot.c
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
(cherry picked from commit 04ca9e6c8ff19630116722240ae0136cea831c5c)
173 lines
7.0 KiB
Diff
173 lines
7.0 KiB
Diff
From 04895c794652c5da1ece0cad82741bed9aa8ad02 Mon Sep 17 00:00:00 2001
|
|
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
|
Date: Sat, 7 Sep 2024 16:34:39 +0200
|
|
Subject: [PATCH 35/78] hw/loongarch: virt: support up to 4 serial ports
|
|
|
|
In order to support additional channels of communication using
|
|
`-serial`, add several serial ports, up to the standard 4 generally
|
|
supported by the 8250 driver.
|
|
|
|
Fixed: https://lore.kernel.org/all/20240907143439.2792924-1-Jason@zx2c4.com/
|
|
|
|
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
|
Tested-by: Bibo Mao <maobibo@loongson.cn>
|
|
[gaosong: ACPI uart need't reverse order]
|
|
Signed-off-by: Song Gao <gaosong@loongson.cn>
|
|
Message-Id: <20240907143439.2792924-1-Jason@zx2c4.com>
|
|
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
|
|
---
|
|
hw/loongarch/acpi-build.c | 23 +++++++++++++++--------
|
|
hw/loongarch/virt.c | 27 +++++++++++++++++----------
|
|
include/hw/pci-host/ls7a.h | 9 +++++----
|
|
3 files changed, 37 insertions(+), 22 deletions(-)
|
|
|
|
diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c
|
|
index 1a9d25fc51..33a92223d8 100644
|
|
--- a/hw/loongarch/acpi-build.c
|
|
+++ b/hw/loongarch/acpi-build.c
|
|
@@ -31,6 +31,7 @@
|
|
|
|
#include "hw/acpi/generic_event_device.h"
|
|
#include "hw/pci-host/gpex.h"
|
|
+#include "sysemu/sysemu.h"
|
|
#include "sysemu/tpm.h"
|
|
#include "hw/platform-bus.h"
|
|
#include "hw/acpi/aml-build.h"
|
|
@@ -252,23 +253,27 @@ struct AcpiBuildState {
|
|
MemoryRegion *linker_mr;
|
|
} AcpiBuildState;
|
|
|
|
-static void build_uart_device_aml(Aml *table)
|
|
+static void build_uart_device_aml(Aml *table, int index)
|
|
{
|
|
Aml *dev;
|
|
Aml *crs;
|
|
Aml *pkg0, *pkg1, *pkg2;
|
|
- uint32_t uart_irq = VIRT_UART_IRQ;
|
|
-
|
|
- Aml *scope = aml_scope("_SB");
|
|
- dev = aml_device("COMA");
|
|
+ Aml *scope;
|
|
+ uint32_t uart_irq;
|
|
+ uint64_t base;
|
|
+
|
|
+ uart_irq = VIRT_UART_IRQ + index;
|
|
+ base = VIRT_UART_BASE + index * VIRT_UART_SIZE;
|
|
+ scope = aml_scope("_SB");
|
|
+ dev = aml_device("COM%d", index);
|
|
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0501")));
|
|
- aml_append(dev, aml_name_decl("_UID", aml_int(0)));
|
|
+ aml_append(dev, aml_name_decl("_UID", aml_int(index)));
|
|
aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
|
|
crs = aml_resource_template();
|
|
aml_append(crs,
|
|
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
|
|
AML_NON_CACHEABLE, AML_READ_WRITE,
|
|
- 0, VIRT_UART_BASE, VIRT_UART_BASE + VIRT_UART_SIZE - 1,
|
|
+ 0, base, base + VIRT_UART_SIZE - 1,
|
|
0, VIRT_UART_SIZE));
|
|
aml_append(crs, aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
|
|
AML_SHARED, &uart_irq, 1));
|
|
@@ -401,6 +406,7 @@ static void acpi_dsdt_add_tpm(Aml *scope, LoongArchVirtMachineState *vms)
|
|
static void
|
|
build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine)
|
|
{
|
|
+ int i;
|
|
Aml *dsdt, *scope, *pkg;
|
|
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(machine);
|
|
AcpiTable table = { .sig = "DSDT", .rev = 1, .oem_id = lvms->oem_id,
|
|
@@ -408,7 +414,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine)
|
|
|
|
acpi_table_begin(&table, table_data);
|
|
dsdt = init_aml_allocator();
|
|
- build_uart_device_aml(dsdt);
|
|
+ for (i = 0; i < VIRT_UART_COUNT; i++)
|
|
+ build_uart_device_aml(dsdt, i);
|
|
build_pci_device_aml(dsdt, lvms);
|
|
build_la_ged_aml(dsdt, machine);
|
|
build_flash_aml(dsdt, lvms);
|
|
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
|
|
index a7283e6755..a6e9309064 100644
|
|
--- a/hw/loongarch/virt.c
|
|
+++ b/hw/loongarch/virt.c
|
|
@@ -281,10 +281,10 @@ static void fdt_add_rtc_node(LoongArchVirtMachineState *lvms,
|
|
}
|
|
|
|
static void fdt_add_uart_node(LoongArchVirtMachineState *lvms,
|
|
- uint32_t *pch_pic_phandle)
|
|
+ uint32_t *pch_pic_phandle, hwaddr base,
|
|
+ int irq, bool chosen)
|
|
{
|
|
char *nodename;
|
|
- hwaddr base = VIRT_UART_BASE;
|
|
hwaddr size = VIRT_UART_SIZE;
|
|
MachineState *ms = MACHINE(lvms);
|
|
|
|
@@ -293,9 +293,9 @@ static void fdt_add_uart_node(LoongArchVirtMachineState *lvms,
|
|
qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", "ns16550a");
|
|
qemu_fdt_setprop_cells(ms->fdt, nodename, "reg", 0x0, base, 0x0, size);
|
|
qemu_fdt_setprop_cell(ms->fdt, nodename, "clock-frequency", 100000000);
|
|
- qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", nodename);
|
|
- qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupts",
|
|
- VIRT_UART_IRQ - VIRT_GSI_BASE, 0x4);
|
|
+ if (chosen)
|
|
+ qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", nodename);
|
|
+ qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupts", irq, 0x4);
|
|
qemu_fdt_setprop_cell(ms->fdt, nodename, "interrupt-parent",
|
|
*pch_pic_phandle);
|
|
g_free(nodename);
|
|
@@ -706,11 +706,18 @@ static void virt_devices_init(DeviceState *pch_pic,
|
|
/* Add pcie node */
|
|
fdt_add_pcie_node(lvms, pch_pic_phandle, pch_msi_phandle);
|
|
|
|
- serial_mm_init(get_system_memory(), VIRT_UART_BASE, 0,
|
|
- qdev_get_gpio_in(pch_pic,
|
|
- VIRT_UART_IRQ - VIRT_GSI_BASE),
|
|
- 115200, serial_hd(0), DEVICE_LITTLE_ENDIAN);
|
|
- fdt_add_uart_node(lvms, pch_pic_phandle);
|
|
+ /*
|
|
+ * Create uart fdt node in reverse order so that they appear
|
|
+ * in the finished device tree lowest address first
|
|
+ */
|
|
+ for (i = VIRT_UART_COUNT; i --> 0;) {
|
|
+ hwaddr base = VIRT_UART_BASE + i * VIRT_UART_SIZE;
|
|
+ int irq = VIRT_UART_IRQ + i - VIRT_GSI_BASE;
|
|
+ serial_mm_init(get_system_memory(), base, 0,
|
|
+ qdev_get_gpio_in(pch_pic, irq),
|
|
+ 115200, serial_hd(i), DEVICE_LITTLE_ENDIAN);
|
|
+ fdt_add_uart_node(lvms, pch_pic_phandle, base, irq, i == 0);
|
|
+ }
|
|
|
|
/* Network init */
|
|
for (i = 0; i < nb_nics; i++) {
|
|
diff --git a/include/hw/pci-host/ls7a.h b/include/hw/pci-host/ls7a.h
|
|
index cd7c9ec7bc..79d4ea8501 100644
|
|
--- a/include/hw/pci-host/ls7a.h
|
|
+++ b/include/hw/pci-host/ls7a.h
|
|
@@ -36,17 +36,18 @@
|
|
#define VIRT_PCH_PIC_IRQ_NUM 32
|
|
#define VIRT_GSI_BASE 64
|
|
#define VIRT_DEVICE_IRQS 16
|
|
+#define VIRT_UART_COUNT 4
|
|
#define VIRT_UART_IRQ (VIRT_GSI_BASE + 2)
|
|
#define VIRT_UART_BASE 0x1fe001e0
|
|
-#define VIRT_UART_SIZE 0X100
|
|
-#define VIRT_RTC_IRQ (VIRT_GSI_BASE + 3)
|
|
+#define VIRT_UART_SIZE 0x100
|
|
+#define VIRT_RTC_IRQ (VIRT_GSI_BASE + 6)
|
|
#define VIRT_MISC_REG_BASE (VIRT_PCH_REG_BASE + 0x00080000)
|
|
#define VIRT_RTC_REG_BASE (VIRT_MISC_REG_BASE + 0x00050100)
|
|
#define VIRT_RTC_LEN 0x100
|
|
-#define VIRT_SCI_IRQ (VIRT_GSI_BASE + 4)
|
|
+#define VIRT_SCI_IRQ (VIRT_GSI_BASE + 7)
|
|
|
|
#define VIRT_PLATFORM_BUS_BASEADDRESS 0x16000000
|
|
#define VIRT_PLATFORM_BUS_SIZE 0x2000000
|
|
#define VIRT_PLATFORM_BUS_NUM_IRQS 2
|
|
-#define VIRT_PLATFORM_BUS_IRQ (VIRT_GSI_BASE + 5)
|
|
+#define VIRT_PLATFORM_BUS_IRQ (VIRT_GSI_BASE + 8)
|
|
#endif
|
|
--
|
|
2.39.1
|
|
|