From nobody Mon Nov 25 05:01:47 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717528097; cv=none; d=zohomail.com; s=zohoarc; b=n93xUs0I6Rzxr5HQESZzByUzsDSVF61w9+R8PGA9bV5Bwfc7MhZvtdzBPS+AmvuZlqzEMrx7jwvAJ7F/Bk+l5oaSI8nAEvoQjZAnXMfoAhq+WlBd6Tu8EfO3+vcXwlGwrcwmQ6OHuYK3sa+2bnM3fWO9fj52eZiKhwI/VK1P4mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528097; h=Content-Type: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=FMOgEcAe53x2nl/kUwLBbhwXiRFlv4+KNdbX+UZGPhI=; b=g8y+cTmQU7DFErk7HmIn6eARHoFsk3VX2MwFWQbKyOoGyJW48YAcf6wEzlSTloaHYWieO+WA95A5jMHjVsYmgRFXBjV8astk6lAMBF2oB2hxE7hRQoA4bbYvMHipKRuQp4rb9C5qIywHn1W6/lexmpNM/LrW7IT3hoyjoDlmUT0= 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 1717528097123896.118020906538; Tue, 4 Jun 2024 12:08:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVJ-0000xE-WA; Tue, 04 Jun 2024 15:07:30 -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 1sEZVH-0000nh-Va for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVF-0000uo-OJ for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:27 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-NmFtPm_WM2Kk9jSYLDxKmw-1; Tue, 04 Jun 2024 15:07:23 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4212adbe3b6so35385255e9.2 for ; Tue, 04 Jun 2024 12:07:22 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42157359000sm402945e9.2.2024.06.04.12.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FMOgEcAe53x2nl/kUwLBbhwXiRFlv4+KNdbX+UZGPhI=; b=NZkVzhxfRkp4k+BeuwhUOaRrLrLw/4d1Zncg4ON4PXmgsFp8UDOEHSSz+9DKKONL58j/8H c9BASptCFaQhWgFrbdwLy8LBA4g0PzNMU90shU7OHm0O+/G+DWqjOArMglknUP+WdZ36dj CaetRWf1VFDgj3JUk/repCDq5R6lWTs= X-MC-Unique: NmFtPm_WM2Kk9jSYLDxKmw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528041; x=1718132841; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FMOgEcAe53x2nl/kUwLBbhwXiRFlv4+KNdbX+UZGPhI=; b=csJG6x3Zs4aog1+H+qi+a9ba6mJyxicgpoKZKhjwTfNgL6e+NEfTYMLq87lqOW1a4f xBtraI+IILTolYgQUIpIx9vuwnmp+6vc5D6IdPsbohTBJVsiS5DIoFk40a8/1DULC8JB bwW9RH4sJqnQee1so/NUQykASU/BGVdK6x9IP9bGYiio1FXFBu22L9SZOq7irMGmHnJj WoQFwsdOGX9A/75pJUdhgxodZxEPOPnZlGil0PZJmOtPNGREaSHfIZ5ktc6IgHXhIucT HA3kvcbdqk987zLWOllDsof9NJKl/62cUNSnOlWypZaJG4PEPgXUME1iQEJSi3vtMGdF 0SKg== X-Gm-Message-State: AOJu0YwsvHOFWHIpbST9vzS80pzDl4UqDT43WoqDR8hTRwspmocuWTyn WN0xBXr6XLIc7kvdsm5PEZUTb603kmMeK2Ro/r1f/uHRwtFitrtjMtMXvib/WzA3nYU0nIz7Drf EAF3bQFJuJfX0SG8zJzsnhlRnAcoqQh7Mf28DTOAPZBGHlQcHFMN1GzqjHKjg/DICHa+o+2EClo +jkG9WbjUP32WPljNdZM2p1YllbBoABA== X-Received: by 2002:a05:600c:3418:b0:41a:a4b1:c098 with SMTP id 5b1f17b1804b1-421562e99bbmr3904545e9.19.1717528040948; Tue, 04 Jun 2024 12:07:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGY/q9Ps1vqEepWXdlG/yVAMGQqTRVhUI+7Fz2LlD/F5IE4D4xmz/Z+B3DtVmFvCZYwjoXlGg== X-Received: by 2002:a05:600c:3418:b0:41a:a4b1:c098 with SMTP id 5b1f17b1804b1-421562e99bbmr3904365e9.19.1717528040374; Tue, 04 Jun 2024 12:07:20 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL 23/46] hw/mem/cxl-type3: Refactor ct3_build_cdat_entries_for_mr to take mr size instead of mr as argument Message-ID: <038ad26b2d5341fda3962617eb38932108e1703f.1717527933.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717528098064100001 Content-Transfer-Encoding: quoted-printable 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 Message-Id: <20240523174651.1089554-8-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 MST