From nobody Mon May 13 08:59:18 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 1710748996030571.9873248394146; Mon, 18 Mar 2024 01:03:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7w9-0003gV-5v; Mon, 18 Mar 2024 04:01:37 -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 1rm7w8-0003fF-3u for qemu-devel@nongnu.org; Mon, 18 Mar 2024 04:01:36 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7w3-0001SM-1t for qemu-devel@nongnu.org; Mon, 18 Mar 2024 04:01:34 -0400 Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8BxXevT9PdlVUAaAA--.63095S3; Mon, 18 Mar 2024 16:01:23 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx8OTR9PdliWtcAA--.46553S3; Mon, 18 Mar 2024 16:01:22 +0800 (CST) From: Bibo Mao To: Song Gao Cc: qemu-devel@nongnu.org Subject: [PATCH 1/5] hw/loongarch: Refine acpi srat table for numa memory Date: Mon, 18 Mar 2024 16:01:17 +0800 Message-Id: <20240318080121.2836548-2-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240318080121.2836548-1-maobibo@loongson.cn> References: <20240318080121.2836548-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8Bx8OTR9PdliWtcAA--.46553S3 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn 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, 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: 1710748996352100001 Content-Type: text/plain; charset="utf-8" One LoongArch virt machine platform, there is limitation for memory map information. The minimum memory size is 256M and minimum memory size for numa node0 is 256M also. With qemu numa qtest, it is possible that memory size of numa node0 is 128M. Limitations for minimum memory size for both total memory and numa node0 is removed for acpi srat table creation. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- hw/loongarch/acpi-build.c | 58 +++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c index e5ab1080af..d0247d93ee 100644 --- a/hw/loongarch/acpi-build.c +++ b/hw/loongarch/acpi-build.c @@ -165,8 +165,9 @@ static void build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) { int i, arch_id, node_id; - uint64_t mem_len, mem_base; - int nb_numa_nodes =3D machine->numa_state->num_nodes; + hwaddr len, base, gap; + NodeInfo *numa_info; + int nodes, nb_numa_nodes =3D machine->numa_state->num_nodes; LoongArchMachineState *lams =3D LOONGARCH_MACHINE(machine); MachineClass *mc =3D MACHINE_GET_CLASS(lams); const CPUArchIdList *arch_ids =3D mc->possible_cpu_arch_ids(machine); @@ -195,35 +196,44 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) build_append_int_noprefix(table_data, 0, 4); /* Reserved */ } =20 - /* Node0 */ - build_srat_memory(table_data, VIRT_LOWMEM_BASE, VIRT_LOWMEM_SIZE, - 0, MEM_AFFINITY_ENABLED); - mem_base =3D VIRT_HIGHMEM_BASE; - if (!nb_numa_nodes) { - mem_len =3D machine->ram_size - VIRT_LOWMEM_SIZE; - } else { - mem_len =3D machine->numa_state->nodes[0].node_mem - VIRT_LOWMEM_S= IZE; + base =3D VIRT_LOWMEM_BASE; + gap =3D VIRT_LOWMEM_SIZE; + numa_info =3D machine->numa_state->nodes; + nodes =3D nb_numa_nodes; + if (!nodes) { + nodes =3D 1; } - if (mem_len) - build_srat_memory(table_data, mem_base, mem_len, 0, MEM_AFFINITY_E= NABLED); - - /* Node1 - Nodemax */ - if (nb_numa_nodes) { - mem_base +=3D mem_len; - for (i =3D 1; i < nb_numa_nodes; ++i) { - if (machine->numa_state->nodes[i].node_mem > 0) { - build_srat_memory(table_data, mem_base, - machine->numa_state->nodes[i].node_mem, = i, - MEM_AFFINITY_ENABLED); - mem_base +=3D machine->numa_state->nodes[i].node_mem; - } + + for (i =3D 0; i < nodes; i++) { + if (nb_numa_nodes) { + len =3D numa_info[i].node_mem; + } else { + len =3D machine->ram_size; + } + + /* + * memory for the node splited into two part + * lowram: [base, +gap) + * highram: [VIRT_HIGHMEM_BASE, +(len - gap)) + */ + if (len >=3D gap) { + build_srat_memory(table_data, base, len, i, MEM_AFFINITY_ENABL= ED); + len -=3D gap; + base =3D VIRT_HIGHMEM_BASE; + gap =3D machine->ram_size - VIRT_LOWMEM_SIZE; + } + + if (len) { + build_srat_memory(table_data, base, len, i, MEM_AFFINITY_ENABL= ED); + base +=3D len; + gap -=3D len; } } =20 if (machine->device_memory) { build_srat_memory(table_data, machine->device_memory->base, memory_region_size(&machine->device_memory->mr), - nb_numa_nodes - 1, + nodes - 1, MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); } =20 --=20 2.39.3 From nobody Mon May 13 08:59:18 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 1710748969193940.2544824771156; Mon, 18 Mar 2024 01:02:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7w9-0003gE-5T; Mon, 18 Mar 2024 04:01:37 -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 1rm7w6-0003fA-VO for qemu-devel@nongnu.org; Mon, 18 Mar 2024 04:01:34 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7w3-0001Su-8B for qemu-devel@nongnu.org; Mon, 18 Mar 2024 04:01:34 -0400 Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8AxuujV9PdlVkAaAA--.43118S3; Mon, 18 Mar 2024 16:01:25 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx8OTR9PdliWtcAA--.46553S4; Mon, 18 Mar 2024 16:01:23 +0800 (CST) From: Bibo Mao To: Song Gao Cc: qemu-devel@nongnu.org Subject: [PATCH 2/5] hw/loongarch: Refine fadt memory table for numa memory Date: Mon, 18 Mar 2024 16:01:18 +0800 Message-Id: <20240318080121.2836548-3-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240318080121.2836548-1-maobibo@loongson.cn> References: <20240318080121.2836548-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8Bx8OTR9PdliWtcAA--.46553S4 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn 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, 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: 1710748970268100001 Content-Type: text/plain; charset="utf-8" One LoongArch virt machine platform, there is limitation for memory map information. The minimum memory size is 256M and minimum memory size for numa node0 is 256M also. With qemu numa qtest, it is possible that memory size of numa node0 is 128M. Limitations for minimum memory size for both total memory and numa node0 is removed for fadt numa memory table creation. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- hw/loongarch/virt.c | 47 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index efce112310..ae79b49774 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -343,6 +343,48 @@ static void fdt_add_memory_node(MachineState *ms, g_free(nodename); } =20 +static void fdt_add_memory_nodes(MachineState *ms) +{ + hwaddr base, size, ram_size, gap; + int i, nb_numa_nodes, nodes; + NodeInfo *numa_info; + + ram_size =3D ms->ram_size; + base =3D VIRT_LOWMEM_BASE; + gap =3D VIRT_LOWMEM_SIZE; + nodes =3D nb_numa_nodes =3D ms->numa_state->num_nodes; + numa_info =3D ms->numa_state->nodes; + if (!nodes) { + nodes =3D 1; + } + + for (i =3D 0; i < nodes; i++) { + if (nb_numa_nodes) { + size =3D numa_info[i].node_mem; + } else { + size =3D ram_size; + } + + /* + * memory for the node splited into two part + * lowram: [base, +gap) + * highram: [VIRT_HIGHMEM_BASE, +(len - gap)) + */ + if (size >=3D gap) { + fdt_add_memory_node(ms, base, gap, i); + size -=3D gap; + base =3D VIRT_HIGHMEM_BASE; + gap =3D ram_size - VIRT_LOWMEM_SIZE; + } + + if (size) { + fdt_add_memory_node(ms, base, size, i); + base +=3D size; + gap -=3D size; + } + } +} + static void virt_build_smbios(LoongArchMachineState *lams) { MachineState *ms =3D MACHINE(lams); @@ -864,9 +906,10 @@ static void loongarch_init(MachineState *machine) } fdt_add_cpu_nodes(lams); =20 + fdt_add_memory_nodes(machine); + /* Node0 memory */ memmap_add_entry(VIRT_LOWMEM_BASE, VIRT_LOWMEM_SIZE, 1); - fdt_add_memory_node(machine, VIRT_LOWMEM_BASE, VIRT_LOWMEM_SIZE, 0); memory_region_init_alias(&lams->lowmem, NULL, "loongarch.node0.lowram", machine->ram, offset, VIRT_LOWMEM_SIZE); memory_region_add_subregion(address_space_mem, phyAddr, &lams->lowmem); @@ -880,7 +923,6 @@ static void loongarch_init(MachineState *machine) } phyAddr =3D VIRT_HIGHMEM_BASE; memmap_add_entry(phyAddr, highram_size, 1); - fdt_add_memory_node(machine, phyAddr, highram_size, 0); memory_region_init_alias(&lams->highmem, NULL, "loongarch.node0.highra= m", machine->ram, offset, highram_size); memory_region_add_subregion(address_space_mem, phyAddr, &lams->highmem= ); @@ -896,7 +938,6 @@ static void loongarch_init(MachineState *machine) offset, numa_info[i].node_mem); memory_region_add_subregion(address_space_mem, phyAddr, nodemem); memmap_add_entry(phyAddr, numa_info[i].node_mem, 1); - fdt_add_memory_node(machine, phyAddr, numa_info[i].node_mem, i); offset +=3D numa_info[i].node_mem; phyAddr +=3D numa_info[i].node_mem; } --=20 2.39.3 From nobody Mon May 13 08:59:18 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 1710748927988678.4959433439184; Mon, 18 Mar 2024 01:02:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7wA-0003hJ-Iy; Mon, 18 Mar 2024 04:01:38 -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 1rm7w8-0003fP-63 for qemu-devel@nongnu.org; Mon, 18 Mar 2024 04:01:36 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7w3-0001Se-82 for qemu-devel@nongnu.org; Mon, 18 Mar 2024 04:01:34 -0400 Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8Dx_7vW9PdlV0AaAA--.43528S3; Mon, 18 Mar 2024 16:01:26 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx8OTR9PdliWtcAA--.46553S5; Mon, 18 Mar 2024 16:01:25 +0800 (CST) From: Bibo Mao To: Song Gao Cc: qemu-devel@nongnu.org Subject: [PATCH 3/5] hw/loongarch: Refine fwcfg memory map Date: Mon, 18 Mar 2024 16:01:19 +0800 Message-Id: <20240318080121.2836548-4-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240318080121.2836548-1-maobibo@loongson.cn> References: <20240318080121.2836548-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8Bx8OTR9PdliWtcAA--.46553S5 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn 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, 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: 1710748930262100003 Content-Type: text/plain; charset="utf-8" Memory map table for fwcfg is used for UEFI BIOS, UEFI BIOS uses the first entry from fwcfg memory map as the first memory HOB, the second memory HOB will be used if the first memory HOB is used up. Memory map table for fwcfg does not care about numa node, however in generic the first memory HOB is part of numa node0, so that runtime memory of UEFI which is allocated from the first memory HOB is located at numa node0. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- hw/loongarch/virt.c | 60 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index ae79b49774..d7e0886c7c 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -796,6 +796,62 @@ static void fw_cfg_add_kernel_info(const struct loader= params *loaderparams, } } =20 +static void fw_cfg_add_memory(MachineState *ms) +{ + hwaddr base, size, ram_size, gap; + int nb_numa_nodes, nodes; + NodeInfo *numa_info; + + ram_size =3D ms->ram_size; + base =3D VIRT_LOWMEM_BASE; + gap =3D VIRT_LOWMEM_SIZE; + nodes =3D nb_numa_nodes =3D ms->numa_state->num_nodes; + numa_info =3D ms->numa_state->nodes; + if (!nodes) { + nodes =3D 1; + } + + /* add fw_cfg memory map of node0 */ + if (nb_numa_nodes) { + size =3D numa_info[0].node_mem; + } else { + size =3D ram_size; + } + + if (size >=3D gap) { + memmap_add_entry(base, gap, 1); + size -=3D gap; + base =3D VIRT_HIGHMEM_BASE; + gap =3D ram_size - VIRT_LOWMEM_SIZE; + } + + if (size) { + memmap_add_entry(base, size, 1); + base +=3D size; + } + + if (nodes < 2) { + return; + } + + /* add fw_cfg memory map of other nodes */ + size =3D ram_size - numa_info[0].node_mem; + gap =3D VIRT_LOWMEM_BASE + VIRT_LOWMEM_SIZE; + if (base < gap && (base + size) > gap) { + /* + * memory map for the maining nodes splited into two part + * lowram: [base, +(gap - base)) + * highram: [VIRT_HIGHMEM_BASE, +(size - (gap - base))) + */ + memmap_add_entry(base, gap - base, 1); + size -=3D gap - base; + base =3D VIRT_HIGHMEM_BASE; + } + + if (size) + memmap_add_entry(base, size, 1); +} + static void loongarch_firmware_boot(LoongArchMachineState *lams, const struct loaderparams *loaderparam= s) { @@ -907,9 +963,9 @@ static void loongarch_init(MachineState *machine) fdt_add_cpu_nodes(lams); =20 fdt_add_memory_nodes(machine); + fw_cfg_add_memory(machine); =20 /* Node0 memory */ - memmap_add_entry(VIRT_LOWMEM_BASE, VIRT_LOWMEM_SIZE, 1); memory_region_init_alias(&lams->lowmem, NULL, "loongarch.node0.lowram", machine->ram, offset, VIRT_LOWMEM_SIZE); memory_region_add_subregion(address_space_mem, phyAddr, &lams->lowmem); @@ -922,7 +978,6 @@ static void loongarch_init(MachineState *machine) highram_size =3D ram_size - VIRT_LOWMEM_SIZE; } phyAddr =3D VIRT_HIGHMEM_BASE; - memmap_add_entry(phyAddr, highram_size, 1); memory_region_init_alias(&lams->highmem, NULL, "loongarch.node0.highra= m", machine->ram, offset, highram_size); memory_region_add_subregion(address_space_mem, phyAddr, &lams->highmem= ); @@ -937,7 +992,6 @@ static void loongarch_init(MachineState *machine) memory_region_init_alias(nodemem, NULL, ramName, machine->ram, offset, numa_info[i].node_mem); memory_region_add_subregion(address_space_mem, phyAddr, nodemem); - memmap_add_entry(phyAddr, numa_info[i].node_mem, 1); offset +=3D numa_info[i].node_mem; phyAddr +=3D numa_info[i].node_mem; } --=20 2.39.3 From nobody Mon May 13 08:59:18 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 1710748999751707.6818343841608; Mon, 18 Mar 2024 01:03:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7wB-0003i2-8t; Mon, 18 Mar 2024 04:01:39 -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 1rm7w8-0003fW-83 for qemu-devel@nongnu.org; Mon, 18 Mar 2024 04:01:36 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7w3-0001Sn-TD for qemu-devel@nongnu.org; Mon, 18 Mar 2024 04:01:35 -0400 Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8DxfevW9PdlWEAaAA--.62748S3; Mon, 18 Mar 2024 16:01:26 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx8OTR9PdliWtcAA--.46553S6; Mon, 18 Mar 2024 16:01:26 +0800 (CST) From: Bibo Mao To: Song Gao Cc: qemu-devel@nongnu.org Subject: [PATCH 4/5] hw/loongarch: Refine system dram memory region Date: Mon, 18 Mar 2024 16:01:20 +0800 Message-Id: <20240318080121.2836548-5-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240318080121.2836548-1-maobibo@loongson.cn> References: <20240318080121.2836548-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8Bx8OTR9PdliWtcAA--.46553S6 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn 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, 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: 1710749000390100001 Content-Type: text/plain; charset="utf-8" For system dram memory region, it is not necessary to use numa node information. There is only low memory region and high memory region. Remove numa node information for ddr memory region here, it can reduce memory region number about LoongArch virt machine. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- hw/loongarch/virt.c | 56 ++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index d7e0886c7c..a2975c3c5a 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -917,19 +917,13 @@ static void loongarch_init(MachineState *machine) { LoongArchCPU *lacpu; const char *cpu_model =3D machine->cpu_type; - ram_addr_t offset =3D 0; - ram_addr_t ram_size =3D machine->ram_size; - uint64_t highram_size =3D 0, phyAddr =3D 0; MemoryRegion *address_space_mem =3D get_system_memory(); LoongArchMachineState *lams =3D LOONGARCH_MACHINE(machine); - int nb_numa_nodes =3D machine->numa_state->num_nodes; - NodeInfo *numa_info =3D machine->numa_state->nodes; int i; - hwaddr fdt_base; + hwaddr fdt_base, base, size, ram_size =3D machine->ram_size; const CPUArchIdList *possible_cpus; MachineClass *mc =3D MACHINE_GET_CLASS(machine); CPUState *cpu; - char *ramName =3D NULL; struct loaderparams loaderparams =3D { }; =20 if (!cpu_model) { @@ -965,41 +959,27 @@ static void loongarch_init(MachineState *machine) fdt_add_memory_nodes(machine); fw_cfg_add_memory(machine); =20 - /* Node0 memory */ - memory_region_init_alias(&lams->lowmem, NULL, "loongarch.node0.lowram", - machine->ram, offset, VIRT_LOWMEM_SIZE); - memory_region_add_subregion(address_space_mem, phyAddr, &lams->lowmem); - - offset +=3D VIRT_LOWMEM_SIZE; - if (nb_numa_nodes > 0) { - assert(numa_info[0].node_mem > VIRT_LOWMEM_SIZE); - highram_size =3D numa_info[0].node_mem - VIRT_LOWMEM_SIZE; - } else { - highram_size =3D ram_size - VIRT_LOWMEM_SIZE; + size =3D ram_size; + base =3D VIRT_LOWMEM_BASE; + if (size > VIRT_LOWMEM_SIZE) { + size =3D VIRT_LOWMEM_SIZE; } - phyAddr =3D VIRT_HIGHMEM_BASE; - memory_region_init_alias(&lams->highmem, NULL, "loongarch.node0.highra= m", - machine->ram, offset, highram_size); - memory_region_add_subregion(address_space_mem, phyAddr, &lams->highmem= ); - - /* Node1 - Nodemax memory */ - offset +=3D highram_size; - phyAddr +=3D highram_size; - - for (i =3D 1; i < nb_numa_nodes; i++) { - MemoryRegion *nodemem =3D g_new(MemoryRegion, 1); - ramName =3D g_strdup_printf("loongarch.node%d.ram", i); - memory_region_init_alias(nodemem, NULL, ramName, machine->ram, - offset, numa_info[i].node_mem); - memory_region_add_subregion(address_space_mem, phyAddr, nodemem); - offset +=3D numa_info[i].node_mem; - phyAddr +=3D numa_info[i].node_mem; + + memory_region_init_alias(&lams->lowmem, NULL, "loongarch.lowram", + machine->ram, base, size); + memory_region_add_subregion(address_space_mem, base, &lams->lowmem); + base +=3D size; + if (ram_size - size) { + base =3D VIRT_HIGHMEM_BASE; + memory_region_init_alias(&lams->highmem, NULL, "loongarch.highram", + machine->ram, VIRT_LOWMEM_BASE + size, ram_size - size); + memory_region_add_subregion(address_space_mem, base, &lams->highme= m); + base +=3D ram_size - size; } =20 /* initialize device memory address space */ if (machine->ram_size < machine->maxram_size) { ram_addr_t device_mem_size =3D machine->maxram_size - machine->ram= _size; - hwaddr device_mem_base; =20 if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) { error_report("unsupported amount of memory slots: %"PRIu64, @@ -1013,9 +993,7 @@ static void loongarch_init(MachineState *machine) "%d bytes", TARGET_PAGE_SIZE); exit(EXIT_FAILURE); } - /* device memory base is the top of high memory address. */ - device_mem_base =3D ROUND_UP(VIRT_HIGHMEM_BASE + highram_size, 1 *= GiB); - machine_memory_devices_init(machine, device_mem_base, device_mem_s= ize); + machine_memory_devices_init(machine, base, device_mem_size); } =20 /* load the BIOS image. */ --=20 2.39.3 From nobody Mon May 13 08:59:18 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 17107489798741021.9329801098235; Mon, 18 Mar 2024 01:02:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7wA-0003gy-0c; Mon, 18 Mar 2024 04:01:38 -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 1rm7w8-0003fJ-47 for qemu-devel@nongnu.org; Mon, 18 Mar 2024 04:01:36 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7w3-0001Sh-DE for qemu-devel@nongnu.org; Mon, 18 Mar 2024 04:01:34 -0400 Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8DxqejW9PdlWUAaAA--.43474S3; Mon, 18 Mar 2024 16:01:26 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx8OTR9PdliWtcAA--.46553S7; Mon, 18 Mar 2024 16:01:26 +0800 (CST) From: Bibo Mao To: Song Gao Cc: qemu-devel@nongnu.org Subject: [PATCH 5/5] hw/loongarch: Remove minimum and default memory size Date: Mon, 18 Mar 2024 16:01:21 +0800 Message-Id: <20240318080121.2836548-6-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240318080121.2836548-1-maobibo@loongson.cn> References: <20240318080121.2836548-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8Bx8OTR9PdliWtcAA--.46553S7 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn 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, 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: 1710748980313100001 Content-Type: text/plain; charset="utf-8" Some qtest test cases such as numa use default memory size of generic machine class, which is 128M by fault. Here generic default memory size is used, and also remove minimum memory size which is 1G originally. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- hw/loongarch/virt.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index a2975c3c5a..deb3750d81 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -930,10 +930,6 @@ static void loongarch_init(MachineState *machine) cpu_model =3D LOONGARCH_CPU_TYPE_NAME("la464"); } =20 - if (ram_size < 1 * GiB) { - error_report("ram_size must be greater than 1G."); - exit(1); - } create_fdt(lams); =20 /* Create IOCSR space */ @@ -1241,7 +1237,6 @@ static void loongarch_class_init(ObjectClass *oc, voi= d *data) =20 mc->desc =3D "Loongson-3A5000 LS7A1000 machine"; mc->init =3D loongarch_init; - mc->default_ram_size =3D 1 * GiB; mc->default_cpu_type =3D LOONGARCH_CPU_TYPE_NAME("la464"); mc->default_ram_id =3D "loongarch.ram"; mc->max_cpus =3D LOONGARCH_MAX_CPUS; --=20 2.39.3