From patchwork Thu Nov 30 19:23:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13474884 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 CCA43C10DC2 for ; Thu, 30 Nov 2023 19:23:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50F6C6B047D; Thu, 30 Nov 2023 14:23:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E6816B047F; Thu, 30 Nov 2023 14:23:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EB0F6B0481; Thu, 30 Nov 2023 14:23:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1204F6B047D for ; Thu, 30 Nov 2023 14:23:32 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D70211202CB for ; Thu, 30 Nov 2023 19:23:31 +0000 (UTC) X-FDA: 81515594622.26.1EFE321 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf29.hostedemail.com (Postfix) with ESMTP id 7BD7E12001F for ; Thu, 30 Nov 2023 19:23:29 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.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=1701372210; 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=MBGZRhOp8qMUSNlnOTq/csFal0Wru08hiRsLIKyoexE=; b=OlqPmpUFVGXD7YGvPiBDuHcOavos11n2g9i9tfDOxNtE2nkpSZl63FqAvesNYoBV6BPJBQ Ud1/porqRoo/Y++YFTcxYO+R8Ya83gSbJelFd7pLiOcKu7ma8x1WAlXobh/RdmTnD3yELy wkN1HtOjO2WUlo3F47S7IaGG9OSwyPE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.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=1701372210; a=rsa-sha256; cv=none; b=gnybYjtGM6LQohr09hJy+42HjihpIhOZsdI8h37ennEvjP+dpO0VOjJItUCwgcKeOA/1mG OSAbCUXouBbVIFQFtiMd/lNFlKG62PUf1ng5kqycYwqikelxq24kScUoU3lmkwrhUhl1tN 9kFyRrNQMfQyCT5kwW1HuYjJmG6S+NE= Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Sh5gq3j9dz6JB3F; Fri, 1 Dec 2023 03:23:03 +0800 (CST) Received: from lhrpeml500006.china.huawei.com (unknown [7.191.161.198]) by mail.maildlp.com (Postfix) with ESMTPS id A88141402CD; Fri, 1 Dec 2023 03:23:26 +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, 30 Nov 2023 19:23:25 +0000 From: To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 01/11] cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command Date: Fri, 1 Dec 2023 03:23:03 +0800 Message-ID: <20231130192314.1220-2-shiju.jose@huawei.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20231130192314.1220-1-shiju.jose@huawei.com> References: <20231130192314.1220-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.122.247.234] X-ClientProxiedBy: lhrpeml500004.china.huawei.com (7.191.163.9) To lhrpeml500006.china.huawei.com (7.191.161.198) X-Rspamd-Queue-Id: 7BD7E12001F X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: rhzfohs49tnaocz9tbdo89qdoryhny6s X-HE-Tag: 1701372209-513215 X-HE-Meta: U2FsdGVkX1+kmaEIKkErpCoQfLEZfFkSlLcJYY5bcW9DqIeMmj/G4UfNPoWgeo4VJL34iiduJenKrTO5EyyWsawRWfZMkqK8o0dXmLbDtPvJlYnvD98m1t8GcsAEBJvKhJV9ODN+uNUAYNSW/fwMfpyLUcquHTFAzsfqVKHUubs2jJXBJoaHpo7AILqm5NXA1TGIuxhwo6tRtYzG5SBmWJ/6TS3ifc7r6bsVsiIvOaT9bwL+vg6SQpd+KUOzoczHyaDNb9bI/gKfsENOIrS/jOW5uDPH1VpVDL99xyDtbnmovYsx5bs9/IzUgeqsy656qkthbzhiVuz7aHSolKRWMz6HuJ4xY2+v/GP41EvS8Bs4vO0GyvRrpqWIUZd8RMOOQBhcEo4gje7zl8MUpi+vZseSKdbOYq+KBzgpFbTMr2GVhoPwoQraGEGEy3jDkhj/r0WrYH7bOMDTGSUlqNAGPHnpkPia54kaJV7dp/sNxhtLtdeXOdTN6zCd4Qw16T9gqiqOnx66Af4qWc2NnJih5R8vnJDiacxud4nYdle5aZyPc7k8YGDorvc4Bh/Y0v824oKcv26QM7eXLZTdzv69RKqybKX1p+m84/9koSx16iWvCHqE73/8dXsqfA/PWDLObh3dQvbUO7vTfXKDDbf5G7h5n7KvdgBZm1DcwxYhBttzvVyeK0tLxYfYD/SnPvyxaFtPJj1kYSJU6NQYQCkIFOGJ6W9nD2F3hUIZ1gCqacIHnWAePdcFLIYyNabXsxMivwDfXcDI2lOfCz1iEjlkL4EN4bWZjBZCi4jGK5E4zpMLo5lLdrrhuyUQqqYb6R3dKgEneQCgPxO1VKe8LbIQqlczYDFBhLqVNCSbjWpR47l8OIecBDx+p0RttcHtOM0NjTOZ2hBlOeh3dU2EOpsYsLsz5oDcXxb3nQuVh91Yx9MLt2RP9QS2aXLpmX4xinOVsIQyZpclTP533AbxhnW FQacJ83Z tEg/Yg7Rv5yhqnnv37YOGdCZZdyP/YjKMxB8hv7hraep8rGvGn83zlbe7e+iZcDCgqVSGntjtfxZYbWvHKtne2eQULWJF1G9hms8WYYJvWckEr5KRSt88vfrlu7Q858+7ThjkfkDxrxmCsUaNYk5tTc/eTPWhB6zlrUe8pRP+GX+9UXGmAmyeUYOtPbtNBNcsnmWI 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 | 23 ++++++++++++++++ drivers/cxl/cxlmem.h | 59 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 36270dcfb42e..6960ce935e73 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1303,6 +1303,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 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);