From nobody Sat May 18 15:08:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1684378017; cv=none; d=zohomail.com; s=zohoarc; b=OZOdRAGPZwA7zGvzouEGgKn9IzUzvZplprXs1LyNcnS9odT9fUYeLC2y3b0RPPpt4OZ9xPfJBQB50Ek42UPj8/McVMtCc+tazqUGJw14bEQ/fRNN6wmRGaHU4vTQbp08/4qAdZrrZZGOekYSousN6F1BZnUKKPn0QOfCFjDoeOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684378017; h=Content-Type: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=hK7K5zMtPJS4jqugPMK6DBQU2XzxEnrL/k1uBppuG0s=; b=Hh+1SvbOkmw0EfR5QlUrtmvxRs1+sbej9o5ejsaGe+bITCeErEPnt/nzcHufA3F6/ZOGYdwIRklUkUjF8dBCTfkVPDldw8LRINw+VnizCy6gCQBzC288tsVoQv6nUQtCqf+uyQ3wc/YGNewMOdDDr99ySY3GuKMOoM+cPrDGBF0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1684378017879675.7266202053145; Wed, 17 May 2023 19:46:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzTee-0005Df-5g; Wed, 17 May 2023 22:46:12 -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 1pzTeb-0005Ad-54 for qemu-devel@nongnu.org; Wed, 17 May 2023 22:46:09 -0400 Received: from mga01.intel.com ([192.55.52.88]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzTeV-0008FG-Eg for qemu-devel@nongnu.org; Wed, 17 May 2023 22:46:08 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 19:46:00 -0700 Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.209.143.168]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 19:45:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684377963; x=1715913963; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=ALosJLPeK/xQ//Ur5NIceXWhZEbxkQaR0DQfbRf0RQM=; b=EntQMmvDMkFfZkvoONi+zI2I1j1ZQoWPrW3nC0NizOhllgKbpZ0+UE7L VVcf808VsiYI68AeiFtu0kSOFCW1JvKbUCq1tQMBUJclP9hziBLpDryA5 IYFAdM4mgOi3M1aSYeIHHv0BUdcmWXkPS4KWm6lcM7vgqkQM9EaK3iH6x n2N6heh1yYxdVZDem6IfmjlO7wqowFtvKD9rGE9IO8GcJRgJH8aIFmCtH ZOggz80+0IU6q3L/Vdm1Uoq+0Dk2SwMJ7RDHNqnJ08AxUtYB3l6/i7q2D H+2Ni3IKim1zTBfPRxtm/g11N9aOYhY6by63TkBVUI0zcj2G3NmQNEiH4 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="380147094" X-IronPort-AV: E=Sophos;i="5.99,284,1677571200"; d="scan'208";a="380147094" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="652466710" X-IronPort-AV: E=Sophos;i="5.99,284,1677571200"; d="scan'208";a="652466710" From: Ira Weiny Date: Wed, 17 May 2023 19:45:54 -0700 Subject: [PATCH RFC 1/5] hw/cxl: Use define for build bug detection MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230517-rfc-type2-dev-v1-1-6eb2e470981b@intel.com> References: <20230517-rfc-type2-dev-v1-0-6eb2e470981b@intel.com> In-Reply-To: <20230517-rfc-type2-dev-v1-0-6eb2e470981b@intel.com> To: Jonathan Cameron Cc: qemu-devel@nongnu.org, linux-cxl@vger.kernel.org, Dave Jiang , Dan Williams , Ira Weiny X-Mailer: b4 0.13-dev-9a8cd X-Developer-Signature: v=1; a=ed25519-sha256; t=1684377956; l=1245; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=ALosJLPeK/xQ//Ur5NIceXWhZEbxkQaR0DQfbRf0RQM=; b=PTXLvgQFzxf6kFAXs/JRAWGbNfCHUPHulVnutVi+rrKIFhXkSG47HH5dDRPWhMLgGJcr8nGGR KT5/B7ZTijJDdHPdhFyfIS7WU2ze14Xt2rLktKwvF3c8GLqVY5beLQx X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= 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=192.55.52.88; envelope-from=ira.weiny@intel.com; helo=mga01.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H3=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 @intel.com) X-ZM-MESSAGEID: 1684378019416100004 Magic numbers can be confusing. Use the range size define for CXL.cachemem rather than a magic number. Update/add spec references. Signed-off-by: Ira Weiny --- include/hw/cxl/cxl_component.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index 52b6a2d67f40..bca2b756c202 100644 --- a/include/hw/cxl/cxl_component.h +++ b/include/hw/cxl/cxl_component.h @@ -10,7 +10,7 @@ #ifndef CXL_COMPONENT_H #define CXL_COMPONENT_H =20 -/* CXL 2.0 - 8.2.4 */ +/* CXL 3.0 - 8.2.3 */ #define CXL2_COMPONENT_IO_REGION_SIZE 0x1000 #define CXL2_COMPONENT_CM_REGION_SIZE 0x1000 #define CXL2_COMPONENT_BLOCK_SIZE 0x10000 @@ -173,7 +173,9 @@ HDM_DECODER_INIT(3); (CXL_IDE_REGISTERS_OFFSET + CXL_IDE_REGISTERS_SIZE) #define CXL_SNOOP_REGISTERS_SIZE 0x8 =20 -QEMU_BUILD_BUG_MSG((CXL_SNOOP_REGISTERS_OFFSET + CXL_SNOOP_REGISTERS_SIZE)= >=3D 0x1000, +/* CXL 3.0 8.2.3 Table 8-21 */ +QEMU_BUILD_BUG_MSG((CXL_SNOOP_REGISTERS_OFFSET + + CXL_SNOOP_REGISTERS_SIZE) >=3D CXL2_COMPONENT_CM_REGIO= N_SIZE, "No space for registers"); =20 typedef struct component_registers { --=20 2.40.0 From nobody Sat May 18 15:08:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1684378017; cv=none; d=zohomail.com; s=zohoarc; b=AIqe5tdeh65R7vb0S5vjicvR2XEqqWN+6qJgMqpMeeVnpHa1Gya9ctXBZ+qcWKLecP/LVR61xI2SJQPLVAIhHk5/YA/d+QUhz1N0001CMvTYE/Z2BYpNM28+x1wtezIiaGLDTYrNs6lMAgGvKOBD4+gXC5EzuuabErEJctLIrvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684378017; h=Content-Type: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=wS4dJU0z63DcX1pF3+lIPOy4ioA0jv7nFod649+Eu/A=; b=e3pH9PwLY6CtkO8utEU1lgz6nH4dv7VHFM/5ENF5B0ZZnbMksr6QQ8NTqWuWjWVnemzhrkeFRjXtVf4cbBkW8UnQDY4Ya5qdU2ZBspPdpqpdO8k/HzykBERTB37bHa/KpF7m2WV2kArul8m7Mu9GZpJNKdPljRfk5B8mTnSxBXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1684378017789885.4286223870845; Wed, 17 May 2023 19:46:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzTee-0005Dq-8V; Wed, 17 May 2023 22:46:12 -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 1pzTeb-0005Ag-I0 for qemu-devel@nongnu.org; Wed, 17 May 2023 22:46:09 -0400 Received: from mga01.intel.com ([192.55.52.88]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzTeY-0008FP-8I for qemu-devel@nongnu.org; Wed, 17 May 2023 22:46:09 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 19:46:02 -0700 Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.209.143.168]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 19:46:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684377966; x=1715913966; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=fgYFIBYZiC7VkXbsH0IZVBAWLK9AVSYJozqW9Xe6I5s=; b=Rf5cvFu8arEAdIccKHrfuuEIjN5qQjLkSJbD/coj2LM4pRkO2N53WwGN ojd93k/SKLlXkivuWIBVyGt4Do26uKhkVgbO/p7Vw1vp3/s3eeurS5enI rDASgNfOsvYKvsjN9SOtkUYWHbGV1f41qsMZsAlIu3Xa38yiVYtfJ8mYE nsn1T8VYEZ5uS7zu9mPmss/QpEOtPvocS3jTswCSXAJrAFDgQTGLgs+qj KuemfgfhnQCy6bYfDCr/IHDcQxsPluwJLPan/jBgN7l8QpDLQCDnPeSVq FrUA0YUYTw31YD19zh6FM0498/Xn+kwW5UDlWvz1ts+APWXuDypK5GP5u g==; X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="380147102" X-IronPort-AV: E=Sophos;i="5.99,284,1677571200"; d="scan'208";a="380147102" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="652466723" X-IronPort-AV: E=Sophos;i="5.99,284,1677571200"; d="scan'208";a="652466723" From: Ira Weiny Date: Wed, 17 May 2023 19:45:55 -0700 Subject: [PATCH RFC 2/5] hw/cxl: Refactor component register initialization MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230517-rfc-type2-dev-v1-2-6eb2e470981b@intel.com> References: <20230517-rfc-type2-dev-v1-0-6eb2e470981b@intel.com> In-Reply-To: <20230517-rfc-type2-dev-v1-0-6eb2e470981b@intel.com> To: Jonathan Cameron Cc: qemu-devel@nongnu.org, linux-cxl@vger.kernel.org, Dave Jiang , Dan Williams , Ira Weiny X-Mailer: b4 0.13-dev-9a8cd X-Developer-Signature: v=1; a=ed25519-sha256; t=1684377956; l=7352; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=fgYFIBYZiC7VkXbsH0IZVBAWLK9AVSYJozqW9Xe6I5s=; b=SW7kGCKggTN6hR3Zz1KBGJtDWJ6DutD7NzX+M9yuDiSMekVRqQFSqEyQRFrh93NOuHDLpOJLX 8aDLH5TsRMlCHn9+7wyp1Yo19PYUS2SHVYntsoWDtPqMIL13cQzaoBs X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= 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=192.55.52.88; envelope-from=ira.weiny@intel.com; helo=mga01.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H3=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 @intel.com) X-ZM-MESSAGEID: 1684378019359100003 CXL 3.0 8.2.4 Table 8-22 defines which capabilities are mandatory, not permitted, or optional for each type of device. cxl_component_register_init_common() uses a rather odd 'fall through' mechanism to define each component register set. This assumes that any device or capability being added builds on the previous devices capabilities. This is not true as there are mutually exclusive capabilities defined. For example, downstream ports can not have snoop but it can have Back Invalidate capable decoders. Refactor this code to make it easier to add individual capabilities as defined by a device type. Any capability which is not specified by the type is left NULL'ed out which complies with the packed nature of the register array. Update all spec references to 3.0. No functional changes should be seen with this patch. Signed-off-by: Ira Weiny --- hw/cxl/cxl-component-utils.c | 73 ++++++++++++++++----------------------= ---- include/hw/cxl/cxl_component.h | 36 ++++++++++++++------- 2 files changed, 52 insertions(+), 57 deletions(-) diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index 0e23e132ed3a..7949d12b7351 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -198,43 +198,19 @@ void cxl_component_register_init_common(uint32_t *reg= _state, uint32_t *write_msk { int caps =3D 0; =20 - /* - * In CXL 2.0 the capabilities required for each CXL component are suc= h that, - * with the ordering chosen here, a single number can be used to define - * which capabilities should be provided. - */ - switch (type) { - case CXL2_DOWNSTREAM_PORT: - case CXL2_DEVICE: - /* RAS, Link */ - caps =3D 2; - break; - case CXL2_UPSTREAM_PORT: - case CXL2_TYPE3_DEVICE: - case CXL2_LOGICAL_DEVICE: - /* + HDM */ - caps =3D 3; - break; - case CXL2_ROOT_PORT: - /* + Extended Security, + Snoop */ - caps =3D 5; - break; - default: - abort(); - } - memset(reg_state, 0, CXL2_COMPONENT_CM_REGION_SIZE); =20 /* CXL Capability Header Register */ ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, ID, 1); ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, VERSION, 1); ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, CACHE_MEM_VERSION, = 1); - ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, ARRAY_SIZE, caps); =20 #define init_cap_reg(reg, id, version) = \ - QEMU_BUILD_BUG_ON(CXL_##reg##_REGISTERS_OFFSET =3D=3D 0); = \ + QEMU_BUILD_BUG_ON(CXL_##reg##_CAP_HDR_IDX =3D=3D 0); = \ do { = \ - int which =3D R_CXL_##reg##_CAPABILITY_HEADER; = \ + int which =3D CXL_##reg##_CAP_HDR_IDX; = \ + if (CXL_##reg##_CAP_HDR_IDX > caps) = \ + caps =3D CXL_##reg##_CAP_HDR_IDX; = \ reg_state[which] =3D FIELD_DP32(reg_state[which], = \ CXL_##reg##_CAPABILITY_HEADER, ID, i= d); \ reg_state[which] =3D = \ @@ -245,25 +221,32 @@ void cxl_component_register_init_common(uint32_t *reg= _state, uint32_t *write_msk CXL_##reg##_REGISTERS_OFFSET); = \ } while (0) =20 - init_cap_reg(RAS, 2, 2); - ras_init_common(reg_state, write_msk); - - init_cap_reg(LINK, 4, 2); - - if (caps < 3) { - return; - } - - init_cap_reg(HDM, 5, 1); - hdm_init_common(reg_state, write_msk, type); - - if (caps < 5) { - return; + /* CXL 3.0 8.2.4 Table 8-22 */ + switch (type) { + case CXL2_ROOT_PORT: + /* + Extended Security, + Snoop */ + init_cap_reg(EXTSEC, 6, 1); + init_cap_reg(SNOOP, 8, 1); + /* FALL THROUGH */ + case CXL2_UPSTREAM_PORT: + case CXL2_TYPE3_DEVICE: + case CXL2_LOGICAL_DEVICE: + /* + HDM */ + init_cap_reg(HDM, 5, 1); + hdm_init_common(reg_state, write_msk, type); + /* FALL THROUGH */ + case CXL2_DOWNSTREAM_PORT: + case CXL2_DEVICE: + /* RAS, Link */ + init_cap_reg(RAS, 2, 2); + ras_init_common(reg_state, write_msk); + init_cap_reg(LINK, 4, 2); + break; + default: + abort(); } =20 - init_cap_reg(EXTSEC, 6, 1); - init_cap_reg(SNOOP, 8, 1); - + ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, ARRAY_SIZE, caps); #undef init_cap_reg } =20 diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index bca2b756c202..7c08c02c5e9d 100644 --- a/include/hw/cxl/cxl_component.h +++ b/include/hw/cxl/cxl_component.h @@ -31,29 +31,41 @@ enum reg_type { }; =20 /* - * Capability registers are defined at the top of the CXL.cache/mem region= and - * are packed. For our purposes we will always define the caps in the same - * order. - * CXL 2.0 - 8.2.5 Table 142 for details. + * CXL 3.0 - 8.2.4 Table 8-22 and 8-23 + * + * Capability registers are defined at the top of the CXL.cache/mem region. + * They are defined to be packed and at variable offsets. However, NULL + * capabilities can be added to the packed array. To facilitate easier ac= cess + * within the QEMU code, define these at specified offsets. Then NULL out= any + * capabilities for devices which don't (or can't) have a particular capab= ility + * (see cxl_component_register_init_common). NULL capabilities are to be + * ignored by software. + * + * 'offsets' are based on index's which can then be used to report the arr= ay + * size in CXL Capability Header Register (index/offset 0). + * + * See CXL 3.0 Table 8-25 for an example of allowing a 'NULL' header. */ =20 -/* CXL 2.0 - 8.2.5.1 */ +/* CXL 3.0 - 8.2.4.1 */ REG32(CXL_CAPABILITY_HEADER, 0) FIELD(CXL_CAPABILITY_HEADER, ID, 0, 16) FIELD(CXL_CAPABILITY_HEADER, VERSION, 16, 4) FIELD(CXL_CAPABILITY_HEADER, CACHE_MEM_VERSION, 20, 4) FIELD(CXL_CAPABILITY_HEADER, ARRAY_SIZE, 24, 8) =20 -#define CXLx_CAPABILITY_HEADER(type, offset) \ - REG32(CXL_##type##_CAPABILITY_HEADER, offset) \ +/* CXL 3.0 - 8.2.4.2 on... */ +#define CXLx_CAPABILITY_HEADER(type, idx) \ + enum { CXL_##type##_CAP_HDR_IDX =3D idx }; \ + REG32(CXL_##type##_CAPABILITY_HEADER, (idx * 0x4)) \ FIELD(CXL_##type##_CAPABILITY_HEADER, ID, 0, 16) \ FIELD(CXL_##type##_CAPABILITY_HEADER, VERSION, 16, 4) \ FIELD(CXL_##type##_CAPABILITY_HEADER, PTR, 20, 12) -CXLx_CAPABILITY_HEADER(RAS, 0x4) -CXLx_CAPABILITY_HEADER(LINK, 0x8) -CXLx_CAPABILITY_HEADER(HDM, 0xc) -CXLx_CAPABILITY_HEADER(EXTSEC, 0x10) -CXLx_CAPABILITY_HEADER(SNOOP, 0x14) +CXLx_CAPABILITY_HEADER(RAS, 1) +CXLx_CAPABILITY_HEADER(LINK, 2) +CXLx_CAPABILITY_HEADER(HDM, 3) +CXLx_CAPABILITY_HEADER(EXTSEC, 4) +CXLx_CAPABILITY_HEADER(SNOOP, 5) =20 /* * Capability structures contain the actual registers that the CXL compone= nt --=20 2.40.0 From nobody Sat May 18 15:08:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1684378043; cv=none; d=zohomail.com; s=zohoarc; b=R4strbaDk1HOl9p/oxSI1Qs+xhrCzlz0ewXdo0GSIpD2b6uGvqsPY62pcaKdw5ylaMrxNDo6+ayPQAVJyIH7KDxx7C/yCyqmeXeXNdUQqy0+DmaOno5v0vZWRaxUsjF3j0A4zPOm0eU6gUn5QWT0vqhXVbyMh4ywX5F7Qknc0vQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684378043; h=Content-Type: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=djjLAVqAA3Ke/W2o3CX6ScDUohOel/MnDp+AOQHVxoM=; b=nx5zzGxYFE8cvaMuCw6GNcI81WXKUhAi+f8B0WYmlhsnwzEBLfxjwwVDwzYLDt+Q0rRKA9q+bE68KZEVku0hNn83HdmeySkhTZXKxO64Lp5u1tQCV/ECz9UNRdAwOEz1XroFyaIStuXanta3qZZ0m1OV1HAaRoPU/+kvWjf6om8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1684378043721626.4498889721647; Wed, 17 May 2023 19:47:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzTf2-0005NH-2G; Wed, 17 May 2023 22:46:36 -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 1pzTef-0005EM-U4 for qemu-devel@nongnu.org; Wed, 17 May 2023 22:46:26 -0400 Received: from mga01.intel.com ([192.55.52.88]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzTea-0008F5-6S for qemu-devel@nongnu.org; Wed, 17 May 2023 22:46:13 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 19:46:04 -0700 Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.209.143.168]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 19:46:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684377972; x=1715913972; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=Zvl4Us5nFwXM+K5uC8NSDV+qsek+5uIPfbxF6GEL2Jw=; b=G5Ay7GXO/Yl9KIwtxa0ynVuJrTHQxAgFWRvNvpCk3dMKaGqPZTjF77oM QYhdjoIrfUmyScEwzBo3EuVgDzaRvjbj/zjLvik1H+W/ReV3OpwZIinOH +vbBvbFCi6UmG3/mODOsP0Rk/fay4yNlpRf9C/oNANGk+dicgp8T8TT3u V0r4aIGoTELy8bqRbzMoozYqnP7ytfRX1dJ9vd74KRqVfw2GcMrU5Miec aRKmdMOZIWe5td011BZ2W1EFxjeU0DdDAAOKKmOT3Hp/6jasxIbpHAEoL rEWKT5VJes4HffwBafwxfrjnPUXe/dx3vTkjRFl1DtV3pBmbS7ZduezAN w==; X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="380147107" X-IronPort-AV: E=Sophos;i="5.99,284,1677571200"; d="scan'208";a="380147107" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="652466733" X-IronPort-AV: E=Sophos;i="5.99,284,1677571200"; d="scan'208";a="652466733" From: Ira Weiny Date: Wed, 17 May 2023 19:45:56 -0700 Subject: [PATCH RFC 3/5] hw/cxl: Derive a CXL accelerator device from Type-3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230517-rfc-type2-dev-v1-3-6eb2e470981b@intel.com> References: <20230517-rfc-type2-dev-v1-0-6eb2e470981b@intel.com> In-Reply-To: <20230517-rfc-type2-dev-v1-0-6eb2e470981b@intel.com> To: Jonathan Cameron Cc: qemu-devel@nongnu.org, linux-cxl@vger.kernel.org, Dave Jiang , Dan Williams , Ira Weiny X-Mailer: b4 0.13-dev-9a8cd X-Developer-Signature: v=1; a=ed25519-sha256; t=1684377956; l=4453; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=Zvl4Us5nFwXM+K5uC8NSDV+qsek+5uIPfbxF6GEL2Jw=; b=t6ps/6MKxcDQEG2REfSRjLaEhVncO5i5rhmh8QiXSfeH4Z7SDLmaKDpZXI5Xv19k8ydbyl7uA GyZTLf0eDebDoXj3C3zJZIv+0RLg919zQo6QcqKHakcGW/zC8UkERx6 X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= 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=192.55.52.88; envelope-from=ira.weiny@intel.com; helo=mga01.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H3=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 @intel.com) X-ZM-MESSAGEID: 1684378045447100001 It is desirable to have a test accelerator device to present various accelerator features such as Back-Invalidate (BI) registers to OS software for testing. BI accelerator devices require memory that can be easily modeled as a sub-class of Type-3 device. Derive 'cxl-accel' from cxl-type3. Add documentation for such a device. Follow on patches will add BI registers and other simulation of the accelerator device. Adding devices qemu can be done with the following example: ... -device cxl-accel,bus=3Dsw0p0,volatile-memdev=3Dcxl-ac-mem5,id=3Dcxl-dev5= ,sn=3D0xCAFE0005 ... Not-Yet-Signed-off-by: Ira Weiny --- The device ID and class code are completely made up by me. As discussed in the last community call perhaps these could be declared in some more official capacity? --- docs/system/devices/cxl.rst | 11 +++++++++++ hw/mem/cxl_type3.c | 28 ++++++++++++++++++++++++++++ include/hw/cxl/cxl_device.h | 16 ++++++++++++++++ include/hw/pci/pci_ids.h | 1 + 4 files changed, 56 insertions(+) diff --git a/docs/system/devices/cxl.rst b/docs/system/devices/cxl.rst index 95900252c56a..5bc931be44b3 100644 --- a/docs/system/devices/cxl.rst +++ b/docs/system/devices/cxl.rst @@ -321,6 +321,17 @@ A very simple setup with just one directly attached CX= L Type 3 Volatile Memory d -device cxl-type3,bus=3Droot_port13,volatile-memdev=3Dvmem0,id=3Dcxl-vme= m0 \ -M cxl-fmw.0.targets.0=3Dcxl.1,cxl-fmw.0.size=3D4G =20 +A very simple setup with just one directly attached CXL Type 2 Volatile Me= mory +Accelerator device:: + + qemu-system-x86_64 -M q35,cxl=3Don -m 4G,maxmem=3D8G,slots=3D8 -smp 4 \ + ... + -object memory-backend-ram,id=3Dvmem0,share=3Don,size=3D256M \ + -device pxb-cxl,bus_nr=3D12,bus=3Dpcie.0,id=3Dcxl.1 \ + -device cxl-rp,port=3D0,bus=3Dcxl.1,id=3Droot_port13,chassis=3D0,slot=3D= 2 \ + -device cxl-accel,bus=3Droot_port13,volatile-memdev=3Dvmem0,id=3Dcxl-acc= el0 \ + -M cxl-fmw.0.targets.0=3Dcxl.1,cxl-fmw.0.size=3D4G + The same volatile setup may optionally include an LSA region:: =20 qemu-system-aarch64 -M virt,gic-version=3D3,cxl=3Don -m 4g,maxmem=3D8G,s= lots=3D8 -cpu max \ diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 3e63dbd83551..c7eafd76d1ea 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1691,3 +1691,31 @@ static void ct3d_registers(void) } =20 type_init(ct3d_registers); + +static void cxl_accel_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + PCIDeviceClass *pc =3D PCI_DEVICE_CLASS(oc); + + pc->class_id =3D PCI_CLASS_CXL_QEMU_ACCEL; + pc->vendor_id =3D PCI_VENDOR_ID_INTEL; + pc->device_id =3D 0xd94; /* LVF for now */ + pc->revision =3D 1; + + dc->desc =3D "CXL Accelerator Device (Type 2)"; +} + +static const TypeInfo cxl_accel_dev_info =3D { + .name =3D TYPE_CXL_ACCEL, + .parent =3D TYPE_CXL_TYPE3, + .class_size =3D sizeof(struct CXLAccelClass), + .class_init =3D cxl_accel_class_init, + .instance_size =3D sizeof(CXLAccelDev), +}; + +static void cxl_accel_dev_registers(void) +{ + type_register_static(&cxl_accel_dev_info); +} + +type_init(cxl_accel_dev_registers); diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index cd7f28dba884..f7f6688ee6e2 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -432,6 +432,22 @@ struct CXLType3Class { bool (*set_cacheline)(CXLType3Dev *ct3d, uint64_t dpa_offset, uint8_t = *data); }; =20 +/* + * Accel devices are a type3 device but with additional functionality. + */ +struct CXLAccelDev { + /* Private: Must be first */ + CXLType3Dev parent_obj; +}; + +struct CXLAccelClass { + /* Private: Must be first */ + CXLType3Class parent_class; +}; + +#define TYPE_CXL_ACCEL "cxl-accel" +OBJECT_DECLARE_TYPE(CXLAccelDev, CXLAccelClass, CXL_ACCEL) + struct CSWMBCCIDev { PCIDevice parent_obj; CXLComponentState cxl_cstate; diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h index e4386ebb2038..2dbf350ebba4 100644 --- a/include/hw/pci/pci_ids.h +++ b/include/hw/pci/pci_ids.h @@ -54,6 +54,7 @@ #define PCI_CLASS_MEMORY_RAM 0x0500 #define PCI_CLASS_MEMORY_FLASH 0x0501 #define PCI_CLASS_MEMORY_CXL 0x0502 +#define PCI_CLASS_CXL_QEMU_ACCEL 0x0503 #define PCI_CLASS_MEMORY_OTHER 0x0580 =20 #define PCI_BASE_CLASS_BRIDGE 0x06 --=20 2.40.0 From nobody Sat May 18 15:08:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1684378039; cv=none; d=zohomail.com; s=zohoarc; b=LdJCY8gfmMgh8XVMZYCiRl9b8agNAaLQ0XBIYdZPAKAxuB+ajDREFnJo8YYuxX7VOuziRJxMuN0jaSmiynKjM6a+ia08rjJLAqX5wsqbxTXXBTVWNEFCNMpi0YZI0lRbHmt+i9BkETQlQ7WHLHqYIyN/NkUJ3E3mGp/SX07YKc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684378039; h=Content-Type: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=VPJMXjb/Gd3kmZV/rbdvHE0CPA7CWsXg/i/1nqVFlSc=; b=dN8UzG80tjmV/2y8q0BGHZVehMaSnqT8ez5nQLY/AV6aAwIoI6nhI0pdsZ+G+yyZWOMn/M5l2h97C37Cq/ssY3D/OntS61jr6BX5TWAu8PLTd13AzlsU9TXFoRpF6VGqTXgkK9gSurs12SV0Nm+WYEsTKmVSZi+b6fJYW6r6HoM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1684378039312143.308525456741; Wed, 17 May 2023 19:47:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzTf1-0005LU-Js; Wed, 17 May 2023 22:46:35 -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 1pzTeg-0005EO-IM for qemu-devel@nongnu.org; Wed, 17 May 2023 22:46:26 -0400 Received: from mga01.intel.com ([192.55.52.88]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzTee-0008FG-Ln for qemu-devel@nongnu.org; Wed, 17 May 2023 22:46:14 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 19:46:06 -0700 Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.209.143.168]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 19:46:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684377972; x=1715913972; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=46y0FaBxziwuSbTAR4YOkMaktxaMBddzA2VrCi6VZS8=; b=VNpv8Akb3diDsKpX0e6kuYE7BDprO7avY8MHT4BdRK/PCRcwBbg9ajrE Iqppyk1zRaqus2yYHmoNBrW+LSAFiKtYyOaYkZ4+JjyDvrt//L/1wpglo 402EaTQgY91aNaUT3CEtg0qmYs2HjUBUGmThlxjolP+2SpF0ChTx5iZmQ JvKyqqb8WDjvn0U/6HyV1ndMk5dOLhhaAvJEGdcNyEtIHwbDHNnbuYByl rgbVa10TuqXw3AYIaWUNFds19TERzr/kpnpdB0UTmxu69yJjsQnG+cm/F OHX0X1aoIARERhdXxZcmuQe0ketg26PvzK18eWHoIgFr1cVC84Fexr84f w==; X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="380147110" X-IronPort-AV: E=Sophos;i="5.99,284,1677571200"; d="scan'208";a="380147110" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="652466741" X-IronPort-AV: E=Sophos;i="5.99,284,1677571200"; d="scan'208";a="652466741" From: Ira Weiny Date: Wed, 17 May 2023 19:45:57 -0700 Subject: [PATCH RFC 4/5] hw/cxl/accel: Add Back-Invalidate decoder capbility structure MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230517-rfc-type2-dev-v1-4-6eb2e470981b@intel.com> References: <20230517-rfc-type2-dev-v1-0-6eb2e470981b@intel.com> In-Reply-To: <20230517-rfc-type2-dev-v1-0-6eb2e470981b@intel.com> To: Jonathan Cameron Cc: qemu-devel@nongnu.org, linux-cxl@vger.kernel.org, Dave Jiang , Dan Williams , Ira Weiny X-Mailer: b4 0.13-dev-9a8cd X-Developer-Signature: v=1; a=ed25519-sha256; t=1684377956; l=3758; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=46y0FaBxziwuSbTAR4YOkMaktxaMBddzA2VrCi6VZS8=; b=Tkagk9parcBDGYn7JPISiNLaEp7zYK69R4NQPXePCpSdSOpb2z/s+4AHvAKQ/quxnhs3APqae lCSEEGALSI9D2QWgJyqJl/rTjUs087YuKIgDiLdsbb2DJ8AVIAj1DyX X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= 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=192.55.52.88; envelope-from=ira.weiny@intel.com; helo=mga01.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H3=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 @intel.com) X-ZM-MESSAGEID: 1684378039829100001 The presence of the Back-Invalidate (BI) decoder capability structure indicates a CXL downstream port, root port, or device supports the BI messages. Add the BI capability structure to the accelerator device. Not-Yet-Signed-off-by: Ira Weiny --- hw/cxl/cxl-component-utils.c | 5 +++++ hw/mem/cxl_type3.c | 11 +++++++++++ include/hw/cxl/cxl_component.h | 11 +++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index 7949d12b7351..a9efa252b4ae 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -228,6 +228,7 @@ void cxl_component_register_init_common(uint32_t *reg_s= tate, uint32_t *write_msk init_cap_reg(EXTSEC, 6, 1); init_cap_reg(SNOOP, 8, 1); /* FALL THROUGH */ + case CXL3_TYPE2_DEVICE: case CXL2_UPSTREAM_PORT: case CXL2_TYPE3_DEVICE: case CXL2_LOGICAL_DEVICE: @@ -246,6 +247,10 @@ void cxl_component_register_init_common(uint32_t *reg_= state, uint32_t *write_msk abort(); } =20 + if (type =3D=3D CXL3_TYPE2_DEVICE) { + init_cap_reg(BI_DECODER, 12, 1); + } + ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, ARRAY_SIZE, caps); #undef init_cap_reg } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index c7eafd76d1ea..95fdaaa18f37 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1692,6 +1692,16 @@ static void ct3d_registers(void) =20 type_init(ct3d_registers); =20 +static void accel_reset(DeviceState *dev) +{ + CXLAccelDev *acceld =3D CXL_ACCEL(dev); + uint32_t *reg_state =3D acceld->parent_obj.cxl_cstate.crb.cache_mem_re= gisters; + uint32_t *write_msk =3D acceld->parent_obj.cxl_cstate.crb.cache_mem_re= gs_write_mask; + + cxl_component_register_init_common(reg_state, write_msk, CXL3_TYPE2_DE= VICE); + cxl_device_register_init_common(&acceld->parent_obj.cxl_dstate); +} + static void cxl_accel_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -1703,6 +1713,7 @@ static void cxl_accel_class_init(ObjectClass *oc, voi= d *data) pc->revision =3D 1; =20 dc->desc =3D "CXL Accelerator Device (Type 2)"; + dc->reset =3D accel_reset; } =20 static const TypeInfo cxl_accel_dev_info =3D { diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index 7c08c02c5e9d..a5b5512aed94 100644 --- a/include/hw/cxl/cxl_component.h +++ b/include/hw/cxl/cxl_component.h @@ -28,6 +28,7 @@ enum reg_type { CXL2_UPSTREAM_PORT, CXL2_DOWNSTREAM_PORT, CXL3_SWITCH_MAILBOX_CCI, + CXL3_TYPE2_DEVICE, }; =20 /* @@ -66,6 +67,7 @@ CXLx_CAPABILITY_HEADER(LINK, 2) CXLx_CAPABILITY_HEADER(HDM, 3) CXLx_CAPABILITY_HEADER(EXTSEC, 4) CXLx_CAPABILITY_HEADER(SNOOP, 5) +CXLx_CAPABILITY_HEADER(BI_DECODER, 6) =20 /* * Capability structures contain the actual registers that the CXL compone= nt @@ -185,9 +187,14 @@ HDM_DECODER_INIT(3); (CXL_IDE_REGISTERS_OFFSET + CXL_IDE_REGISTERS_SIZE) #define CXL_SNOOP_REGISTERS_SIZE 0x8 =20 +/* CXL 3.0 8.2.4.26 - CXL BI Decoder Capability Structure */ +#define CXL_BI_DECODER_REGISTERS_OFFSET \ + (CXL_SNOOP_REGISTERS_OFFSET + CXL_SNOOP_REGISTERS_SIZE) +#define CXL_BI_DECODER_REGISTERS_SIZE 0xC + /* CXL 3.0 8.2.3 Table 8-21 */ -QEMU_BUILD_BUG_MSG((CXL_SNOOP_REGISTERS_OFFSET + - CXL_SNOOP_REGISTERS_SIZE) >=3D CXL2_COMPONENT_CM_REGIO= N_SIZE, +QEMU_BUILD_BUG_MSG((CXL_BI_DECODER_REGISTERS_OFFSET + + CXL_BI_DECODER_REGISTERS_SIZE) >=3D CXL2_COMPONENT_CM_= REGION_SIZE, "No space for registers"); =20 typedef struct component_registers { --=20 2.40.0 From nobody Sat May 18 15:08:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1684378002; cv=none; d=zohomail.com; s=zohoarc; b=fVoMkQs8RWGF5Yld0kfIOwBGPh7Oaf3v7T/CNJFHO8ylS+fdcuoL/YXlXaP390LDZ0oe0YHfaVGwlnzUE+RVAXimCkLbPWBhJecE3zkTN09g3dMpugz4rkbWmksuZOlZKr0kHubKzMoDm9dNjq4HIQDwzixR1EmyaEjmgwulsRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684378002; h=Content-Type: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=PyUTZo+fbXp6tDlsSyFlIhh8CyFnIqt/UWiXtqKLhaU=; b=WfyxEXGLQlx/AWwJNfCWG96CepeA3r7aitlJB2bX0NSGweQNX2NAcJfWmvS3+VGWUcHRL4WZQFtwX/UaFV2P/aoHjUtiEK3srBsER0jUaifzNieIuwAg+4a5N9ckXqRNEY0YnkzSphlbzpfuDIBcHIiOzuzn402MnLDcKapFLtM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1684378002612409.02913893148116; Wed, 17 May 2023 19:46:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzTf1-0005LV-OI; Wed, 17 May 2023 22:46:35 -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 1pzTeh-0005ER-Rz for qemu-devel@nongnu.org; Wed, 17 May 2023 22:46:26 -0400 Received: from mga01.intel.com ([192.55.52.88]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzTeg-0008FP-5G for qemu-devel@nongnu.org; Wed, 17 May 2023 22:46:15 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 19:46:12 -0700 Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.209.143.168]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 19:46:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684377974; x=1715913974; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=+qdtcDX7aPtUFG16xTDOpRYYrPeh1b8whv2sXdCmkMg=; b=SwvVpAvsWgQWHh8D+wRgfUv4NkPf5ZAu30SaKKVqIXmAaC4NDW0F/ogG HsRpFpA5nggtGaWvCftFt4lO2JT4v5bwboeR1svsYZsd0Hdb5UXsycTUc Vih2hXaMy05gwx3IK6Qe1a7EhiHzTY3C/bZ0gO0orMHDn4OfD+eEeKX4B 3+nkdVe4AVswYuGwHHcyZdMv5DTl4960me9B879zdKoG2qfZMjSrlFRZY M96EKZk3w0Wg7GfE3bpQxYZ//fmul+zN3zZ2p/MD4Td8CUx/iOuZM0YK4 VFvumZCCpPWFFkEZQ7sDFjQg+BhCLm0cmQQWsvQ6n56qrwQBRacV63nXF g==; X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="380147116" X-IronPort-AV: E=Sophos;i="5.99,284,1677571200"; d="scan'208";a="380147116" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="652466748" X-IronPort-AV: E=Sophos;i="5.99,284,1677571200"; d="scan'208";a="652466748" From: Ira Weiny Date: Wed, 17 May 2023 19:45:58 -0700 Subject: [PATCH RFC 5/5] hw/cxl: Add UIO HDM decoder register fields MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230517-rfc-type2-dev-v1-5-6eb2e470981b@intel.com> References: <20230517-rfc-type2-dev-v1-0-6eb2e470981b@intel.com> In-Reply-To: <20230517-rfc-type2-dev-v1-0-6eb2e470981b@intel.com> To: Jonathan Cameron Cc: qemu-devel@nongnu.org, linux-cxl@vger.kernel.org, Dave Jiang , Dan Williams , Ira Weiny X-Mailer: b4 0.13-dev-9a8cd X-Developer-Signature: v=1; a=ed25519-sha256; t=1684377956; l=2286; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=+qdtcDX7aPtUFG16xTDOpRYYrPeh1b8whv2sXdCmkMg=; b=1qJL70bed0jThaHUc+ucsX3tY2DnXquwk6PxAVz4qUOpUvEduJBAk0C6X1XNMpJZ9VieRM+dh z7G4wmZ4T7NAM6KU+UIXl7us0rSNk2ByujqzAbOiftoX55N4kSxj3EO X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= 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=192.55.52.88; envelope-from=ira.weiny@intel.com; helo=mga01.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H3=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 @intel.com) X-ZM-MESSAGEID: 1684378003312100001 HDM decoders optionally support Unordered IO (UIO) access. Devices indicate UIO support by setting the capable bit. Software can then set up to UIO decoder count HDM's as UIO enabled when configuring the HDMs on the device. Define the UIO capable bit and decoder count. Default type 2 devices to support UIO for testing. Not-Yet-Signed-off-by: Ira Weiny --- hw/cxl/cxl-component-utils.c | 6 ++++++ include/hw/cxl/cxl_component.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index a9efa252b4ae..252b2beb2110 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -173,6 +173,12 @@ static void hdm_init_common(uint32_t *reg_state, uint3= 2_t *write_msk, ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, INTERLEAVE_256= B, 1); ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, INTERLEAVE_4K,= 1); ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, POISON_ON_ERR_= CAP, 0); + if (type =3D=3D CXL3_TYPE2_DEVICE) { + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, UIO_CAPABL= E, 1); + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, UIO_DECODE= R_CNT, + decoder_count); + } + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_GLOBAL_CONTROL, HDM_DECODER_ENABLE, 0); write_msk[R_CXL_HDM_DECODER_GLOBAL_CONTROL] =3D 0x3; diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index a5b5512aed94..7c24e699ef80 100644 --- a/include/hw/cxl/cxl_component.h +++ b/include/hw/cxl/cxl_component.h @@ -162,6 +162,8 @@ REG32(CXL_HDM_DECODER_CAPABILITY, CXL_HDM_REGISTERS_OFF= SET) FIELD(CXL_HDM_DECODER_CAPABILITY, INTERLEAVE_256B, 8, 1) FIELD(CXL_HDM_DECODER_CAPABILITY, INTERLEAVE_4K, 9, 1) FIELD(CXL_HDM_DECODER_CAPABILITY, POISON_ON_ERR_CAP, 10, 1) + FIELD(CXL_HDM_DECODER_CAPABILITY, UIO_CAPABLE, 13, 1) + FIELD(CXL_HDM_DECODER_CAPABILITY, UIO_DECODER_CNT, 16, 4) REG32(CXL_HDM_DECODER_GLOBAL_CONTROL, CXL_HDM_REGISTERS_OFFSET + 4) FIELD(CXL_HDM_DECODER_GLOBAL_CONTROL, POISON_ON_ERR_EN, 0, 1) FIELD(CXL_HDM_DECODER_GLOBAL_CONTROL, HDM_DECODER_ENABLE, 1, 1) --=20 2.40.0