From nobody Sun Feb 8 14:11:00 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; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598965099; cv=none; d=zohomail.com; s=zohoarc; b=A/+NTIisksIfyOFSWFCqw7HDzD9sUXKfFrF5EBf+SfdEgRH1Xw62MQwZixYA8H5NOHMqduxYmdSdGY23aqONf5kYDXfJmt5i/qzcZRvSwMt5WXLvC0n0CtT/81e3zy2ADwPivf/VKGaKkjlhH+PO5oXZan35IjK8TlNdL6Rp8jA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598965099; 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=2JShfyJfS/zPyW00aOHuTSz2uDpf88AEIFLQZdU+7JY=; b=cQePZN4JB++WW/vG134+VLBhvca+3V2scdjiAB75uHizmQX0mwFakrELD3Wg1uI6MpH8FsMPCCVElVc1KsV3EjTUyFIGvnf4LMR3Qc+u36oqMOPqiSCfrUGbRFdG+Fbt8dkWMVlyWLws4g8SXBBi5d07rZbpkLhaE1+IFFGzSD8= 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; 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 1598965099864668.6217298235514; Tue, 1 Sep 2020 05:58:19 -0700 (PDT) Received: from localhost ([::1]:59112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kD5rf-0003Dr-2g for importer@patchew.org; Tue, 01 Sep 2020 08:58:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kD5qU-0001RX-A8; Tue, 01 Sep 2020 08:57:06 -0400 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:46137) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kD5qS-0002my-Fm; Tue, 01 Sep 2020 08:57:05 -0400 Received: by mail-qt1-x843.google.com with SMTP id b3so722642qtg.13; Tue, 01 Sep 2020 05:57:03 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:6be:f6e3:c671:cefe:b943]) by smtp.gmail.com with ESMTPSA id q7sm1430164qkf.35.2020.09.01.05.57.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 05:57:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2JShfyJfS/zPyW00aOHuTSz2uDpf88AEIFLQZdU+7JY=; b=J7sc2BeZIc0F4Jnwj5qicUhFh+x5JuIcpu081afNgAZIkrWbpYAJa3WCgW5KuNKx// rqw1FZl6symCFL2Mo9BoKwUdD37Ik8YHzeh611mwwHiBgX4VFdezts5LkwsmxPb2g+x/ D8EQ/9K6pLx9qymbVFqDxjZ0U/Q4lFWMH9l+ROFQQYUBLMPGUfUU7YjijqQ1oYCZxtsy NnaOw51elqSk9KJyMQ8w7rmJIyenhIjCEn54h83vV+8aC2ly/Ucs0SYmuBxJDWrB2ixc ri72G/yJjrRI0RaKPb3co5niUW7RmojUVNa+MuhpWGNrhHm72EJKorZb2ve1D2JPn0m3 8U4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2JShfyJfS/zPyW00aOHuTSz2uDpf88AEIFLQZdU+7JY=; b=V4xCWSNvsmOw4k0rflEYyvsWyYPtQBs6LFk6PsIplA71dqURpukcwJndoV/mKYaQ9a 1VcCnHWBbCpeCqi5iQP6NWVsiOlswkuBON3Upd9dl0d3kW/F6nkgLD+OCtxp7On43XeB snRu3+db1XfNxgyLWNQmawTnLlwHCXPYDFw42C29Mo8Ka+qz+Pw9yXuSJ6zzza6hUQWg loyFiMrGBT03eN+ihVVwHFnhoOjmlMopiwGdN2gHdl0nUZXLrBs7zbdCh8xbIY3KH/HL fLAYb38SfScH/z+JLhdX9Aa/wwtHCA0Bu0SqTUukGu3UorQnnqsZO8/eYX/KfEOUrA7n dL+g== X-Gm-Message-State: AOAM532ozrgawhnCUS9+RpZ2wHgdff+8sSM0LL27RX42/sdpxPEm+EOn tV7Eq7GQwFf62BW5egV6VgLT7isfwx4VcA== X-Google-Smtp-Source: ABdhPJyfcDPQTDj+bsXpBCGAEOG9XcnhUPfsOoUlXG/rcNBnlQ9NTnHWkx2bSj/8Ltx6H/W+t0SbJQ== X-Received: by 2002:aed:30e1:: with SMTP id 88mr1719972qtf.66.1598965023028; Tue, 01 Sep 2020 05:57:03 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v2 5/7] spapr, spapr_numa: move lookup-arrays handling to spapr_numa.c Date: Tue, 1 Sep 2020 09:56:43 -0300 Message-Id: <20200901125645.118026-6-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200901125645.118026-1-danielhb413@gmail.com> References: <20200901125645.118026-1-danielhb413@gmail.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: pass client-ip=2607:f8b0:4864:20::843; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x843.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: Daniel Henrique Barboza , qemu-ppc@nongnu.org, david@gibson.dropbear.id.au 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" 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 --- hw/ppc/spapr.c | 25 ++---------------------- hw/ppc/spapr_numa.c | 39 +++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr_numa.h | 2 ++ 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 172f965fe0..65d2ccd578 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 b8882d209e..9eb4bdbe80 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -75,6 +75,45 @@ 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); + SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(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, j; + + /* 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[MAX_DISTANCE_REF_POINTS]; + + for (j =3D 0; j < MAX_DISTANCE_REF_POINTS; j++) { + associativity[j] =3D smc->numa_assoc_array[i][j + 1]; + } + + 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); + + 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 f92fb4f28a..f6127501a6 100644 --- a/include/hw/ppc/spapr_numa.h +++ b/include/hw/ppc/spapr_numa.h @@ -22,6 +22,8 @@ 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 =20 #endif /* HW_SPAPR_NUMA_H */ --=20 2.26.2