From patchwork Tue Nov 21 10:18:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13462759 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 E5ACFC54FB9 for ; Tue, 21 Nov 2023 10:19:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 148426B03D2; Tue, 21 Nov 2023 05:19:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 086C96B03D4; Tue, 21 Nov 2023 05:19:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D97E36B03DA; Tue, 21 Nov 2023 05:19:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CB1AA6B03D2 for ; Tue, 21 Nov 2023 05:19:06 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A1486140AC1 for ; Tue, 21 Nov 2023 10:19:06 +0000 (UTC) X-FDA: 81481563492.19.203A2ED Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf06.hostedemail.com (Postfix) with ESMTP id B109818001A for ; Tue, 21 Nov 2023 10:19:04 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.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=1700561945; 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=CTZGfmSGBMzmqxch/1IeC/a8kOeZK8tGQNAr8pOjSCw=; b=TR4Nyck86vDu6baIVXRYmXvs4IdK6eprBpS3kVybUs+fE1Le6xcel+Ujm1TxhXsgrUHauQ GBsrCjogipu+WKuAUnvmdV+GZUaqzAfB45WKlkj49KpUXnUjRC1uMKqVEStgXT7uX5CUmA 0eRUzqeP7KbQvXMY4U6jujHmee3FRRE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.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=1700561945; a=rsa-sha256; cv=none; b=l+Aia+sSJIplPf543McBk3n7WtA1W4NpnKTX/VnTZ4e34rI5B89yPgCEv95kXLVgu4heU/ dQNrGd3t3s2o4ClKnkEQ/O/qYsxujfWuxvuvJrxbMTAMNa+Zn/r75ZTFv0vnKvYs+FwOsD mnIvLDb0ZVXGQajYyE3MjEscZH6Wkww= Received: from lhrpeml500006.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4SZKwW5hG9z6J9Sj; Tue, 21 Nov 2023 18:14:03 +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; Tue, 21 Nov 2023 10:18:59 +0000 From: To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 01/10] cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command Date: Tue, 21 Nov 2023 18:18:34 +0800 Message-ID: <20231121101844.1161-2-shiju.jose@huawei.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20231121101844.1161-1-shiju.jose@huawei.com> References: <20231121101844.1161-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.122.247.234] X-ClientProxiedBy: lhrpeml100005.china.huawei.com (7.191.160.25) To lhrpeml500006.china.huawei.com (7.191.161.198) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: B109818001A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 11krws9mhba3xnkeczaomgwbmo3e3i4t X-HE-Tag: 1700561944-377535 X-HE-Meta: U2FsdGVkX1/Dz4YtS2bx4x//zL4lzc3QoEObDFQRX+cqk6T4q2/IMy1ENLiUByyT7/8+Tvcea1IyiEz6XEaaneS3TA3h2CsX3coHoMGKtIu6H6+Tp09UtDpqjuKITaIu3agQ9TEGN1CbIcDTQetyyuCaAtL/aON2Yf7GG54NTKpr089/xraej31vfsF75fqmSTmZBikb+3LhVEeOcwTITN+7+0CHfyi++WTG0rpmwRetdE2Lx0GFCFWv6l+vPCZhp9Cr2NECuiqzmMBtDwOUTycQacckRxbnOZNK/7Rizxq5MniFwPfRwzVGWNNaahfvWv0LOKpRyhMU1OzaPI/1TSQcJSLu8gmikkH7TcesWO1h7zL7q6IhHDKF3jsKbDay+qO5uV99A6TNKBcPtcqQBKmCNYtMuMwrOTkVZUW0IS4xdy2MiP94IAlc4bjpBp0rHO35MFoWXBBoytJMPObKgFb3+X4SVPAGGBjwTWUJZdyCWmk0G19hwZ6nmJU6awrXA3huNRk/OgK81yfWP8jdQkY9gQuVFzGcn5vybFd34NcfkWHrMPAIkHfEYLUmYo4upIv1P/ZnH6LfqF+9jSwpe527mm+BllqNwWHUjWIW2Uqp4jtgarPaJ5ICQg0F6/d5SGo+Bha2dSJlY6+RteE9aFW/OiQfiEQJ7mZfIDfitQOF72LvZX6g6YnhT292TtogFJx0WayORBW8zHSw6MKiGXxE07v/kjWEkFFr+ekLqorMLL+CweTKh+2Q7oPACEnKX8RoQ27tmfEYmEzDOUcCAu6eYdzZ9PO+Fi9Wy9MwnNvQNZxOjRYMAO3HVQYWzq4eue4NR3MYvGPuCi1IlGn1Xh2YhElbLoePx4syH1uzDxFmbX3jtZ+mCZ9ALX6Bj0tLu9PVSWbiCyRPQtkWK7Ur3MassLjAJrq/W6i6HjKSn7+TEt7KmpzN/gLvRAaKcQS8ZB0Z0jVYakZOP+wpxAq i2RkmHTp 5v3fTirDkcLsB6hyPx6bDUHulIFg0foyBjwtsfD2PHHNI+hKdU5mTEbAXhfSykJOaW0DJQVVlMxxNIFVETNsQH6xGL7Fbo2uQKhtxMQHTjD4HW7h7v+pwysnwrwlJrmof7Bjmb7a//l4Eo3lwDq2DfocdGkoxfPPNggTirZIh5/v55OXy1QVk/09W39dMPvHwfWrj 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.0 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 | 24 +++++++++++++++ drivers/cxl/cxlmem.h | 59 ++++++++++++++++++++++++++++++++++++ include/uapi/linux/cxl_mem.h | 1 + 3 files changed, 84 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 36270dcfb42e..06ec9ef50e7f 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -63,6 +63,7 @@ static struct cxl_mem_command cxl_mem_commands[CXL_MEM_COMMAND_ID_MAX] = { CXL_CMD(GET_SHUTDOWN_STATE, 0, 0x1, 0), CXL_CMD(SET_SHUTDOWN_STATE, 0x1, 0, 0), CXL_CMD(GET_SCAN_MEDIA_CAPS, 0x10, 0x4, 0), + CXL_CMD(GET_SUPPORTED_FEATURES, 0x8, CXL_VARIABLE_PAYLOAD, 0), }; /* @@ -1303,6 +1304,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 = 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 a2fcbca253f3..d831dad748f5 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -506,6 +506,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, @@ -740,6 +741,61 @@ struct cxl_mbox_set_timestamp_in { } __packed; +/* Get Supported Features CXL 3.0 Spec 8.2.9.6.1 */ +/* + * Get Supported Features input payload + * CXL rev 3.0 section 8.2.9.6.1; Table 8-75 + */ +struct cxl_mbox_get_supp_feats_in { + __le32 count; + __le16 start_index; + u16 reserved; +} __packed; + +/* + * Get Supported Features Supported Feature Entry + * CXL rev 3.0 section 8.2.9.6.1; Table 8-77 + */ +/* 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) + +enum cxl_feat_attrib_value_persistence { + CXL_FEAT_ATTRIB_VALUE_PERSISTENCE_NONE = 0x0, + CXL_FEAT_ATTRIB_VALUE_PERSISTENCE_CXL_RESET = 0x1, + CXL_FEAT_ATTRIB_VALUE_PERSISTENCE_HOT_RESET = 0x2, + CXL_FEAT_ATTRIB_VALUE_PERSISTENCE_WARM_RESET = 0x3, + CXL_FEAT_ATTRIB_VALUE_PERSISTENCE_COLD_RESET = 0x4, + CXL_FEAT_ATTRIB_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 attrb_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.0 section 8.2.9.6.1; Table 8-76 + */ +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; @@ -867,6 +923,9 @@ void clear_exclusive_cxl_commands(struct cxl_memdev_state *mds, unsigned long *cmds); void cxl_mem_get_event_records(struct cxl_memdev_state *mds, u32 status); 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); diff --git a/include/uapi/linux/cxl_mem.h b/include/uapi/linux/cxl_mem.h index 14bc6e742148..656450274001 100644 --- a/include/uapi/linux/cxl_mem.h +++ b/include/uapi/linux/cxl_mem.h @@ -46,6 +46,7 @@ ___C(GET_SCAN_MEDIA_CAPS, "Get Scan Media Capabilities"), \ ___DEPRECATED(SCAN_MEDIA, "Scan Media"), \ ___DEPRECATED(GET_SCAN_MEDIA, "Get Scan Media Results"), \ + ___C(GET_SUPPORTED_FEATURES, "Get Supported Features"), \ ___C(MAX, "invalid / last command") #define ___C(a, b) CXL_MEM_COMMAND_ID_##a