From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: qemu-devel@nongnu.org
Cc: "Aurelien Jarno" <aurelien@aurel32.net>,
"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
"Huacai Chen" <chenhuacai@kernel.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [PATCH v2 2/2] hw/mips/loongson3_virt: Add TCG SMP support
Date: Thu, 14 Jan 2021 09:31:47 +0800 [thread overview]
Message-ID: <20210114013147.92962-3-jiaxun.yang@flygoat.com> (raw)
In-Reply-To: <20210114013147.92962-1-jiaxun.yang@flygoat.com>
loongson3_virt has KVM SMP support in kenrel.
This patch adds TCG SMP support by enable IPI controller
for machine.
Note that TCG SMP can only support up to 4 CPUs as we
didn't implement multi-node support.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
hw/mips/loongson3_bootp.h | 1 +
hw/mips/loongson3_virt.c | 20 +++++++++++++++++++-
hw/mips/Kconfig | 1 +
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/hw/mips/loongson3_bootp.h b/hw/mips/loongson3_bootp.h
index 09f8480abf..4756aa44f6 100644
--- a/hw/mips/loongson3_bootp.h
+++ b/hw/mips/loongson3_bootp.h
@@ -210,6 +210,7 @@ enum {
VIRT_PCIE_ECAM,
VIRT_BIOS_ROM,
VIRT_UART,
+ VIRT_IPIS,
VIRT_LIOINTC,
VIRT_PCIE_MMIO,
VIRT_HIGHMEM
diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
index d4a82fa536..0684a035b0 100644
--- a/hw/mips/loongson3_virt.c
+++ b/hw/mips/loongson3_virt.c
@@ -35,6 +35,7 @@
#include "hw/boards.h"
#include "hw/char/serial.h"
#include "hw/intc/loongson_liointc.h"
+#include "hw/intc/loongson_ipi.h"
#include "hw/mips/mips.h"
#include "hw/mips/cpudevs.h"
#include "hw/mips/fw_cfg.h"
@@ -59,6 +60,7 @@
#define PM_CNTL_MODE 0x10
+#define LOONGSON_TCG_MAX_VCPUS 4
#define LOONGSON_MAX_VCPUS 16
/*
@@ -71,6 +73,7 @@
#define UART_IRQ 0
#define RTC_IRQ 1
#define PCIE_IRQ_BASE 2
+#define IPI_REG_SPACE 0x100
const struct MemmapEntry virt_memmap[] = {
[VIRT_LOWMEM] = { 0x00000000, 0x10000000 },
@@ -81,6 +84,7 @@ const struct MemmapEntry virt_memmap[] = {
[VIRT_PCIE_ECAM] = { 0x1a000000, 0x2000000 },
[VIRT_BIOS_ROM] = { 0x1fc00000, 0x200000 },
[VIRT_UART] = { 0x1fe001e0, 0x8 },
+ [VIRT_IPIS] = { 0x3ff01000, 0x400 },
[VIRT_LIOINTC] = { 0x3ff01400, 0x64 },
[VIRT_PCIE_MMIO] = { 0x40000000, 0x40000000 },
[VIRT_HIGHMEM] = { 0x80000000, 0x0 }, /* Variable */
@@ -495,6 +499,10 @@ static void mips_loongson3_virt_init(MachineState *machine)
error_report("Loongson-3/TCG needs cpu type Loongson-3A1000");
exit(1);
}
+ if (machine->smp.cpus > LOONGSON_TCG_MAX_VCPUS) {
+ error_report("Loongson-3/TCG supports up to 4 CPUs");
+ exit(1);
+ }
} else {
if (!machine->cpu_type) {
machine->cpu_type = MIPS_CPU_TYPE_NAME("Loongson-3A4000");
@@ -545,7 +553,17 @@ static void mips_loongson3_virt_init(MachineState *machine)
qemu_register_reset(main_cpu_reset, cpu);
if (i >= 4) {
- continue; /* Only node-0 can be connected to LIOINTC */
+ continue; /* Only node-0 can be connected to LIOINTC and IPI */
+ }
+
+ if (!kvm_enabled()) {
+ /* IPI is handled by kernel for KVM */
+ DeviceState *ipi;
+ ipi = qdev_new(TYPE_LOONGSON_IPI);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(ipi), &error_fatal);
+ sysbus_mmio_map(SYS_BUS_DEVICE(ipi), 0,
+ virt_memmap[VIRT_IPIS].base + IPI_REG_SPACE * i);
+ sysbus_connect_irq(SYS_BUS_DEVICE(ipi), 0, cpu->env.irq[6]);
}
for (ip = 0; ip < 4 ; ip++) {
diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
index aadd436bf4..4fb0cc49e8 100644
--- a/hw/mips/Kconfig
+++ b/hw/mips/Kconfig
@@ -39,6 +39,7 @@ config LOONGSON3V
select SERIAL
select GOLDFISH_RTC
select LOONGSON_LIOINTC
+ select LOONGSON_IPI if TCG
select PCI_DEVICES
select PCI_EXPRESS_GENERIC_BRIDGE
select MSI_NONBROKEN
--
2.30.0
next prev parent reply other threads:[~2021-01-14 1:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 1:31 [PATCH v2 0/2] loongson3_virt TCG SMP support Jiaxun Yang
2021-01-14 1:31 ` [PATCH v2 1/2] hw/intc: Add Loongson Inter Processor Interrupt controller Jiaxun Yang
2021-01-14 15:08 ` Philippe Mathieu-Daudé
2021-01-14 15:21 ` Peter Maydell
2021-01-14 1:31 ` Jiaxun Yang [this message]
2021-01-17 22:46 ` [PATCH v2 2/2] hw/mips/loongson3_virt: Add TCG SMP support Philippe Mathieu-Daudé
2021-01-17 22:58 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210114013147.92962-3-jiaxun.yang@flygoat.com \
--to=jiaxun.yang@flygoat.com \
--cc=aleksandar.rikalo@syrmia.com \
--cc=aurelien@aurel32.net \
--cc=chenhuacai@kernel.org \
--cc=f4bug@amsat.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).