From nobody Tue Feb 10 00:23:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=1599192055; cv=none; d=zohomail.com; s=zohoarc; b=ERUefZU/TXQx5SIwp0YnfCxA9CaAlA8ZwXHB8g4UplgNHKyO7WdJtqeIRaC7CY+s7BVdVyrSGJr83p2HMWukKYUBg87p3NR5rrdj9DK96ymdPBFWb686yed/4vLNuTQyMIEDqzXLAr0M13swbEPC3AZXMAhP9Jy6itP+HfxQSwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599192055; 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=JuGMpxPMDHYuhO2UrsYNlwmlP8Rf15ZVktKPq4snH5Q=; b=Mkv+PDkGM1HfNdOSrBxwUUtcVlnRI2Y6mL7CDcqRwB9cKsV8Z6kNe6oDh32a7ENsWFMqpmdLN6Ha8OT1J8S86Ba/RuOEFMtGuEtiMafRmugqWSZ0f0266K3+TRd5ygtBO0fzDrcdRWyR7N+nNogNUzlnD82Hb2K8oITt3f4lvrE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1599192055493775.2737727070752; Thu, 3 Sep 2020 21:00:55 -0700 (PDT) Received: from localhost ([::1]:55456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kE2uE-0007th-NI for importer@patchew.org; Fri, 04 Sep 2020 00:00:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kE2i2-0003f1-Sd; Thu, 03 Sep 2020 23:48:18 -0400 Received: from ozlabs.org ([203.11.71.1]:53445) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kE2i0-0004zF-Qi; Thu, 03 Sep 2020 23:48:18 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 4BjNsv2gKJz9sWJ; Fri, 4 Sep 2020 13:47:31 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1599191251; bh=XKIMjGNwIAfcg9KlNAGb8EphqdBFc6RwVmnv8aujmlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hnUlETa1n3F7bmjTUE6sW2CLIO4BiATkiFApVie+8zdQDPk3Ia0dgiNapfbe0sPWZ FSRlS+Y51+DPCdDu4WoqzMX/6qTxJDoPSjlpPyy2IP0GQKEj7bUupe4ZGSdXGXiM53 p/0fQbB8MWFDsfVHSW4su03xvu5JoxMdPZBLyyV4= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 29/30] spapr, spapr_numa: move lookup-arrays handling to spapr_numa.c Date: Fri, 4 Sep 2020 13:47:18 +1000 Message-Id: <20200904034719.673626-30-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200904034719.673626-1-david@gibson.dropbear.id.au> References: <20200904034719.673626-1-david@gibson.dropbear.id.au> 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: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/03 23:47:26 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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: danielhb413@gmail.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, bauerman@linux.ibm.com, David Gibson 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" From: Daniel Henrique Barboza In a similar fashion as the previous patch, let's move the handling of ibm,associativity-lookup-arrays from spapr.c to spapr_numa.c. A spapr_numa_write_assoc_lookup_arrays() helper was created, and spapr_dt_dynamic_reconfiguration_memory() can now use it to advertise the lookup-arrays. Signed-off-by: Daniel Henrique Barboza Message-Id: <20200903220639.563090-4-danielhb413@gmail.com> Signed-off-by: David Gibson --- hw/ppc/spapr.c | 25 ++----------------------- hw/ppc/spapr_numa.c | 34 ++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr_numa.h | 2 ++ 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index badfa86319..9bce1892b5 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -535,13 +535,10 @@ static int spapr_dt_dynamic_reconfiguration_memory(Sp= aprMachineState *spapr, void *fdt) { MachineState *machine =3D MACHINE(spapr); - int nb_numa_nodes =3D machine->numa_state->num_nodes; - int ret, i, offset; + int ret, offset; uint64_t lmb_size =3D SPAPR_MEMORY_BLOCK_SIZE; uint32_t prop_lmb_size[] =3D {cpu_to_be32(lmb_size >> 32), cpu_to_be32(lmb_size & 0xffffffff)}; - uint32_t *int_buf, *cur_index, buf_len; - int nr_nodes =3D nb_numa_nodes ? nb_numa_nodes : 1; MemoryDeviceInfoList *dimms =3D NULL; =20 /* @@ -582,25 +579,7 @@ static int spapr_dt_dynamic_reconfiguration_memory(Spa= prMachineState *spapr, return ret; } =20 - /* ibm,associativity-lookup-arrays */ - buf_len =3D (nr_nodes * 4 + 2) * sizeof(uint32_t); - cur_index =3D int_buf =3D g_malloc0(buf_len); - int_buf[0] =3D cpu_to_be32(nr_nodes); - int_buf[1] =3D cpu_to_be32(4); /* Number of entries per associativity = list */ - cur_index +=3D 2; - for (i =3D 0; i < nr_nodes; i++) { - uint32_t associativity[] =3D { - cpu_to_be32(0x0), - cpu_to_be32(0x0), - cpu_to_be32(0x0), - cpu_to_be32(i) - }; - memcpy(cur_index, associativity, sizeof(associativity)); - cur_index +=3D 4; - } - ret =3D fdt_setprop(fdt, offset, "ibm,associativity-lookup-arrays", in= t_buf, - (cur_index - int_buf) * sizeof(uint32_t)); - g_free(int_buf); + ret =3D spapr_numa_write_assoc_lookup_arrays(spapr, fdt, offset); =20 return ret; } diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index 1a1ec8bcff..5a82a84438 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -72,6 +72,40 @@ int spapr_numa_fixup_cpu_dt(SpaprMachineState *spapr, vo= id *fdt, vcpu_assoc, sizeof(vcpu_assoc)); } =20 + +int spapr_numa_write_assoc_lookup_arrays(SpaprMachineState *spapr, void *f= dt, + int offset) +{ + MachineState *machine =3D MACHINE(spapr); + int nb_numa_nodes =3D machine->numa_state->num_nodes; + int nr_nodes =3D nb_numa_nodes ? nb_numa_nodes : 1; + uint32_t *int_buf, *cur_index, buf_len; + int ret, i; + + /* ibm,associativity-lookup-arrays */ + buf_len =3D (nr_nodes * MAX_DISTANCE_REF_POINTS + 2) * sizeof(uint32_t= ); + cur_index =3D int_buf =3D g_malloc0(buf_len); + int_buf[0] =3D cpu_to_be32(nr_nodes); + /* Number of entries per associativity list */ + int_buf[1] =3D cpu_to_be32(MAX_DISTANCE_REF_POINTS); + cur_index +=3D 2; + for (i =3D 0; i < nr_nodes; i++) { + /* + * For the lookup-array we use the ibm,associativity array, + * from numa_assoc_array. without the first element (size). + */ + uint32_t *associativity =3D spapr->numa_assoc_array[i]; + memcpy(cur_index, ++associativity, + sizeof(uint32_t) * MAX_DISTANCE_REF_POINTS); + cur_index +=3D MAX_DISTANCE_REF_POINTS; + } + ret =3D fdt_setprop(fdt, offset, "ibm,associativity-lookup-arrays", in= t_buf, + (cur_index - int_buf) * sizeof(uint32_t)); + g_free(int_buf); + + return ret; +} + /* * Helper that writes ibm,associativity-reference-points and * max-associativity-domains in the RTAS pointed by @rtas diff --git a/include/hw/ppc/spapr_numa.h b/include/hw/ppc/spapr_numa.h index 43c6a16fe3..b3fd950634 100644 --- a/include/hw/ppc/spapr_numa.h +++ b/include/hw/ppc/spapr_numa.h @@ -29,5 +29,7 @@ void spapr_numa_write_associativity_dt(SpaprMachineState = *spapr, void *fdt, int offset, int nodeid); int spapr_numa_fixup_cpu_dt(SpaprMachineState *spapr, void *fdt, int offset, PowerPCCPU *cpu); +int spapr_numa_write_assoc_lookup_arrays(SpaprMachineState *spapr, void *f= dt, + int offset); =20 #endif /* HW_SPAPR_NUMA_H */ --=20 2.26.2