From patchwork Tue Nov 21 10:18:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13462757 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 CD425C54FB9 for ; Tue, 21 Nov 2023 10:19:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24DA66B01A3; Tue, 21 Nov 2023 05:19:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D8586B03C3; 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 078E66B03D4; Tue, 21 Nov 2023 05:19:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E83A86B03C3 for ; Tue, 21 Nov 2023 05:19:05 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B7FD9140373 for ; Tue, 21 Nov 2023 10:19:05 +0000 (UTC) X-FDA: 81481563450.28.71AA61E Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf24.hostedemail.com (Postfix) with ESMTP id 6495A180004 for ; Tue, 21 Nov 2023 10:19:03 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.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=1700561944; 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=//n0F7OcaeRIPpiOVYmqt0buUBHrmDgVTO2CqH4zRmc=; b=s9gOlpOosixtp0QYYHcNN4HOpx+GdZ9PB1tFJ3DMKV1XkOdXujvyHAKDuBmR4NIo1TuGT/ WiSURGzSt9P/oJK2EzQu3bPnhLNza0qo8HbExcf8Dwwaw+HwHZWHPTO+MsjuN4k1OEMev6 y9qDsEIoHubUZZKdAnmTpOQ1/NJdVqI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700561944; a=rsa-sha256; cv=none; b=C+94pMsNspoLJ1Hk8en5tHumQTtRTXqqHBz87ST7boj3KC69RjR4oo8Ui7p4rGyYo3p63s RcANHLTYC3KrOSaCKMJ1d93Z2NQjW57OpUx8Vz2sVuH28xOzUbRkhzwLgpwllSAsk1AzRb PUK7mpvLlGLOprUFs1w6UyCHGVSp1aY= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.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 Received: from lhrpeml500006.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4SZKwX3Mwgz6J9pf; Tue, 21 Nov 2023 18:14:04 +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:19:00 +0000 From: To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 02/10] cxl/mbox: Add GET_FEATURE mailbox command Date: Tue, 21 Nov 2023 18:18:35 +0800 Message-ID: <20231121101844.1161-3-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-Stat-Signature: 8x9k7n4g3yrji7zoe8cwye1j9653cifh X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6495A180004 X-Rspam-User: X-HE-Tag: 1700561943-890142 X-HE-Meta: U2FsdGVkX1/a9PAUh9QMjAHu1h9UhczYXrxuA4tlS0mteMKr6qgqgBhsYxtPfan5ldi+dcUE/XRStD1ll/Mo149Z40WKrbH+UwJUmWFskX/KjzZe2dcKJ085SQp92BQtnN1IfOHifYGk9pKGuu3YyByKjC+gGep4OyIdk563gHvwha/pmMmDmIpxduVcfYD9tA4Yo7cken5mqw/oz+Zu3YepmP19bcpU9lfpxItaDsjyplCWRzWIBCtyqUmWoPyQdtxZDMgabUKNPgB4n8m5kpmZb58Z7DjcLHQf/+AP5hpSfm+54Zjyd7UPZKaeY4etY5reTwJKtvQCLOZfjKR11HfhGjkBzsZATkad5tplsWoGWDHrE3WwptSvdNvgw3w69kO9A/IHSIFIrs10h4KXWcH2/h19PrqZfLPO31GziCnrSXvZd8Op75XqK6G0xzXbwYBZH00X1hYf385hCD4wVsrw4YEUEi9js42QaoqcbFOr42sIz/4jTtCj3qZSjpLWXXzefOWRogukwMlKCXkpLpnT19h6aoYrsJEj/6DzTZkAZBcSpRgZZ20VweyXZX06HnVEeABTdgxZxkDdKWcmMjk/8xaiBo12hl4Q48hpufOOhJk3BgBYmKE+C6iHIZVdNpHmyOBZlDu+X6PR37AAf1sBjDx/pjOIuoPobpcN1D6TqQmBVMjmMQum+nA8oXCInnPhhvXriCdv5STQvryZX7UxRM3kY/4Ou+sHld9+p+EJKjrPDcbC3n9QmL4EZpj/ibvQPfetcSM60Rzwo0n+V9n3YfaIPQE3L2CoDN7Yz78KpreiotPIs2UZgcnV5LsgKYvB1pCAax2Gk0AybfEAXwr6lGaG+oodvNEnqBhsu9DRMo/8KqleaTGT9rO+k+fooNxK93F2Xcb2mLNX1n0ktigqTYlyfFX29Oj/oRKpH4M+li0XnnLsGlemHSqiRAJE41HzbT24LNSeuffZ3O6 CcQO3Xxj GAqGbC/2giLHInPC4BMEfCLDF+0PP9exX5XxS2t9vKUqGXOldaF37n8QKCltg0Xclsx2M1Jrihm+BHaZE15dTrAiYre4/fo7Mkn3OMjj3RdDEFnf944V4AqVK3mTH8AEWrk/smwDmpfQjnUtQP3wzDHD80BtetKe00zQJwNHK4UiMFm7qd6/4TqLfNdhmRJLfg6DvYOHkK7+F6ppBjrbNNMo+vWYiUSctq/0K7TohfzFnzP8= 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.0 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 | 23 +++++++++++++++++++++++ drivers/cxl/cxlmem.h | 23 +++++++++++++++++++++++ include/uapi/linux/cxl_mem.h | 1 + 3 files changed, 47 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 06ec9ef50e7f..2675c616caec 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -64,6 +64,7 @@ static struct cxl_mem_command cxl_mem_commands[CXL_MEM_COMMAND_ID_MAX] = { 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), + CXL_CMD(GET_FEATURE, 0x15, CXL_VARIABLE_PAYLOAD, 0), }; /* @@ -1327,6 +1328,28 @@ int cxl_get_supported_features(struct cxl_memdev_state *mds, } EXPORT_SYMBOL_NS_GPL(cxl_get_supported_features, CXL); +int cxl_get_feature(struct cxl_memdev_state *mds, + struct cxl_mbox_get_feat_in *pi, void *feat_out) +{ + struct cxl_mbox_cmd mbox_cmd; + int rc; + + mbox_cmd = (struct cxl_mbox_cmd) { + .opcode = CXL_MBOX_OP_GET_FEATURE, + .size_in = sizeof(*pi), + .payload_in = pi, + .size_out = pi->count, + .payload_out = feat_out, + .min_out = pi->count, + }; + rc = cxl_internal_send_cmd(mds, &mbox_cmd); + if (rc < 0) + return rc; + + return 0; +} +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 d831dad748f5..92c1f2a44713 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -507,6 +507,7 @@ enum cxl_opcode { CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400, CXL_MBOX_OP_GET_LOG = 0x0401, 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, @@ -796,6 +797,26 @@ struct cxl_mbox_get_supp_feats_out { struct cxl_mbox_supp_feat_entry feat_entries[]; } __packed; +/* Get Feature CXL 3.0 Spec 8.2.9.6.2 */ +/* + * Get Feature input payload + * CXL rev 3.0 section 8.2.9.6.2; Table 8-79 + */ +/* Get Feature : Payload in selection */ +enum cxl_get_feat_selection { + CXL_GET_FEAT_SEL_CURRENT_VALUE = 0x0, + CXL_GET_FEAT_SEL_DEFAULT_VALUE = 0x1, + CXL_GET_FEAT_SEL_SAVED_VALUE = 0x2, + 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; @@ -926,6 +947,8 @@ 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_get_feature(struct cxl_memdev_state *mds, + struct cxl_mbox_get_feat_in *pi, void *feat_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 656450274001..b20de60bfc71 100644 --- a/include/uapi/linux/cxl_mem.h +++ b/include/uapi/linux/cxl_mem.h @@ -47,6 +47,7 @@ ___DEPRECATED(SCAN_MEDIA, "Scan Media"), \ ___DEPRECATED(GET_SCAN_MEDIA, "Get Scan Media Results"), \ ___C(GET_SUPPORTED_FEATURES, "Get Supported Features"), \ + ___C(GET_FEATURE, "Get Feature"), \ ___C(MAX, "invalid / last command") #define ___C(a, b) CXL_MEM_COMMAND_ID_##a