From patchwork Tue Jul 16 15:03:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13734593 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 77FC0C3DA49 for ; Tue, 16 Jul 2024 15:04:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF0106B0092; Tue, 16 Jul 2024 11:04:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AA0906B0093; Tue, 16 Jul 2024 11:04:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CB4E6B0095; Tue, 16 Jul 2024 11:04:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 681F46B0092 for ; Tue, 16 Jul 2024 11:04:39 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E7D3A40602 for ; Tue, 16 Jul 2024 15:04:38 +0000 (UTC) X-FDA: 82345937436.09.4851B3F Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf22.hostedemail.com (Postfix) with ESMTP id DF098C0031 for ; Tue, 16 Jul 2024 15:04:36 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.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=1721142233; 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=emuOm0QizK0fUMnK500USG2lwp1vJ2vFsDbBWWUOs04=; b=Uxk41nZNRVgZdmDMBr1Fm+kXdsTidlLL5un5o6dmL/AtjDjXnA9O95QvTpo3pdIZyuoWgN h5r/vyVk2fdf3K77BFCP6ae8+QWALQHrDCsJUYN+uS3vS55e59ivqEnk5UCWEx0gkRRr4p CEn2g6zWikt7yW8PywIlN+iRrckdZPA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721142233; a=rsa-sha256; cv=none; b=nrQAQNpD6IsNO404OmNcf+51qXVsgwoy5EashrNkuCiGL1lltX7sVlGVKkxJYezDqocq17 ylRiPLQ/FNTjZBPv9HLGKe1dgzy03V5iOJIehcHuc8PitG/N5RYquXzI9frPVlvHp3+3ee 0QxrofFQMhPuS2qKbbUM2DZjad9Ji4I= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.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.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4WNj3K4z60z6K96J; Tue, 16 Jul 2024 23:02:21 +0800 (CST) Received: from lhrpeml500006.china.huawei.com (unknown [7.191.161.198]) by mail.maildlp.com (Postfix) with ESMTPS id 9F548140B39; Tue, 16 Jul 2024 23:04:34 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.48.159.153) by lhrpeml500006.china.huawei.com (7.191.161.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 16 Jul 2024 16:04:32 +0100 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH v9 05/11] cxl/mbox: Add GET_FEATURE mailbox command Date: Tue, 16 Jul 2024 16:03:29 +0100 Message-ID: <20240716150336.2042-6-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20240716150336.2042-1-shiju.jose@huawei.com> References: <20240716150336.2042-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.48.159.153] X-ClientProxiedBy: lhrpeml500005.china.huawei.com (7.191.163.240) To lhrpeml500006.china.huawei.com (7.191.161.198) X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: DF098C0031 X-Stat-Signature: oup4jsntg39ebn3hezyrbmabbiwadexp X-Rspam-User: X-HE-Tag: 1721142276-690524 X-HE-Meta: U2FsdGVkX1/RkqIGIUzF55UzhxwWN5zQEff6iWriLI31cp0+lZBX/QI9DylGqGvWRIYnLuFv//XJjSNHzgyTYFmJI1IOH+/x4OccJUNi2dQxYjs29NF0+YhpIRdUgYOImCWbzPLlX3Kan9rMsBRQpBwKiE72OMKw9L+EU3N/qTi5mxqJCD5S/bTgvsAE1PM1UyQ3aHkuo2Zlphcn/C/h3N2OeFNdrsf2A7b6Jr5zp36/0pDLbNjLoaB+H/VzhfP3Dp993H+VD0+h9NBBJKXhWmiBaXrLMvasdDN1Xl5JEOPsgHqEllJ11ClFriwBcyG4MyGTdxW+iTSkjQqEncAnRrMvt2k5vHb6dNfvhLLPTRnX9BTang6Gi6icXfdX7omy8Kv+79ndsAKb7Ia09Kzy/hefy+TIJBHfKYnWXeDlJycE5RwvDyJBE7QmxKjuolXKTwB4eQQ6k8LbZ2CarFA+9uV8k+m4ZtQCW6jBiCfxWE9wt2jbZH4AcfsamFXRfsOAm/F47W68RIFQ4dmM0Wy2m6AyWu4LKk+QpVAxJmPti64PpVLDKzMAZ7Z07XCNy3JQGT578BKP2D1phkFk9ybg5dKG2QQUlL2eBYsE3VKBvl1BYDFvJzd9pncfak9PV2WLSELhzkM1KcZKPJEX5YYfB40sLfRWTJPHob0V2uvLF73lM/1hb35s7H2/ubNhsGjqZma/MwZ92HZPtXiYDg6UMubo+2E4B2ndzwBzmuwMN5k0zK3+yWTSO88fh7Mz7pX30KQ2ETQgcI9q8ocNHNW6x2q3jyzgxFaNQodLmDOjuumPQXYVbmM43bHwdJnXrCp+Yr5oTs+wrM2mWZr+6QSRdkjipFN903YLYO+D7u3mxelUV2vXAJKcHHBVKOUHqMyX0PyJYEoutNH0NUQMNsRToMrjEx7vwjDiEojXUxJSS2LL38WoohgBKVqMv4DJDW5FcFo4eepNDZyVV6e12VW 3zcnYl4A 0YTN6XrqRFK1smBHBaqIOOZihz1rHP5U5DuzT3WHApb40SKlMNviDdWAcTxxZ6+j4lMpgYbMW9pAyD1T6WKHdLfNpfyg4JNl4Z7oXnu3jVTolYdvVRN+R/G1TUNDagCTZLMCQvZhE0kPOPAfrW+yxBsP3vrH31If4B36O0VRQeqLGhWFmfnxmHmmbS1C1D4qBQbdjsSJr0XkZYDB801LXcZHCi6eJbsf7TgYlOfQoxRj1PfCeF0n30TBJPL7aIdokcMuZTpK4Oo0PitY= 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. Signed-off-by: Shiju Jose --- drivers/cxl/core/mbox.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 27 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 9b9b1d26454e..b1eeed508459 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1351,6 +1351,43 @@ int cxl_get_supported_features(struct cxl_memdev_state *mds, } EXPORT_SYMBOL_NS_GPL(cxl_get_supported_features, CXL); +size_t cxl_get_feature(struct cxl_memdev_state *mds, + const uuid_t feat_uuid, void *feat_out, + size_t feat_out_size, + enum cxl_get_feat_selection selection) +{ + 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; + + size_out = min(feat_out_size, mds->payload_size); + pi.uuid = feat_uuid; + pi.selection = selection; + do { + data_to_rd_size = min(feat_out_size - data_rcvd_size, mds->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(mds, &mbox_cmd); + if (rc < 0 || mbox_cmd.size_out == 0) + 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); + 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 b0e1565b9d2e..25698a6fbe66 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, @@ -757,6 +758,28 @@ struct cxl_mbox_get_supp_feats_out { struct cxl_mbox_supp_feat_entry feat_entries[]; } __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; + /* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in { __le64 offset; @@ -891,6 +914,10 @@ int cxl_set_timestamp(struct cxl_memdev_state *mds); int cxl_get_supported_features(struct cxl_memdev_state *mds, u32 count, u16 start_index, struct cxl_mbox_get_supp_feats_out *feats_out); +size_t cxl_get_feature(struct cxl_memdev_state *mds, + const uuid_t feat_uuid, void *feat_out, + size_t feat_out_size, + enum cxl_get_feat_selection selection); 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);