From nobody Mon Nov 25 09:17:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1716486621; cv=none; d=zohomail.com; s=zohoarc; b=KXsOrFvCcvhcCb695BKyaTkwhvrENExEctCdI62y62ZHx+UtyB3EsUbrrblUv7WIJQQLV3PvgzOhZKmAKX6XYSf7Aohjj/5kRWake6KQAbWANAecBN5z839mHBFUxAILX0VWOL8nm4qRyo/wXI4qXqDkEkbwynDFKaoDlXUuasc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716486621; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ocPCyo8rhL+lFVIKpLa8nzkC2tFA2ADDZSvrzw2Bp6k=; b=JiTAu356UoQvZrJJMkhlU/7DWojrRE2cnh3x3JC4vtafyVnNaXinU7xzIikaqaGM9Ks+BR0RqFaIknYbSXIrOyuDd66+AdZPtS4J0yZMbpas2zlAALiuZA0da2HLwG35eIWi+nIa/neoxAZH0LOYgW26+wdyp7v3VC7TzboZ0n0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1716486621238736.2090424993091; Thu, 23 May 2024 10:50:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sACZ9-0006FF-Cr; Thu, 23 May 2024 13:49:23 -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 1sACYx-000654-2K for qemu-devel@nongnu.org; Thu, 23 May 2024 13:49:11 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sACYo-0003fN-1Z for qemu-devel@nongnu.org; Thu, 23 May 2024 13:49:05 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1f32a3b9491so15562035ad.0 for ; Thu, 23 May 2024 10:48:50 -0700 (PDT) Received: from localhost.localdomain ([2601:646:8f03:9fee:4f9e:216e:ed5a:642d]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c137e7esm253436265ad.257.2024.05.23.10.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 10:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716486529; x=1717091329; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ocPCyo8rhL+lFVIKpLa8nzkC2tFA2ADDZSvrzw2Bp6k=; b=SmrHrWrwrrU92VkZUHeHZ89TkBdRinl0htsp0s3+0Vz4WEqYPgc2Dy7fW1Tg3dzZSO +vb2qaPSvH4s4xXWs5P7UqvWGsT/kf9Ji6YPgPOD/GLXs4m9mJxNO3QeWe1ZVJK4AlEW HL5n2z8OegBvhnMDh5EtPXnbKqXVB26qhTTc+dSnxpRCj/ihgsf/2B3FJuBnOgWk+IvE 1e9ISsxoClQEHrhCcZSxyY9MoqX+PWs0mKajmXDeICq4FfTVkiRxrE4MJ1jI1Bc93gSB PWw7NFsfwW3ZLguku9uc6JuWxoQqGazS/LfGThxC2RhP2H8K19HjvSAW4h7KHTpi/nlr SwSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716486529; x=1717091329; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ocPCyo8rhL+lFVIKpLa8nzkC2tFA2ADDZSvrzw2Bp6k=; b=UB5uJScfW3Vp46VIwqQWanZ0Q6Qa9ERBt/dO2uob9CuXG5sFyEeM/AnJt75l/5BzPE uwfEDWGRkWQF9w4cz2KAXJ91cAys6rk7iAyJRom/TkrRqCObzG8rr9GAIoJDI4bkWjAH 2UF3RxqVBdyjEuadHemixrdIF02LlXWi5qK3GHuPjEvxKmgM/FA7E972O+F57hVeO2NY N53yIsdu+vAGQT582ZAwegk8cYUqzftJ4u1SKaQw30bTSC0Ha2+ZOYIeRqIWw63OZJ/0 bAk2moLecp/9M+l/FeGeKkpIzAM7MUqB/Jex/uDisYN6H4D/Q4hIbZstR4DCXWoBTsoF tYHw== X-Gm-Message-State: AOJu0YyjFcctxfSEH6M+l2GpvVVXb4y6CIeClYINFF6nEJNXutiNpo73 UcxU9+yatANYGty98dpfXiUYSs3UYLNTf2PQwFC5b1eMl9hO12J+9z5QGg== X-Google-Smtp-Source: AGHT+IFswUc2pHV2hG9gPI1WJGwqcncOm/fJ4wA/eCxhF++49CLYGicqoq3D94ExiC3uMcz2ax5Ugw== X-Received: by 2002:a17:902:f54c:b0:1e4:8eb3:26f5 with SMTP id d9443c01a7336-1f44883b0a7mr569065ad.38.1716486529000; Thu, 23 May 2024 10:48:49 -0700 (PDT) From: nifan.cxl@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, linux-cxl@vger.kernel.org, gregory.price@memverge.com, ira.weiny@intel.com, dan.j.williams@intel.com, a.manzanares@samsung.com, dave@stgolabs.net, nmtadam.samsung@gmail.com, nifan.cxl@gmail.com, jim.harris@samsung.com, Jorgen.Hansen@wdc.com, wj28.lee@gmail.com, armbru@redhat.com, mst@redhat.com, Fan Ni , Jonathan Cameron Subject: [PATCH v8 07/14] hw/mem/cxl-type3: Refactor ct3_build_cdat_entries_for_mr to take mr size instead of mr as argument Date: Thu, 23 May 2024 10:44:47 -0700 Message-ID: <20240523174651.1089554-8-nifan.cxl@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240523174651.1089554-1-nifan.cxl@gmail.com> References: <20240523174651.1089554-1-nifan.cxl@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::629; envelope-from=nifan.cxl@gmail.com; helo=mail-pl1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_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.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-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1716486622621100007 Content-Type: text/plain; charset="utf-8" From: Fan Ni The function ct3_build_cdat_entries_for_mr only uses size of the passed memory region argument, refactor the function definition to make the passed arguments more specific. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni --- hw/mem/cxl_type3.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 06c6f9bb78..51be50ce87 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -44,7 +44,7 @@ enum { }; =20 static void ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, - int dsmad_handle, MemoryRegion *= mr, + int dsmad_handle, uint64_t size, bool is_pmem, uint64_t dpa_base) { CDATDsmas *dsmas; @@ -63,7 +63,7 @@ static void ct3_build_cdat_entries_for_mr(CDATSubHeader *= *cdat_table, .DSMADhandle =3D dsmad_handle, .flags =3D is_pmem ? CDAT_DSMAS_FLAG_NV : 0, .DPA_base =3D dpa_base, - .DPA_length =3D memory_region_size(mr), + .DPA_length =3D size, }; =20 /* For now, no memory side cache, plausiblish numbers */ @@ -132,7 +132,7 @@ static void ct3_build_cdat_entries_for_mr(CDATSubHeader= **cdat_table, */ .EFI_memory_type_attr =3D is_pmem ? 2 : 1, .DPA_offset =3D 0, - .DPA_length =3D memory_region_size(mr), + .DPA_length =3D size, }; =20 /* Header always at start of structure */ @@ -149,6 +149,7 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_t= able, void *priv) g_autofree CDATSubHeader **table =3D NULL; CXLType3Dev *ct3d =3D priv; MemoryRegion *volatile_mr =3D NULL, *nonvolatile_mr =3D NULL; + uint64_t vmr_size =3D 0, pmr_size =3D 0; int dsmad_handle =3D 0; int cur_ent =3D 0; int len =3D 0; @@ -163,6 +164,7 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_t= able, void *priv) return -EINVAL; } len +=3D CT3_CDAT_NUM_ENTRIES; + vmr_size =3D memory_region_size(volatile_mr); } =20 if (ct3d->hostpmem) { @@ -171,21 +173,22 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat= _table, void *priv) return -EINVAL; } len +=3D CT3_CDAT_NUM_ENTRIES; + pmr_size =3D memory_region_size(nonvolatile_mr); } =20 table =3D g_malloc0(len * sizeof(*table)); =20 /* Now fill them in */ if (volatile_mr) { - ct3_build_cdat_entries_for_mr(table, dsmad_handle++, volatile_mr, + ct3_build_cdat_entries_for_mr(table, dsmad_handle++, vmr_size, false, 0); cur_ent =3D CT3_CDAT_NUM_ENTRIES; } =20 if (nonvolatile_mr) { - uint64_t base =3D volatile_mr ? memory_region_size(volatile_mr) : = 0; + uint64_t base =3D vmr_size; ct3_build_cdat_entries_for_mr(&(table[cur_ent]), dsmad_handle++, - nonvolatile_mr, true, base); + pmr_size, true, base); cur_ent +=3D CT3_CDAT_NUM_ENTRIES; } assert(len =3D=3D cur_ent); --=20 2.43.0