Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp941767lql; Tue, 12 Mar 2024 02:41:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWWNEUEp5ftaGV8jKbqLdIvJ+MAr6Cn8KdnLKcmdf60RWA4bPbmrKj6dOlPSY0lZI0hCK0rxr+UxzM721/J6XqbU0xHkpm37/T3lsAgQQ== X-Google-Smtp-Source: AGHT+IFbaVsJBVRYIoNrlJd1pmI17w4MBebjLGXzAg3kkbgRIYtQzKHGN3BExzAafs3lkfVAdAaY X-Received: by 2002:a50:f61e:0:b0:566:4654:4fac with SMTP id c30-20020a50f61e000000b0056646544facmr6229941edn.5.1710236505503; Tue, 12 Mar 2024 02:41:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710236505; cv=pass; d=google.com; s=arc-20160816; b=RmWnwxDvgfJ/ciJzTefqxAUr1xnyl6Yon6Ik6cvfGF/qU6Y9DIvD+MTpHUBrvVC0SD TxI0oUfHSkk1GGuZqvCy+pQVWJJQpfJ3C3JPD6n4zzbYQBfeZ6kMwQEjQhJh18lZSKGt 3q2Bc0kyUx5EgX2asnhN/5lHkkLeNnlNqOl7I/4uc3XtFgPk0FgEJyBDfeyfSWiQb+ze QpURqcZ4FZTyUneIlSMNWfuGdI+WVRUOTFC53YYT6w1A0PWoo4OfBiccpxloNX0Ys0Vc NhyKd6dhm8ReQNFZyuBNhAmTre3Rh2vZnWcl3T5JWxvPknPLfZxco7gJAVhwjkm5Apai Hz7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=sGq9/OS66AvGvlNzWFK5jF+e/wG/3e8AEIa5hSEDHw4=; fh=OvrBd9fmSubORaJFQOA5e4CQSpzY1guZZwy0Bw2XnFY=; b=id9MQQT6MVHHTRZDl7e50mMafX+ck3A4x9wTCoEqoter2lU3f/60UaGpVv4OgMi5JX ZYDbqiDJOiQF2Pawly6PQO5xhEulT1yrJLlhwo2W3IseUbo2AIA2u2F8fZ/wCiFAkhBm F+fu2sZSLnsyldSBH2g3ExLrs91yy5nKmr2cN70mD4hO/WtNN3LLeiv6c4IiGHw/57Fv 0Eo093rVhEzE3gKVC16vMus7HBbKGdOGTqz99dP804z/2R4ofXNC2S6NZXFE3iC/9Yn4 Y1yhU93ZEopCBUON9kqsXJ/TbkBD7rZNG5O+7LG0Nb4xiCBKHEaT3W90j10qcuaJFBZ2 AdIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-100034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id eo5-20020a056402530500b0056830d7fd0asi3519815edb.74.2024.03.12.02.41.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 02:41:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-100034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0CEB01F23A66 for ; Tue, 12 Mar 2024 09:41:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D74047828B; Tue, 12 Mar 2024 09:41:35 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13AF278273; Tue, 12 Mar 2024 09:41:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710236495; cv=none; b=ZbTOulhdLw+++OtY683nKbzLHkEDoCNXrIW3FESjfrBDC8IJM8yQLJ3CyoctQavDA5YH8WuaL4+DT+FyU4Q9rvz+e1rqsOtepY9T3DdeRD+tJ1c/a//WkpObsnbfTKbFvpWfP/rNkH4KJd0S7y4H75RMORduz5ECfAW0nJLZax8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710236495; c=relaxed/simple; bh=9BVd3T4GZqlg+poIfhaoPYk3KkThuqvVtjsxrrpVzUg=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=nXsjDloJSJjTY1IYr81d91FJtZJfe9iTyfdcFrYgOo2ukmQqw19ry4ICQz/avYpvbtpPGC9V+phYCf4Wq8KpEjge7+eO3334C8ShFZ3aN/NWFnDOeg2DDTLr0X4o3bWuXI1m6DXx8GYb1Dl1S8XeIavYxCYu9AarsH7yPI10UVA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Tv7pW0sy4z688hZ; Tue, 12 Mar 2024 17:37:23 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (unknown [7.191.162.67]) by mail.maildlp.com (Postfix) with ESMTPS id 5738E140D1D; Tue, 12 Mar 2024 17:41:28 +0800 (CST) Received: from lhrpeml500006.china.huawei.com (7.191.161.198) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 12 Mar 2024 09:41:27 +0000 Received: from lhrpeml500006.china.huawei.com ([7.191.161.198]) by lhrpeml500006.china.huawei.com ([7.191.161.198]) with mapi id 15.01.2507.035; Tue, 12 Mar 2024 09:41:27 +0000 From: Shiju Jose To: fan CC: "linux-cxl@vger.kernel.org" , "linux-acpi@vger.kernel.org" , "linux-mm@kvack.org" , "dan.j.williams@intel.com" , "dave@stgolabs.net" , "Jonathan Cameron" , "dave.jiang@intel.com" , "alison.schofield@intel.com" , "vishal.l.verma@intel.com" , "ira.weiny@intel.com" , "linux-edac@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "david@redhat.com" , "Vilas.Sridharan@amd.com" , "leo.duran@amd.com" , "Yazen.Ghannam@amd.com" , "rientjes@google.com" , "jiaqiyan@google.com" , "tony.luck@intel.com" , "Jon.Grimm@amd.com" , "dave.hansen@linux.intel.com" , "rafael@kernel.org" , "lenb@kernel.org" , "naoya.horiguchi@nec.com" , "james.morse@arm.com" , "jthoughton@google.com" , "somasundaram.a@hpe.com" , "erdemaktas@google.com" , "pgonda@google.com" , "duenwen@google.com" , "mike.malvestuto@intel.com" , "gthelen@google.com" , "wschwartz@amperecomputing.com" , "dferguson@amperecomputing.com" , tanxiaofei , "Zengtao (B)" , "kangkang.shen@futurewei.com" , wanghuiqiang , Linuxarm Subject: RE: [RFC PATCH v7 03/12] cxl/mbox: Add SET_FEATURE mailbox command Thread-Topic: [RFC PATCH v7 03/12] cxl/mbox: Add SET_FEATURE mailbox command Thread-Index: AQHaZmXa2rf54FiQvUO4a7U5LboEzbEzJw+AgADJeeA= Date: Tue, 12 Mar 2024 09:41:27 +0000 Message-ID: References: <20240223143723.1574-1-shiju.jose@huawei.com> <20240223143723.1574-4-shiju.jose@huawei.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi Fan, >-----Original Message----- >From: fan >Sent: 11 March 2024 21:20 >To: Shiju Jose >Cc: linux-cxl@vger.kernel.org; linux-acpi@vger.kernel.org; linux- >mm@kvack.org; dan.j.williams@intel.com; dave@stgolabs.net; Jonathan >Cameron ; dave.jiang@intel.com; >alison.schofield@intel.com; vishal.l.verma@intel.com; ira.weiny@intel.com; >linux-edac@vger.kernel.org; linux-kernel@vger.kernel.org; david@redhat.com= ; >Vilas.Sridharan@amd.com; leo.duran@amd.com; Yazen.Ghannam@amd.com; >rientjes@google.com; jiaqiyan@google.com; tony.luck@intel.com; >Jon.Grimm@amd.com; dave.hansen@linux.intel.com; rafael@kernel.org; >lenb@kernel.org; naoya.horiguchi@nec.com; james.morse@arm.com; >jthoughton@google.com; somasundaram.a@hpe.com; >erdemaktas@google.com; pgonda@google.com; duenwen@google.com; >mike.malvestuto@intel.com; gthelen@google.com; >wschwartz@amperecomputing.com; dferguson@amperecomputing.com; >tanxiaofei ; Zengtao (B) = ; >kangkang.shen@futurewei.com; wanghuiqiang ; >Linuxarm >Subject: Re: [RFC PATCH v7 03/12] cxl/mbox: Add SET_FEATURE mailbox >command > >On Fri, Feb 23, 2024 at 10:37:14PM +0800, shiju.jose@huawei.com wrote: >> From: Shiju Jose >> >> Add support for SET_FEATURE mailbox command. >> >> CXL spec 3.1 section 8.2.9.6 describes optional device specific features= . >> CXL devices supports features with changeable attributes. >> The settings of a feature can be optionally modified using Set Feature >> command. >> >> Signed-off-by: Shiju Jose >> --- >> drivers/cxl/core/mbox.c | 67 >+++++++++++++++++++++++++++++++++++++++++ >> drivers/cxl/cxlmem.h | 30 ++++++++++++++++++ >> 2 files changed, 97 insertions(+) >> >> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index >> c078e62ea194..d1660bd20bdb 100644 >> --- a/drivers/cxl/core/mbox.c >> +++ b/drivers/cxl/core/mbox.c >> @@ -1366,6 +1366,73 @@ size_t cxl_get_feature(struct cxl_memdev_state >> *mds, } EXPORT_SYMBOL_NS_GPL(cxl_get_feature, CXL); >> >> +int cxl_set_feature(struct cxl_memdev_state *mds, >> + const uuid_t feat_uuid, u8 feat_version, >> + void *feat_data, size_t feat_data_size, >> + u8 feat_flag) >> +{ >> + struct cxl_memdev_set_feat_pi { >> + struct cxl_mbox_set_feat_hdr hdr; >> + u8 feat_data[]; >> + } __packed; >> + size_t data_in_size, data_sent_size =3D 0; >> + struct cxl_mbox_cmd mbox_cmd; >> + size_t hdr_size; >> + int rc =3D 0; >> + >> + struct cxl_memdev_set_feat_pi *pi __free(kfree) =3D >> + kmalloc(mds->payload_size, >GFP_KERNEL); >> + pi->hdr.uuid =3D feat_uuid; >> + pi->hdr.version =3D feat_version; >> + feat_flag &=3D ~CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK; >> + hdr_size =3D sizeof(pi->hdr); >> + /* >> + * Check minimum mbox payload size is available for >> + * the feature data transfer. >> + */ >> + if (hdr_size + 10 > mds->payload_size) > >Where does this magic number come from? This represents minimum extra number of bytes to be available in the mail b= ox for storing the actual feature data to work with multipart feature data tra= nsfers. This will be set as a definition in the next version and however not sure t= he best value to be set. > >Fan > >> + return -ENOMEM; >> + >> + if ((hdr_size + feat_data_size) <=3D mds->payload_size) { >> + pi->hdr.flags =3D cpu_to_le32(feat_flag | >> + >CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER); >> + data_in_size =3D feat_data_size; >> + } else { >> + pi->hdr.flags =3D cpu_to_le32(feat_flag | >> + >CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER); >> + data_in_size =3D mds->payload_size - hdr_size; >> + } >> + >> + do { >> + pi->hdr.offset =3D cpu_to_le16(data_sent_size); >> + memcpy(pi->feat_data, feat_data + data_sent_size, >data_in_size); >> + mbox_cmd =3D (struct cxl_mbox_cmd) { >> + .opcode =3D CXL_MBOX_OP_SET_FEATURE, >> + .size_in =3D hdr_size + data_in_size, >> + .payload_in =3D pi, >> + }; >> + rc =3D cxl_internal_send_cmd(mds, &mbox_cmd); >> + if (rc < 0) >> + return rc; >> + >> + data_sent_size +=3D data_in_size; >> + if (data_sent_size >=3D feat_data_size) >> + return 0; >> + >> + if ((feat_data_size - data_sent_size) <=3D (mds->payload_size - >hdr_size)) { >> + data_in_size =3D feat_data_size - data_sent_size; >> + pi->hdr.flags =3D cpu_to_le32(feat_flag | >> + >CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER); >> + } else { >> + pi->hdr.flags =3D cpu_to_le32(feat_flag | >> + >CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER); >> + } >> + } while (true); >> + >> + return rc; >> +} >> +EXPORT_SYMBOL_NS_GPL(cxl_set_feature, CXL); >> + >> int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len, >> struct cxl_region *cxlr) >> { >> diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index >> bcfefff062a6..a8d4104afa53 100644 >> --- a/drivers/cxl/cxlmem.h >> +++ b/drivers/cxl/cxlmem.h >> @@ -531,6 +531,7 @@ enum cxl_opcode { >> CXL_MBOX_OP_GET_LOG =3D 0x0401, >> CXL_MBOX_OP_GET_SUPPORTED_FEATURES =3D 0x0500, >> CXL_MBOX_OP_GET_FEATURE =3D 0x0501, >> + CXL_MBOX_OP_SET_FEATURE =3D 0x0502, >> CXL_MBOX_OP_IDENTIFY =3D 0x4000, >> CXL_MBOX_OP_GET_PARTITION_INFO =3D 0x4100, >> CXL_MBOX_OP_SET_PARTITION_INFO =3D 0x4101, >> @@ -773,6 +774,31 @@ struct cxl_mbox_get_feat_in { >> u8 selection; >> } __packed; >> >> +/* Set Feature CXL 3.1 Spec 8.2.9.6.3 */ >> +/* >> + * Set Feature input payload >> + * CXL rev 3.1 section 8.2.9.6.3 Table 8-101 */ >> +/* Set Feature : Payload in flags */ >> +#define CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK GENMASK(2, 0) >> +enum cxl_set_feat_flag_data_transfer { >> + CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER, >> + CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER, >> + CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER, >> + CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER, >> + CXL_SET_FEAT_FLAG_ABORT_DATA_TRANSFER, >> + CXL_SET_FEAT_FLAG_DATA_TRANSFER_MAX >> +}; >> +#define CXL_SET_FEAT_FLAG_DATA_SAVED_ACROSS_RESET BIT(3) >> + >> +struct cxl_mbox_set_feat_hdr { >> + uuid_t uuid; >> + __le32 flags; >> + __le16 offset; >> + u8 version; >> + u8 rsvd[9]; >> +} __packed; >> + >> /* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct >> cxl_mbox_poison_in { >> __le64 offset; >> @@ -912,6 +938,10 @@ size_t cxl_get_feature(struct cxl_memdev_state >*mds, >> size_t feat_out_size, >> size_t feat_out_min_size, >> enum cxl_get_feat_selection selection); >> +int cxl_set_feature(struct cxl_memdev_state *mds, >> + const uuid_t feat_uuid, u8 feat_version, >> + void *feat_data, size_t feat_data_size, >> + u8 feat_flag); >> int cxl_poison_state_init(struct cxl_memdev_state *mds); int >> cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len, >> struct cxl_region *cxlr); >> -- >> 2.34.1 >> Thanks, Shiju