From patchwork Thu May 11 17:56:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Ni X-Patchwork-Id: 13238291 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 D7306C77B7F for ; Thu, 11 May 2023 17:57:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxAXH-0003qn-O7; Thu, 11 May 2023 13:57:03 -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 1pxAXG-0003qA-RS for qemu-devel@nongnu.org; Thu, 11 May 2023 13:57:02 -0400 Received: from mailout2.w2.samsung.com ([211.189.100.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxAX2-0004oe-1O for qemu-devel@nongnu.org; Thu, 11 May 2023 13:57:02 -0400 Received: from uscas1p2.samsung.com (unknown [182.198.245.207]) by mailout2.w2.samsung.com (KnoxPortal) with ESMTP id 20230511175642usoutp021cee2a55ffb44c18cbdb5b6d3425d1da~eKHb8rVmO2433724337usoutp02U; Thu, 11 May 2023 17:56:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w2.samsung.com 20230511175642usoutp021cee2a55ffb44c18cbdb5b6d3425d1da~eKHb8rVmO2433724337usoutp02U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683827802; bh=UX2rYCNF7mEa58KU74awtybeT0Okf+CTLNXne31BcQ8=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=QSHBDzocbQfNwJi8lVZgIvQKzlLwxBLHkFKLgKTMus5xYTrKdYIJLxSOzBninaWFQ CQAOv0OrUhOgf29oWpBkoHa+fbKrjkQC4yUZU+OIMZY4CuOg3wplP15uPpZoFIp953 btQBlW/od/URrF0dPgbrJCCDTfkTMEr3LgHuk1J8= Received: from ussmges2new.samsung.com (u111.gpu85.samsung.co.kr [203.254.195.111]) by uscas1p1.samsung.com (KnoxPortal) with ESMTP id 20230511175642uscas1p1277c2430cf100d607b33b68fffa0c239~eKHbzQjpJ3115831158uscas1p17; Thu, 11 May 2023 17:56:42 +0000 (GMT) Received: from uscas1p1.samsung.com ( [182.198.245.206]) by ussmges2new.samsung.com (USCPEMTA) with SMTP id C5.DA.42611.95C2D546; Thu, 11 May 2023 13:56:41 -0400 (EDT) Received: from ussmgxs3new.samsung.com (u92.gpu85.samsung.co.kr [203.254.195.92]) by uscas1p1.samsung.com (KnoxPortal) with ESMTP id 20230511175641uscas1p13ee26532e3a1de36f6081f970190eeed~eKHbfQNCm0296202962uscas1p1F; Thu, 11 May 2023 17:56:41 +0000 (GMT) X-AuditID: cbfec36f-249ff7000000a673-92-645d2c597ee0 Received: from SSI-EX2.ssi.samsung.com ( [105.128.2.145]) by ussmgxs3new.samsung.com (USCPEXMTA) with SMTP id D9.48.64580.95C2D546; Thu, 11 May 2023 13:56:41 -0400 (EDT) Received: from SSI-EX2.ssi.samsung.com (105.128.2.227) by SSI-EX2.ssi.samsung.com (105.128.2.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.2375.24; Thu, 11 May 2023 10:56:40 -0700 Received: from SSI-EX2.ssi.samsung.com ([105.128.2.227]) by SSI-EX2.ssi.samsung.com ([105.128.2.227]) with mapi id 15.01.2375.024; Thu, 11 May 2023 10:56:40 -0700 From: Fan Ni 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" , Adam Manzanares , "dave@stgolabs.net" , "nmtadam.samsung@gmail.com" , "nifan@outlook.com" , Fan Ni Subject: [RFC 3/7] hw/mem/cxl_type3: Add a parameter to pass number of DC regions the device supports in qemu command line Thread-Topic: [RFC 3/7] hw/mem/cxl_type3: Add a parameter to pass number of DC regions the device supports in qemu command line Thread-Index: AQHZhDHwgPX9k8X0Wk2f5wJohcsLYA== Date: Thu, 11 May 2023 17:56:40 +0000 Message-ID: <20230511175609.2091136-4-fan.ni@samsung.com> In-Reply-To: <20230511175609.2091136-1-fan.ni@samsung.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.25.1 x-originating-ip: [105.128.2.176] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNKsWRmVeSWpSXmKPExsWy7djXc7qROrEpBs+fW1p0n9/AaDF96gVG i9U31zBaNDQ9YrFo2f2eyWL/0+csFqsWXmOzOD/rFIvF84nPmSyWLnnEbHG8dweLA7fHhckT WD0WN7h67Jx1l92j5chbIG/PSyaPjR//s3s8ubaZyWPz6xfMHlNn13t83iQXwBXFZZOSmpNZ llqkb5fAlfFg6znGgjeCFV3nj7A1MB7m62Lk5JAQMJFYdnoDaxcjF4eQwEpGic5dixkhnFYm iddfl7DDVP19vQ3MFhJYyyhx8kY2RNEnRolrs/awQzjLGCX+LrzLBlLFJqAosa9rO5gtImAs cezwEmaQImaBtywSH9e8YQFJCAvUSOyed5kFJCEi0Mgo8eboP1aIDj2J/Y33wfaxCKhKnLux gxHE5hWwlJhwt5EZxOYUsJLY0HyCCcRmFBCT+H5qDZjNLCAucevJfCaIuwUlFs3ewwxhi0n8 2/WQDcK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EDLM4rYCkx4W4j2CAhIPvjz51gNZwCVhIb mk8wgdiMAmIS30+tYYJYJi5x68l8JogfBCSW7DnPDGGLSrx8/I8VwpaXmPxjBhuErShx//tL dohePYkbU6ewQdjaEssWvmaGuEFQ4uTMJywQ9ZISB1fcYJnAKDELybpZSNpnIWmfhaR9ASPL Kkbx0uLi3PSKYuO81HK94sTc4tK8dL3k/NxNjMDkcPrf4ZgdjPdufdQ7xMjEwXiIUYKDWUmE 9+2S6BQh3pTEyqrUovz4otKc1OJDjNIcLErivB6xE+OFBNITS1KzU1MLUotgskwcnFINTAGJ DKI6f9QnsU0pZ74pzXTsivHrUL4VnHdF/uu4iVYf0n1wXWRH7IZ9TgsLfH8VP7yWVerz+fXx 7p1KbWWMDkHhBszb8woy25sO7l7LrDhdemn0AdldfsZMSiFrPzxu3CbddTV/yZTzT7z4wxsy L69g5dumEP/y2u2Uip6nQr7/TKZ1GZpwqkhfWpYqle6/e+a8utW6311i7kneU37AkPz7S9c8 FQVTNyUGsZ/CRRH/jvGVaaq1LTeMK5kq/98gpuv6ttPv/07xCEjbMC2HfYOiU5tvWcdzA2+J tc0Xknnf8+wTFdx/IWS5Y/SWFYKPzQLPuZye9TWGT6RLkV+5gv+8b7v5xe+bJJdOiElXYinO SDTUYi4qTgQAyB8Y830DAAA= X-CMS-MailID: 20230511175641uscas1p13ee26532e3a1de36f6081f970190eeed CMS-TYPE: 301P X-CMS-RootMailID: 20230511175641uscas1p13ee26532e3a1de36f6081f970190eeed References: <20230511175609.2091136-1-fan.ni@samsung.com> Received-SPF: pass client-ip=211.189.100.12; envelope-from=fan.ni@samsung.com; helo=mailout2.w2.samsung.com X-Spam_score_int: -70 X-Spam_score: -7.1 X-Spam_bar: ------- X-Spam_report: (-7.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_HI=-5, 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 Add a property 'num-dc-regions' to ct3_props to allow users to create DC regions. With the change, users can control the number of DC regions the device supports. To make it easier, other parameters of the region like region base, length, and block size are hard coded. If desired, these parameters can be added easily. Signed-off-by: Fan Ni --- hw/mem/cxl_type3.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 2b483d3d8e..b9c375d9b4 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -684,6 +684,34 @@ static void ct3d_reg_write(void *opaque, hwaddr offset, uint64_t value, } } +/* + * Create a dc region to test "Get Dynamic Capacity Configuration" command. + */ +static int cxl_create_toy_regions(CXLType3Dev *ct3d) +{ + int i; + uint64_t region_base = ct3d->hostvmem?ct3d->hostvmem->size + + ct3d->hostpmem->size:ct3d->hostpmem->size; + uint64_t region_len = 1024*1024*1024; + uint64_t decode_len = 4; /* 4*256MB */ + uint64_t blk_size = 2*1024*1024; + struct CXLDCD_Region *region; + + for (i = 0; i < ct3d->dc.num_regions; i++) { + region = &ct3d->dc.regions[i]; + region->base = region_base; + region->decode_len = decode_len; + region->len = region_len; + region->block_size = blk_size; + /* dsmad_handle is set when creating cdat table entries */ + region->flags = 0; + + region_base += region->len; + } + + return 0; +} + static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) { DeviceState *ds = DEVICE(ct3d); @@ -752,6 +780,9 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) g_free(p_name); } + if (cxl_create_toy_regions(ct3d)) + return false; + return true; } @@ -1036,6 +1067,7 @@ static Property ct3_props[] = { DEFINE_PROP_UINT64("sn", CXLType3Dev, sn, UI64_NULL), DEFINE_PROP_STRING("cdat", CXLType3Dev, cxl_cstate.cdat.filename), DEFINE_PROP_UINT16("spdm", CXLType3Dev, spdm_port, 0), + DEFINE_PROP_UINT8("num-dc-regions", CXLType3Dev, dc.num_regions, 0), DEFINE_PROP_END_OF_LIST(), };