From nobody Sat May 11 13:12:49 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710232360029358.1142924599678; Tue, 12 Mar 2024 01:32:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjxYe-0002x3-Tp; Tue, 12 Mar 2024 04:32:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjxYb-0002wZ-9c; Tue, 12 Mar 2024 04:32:21 -0400 Received: from sgoci-sdnproxy-4.icoremail.net ([129.150.39.64]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjxYY-0002iF-Nl; Tue, 12 Mar 2024 04:32:21 -0400 Received: from prodtpl.icoremail.net (unknown [10.12.1.20]) by hzbj-icmmx-6 (Coremail) with SMTP id AQAAfwAHDwsKE_BlgM6GBg--.36585S2; Tue, 12 Mar 2024 16:32:10 +0800 (CST) Received: from phytium.com.cn (unknown [218.76.62.144]) by mail (Coremail) with SMTP id AQAAfwCXjPAEE_BlkXMAAA--.584S4; Tue, 12 Mar 2024 16:32:05 +0800 (CST) From: Xiong Yining To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: rad@semihalf.com, peter.maydell@linaro.org, quic_llindhol@quicinc.com, marcin.juszkiewicz@linaro.org, chenbaozi@phytium.com.cn, xiongyining1480 Subject: [PATCH v2 1/2] hw/arm/sbsa-ref:Enable CPU cluster on ARM sbsa machine Date: Tue, 12 Mar 2024 08:30:48 +0000 Message-Id: <20240312083049.3412522-2-xiongyining1480@phytium.com.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312083049.3412522-1-xiongyining1480@phytium.com.cn> References: <20240312083049.3412522-1-xiongyining1480@phytium.com.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAfwCXjPAEE_BlkXMAAA--.584S4 X-CM-SenderInfo: x0lr0wp1lqx0bjrumio6sk53xlxphulrpou0/1tbiAQACBmXvXPYDKAAAsO Authentication-Results: hzbj-icmmx-6; spf=neutral smtp.mail=xiongyinin g1480@phytium.com.cn; X-Coremail-Antispam: 1Uk129KBjvdXoWrZr1kXr4UKF15uw1fKF4UJwb_yoWDWwc_Jw 1xXwnxWF1UKwnF9ryYyF4fAryrKw4UKFsrKrn7uFyrJw1jgF1UG3Z8JrZ7Xw18Za15Za4S kF4UZF45uwnxGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrnU Uv73VFW2AGmfu7jjvjm3AaLaJ3UjIYCTnIWjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRUUUUU UUUU= 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: pass client-ip=129.150.39.64; envelope-from=xiongyining1480@phytium.com.cn; helo=sgoci-sdnproxy-4.icoremail.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1710232362981100003 Content-Type: text/plain; charset="utf-8" From: xiongyining1480 Enable the CPU cluster on ARM sbsa machine, so user can configure the cluster hierarchy. Signed-off-by: Xiong Yining Signed-off-by: Chen Baozi Tested-by: Marcin Juszkiewicz --- hw/arm/sbsa-ref.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index f5709d6c14..fde7dd528f 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -886,6 +886,7 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *= data) mc->default_ram_size =3D 1 * GiB; mc->default_ram_id =3D "sbsa-ref.ram"; mc->default_cpus =3D 4; + mc->smp_props.clusters_supported =3D true; mc->possible_cpu_arch_ids =3D sbsa_ref_possible_cpu_arch_ids; mc->cpu_index_to_instance_props =3D sbsa_ref_cpu_index_to_props; mc->get_default_cpu_node_id =3D sbsa_ref_get_default_cpu_node_id; --=20 2.34.1 From nobody Sat May 11 13:12:49 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710232400764455.4529179528505; Tue, 12 Mar 2024 01:33:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjxYm-0002zB-0z; Tue, 12 Mar 2024 04:32:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjxYf-0002xr-2D; Tue, 12 Mar 2024 04:32:25 -0400 Received: from sgoci-sdnproxy-4.icoremail.net ([129.150.39.64]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjxYc-0002kd-UZ; Tue, 12 Mar 2024 04:32:24 -0400 Received: from prodtpl.icoremail.net (unknown [10.12.1.20]) by hzbj-icmmx-7 (Coremail) with SMTP id AQAAfwDHzEQPE_Bl4iXhDA--.32666S2; Tue, 12 Mar 2024 16:32:15 +0800 (CST) Received: from phytium.com.cn (unknown [218.76.62.144]) by mail (Coremail) with SMTP id AQAAfwCXjPAEE_BlkXMAAA--.584S5; Tue, 12 Mar 2024 16:32:08 +0800 (CST) From: Xiong Yining To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: rad@semihalf.com, peter.maydell@linaro.org, quic_llindhol@quicinc.com, marcin.juszkiewicz@linaro.org, chenbaozi@phytium.com.cn, xiongyining1480 Subject: [PATCH v2 2/2] hw/arm/sbsa-ref: Add cpu-map to device tree Date: Tue, 12 Mar 2024 08:30:49 +0000 Message-Id: <20240312083049.3412522-3-xiongyining1480@phytium.com.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312083049.3412522-1-xiongyining1480@phytium.com.cn> References: <20240312083049.3412522-1-xiongyining1480@phytium.com.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAfwCXjPAEE_BlkXMAAA--.584S5 X-CM-SenderInfo: x0lr0wp1lqx0bjrumio6sk53xlxphulrpou0/1tbiAQACBmXvXPYDKwAAsN Authentication-Results: hzbj-icmmx-7; spf=neutral smtp.mail=xiongyinin g1480@phytium.com.cn; X-Coremail-Antispam: 1Uk129KBjvJXoW7AF13Cr1kAw1xJFWDWFy7GFg_yoW8Cw15pw 4UGFn8WrW5CrnFvayfWa42gFyFgw1rXw47Xw47KayFyw17G34fXF1IyF9Yk34UGry2gFya krsxCFyFg34UJr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj DUYxn0WfASr-VFAU7a7-sFnT9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUU UUUUU 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: pass client-ip=129.150.39.64; envelope-from=xiongyining1480@phytium.com.cn; helo=sgoci-sdnproxy-4.icoremail.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1710232402918100003 Content-Type: text/plain; charset="utf-8" From: xiongyining1480 Support CPU topology description through device tree. Signed-off-by: Xiong Yining Signed-off-by: Chen Baozi Reviewed-by: Marcin Juszkiewicz --- hw/arm/sbsa-ref.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index fde7dd528f..5b2c32515d 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -264,9 +264,43 @@ static void create_fdt(SBSAMachineState *sms) ms->possible_cpus->cpus[cs->cpu_index].props.node_id); } =20 + qemu_fdt_setprop_cell(sms->fdt, nodename, "phandle", + qemu_fdt_alloc_phandle(sms->fdt)); + g_free(nodename); } =20 + /* + * Add vCPU topology description through fdt node cpu-map. + * See fdt_add_cpu_nodes() on hw/arm/virt.c for longer description. + */ + qemu_fdt_add_subnode(sms->fdt, "/cpus/cpu-map"); + + for (cpu =3D sms->smp_cpus - 1; cpu >=3D 0; cpu--) { + char *cpu_path =3D g_strdup_printf("/cpus/cpu@%d", cpu); + char *map_path; + + if (ms->smp.threads > 1) { + map_path =3D g_strdup_printf( + "/cpus/cpu-map/socket%d/cluster%d/core%d/thread%d", + cpu / (ms->smp.clusters * ms->smp.cores * ms->smp.threads), + (cpu / (ms->smp.cores * ms->smp.threads)) % ms->smp.cluste= rs, + (cpu / ms->smp.threads) % ms->smp.cores, + cpu % ms->smp.threads); + } else { + map_path =3D g_strdup_printf( + "/cpus/cpu-map/socket%d/cluster%d/core%d", + cpu / (ms->smp.clusters * ms->smp.cores), + (cpu / ms->smp.cores) % ms->smp.clusters, + cpu % ms->smp.cores); + } + qemu_fdt_add_path(sms->fdt, map_path); + qemu_fdt_setprop_phandle(sms->fdt, map_path, "cpu", cpu_path); + + g_free(map_path); + g_free(cpu_path); + } + sbsa_fdt_add_gic_node(sms); } =20 --=20 2.34.1