From patchwork Thu Jul 20 20:37:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "nifan@outlook.com" X-Patchwork-Id: 13321028 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D7C8EB64DA for ; Thu, 20 Jul 2023 20:39:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMaQG-0000qh-TS; Thu, 20 Jul 2023 16:38:52 -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 1qMaQE-0000qR-KI for qemu-devel@nongnu.org; Thu, 20 Jul 2023 16:38:50 -0400 Received: from mail-tyzapc01olkn20817.outbound.protection.outlook.com ([2a01:111:f403:704b::817] helo=APC01-TYZ-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMaQD-0006HU-3t for qemu-devel@nongnu.org; Thu, 20 Jul 2023 16:38:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fhqe5WwifhNAEfA/zRqXb6DYXC3sH/iRcIP2L4nznXvhMYtKY8D1Ohc5gousEd/YnNFd0ran+e3EAFAsu1l+POSUHcwqf0SIyZ8BZq47MlS0D2xt+cS4jIp1k8L8LlfYnkriKcsT13pD//MPlnq8JL7pg1KI+2kTSdpiciwuMPjhwhUPlmPjloHn5hYzHAb8CrJYVq7lKC+meDbjuDOX2bCg02MA+PHn/7hrsphZxjvL5wf31/3569hyXRTOpB5Vt3sTO1HtA5gyn5lBo0KPC2DKKQuUd77FRZ9y0WtmrYFRdIfawwmrfvczh9JdLc+sTUfRpYGXpuHHXGCZ9urvtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=p1Ls8RaUR8iOs9aFBBtVavJgh3k6/iM7CXqLOqQfHho=; b=TJgn+6/dUP5S6kxP2pv14gKc/j7nlUPr/NqRUhzlQ8XclkMsvraQc08Bh9KFg8FcoS1asEj+xwMh8koL2LKnjFLM/SYevyorKeedE4GaLKCfrZNf15kS6R+9k+hE9ix/vhOm62d5bK7lubxNwMuuAEpSGlC5E30UdtELhPfZg3ws8lkldDBxzXbItOX4C3uwUqOS8GqFciXeG2FG3foD7ZKzBmqV0febs37sxL3w+YvjR8BXT0Ipkrx+AZLni+v1C/kQIN+Cjn+mHz+3rtV953dj8PIh7k4wVFD5Eyfm5vagY4RFK+/dV1JS6zv/fDM91EW2KNMp1II5PA37SiKGRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p1Ls8RaUR8iOs9aFBBtVavJgh3k6/iM7CXqLOqQfHho=; b=NHAGkTE7f0ie4jflXGZmEsyrJZYjjKEf59pAybk3zeV5eIDZfD4ROfZxPlQhvqUHxZZFWkoywcdRasiT0JAmdYXHy2D1mI6DkK8fDmr6Vf8nfxVzxPwL8Tk2fxCIxg8v9m7oTz9Z+2T/8zOeTgfbg8RPOTGC6tlJCxP/lB5d/yj097xJ6bFbD4I3LWGU7oAN/XrhuMAISyZzFuvIfq86fhc1W6huQNB37F3YnnlVBU9VZ3+w2+QBYchRCyDqPQNzgbrAHdjI7y0jWJVWC68QzY7MUJvvIOSKwkrVFM0DG2RB9iGFyfjbVN7PJQ7KPVG9moVEmuMhhOhWXOPnFB3wdQ== Received: from SG2PR06MB3397.apcprd06.prod.outlook.com (2603:1096:4:7a::17) by KL1PR0601MB4100.apcprd06.prod.outlook.com (2603:1096:820:24::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 20:38:30 +0000 Received: from SG2PR06MB3397.apcprd06.prod.outlook.com ([fe80::450:9c8c:9058:c94c]) by SG2PR06MB3397.apcprd06.prod.outlook.com ([fe80::450:9c8c:9058:c94c%5]) with mapi id 15.20.6609.024; Thu, 20 Jul 2023 20:38:30 +0000 From: nifan@outlook.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, linux-cxl@vger.kernel.org, gregory.price@memverge.com, hchkuo@avery-design.com.tw, cbrowy@avery-design.com, ira.weiny@intel.com, dan.j.williams@intel.com, a.manzanares@samsung.com, dave@stgolabs.net, nmtadam.samsung@gmail.com, Fan Ni , Fan Ni Subject: [PATCH 3/9] include/hw/cxl/cxl_device: Rename mem_size as static_mem_size for type3 memory devices Date: Thu, 20 Jul 2023 13:37:02 -0700 Message-ID: X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230720203708.25825-1-nifan@outlook.com> References: <20230720203708.25825-1-nifan@outlook.com> X-TMN: [vAKZQcoDvyBdDGL92Wqx4vXCLo+YG/1/] X-ClientProxiedBy: BYAPR03CA0008.namprd03.prod.outlook.com (2603:10b6:a02:a8::21) To SG2PR06MB3397.apcprd06.prod.outlook.com (2603:1096:4:7a::17) X-Microsoft-Original-Message-ID: <20230720203708.25825-4-nifan@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG2PR06MB3397:EE_|KL1PR0601MB4100:EE_ X-MS-Office365-Filtering-Correlation-Id: 4320e7b0-b47e-46ff-26b6-08db89612887 X-MS-Exchange-SLBlob-MailProps: quCBMN2EvO/qzAKd82WE1LuLgf/v/GCyfCN3eiEvalunYMK4N9yliiWxkhPIwJNy+TfDmzQCvhqgkpCJ3BGxzkL0IIqUs3zNwVyqQ7FfV9ueVkLGLitN/HsXVLCPZxXm2lOJNp/b/s25KdgeS06pYufuxafwPYddkMFrrEp/Dsnck08bQjgu7W2VOKoWfB0RrlPAOzlDmbbu6PpwgqwQWfis2P9eiGVoBh8SkEOif9X0MtdB7jZTI7KvLhS6B1uRZYU/dQ8Fg9la7FJNrMNEmxSvAVdXxDEUbxyKkCeZphldsqOGtYUwn6yLkCb6FjS2c8pVGzSZJCJK3ADnsE0tAD4Fuwkn+QCP3yY6Bdt0KE/908kLo7TQddFO9xGKEAOdRVGBpAMJnoCMvIB7m2oKdWjahbEbqTpg1kFTgsA98LJUuqhC8kNrhNb+Lg9TMV1ZDqQswONPeayP6Sbob7SUJx3RoGMBww0KdwihKWioL8OT1fhZLIjpM4EtbtNyQQ7sCMapL/SAQOe1Ib9r1BCbpiw22DeIytKS2WZgYGXtLgkE3jNpim2gdrhPXUWWAUqlfXeCyNu1LhtVRi6zqMvBvK5erA3VVy6TJeuj0l3IHAVWDH0q5XfgiLivWXczHYkSYU6RLYqgDJVotxe5GLfxqzvz8sGZqbv1ceXboYv3hjBDyn3iczTji7Fu12Iwp2P/Y0g7AanYCpzm2fS95J2qvA== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tMHaSwdf3Pzcn4/hfRARAzraO6dhCRLn4/dCsalFeHnoPeBcsVABvvFy8wJN6tyTVEQ3D+3KkLeAQgBwPJ97XCiBkK8ATnHK6xGG+Uy02OC8mUdPNGGaUuAoUiA+cfXNzO/a4Mc09IG8lwZIdRBW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mmKz1nzqoP2qDIf1CJEbttCOZmkDrRFFdrPzdpgN+tlFhS17sPqdidFRqTRoqsmcPoyUoSpdM6owR3GQ1WD41bQfXghFLQBGt2KM8cYKKGdjBHhyYGHJs8GwYy+SiGG5EWtbz8PXuMxJU3J8AXIioWWPn0Yxjt/pizMmsZ7DbZnvQDtB6/M/qszKKp6GSBgt6rVpZ/bByeQnG6kJ7o3nNXl2f5C+fHW8kmVnKUyIRLPMXqWvWmk27/y+e3S2R9AEPyOWcveNuKLOUzRjvbkjxqioVkR1G9FJgOrN17bnDCTMLBVWoWAtwT+M7TzMRYVbJIexTqHizPWYWjRaF6jYshl+03tCYeLJqJDVTKK4PD0rBL4h6QefJ/pM+xUSUzes2rRO0LPIGT+QfWmwghqmAXI0jtFH3AIYuX69YAfjOKGF4wwhUgEAYJAfnlNh1ABTTMtDTHd6/127GbGYZnZhPZm7uZJvpSwxCBphm/NZObKNGxf89y3QHRjp1/8wrB0y+T3JiyekmCeYpoStSs2u0/fsUhng9oxH13d3CycqM93eFpg6lF5XZ8JMOp1gpyzVm7tT3PJM2CS0haaPNYOWq4RYPAmQYHT8XDlOSaQRzvlpBU76qrOf9H/nNTqHe8MaRkPunWulJUTtRIpGdYeLm+LDBmrHRYl9rX+AVtaP9/jQVPJXpZSZ5ElhQWSWsMGZE4pdeUrzw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4320e7b0-b47e-46ff-26b6-08db89612887 X-MS-Exchange-CrossTenant-AuthSource: SG2PR06MB3397.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 20:37:39.0356 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB4100 Received-SPF: pass client-ip=2a01:111:f403:704b::817; envelope-from=nifan@outlook.com; helo=APC01-TYZ-obe.outbound.protection.outlook.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, SPF_HELO_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni Rename mem_size as static_mem_size for type3 memdev to cover static RAM and pmem capacity, preparing for the introduction of dynamic capacity to support dynamic capacity devices. Signed-off-by: Fan Ni --- hw/cxl/cxl-mailbox-utils.c | 5 +++-- hw/mem/cxl_type3.c | 8 ++++---- include/hw/cxl/cxl_device.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 41e43ec231..59d57ae245 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -540,7 +540,8 @@ static CXLRetCode cmd_identify_memory_device(struct cxl_cmd *cmd, snprintf(id->fw_revision, 0x10, "BWFW VERSION %02d", 0); - stq_le_p(&id->total_capacity, cxl_dstate->mem_size / CXL_CAPACITY_MULTIPLIER); + stq_le_p(&id->total_capacity, + cxl_dstate->static_mem_size / CXL_CAPACITY_MULTIPLIER); stq_le_p(&id->persistent_capacity, cxl_dstate->pmem_size / CXL_CAPACITY_MULTIPLIER); stq_le_p(&id->volatile_capacity, cxl_dstate->vmem_size / CXL_CAPACITY_MULTIPLIER); stl_le_p(&id->lsa_size, cvc->get_lsa_size(ct3d)); @@ -879,7 +880,7 @@ static CXLRetCode cmd_media_clear_poison(struct cxl_cmd *cmd, struct clear_poison_pl *in = (void *)cmd->payload; dpa = ldq_le_p(&in->dpa); - if (dpa + CXL_CACHE_LINE_SIZE > cxl_dstate->mem_size) { + if (dpa + CXL_CACHE_LINE_SIZE > cxl_dstate->static_mem_size) { return CXL_MBOX_INVALID_PA; } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 862107c5ef..237b544b9c 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -748,7 +748,7 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) } address_space_init(&ct3d->hostvmem_as, vmr, v_name); ct3d->cxl_dstate.vmem_size = memory_region_size(vmr); - ct3d->cxl_dstate.mem_size += memory_region_size(vmr); + ct3d->cxl_dstate.static_mem_size += memory_region_size(vmr); g_free(v_name); } @@ -771,7 +771,7 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) } address_space_init(&ct3d->hostpmem_as, pmr, p_name); ct3d->cxl_dstate.pmem_size = memory_region_size(pmr); - ct3d->cxl_dstate.mem_size += memory_region_size(pmr); + ct3d->cxl_dstate.static_mem_size += memory_region_size(pmr); g_free(p_name); } @@ -984,7 +984,7 @@ static int cxl_type3_hpa_to_as_and_dpa(CXLType3Dev *ct3d, return -EINVAL; } - if (*dpa_offset > ct3d->cxl_dstate.mem_size) { + if (*dpa_offset > ct3d->cxl_dstate.static_mem_size) { return -EINVAL; } @@ -1142,7 +1142,7 @@ static bool set_cacheline(CXLType3Dev *ct3d, uint64_t dpa_offset, uint8_t *data) return false; } - if (dpa_offset + CXL_CACHE_LINE_SIZE > ct3d->cxl_dstate.mem_size) { + if (dpa_offset + CXL_CACHE_LINE_SIZE > ct3d->cxl_dstate.static_mem_size) { return false; } diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index bf564f4a0b..a32ee6d6ba 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -209,7 +209,7 @@ typedef struct cxl_device_state { } timestamp; /* memory region size, HDM */ - uint64_t mem_size; + uint64_t static_mem_size; uint64_t pmem_size; uint64_t vmem_size;