From nobody Thu May 2 13:45:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1561417102; cv=none; d=zoho.com; s=zohoarc; b=ZXaofJkwanvvNBwQHjuD2e6eUHPQe3gwW2qpguRi7n3WZM5d9kbekuX0Ywt/Wen5wnDsPC/FH7CrvawkPI/2EmJA57zVc/ZOWzxfk2eOkSHEywFzhCK0UeH0xS8/ybaedtC6YY01nrIEhbK+SLxASJjL1K00Q19Iv1+q81eTIWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561417102; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=kabah8LupC2KfzQjz7xLzVRKj8AFRD9CxF//rz1zYBg=; b=bAWLSubew5Rv9c9yUatZ7Pjr5SdGmTvlsiWJBW9LA+PwlzNPq2eDPJI9uocWD0R+1TLtbafkA9v3ntvw5t0yq5WOhFLGKXPMahAbtmrUOL8WsrP0/CdewN8irBaVGvutCKWyd4UcaH1uEEev0OeEeLJTURPQxT6dAKbAr73b2Co= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail header.i=@wdc.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561417102535854.0944227760605; Mon, 24 Jun 2019 15:58:22 -0700 (PDT) Received: from localhost ([::1]:55278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfXuT-0007vu-HY for importer@patchew.org; Mon, 24 Jun 2019 18:58:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41037) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfXsp-0006tB-H2 for qemu-devel@nongnu.org; Mon, 24 Jun 2019 18:56:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfXso-00065y-6S for qemu-devel@nongnu.org; Mon, 24 Jun 2019 18:56:19 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:56763) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hfXsn-00063f-D4; Mon, 24 Jun 2019 18:56:18 -0400 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 25 Jun 2019 06:56:13 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 24 Jun 2019 15:55:25 -0700 Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip01.wdc.com with ESMTP; 24 Jun 2019 15:56:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1561416977; x=1592952977; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3AUXQQAZEh4jzG7H7BvgMbcDXA2spgGdkyHwKqSnOD8=; b=HYJv474WpI8VdNLinkCciL7MGy6GHcPsFPRNDUEFlfwfhaSfivxFFQAW 2TW/0QS17XSHQcHUwVBO6IrYYsiJJp4DvH7AsW+xYHwHZIg7mJWyr4lku 6FZo7F6qPZEzcMdmS9PvPoWVk0t0vS08OKHhpCURatH9t/iNvnslSqcH6 yeiAugZ0mNWzLCacSiKuL81K8c9y6CsRyFJNXPiaPdQqVynSQONzcjfcp 5uEiX5R0SYRUjk96s6Rt2Sig81b+RM8OIOz4KgOk4jTWsYnbS+xnyPBIW tyiT8Fkugk6gA9jRx1Ekd+JaO2LcFWgkShsXkkv062t1OPA90bpA4DibU Q==; X-IronPort-AV: E=Sophos;i="5.63,413,1557158400"; d="scan'208";a="112640758" IronPort-SDR: Jyex/PcCaIWT7aFA/2ILmMqn/z92QR4jsWLoX+4ct4LK/DDorOSZerdSnqHhKE7c3DS+UE1NdA r8Mo+08ZIqe0jkFKhUUvCfDyoQeF2RAkY3HoeCxhH6nm6ocY0aLPTjzIDPl/MzoSywCEyI7hUs ZdXWmDkp9Dy2V+tr6dEuZJGQyYTWV9dMyUaQ0QfYK2htZ0UbVpnGHlJB/bmarDuyocvTHERXcE ngbwMrldjLisI8KkgJhsHMPO5gge0A7JoRzfz+pthMP0DDaugblHIi9mgWSDrT29VoTSTcP0Jq xUinqvvt/50RueA24VhTR65k IronPort-SDR: Nel1QvdyK91cMWxn3Xw6K+qj82jIFE2HpfBHAzjRoVkcWHXbWvOChewBzgCZ4Gfjy9uVrDAtrO /ilFSkBOj5NI1ybnehf9SB4DDboZvwO9dIazGW/7KhfONz6McTOgqIzlxAzQQfIjdDy7I+h/mc EY6vSjn8hH3RR4AUQNzbYPp8vs8Ko+ijHCko0cEkNxEgMqigyMcIleChHcRDGbpJUmwbVUqM+Z cQ39PC2OWD2Tj14LBN3GSEgcZNtuyDGqqwNRg8G9m9Xe0D8RnExxGBsli++nWu064QN2sGO/e1 y5M= From: Atish Patra To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Mon, 24 Jun 2019 15:54:46 -0700 Message-Id: <20190624225446.22597-1-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 X-Mailman-Approved-At: Mon, 24 Jun 2019 18:56:58 -0400 Subject: [Qemu-devel] [PATCH] riscv: virt: Add cpu-topology DT node. 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: Atish Patra , Palmer Dabbelt , Alistair Francis , Sagar Karandikar , Bastian Koppelmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Currently, there is no cpu topology defined in RISC-V. Define a device tree node that clearly describes the entire topology. This saves the trouble of scanning individual cache to figure out the topology. Here is the linux kernel patch series that enables topology for RISC-V. http://lists.infradead.org/pipermail/linux-riscv/2019-June/005072.html CPU topology after applying this patch in QEMU & above series in kernel / # cat /sys/devices/system/cpu/cpu2/topology/thread_siblings_list 2 / # cat /sys/devices/system/cpu/cpu2/topology/physical_package_id 0 / # cat /sys/devices/system/cpu/cpu2/topology/core_siblings_list 0-7 Signed-off-by: Atish Patra Reviewed-by: Alistair Francis --- hw/riscv/virt.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 84d94d0c42d8..da0b8aa18747 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -203,9 +203,12 @@ static void *create_fdt(RISCVVirtState *s, const struc= t MemmapEntry *memmap, qemu_fdt_setprop_string(fdt, nodename, "status", "okay"); qemu_fdt_setprop_cell(fdt, nodename, "reg", cpu); qemu_fdt_setprop_string(fdt, nodename, "device_type", "cpu"); + qemu_fdt_setprop_cell(fdt, nodename, "phandle", cpu_phandle); + qemu_fdt_setprop_cell(fdt, nodename, "linux,phandle", cpu_phandle); + int intc_phandle =3D phandle++; qemu_fdt_add_subnode(fdt, intc); - qemu_fdt_setprop_cell(fdt, intc, "phandle", cpu_phandle); - qemu_fdt_setprop_cell(fdt, intc, "linux,phandle", cpu_phandle); + qemu_fdt_setprop_cell(fdt, intc, "phandle", intc_phandle); + qemu_fdt_setprop_cell(fdt, intc, "linux,phandle", intc_phandle); qemu_fdt_setprop_string(fdt, intc, "compatible", "riscv,cpu-intc"); qemu_fdt_setprop(fdt, intc, "interrupt-controller", NULL, 0); qemu_fdt_setprop_cell(fdt, intc, "#interrupt-cells", 1); @@ -214,6 +217,20 @@ static void *create_fdt(RISCVVirtState *s, const struc= t MemmapEntry *memmap, g_free(nodename); } =20 + /* Add cpu-topology node */ + qemu_fdt_add_subnode(fdt, "/cpus/cpu-map"); + qemu_fdt_add_subnode(fdt, "/cpus/cpu-map/cluster0"); + for (cpu =3D s->soc.num_harts - 1; cpu >=3D 0; cpu--) { + char *core_nodename =3D g_strdup_printf("/cpus/cpu-map/cluster0/co= re%d", + cpu); + char *cpu_nodename =3D g_strdup_printf("/cpus/cpu@%d", cpu); + uint32_t intc_phandle =3D qemu_fdt_get_phandle(fdt, cpu_nodename); + qemu_fdt_add_subnode(fdt, core_nodename); + qemu_fdt_setprop_cell(fdt, core_nodename, "cpu", intc_phandle); + g_free(core_nodename); + g_free(cpu_nodename); + } + cells =3D g_new0(uint32_t, s->soc.num_harts * 4); for (cpu =3D 0; cpu < s->soc.num_harts; cpu++) { nodename =3D --=20 2.21.0