From nobody Tue Nov 18 11:52:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1610422635; cv=none; d=zohomail.com; s=zohoarc; b=mKIvXIRJuSvYBMSI+nCMoHsiPkPQ3Hiy6ieHzV9oTKJbGiEqwyWfNwETKXTFI7k/896oMWTaHdSJO1xK4go2wEY3jqR4A8Ev2M8uW6vpJU2Aeopmps+Re4Tl1/2+7/L/qkQfsHbSTJU4kHQ34Xw0EYHazKZFVx5IyxDpA2Y5XXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610422635; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=++sU1rL1R7cJUXiQgehNhtvWyv2dn1/hfiDlIC0/mV4=; b=CGchO2W/zBNu2MfpHHtir7IpeQ2txhlHorCa90rKoQLP9BIHJF78WNKbVk6A/K5EiL13Xe9cIWrovWdr6yhoQ4sMgas9JrIxhTLiRaN/zMjSEdIDmY1ef6hVB6YTjDMqmLuw34C59e9F8Zbp0MgcIH3eDz1eN8vYdy97GbAHh7A= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610422635624350.46468202475523; Mon, 11 Jan 2021 19:37:15 -0800 (PST) Received: from localhost ([::1]:55078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzAUc-0003wy-D4 for importer@patchew.org; Mon, 11 Jan 2021 22:37:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzAQz-0001Mz-8s for qemu-devel@nongnu.org; Mon, 11 Jan 2021 22:33:34 -0500 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:60567) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzAQw-0001Li-FB for qemu-devel@nongnu.org; Mon, 11 Jan 2021 22:33:29 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 79F2158058D; Mon, 11 Jan 2021 22:33:25 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 11 Jan 2021 22:33:25 -0500 Received: from localhost.localdomain (unknown [180.97.240.21]) by mail.messagingengine.com (Postfix) with ESMTPA id 502701080067; Mon, 11 Jan 2021 22:33:19 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=++sU1rL1R7cJU XiQgehNhtvWyv2dn1/hfiDlIC0/mV4=; b=bJ21v5ki4eiTZfxE0TjB8sTBBasl/ U3iZ7o71oZkEIM0pMOf2maX31ju2a3TMa3KpnHbQld1C0xSGNrWKfdViOUmE1Fk6 8pHqxfIyU+TQsZt2vzzwBBfED4lktJxqDTwRBaz0uSPj3kf0vBqqnb0oosHy11rm YkrB5MAKVxk9qoxhgid10nJ9OGLDj3HhhsGodrgZbaf8OtrPBE+JTuRsxVz/euyn gvjlD3IRsbAbrb4XVpu1yx5xwwV6xaOj+H0HBr5G+qgLrcwXjZFNPQdEsT+wicRp IxqVPiEp12aEpCEb7t8pDsNdLVZykQHJtd8FULqFUEwGmBkuZ/9EfR/3w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=++sU1rL1R7cJUXiQgehNhtvWyv2dn1/hfiDlIC0/mV4=; b=PVZfFbgl JO6Ztr1tfp8NidxL61ZEM8yinCO6DFp7LE6I6Hwk+p8HwA3rwI2XDhHL6fCxNBOK zLvEqUdWFmjbe/yq5AmQPvODtZO127xMVGKH/ba+rU7Tg0dfcLQ1Pufm7Xa9K4/2 FMVbOJWQEIuXNT1QHV82XQ9GFr2ExeGsZG8Kfa8Q8arO969bCxZ6NzXONPP8WqSz 0Mj/PKKX8h9Kcu1hYRYrBeJk4VKVda+TJwGDryEsCk4ptboIy+kiCABhKhe+nj8l I/q27wL8T0pfeZeC7htS06mer5YjGbwoJxzCUrS4rgnx1nzyGkQw+3HUq2ipWrj/ TuOekwyMRxf42w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdehvddgiedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeflihgrgihu nhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqnecugg ftrfgrthhtvghrnhepjeeihffgteelkeelffdukedtheevudejvdegkeekjeefhffhhfet udetgfdtffeunecukfhppedukedtrdeljedrvdegtddrvddunecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhl hihgohgrthdrtghomh X-ME-Proxy: From: Jiaxun Yang To: qemu-devel@nongnu.org Subject: [PATCH 2/2] hw/mips/loongson3_virt: Add TCG SMP support Date: Tue, 12 Jan 2021 11:32:53 +0800 Message-Id: <20210112033253.138140-3-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210112033253.138140-1-jiaxun.yang@flygoat.com> References: <20210112033253.138140-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: permerror client-ip=66.111.4.224; envelope-from=jiaxun.yang@flygoat.com; helo=new2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aurelien Jarno , Aleksandar Rikalo , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 --- hw/mips/Kconfig | 1 + hw/mips/loongson3_bootp.h | 1 + hw/mips/loongson3_virt.c | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) 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 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 @@ =20 #define PM_CNTL_MODE 0x10 =20 +#define LOONGSON_TCG_MAX_VCPUS 4 #define LOONGSON_MAX_VCPUS 16 =20 /* @@ -71,6 +73,7 @@ #define UART_IRQ 0 #define RTC_IRQ 1 #define PCIE_IRQ_BASE 2 +#define IPI_REG_SPACE 0x100 =20 const struct MemmapEntry virt_memmap[] =3D { [VIRT_LOWMEM] =3D { 0x00000000, 0x10000000 }, @@ -81,6 +84,7 @@ const struct MemmapEntry virt_memmap[] =3D { [VIRT_PCIE_ECAM] =3D { 0x1a000000, 0x2000000 }, [VIRT_BIOS_ROM] =3D { 0x1fc00000, 0x200000 }, [VIRT_UART] =3D { 0x1fe001e0, 0x8 }, + [VIRT_IPIS] =3D { 0x3ff01000, 0x400 }, [VIRT_LIOINTC] =3D { 0x3ff01400, 0x64 }, [VIRT_PCIE_MMIO] =3D { 0x40000000, 0x40000000 }, [VIRT_HIGHMEM] =3D { 0x80000000, 0x0 }, /* Variable */ @@ -495,6 +499,10 @@ static void mips_loongson3_virt_init(MachineState *mac= hine) 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 =3D MIPS_CPU_TYPE_NAME("Loongson-3A4000"); @@ -545,7 +553,17 @@ static void mips_loongson3_virt_init(MachineState *mac= hine) qemu_register_reset(main_cpu_reset, cpu); =20 if (i >=3D 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 =3D 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]); } =20 for (ip =3D 0; ip < 4 ; ip++) { --=20 2.30.0