From patchwork Fri Oct 25 17:13:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13851082 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C461D149D6 for ; Fri, 25 Oct 2024 17:14:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 578386B0099; Fri, 25 Oct 2024 13:14:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B17E6B009B; Fri, 25 Oct 2024 13:14:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32B706B009C; Fri, 25 Oct 2024 13:14:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0E2726B0099 for ; Fri, 25 Oct 2024 13:14:41 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DDF40140F05 for ; Fri, 25 Oct 2024 17:14:19 +0000 (UTC) X-FDA: 82712773122.27.E35A3E4 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf12.hostedemail.com (Postfix) with ESMTP id 873B340016 for ; Fri, 25 Oct 2024 17:14:29 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729876438; a=rsa-sha256; cv=none; b=8roURmXyHPt1miZ2txLV5Dxi0S+ut0hcZlPT+bgYC/IhQhaq1F4xIhKtGycKGpboStVSs6 sK5JPnVrjF7/Cbou91XvBECv7WOXwffghlyuykP/tjegGIqASLyRGsvWckSO9JMIdQ+AKh oOPAWpl9yTbi1FSe53nZHdnrOZHY1l8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729876438; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4vfhGgDkLXVic4Y39cG0WRVw5tEjKwNc0GmRh+N8AzA=; b=sqRSz3xJUS5xUsmVbsZSMHrBkN8TbYT+1nqnoBDEDPjfYiWIMhtJWtwI3NB7j4me3BJ3qS JFSGKXQyka+tcTXvva/5Wth56HTjX85RWjPAoD1GoOdzO4LJSYSOw4kADUW+KS/M4c9Xqz WIKOlU9UgNe9AVxlpUlgIQaP+HBY3Ts= Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XZq5s2x2Cz67CxC; Sat, 26 Oct 2024 01:09:53 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id D7CFA140A70; Sat, 26 Oct 2024 01:14:36 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.48.151.104) by frapeml500007.china.huawei.com (7.182.85.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 25 Oct 2024 19:14:34 +0200 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v14 05/14] cxl/mbox: Add GET_FEATURE mailbox command Date: Fri, 25 Oct 2024 18:13:46 +0100 Message-ID: <20241025171356.1377-6-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20241025171356.1377-1-shiju.jose@huawei.com> References: <20241025171356.1377-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.48.151.104] X-ClientProxiedBy: lhrpeml500002.china.huawei.com (7.191.160.78) To frapeml500007.china.huawei.com (7.182.85.172) X-Rspam-User: X-Stat-Signature: cqjcka6gcur1zxwxsim9dq5p9aeunyi6 X-Rspamd-Queue-Id: 873B340016 X-Rspamd-Server: rspam02 X-HE-Tag: 1729876469-603857 X-HE-Meta: U2FsdGVkX1/Ywz42FSR6W13BoB/R9bemqzGkbeZKJF57RwU3Z9aSES1uzkxA/muVTN9QxpgwPQRQwYg6XSLjikdENGqUlD8vCA0JDEGK57v+xabFXZCtx3sRNUkvROG9AKmS4XWZM6LnGUi9ovfBmPhse37XGo4X4gX4oqZg4zxzqgrrB8f92x94Szfg+73xFrcoVSrqQMEd4C79fYoE4RZ19+J4DEqibTrCmCD+ye5xg9Bm0s/KDdWNZxKQWSIKFHJskcVC0K8vDShCdLtv0nPKqXA75YB+mvSbc7iYd3G0MkUwY94bQCashok7tBYmBpPRQKZ8fwfhcodpZFWtqUhAOqTIeh8SfXMPl3FiINmoj0MtXzWb3fZY6bL/xMThAq8GDepjXhi1ttX9q+LgjggmoznZxxpXkayq0UHxJRN4LxXP3fpplPFay2G3MhmG5KQCLL7wNwI+L42IEeiynHAQwdtqQxPISFR5jIcJUeGtqEPvfCgskT8kVLOshALAwbPFQfzNOF/lg4Mafpc7wpUezi+cwkuPaznwvhs4JMklaqdgkm7G9Ejy4JTFalDe/K6FDyaN0Yd9EkDioGU8lWcMfhl0NDZBRxmvt0RyLvKResvFTXBRLWAsJxm2Z2Avz5/dCpdAAqKX6+ex681tRW17w0gTGxHjDYYfN8tQhnrKkHX4Ya9e8V62tY62a9iuD607uX/4B83w1mHyIKVEuvzcK9b8qxM7hVtNmyphcQFCFsJQPjIp1TDiLG6hCjyeSnsocSrs3dmtT/0Ab8IFOb4L9VF5twZ6Fvrx43kZllY985h9wOuGOKja3zUHLeBcR6ZYGE/5sNzFLW74q6Vk+rXa0SK3VwEK71onNXkMCIJY4LkYDb2o4orqvlIw6wV72btB83FqyGw9PQL9Yst5fjI8W2qPVH5m8n6K02VKeGywRz0YQjglLuUjP3iRQ/1c13qMibMqAvBDaYciPgf u3wUm0OP RXvdlKW8FLgBuUNRr1555X79NAo1aAkiiCirP7XjUwcgdh3Ipd9eaZUtqatT3HY0HxMgmvzlMUs0jn/TtpWjB2g63tXf4XI06UYFRU/fU16HSKg9RZ8KAKxacdZZtPOA1Okr9A/UMNZgc+QHUDAV5GmGT7zciig2veigGafZPHPSvamwNhXhfRzAUKl+os23bxXXLGhrwDuldruZhxKYK7bQ+7gzZJIB0OxT98AofabiHChlt5gLpm1k1YialPaJdawX+6cS0b0i+uMv0c6/KgzMt1+2SZVmZI+Jo X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Shiju Jose Add support for GET_FEATURE mailbox command. CXL spec 3.1 section 8.2.9.6 describes optional device specific features. The settings of a feature can be retrieved using Get Feature command. CXL spec 3.1 section 8.2.9.6.2 describes Get Feature command. Reviewed-by: Fan Ni Reviewed-by: Jonathan Cameron Signed-off-by: Shiju Jose Reviewed-by: Dave Jiang --- drivers/cxl/core/mbox.c | 41 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 26 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 5045960e3bfe..3cd4bce2872d 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -970,6 +970,47 @@ int cxl_get_supported_feature_entry(struct cxl_memdev_state *mds, const uuid_t * } EXPORT_SYMBOL_NS_GPL(cxl_get_supported_feature_entry, CXL); +size_t cxl_get_feature(struct cxl_memdev_state *mds, const uuid_t feat_uuid, + enum cxl_get_feat_selection selection, + void *feat_out, size_t feat_out_size) +{ + struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox; + size_t data_to_rd_size, size_out; + struct cxl_mbox_get_feat_in pi; + struct cxl_mbox_cmd mbox_cmd; + size_t data_rcvd_size = 0; + int rc; + + if (!feat_out || !feat_out_size) + return 0; + + size_out = min(feat_out_size, cxl_mbox->payload_size); + pi.uuid = feat_uuid; + pi.selection = selection; + do { + data_to_rd_size = min(feat_out_size - data_rcvd_size, + cxl_mbox->payload_size); + pi.offset = cpu_to_le16(data_rcvd_size); + pi.count = cpu_to_le16(data_to_rd_size); + + mbox_cmd = (struct cxl_mbox_cmd) { + .opcode = CXL_MBOX_OP_GET_FEATURE, + .size_in = sizeof(pi), + .payload_in = &pi, + .size_out = size_out, + .payload_out = feat_out + data_rcvd_size, + .min_out = data_to_rd_size, + }; + rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd); + if (rc < 0 || !mbox_cmd.size_out) + return 0; + data_rcvd_size += mbox_cmd.size_out; + } while (data_rcvd_size < feat_out_size); + + return data_rcvd_size; +} +EXPORT_SYMBOL_NS_GPL(cxl_get_feature, CXL); + /** * cxl_enumerate_cmds() - Enumerate commands for a device. * @mds: The driver data for the operation diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index f88b10188632..0c152719669a 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -531,6 +531,7 @@ enum cxl_opcode { CXL_MBOX_OP_CLEAR_LOG = 0x0403, CXL_MBOX_OP_GET_SUP_LOG_SUBLIST = 0x0405, CXL_MBOX_OP_GET_SUPPORTED_FEATURES = 0x0500, + CXL_MBOX_OP_GET_FEATURE = 0x0501, CXL_MBOX_OP_IDENTIFY = 0x4000, CXL_MBOX_OP_GET_PARTITION_INFO = 0x4100, CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101, @@ -856,6 +857,28 @@ struct cxl_mbox_get_sup_feats_out { struct cxl_feat_entry ents[] __counted_by_le(supported_feats); } __packed; +/* + * Get Feature CXL 3.1 Spec 8.2.9.6.2 + */ + +/* + * Get Feature input payload + * CXL rev 3.1 section 8.2.9.6.2 Table 8-99 + */ +enum cxl_get_feat_selection { + CXL_GET_FEAT_SEL_CURRENT_VALUE, + CXL_GET_FEAT_SEL_DEFAULT_VALUE, + CXL_GET_FEAT_SEL_SAVED_VALUE, + CXL_GET_FEAT_SEL_MAX +}; + +struct cxl_mbox_get_feat_in { + uuid_t uuid; + __le16 offset; + __le16 count; + u8 selection; +} __packed; + int cxl_internal_send_cmd(struct cxl_mailbox *cxl_mbox, struct cxl_mbox_cmd *cmd); int cxl_dev_state_identify(struct cxl_memdev_state *mds); @@ -919,4 +942,7 @@ void cxl_dpa_debug(struct seq_file *file, struct cxl_dev_state *cxlds); int cxl_get_supported_features(struct cxl_memdev_state *mds); int cxl_get_supported_feature_entry(struct cxl_memdev_state *mds, const uuid_t *feat_uuid, struct cxl_feat_entry *feat_entry_out); +size_t cxl_get_feature(struct cxl_memdev_state *mds, const uuid_t feat_uuid, + enum cxl_get_feat_selection selection, + void *feat_out, size_t feat_out_size); #endif /* __CXL_MEM_H__ */