From patchwork Wed Oct 9 12:41:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13828309 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 313CDCEDD90 for ; Wed, 9 Oct 2024 12:43:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D696A6B00BE; Wed, 9 Oct 2024 08:43:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D1A956B00DF; Wed, 9 Oct 2024 08:43:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B466F6B00E0; Wed, 9 Oct 2024 08:43:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8A6C76B00BE for ; Wed, 9 Oct 2024 08:43:26 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A5BD5AC90A for ; Wed, 9 Oct 2024 12:43:21 +0000 (UTC) X-FDA: 82654029612.22.6558CC2 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf27.hostedemail.com (Postfix) with ESMTP id 4C7444000D for ; Wed, 9 Oct 2024 12:43:24 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.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=1728477669; 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=eH7N0Oq73mcJ8VLVAaTDlxTxNV/ARttM3gyvKpxyg/0=; b=0Gx6SamokOhpQ5wSZbCsGp4RXJG8Xo6vLJD9EdEpOFByaDv1Wa+v2eEBPG/sRb09E5f3Tg gv86DKRSChkYYXk3M4vbPYr6+/ojXuA7Ek/82lN8T4AUc4cO30F5afu7ueZg0MU3cvAswU TubFl94YsgxMK4AsyrCvgXBuULP+Hpc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728477669; a=rsa-sha256; cv=none; b=ehfg5B3bDPWrIvnPZDaCsMPvgLGPGzGx/WpveLHfBJGpBZyeGyymBNCcFOcRMpTCoCJWEg 3fES/RHYyDzBtB1ZcuW5bcYqnt4kgWallTBHmm1VO+SNiZcD9zP52q68j9XGIqCmLtpwtW hPmfZ5hKecatKht0z4oUTP/iQja4qf0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XNsxN710mz6GD4Y; Wed, 9 Oct 2024 20:43:04 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id B4C05140B3C; Wed, 9 Oct 2024 20:43:22 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.48.152.209) 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; Wed, 9 Oct 2024 14:43:20 +0200 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 08/18] cxl/mbox: Add GET_FEATURE mailbox command Date: Wed, 9 Oct 2024 13:41:09 +0100 Message-ID: <20241009124120.1124-9-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20241009124120.1124-1-shiju.jose@huawei.com> References: <20241009124120.1124-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.48.152.209] X-ClientProxiedBy: lhrpeml500003.china.huawei.com (7.191.162.67) To frapeml500007.china.huawei.com (7.182.85.172) X-Rspamd-Queue-Id: 4C7444000D X-Stat-Signature: 4ud9fh65kaeki86jmhtaweh95kyzgcs9 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1728477804-583861 X-HE-Meta: U2FsdGVkX18hY5qXOz+E1p910hXHfI4y/xuTV/3arSFufGSjGJr3o/yafBDML74fw3W/8tsJI095rInpL1g6JZf2gyAS1sZssdRkePxGmvqL6lMUoVeq7G+hrLdKAhLWTR0mB+K5recvMcoU6GNxCXZlZCMs3axmaGIoAkp9xCK+mvCGdsr6IawDSGeqI8NHOs3LoJkwYjMifDq9Lk5/Yi+ETv0d5tMxyo5JWQ8pIFSuWacgKfR61YnVYyz8s1Z6yIOdl6h70Bgg2WUj3Hen8L+f52yUupRw0DMxPkF06FX8elRE93OWz8Vo1yl6CC6KZfXqSvOZ1sNJBthf6kJiHfF5z1OrsLX5NELUqghnm5YscyxWP0CsOY1p0oYXshpAfenTgE8yx2UOj5xod9cUV79m25mIAUP2zVSlt8k9s6ZZIRhFD/7nhjS+twu6qc8RssPTe+1qfte6EJCCdJh+3n82yyPQNsvhsr03CKibgd6v9iDEGlXfgjV8ExDzyo4hPq5y/Y1ynDAp8mK8jcSBFpEu2C6H9QRdgkwrJ+LjHBMJHREnQSNfMNR5FyyshoKrumftVdAUvDAW5eDtkQq+09N9/5D4abuxHIdfDSQiJLX0k3FpZTa84dcRBvUYxxVDpP7ymxxyq2zBRSblMbuVCSZxAPVtHeLU67Fd50c3Kam/i+aAqAAgXHM3es+PO0c146oYbQvqTNkry9nsFSaPRIuYwdkrELcFU0wW7jC/RddWZNVHVsEFQhjrUWnAEG/NB8bOhD9nCNlbkJ3KH6/w6BvcpFp/VKManrP51Fmfqj9warFa9i8z9c49TOgUnLhrzWELhUTyIXL9hFdwdjXAglNrnoMOfw0Z05BitY1X5aateSphORNhCsGQaMgVTMVEgyWgdLIDI8NyzrsykKIgePPlAgLP7tbPNY3DVH265JRrZIyoQZK9stwNDmuQ3+MpDozhKXihLlyNyQT+ZhG mA+anxS3 dJnPcKZ/NmN58nZkPg3Lric43XLw4+2IgJNtlsQNWvSH5kXNRfe18J9tkGycuJ/hDu3fI0USdYhNe0CQIV+ca5hpy5iIITPQMe+ISlikWNPEfnlp/Tu8/NFWe/vM+2Xu3NovVcnmLPFK8K2J18Dl29/qPHVwLy3+XYicgh6AF4zCmrDijxyk2tXdXagCKqWVqldg0YlkT6hO1RbvOTd2/dORv5BNQ1Tvepz9CxrKG355cJHZX8OO2ES/M+03CEqWEt04qLulrROY5G4PocurrgfhAKn68RTBns0Ga 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 Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- 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 6493cad8c325..eae374a90a9f 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 94ce4645e605..c7ad63597709 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -529,6 +529,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, @@ -854,6 +855,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); @@ -917,4 +940,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__ */