From patchwork Thu Feb 15 11:14:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13558140 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 0D121C4829E for ; Thu, 15 Feb 2024 11:15:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8F326B0096; Thu, 15 Feb 2024 06:15:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CEB588D001B; Thu, 15 Feb 2024 06:15:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BA2B6B0096; Thu, 15 Feb 2024 06:15:12 -0500 (EST) 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 576768D0017 for ; Thu, 15 Feb 2024 06:15:12 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0A9F880867 for ; Thu, 15 Feb 2024 11:15:12 +0000 (UTC) X-FDA: 81793781664.27.51C63AC Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf07.hostedemail.com (Postfix) with ESMTP id 2E7FF4000D for ; Thu, 15 Feb 2024 11:15:08 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707995710; 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=uO3NwCK1Yw5d8gIfT6RR9uvkbDyekI1rX6ypke5k7UQ=; b=wtUCjy7yocG4OhTk26WmnhsIB1IJnNqlq22NQbsXzP43XHSVRVDaPDC2NtkG7hH5Ol+M+G 3yTvTHCPWSZZT/PtkP3mvE26ziq9FDXOhhLVTLBt7vSm6cDBm3xcTeoUmOTlZ+pfFDxIPU SNmvi3lARj5M900ITIpXGEijhL9Epes= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707995710; a=rsa-sha256; cv=none; b=sEcvgTkTFwCO7ZMRIQDuJYWT3To+c+kl24fz2ThKHMpoUReAtEzlGc2G9lBZmOwNS7GUG9 K251qycBmo2i8LHazBWp5BNYIoOOOIkp7LOcbp1SjyD0BIl1bxivGAECmNbBQ+MrbtQH9u DzFWYIZ6qLH+7M2WaBYpOJ5EpTcc1yM= Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4TbC6x3XWYz67MfY; Thu, 15 Feb 2024 19:11:21 +0800 (CST) Received: from lhrpeml500006.china.huawei.com (unknown [7.191.161.198]) by mail.maildlp.com (Postfix) with ESMTPS id 7334114025A; Thu, 15 Feb 2024 19:15:05 +0800 (CST) Received: from SecurePC30232.china.huawei.com (10.122.247.234) by lhrpeml500006.china.huawei.com (7.191.161.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 15 Feb 2024 11:15:04 +0000 From: To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH v6 01/12] cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command Date: Thu, 15 Feb 2024 19:14:43 +0800 Message-ID: <20240215111455.1462-2-shiju.jose@huawei.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20240215111455.1462-1-shiju.jose@huawei.com> References: <20240215111455.1462-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.122.247.234] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500006.china.huawei.com (7.191.161.198) X-Rspamd-Queue-Id: 2E7FF4000D X-Rspam-User: X-Stat-Signature: yfwktnkpxodkujqwxcriakbd8ppmqs4k X-Rspamd-Server: rspam01 X-HE-Tag: 1707995708-386788 X-HE-Meta: U2FsdGVkX18rhOMrAIw8hIdkweokPE5nEcmhMZ9D4LSHdCvFTyNIwuUSe2vlNufp541Y7SKOfan6kWrqUQGwAQb/ovmvgv5ZxBzztecZWbTgC1GkjZhri+ZblthYf+BvH64hWp4Ou6mJ0PAxNSbAqtgwhJObcLbhu/VJuhxnO0TRhyn2jFe/1DAAiWlmAnA6bluuVmN9BGmuZ/rGTWkhlzGv6+XjlviAItbrSmou125cmqa15wWPTc/NG3gCZqvOehvRkeANAGf1lGpSFc0mVXw/EhFCAixDLQpPddnaQESi6NnHHHNbTo/8OUnDlAaAkTimBkC9VApqPYIE2dzlo9PKBsBR0gszG0FxQDPdeKoReXN28VY8rH0DeX4ZOBxu7DJ4Yp/+4aH1j28/4TEkfWghkOk/AzVIBIOlPbeMxxlypu4MfYyXyMEe6035dAr72/AfjNCeB1trdD8gwzVNZpezhKandcCioN56FbWyq3NhCfEkpTfFphz5mXrbnQPZkMdLs8P7ZOU8L8sVz3nHsRM7bvhI1C8cXpF/7j79sJ57r0DybNWDYCA1OqKwYxErX9Pdvh1FGQB+No55JMiO5YjEUuyIMuM+a2oWpK07Bu4ZSMeggRLMEa/o+0VbeyJQm70FaBAJpESJzY8cq7OpgoXmaRW//c4w54AkcH95wazmG5ivCTk4FxUOcYzW+VOhR+08UDiUM/0gV5lME147ahT5AVZR3yAdTugzToMTzoq7dWxg7u2m7syrISjWu2+moeqJuwbtqbGaK4WatS1o89SeFdepvCDb4GFSMtOsl2zCZ60B+yBTvBSPJh3SBUmWXQgFOZLxfjozVeuFESgDBOL1BRFhrmV+VGs+5uMT+she6flMuEVyis0C3Dqfn9XuRqaK5/5SeWB6TwbuKwC308LzYHGLa+K3/YYNuJUSOKBuMI7r9lOTA5qhSsOGhSsjwmUV5I7iQv9ZcxztA9E NOIp+F+v aYT5IRknOnfQOOWdXEIxq3wdhnev2fS6QMes84glLIWk3AXs+edbxKtmE/l8B81+ntW/Tc5KWXdffgh8LIVVIZFSwolNz8iF+kQZVG9uPm2dtkIywciCkQtyROIwTC3P7MdCMwYF1L/AQrJClnUpHzyqm+73yOR3m0TVZlDN+8MG4c++URKP6R6GwYAldggGQw67L 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_SUPPORTED_FEATURES mailbox command. CXL spec 3.1 section 8.2.9.6 describes optional device specific features. CXL devices supports features with changeable attributes. Get Supported Features retrieves the list of supported device specific features. The settings of a feature can be retrieved using Get Feature and optionally modified using Set Feature. Signed-off-by: Shiju Jose --- drivers/cxl/core/mbox.c | 23 +++++++++++++++ drivers/cxl/cxlmem.h | 62 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 27166a411705..191f51f3df0e 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1290,6 +1290,29 @@ int cxl_set_timestamp(struct cxl_memdev_state *mds) } EXPORT_SYMBOL_NS_GPL(cxl_set_timestamp, CXL); +int cxl_get_supported_features(struct cxl_memdev_state *mds, + struct cxl_mbox_get_supp_feats_in *pi, + void *feats_out) +{ + struct cxl_mbox_cmd mbox_cmd; + int rc; + + mbox_cmd = (struct cxl_mbox_cmd) { + .opcode = CXL_MBOX_OP_GET_SUPPORTED_FEATURES, + .size_in = sizeof(*pi), + .payload_in = pi, + .size_out = le32_to_cpu(pi->count), + .payload_out = feats_out, + .min_out = sizeof(struct cxl_mbox_get_supp_feats_out), + }; + rc = cxl_internal_send_cmd(mds, &mbox_cmd); + if (rc < 0) + return rc; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(cxl_get_supported_features, 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 5303d6942b88..23e4d98b9bae 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -529,6 +529,7 @@ enum cxl_opcode { CXL_MBOX_OP_SET_TIMESTAMP = 0x0301, CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400, CXL_MBOX_OP_GET_LOG = 0x0401, + CXL_MBOX_OP_GET_SUPPORTED_FEATURES = 0x0500, CXL_MBOX_OP_IDENTIFY = 0x4000, CXL_MBOX_OP_GET_PARTITION_INFO = 0x4100, CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101, @@ -698,6 +699,64 @@ struct cxl_mbox_set_timestamp_in { } __packed; +/* Get Supported Features CXL 3.1 Spec 8.2.9.6.1 */ +/* + * Get Supported Features input payload + * CXL rev 3.1 section 8.2.9.6.1 Table 8-95 + */ +struct cxl_mbox_get_supp_feats_in { + __le32 count; + __le16 start_index; + u16 reserved; +} __packed; + +/* + * Get Supported Features Supported Feature Entry + * CXL rev 3.1 section 8.2.9.6.1 Table 8-97 + */ +/* Supported Feature Entry : Payload out attribute flags */ +#define CXL_FEAT_ENTRY_FLAG_CHANGABLE BIT(0) +#define CXL_FEAT_ENTRY_FLAG_DEEPEST_RESET_PERSISTENCE_MASK GENMASK(3, 1) +#define CXL_FEAT_ENTRY_FLAG_PERSIST_ACROSS_FIRMWARE_UPDATE BIT(4) +#define CXL_FEAT_ENTRY_FLAG_SUPPORT_DEFAULT_SELECTION BIT(5) +#define CXL_FEAT_ENTRY_FLAG_SUPPORT_SAVED_SELECTION BIT(6) + +enum cxl_feat_attr_value_persistence { + CXL_FEAT_ATTR_VALUE_PERSISTENCE_NONE, + CXL_FEAT_ATTR_VALUE_PERSISTENCE_CXL_RESET, + CXL_FEAT_ATTR_VALUE_PERSISTENCE_HOT_RESET, + CXL_FEAT_ATTR_VALUE_PERSISTENCE_WARM_RESET, + CXL_FEAT_ATTR_VALUE_PERSISTENCE_COLD_RESET, + CXL_FEAT_ATTR_VALUE_PERSISTENCE_MAX +}; + +#define CXL_FEAT_ENTRY_FLAG_PERSISTENCE_ACROSS_FW_UPDATE_MASK BIT(4) +#define CXL_FEAT_ENTRY_FLAG_PERSISTENCE_DEFAULT_SEL_SUPPORT_MASK BIT(5) +#define CXL_FEAT_ENTRY_FLAG_PERSISTENCE_SAVED_SEL_SUPPORT_MASK BIT(6) + +struct cxl_mbox_supp_feat_entry { + uuid_t uuid; + __le16 feat_index; + __le16 get_feat_size; + __le16 set_feat_size; + __le32 attr_flags; + u8 get_feat_version; + u8 set_feat_version; + __le16 set_feat_effects; + u8 rsvd[18]; +} __packed; + +/* + * Get Supported Features output payload + * CXL rev 3.1 section 8.2.9.6.1 Table 8-96 + */ +struct cxl_mbox_get_supp_feats_out { + __le16 entries; + __le16 nsuppfeats_dev; + u32 reserved; + struct cxl_mbox_supp_feat_entry feat_entries[]; +} __packed; + /* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in { __le64 offset; @@ -829,6 +888,9 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd, enum cxl_event_type event_type, const uuid_t *uuid, union cxl_event *evt); int cxl_set_timestamp(struct cxl_memdev_state *mds); +int cxl_get_supported_features(struct cxl_memdev_state *mds, + struct cxl_mbox_get_supp_feats_in *pi, + void *feats_out); 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);