From patchwork Thu Feb 15 11:14:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13558138 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 F19CCC4829E for ; Thu, 15 Feb 2024 11:15:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DAED6B0098; Thu, 15 Feb 2024 06:15:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 666018D001B; 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 4392C6B009E; Thu, 15 Feb 2024 06:15:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 266506B0096 for ; Thu, 15 Feb 2024 06:15:12 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 085181A0FF2 for ; Thu, 15 Feb 2024 11:15:12 +0000 (UTC) X-FDA: 81793781664.27.9A5F42B Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf30.hostedemail.com (Postfix) with ESMTP id B33D780012 for ; Thu, 15 Feb 2024 11:15:09 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.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=OXp/r5asDadSLFNBBsXrAjoXHkXI/bBTNbonYYfXR/8=; b=PPciSFhrPHuR9O8+sv4L34jUPDWP+dRZl0Uq4kjriXq8UXpRiMg0n03c+mBch9AAPRMNQF N3NVyhOKAI0fI7lsfUx1TmoLSytsL9EQcWeiEN9G/PGZS7hWlfXmwBlEuXuLWZrqnF6Ums YelCb8rtcFIkQy1hRrxlxPzq7bT8Q4U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707995710; a=rsa-sha256; cv=none; b=r7q0FNXtLrV0BIvNzk7Q3/zwma/AGIZ+wkoVbmrgMIcAkAcGrp7CTWQ0ba5DcoQUUA6Eo/ 0ndZMKTVM6WmDq6ly0MYzrTbaQ9Qyp+0QMaYB9mnXqOqh2VssapuwFahvoQHenkvcr3p52 nCIB7WFXyDOBgxrZzl14nrri1HSmPTU= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.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 mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4TbC6d1wZSz6J9xX; Thu, 15 Feb 2024 19:11:05 +0800 (CST) Received: from lhrpeml500006.china.huawei.com (unknown [7.191.161.198]) by mail.maildlp.com (Postfix) with ESMTPS id 6E39D140B55; Thu, 15 Feb 2024 19:15:07 +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:06 +0000 From: To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH v6 03/12] cxl/mbox: Add SET_FEATURE mailbox command Date: Thu, 15 Feb 2024 19:14:45 +0800 Message-ID: <20240215111455.1462-4-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-Stat-Signature: xwfwmb64nqtnyjie4fcs4rp3knhqbnw8 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: B33D780012 X-Rspam-User: X-HE-Tag: 1707995709-130061 X-HE-Meta: U2FsdGVkX1+5qVYPdLPMrlP7FoeZET9p3wTYtiv+OPaALJlneH5NZhvvPT8ENZkll2KLV/KCRn1sHE3UHvlf796grV1QRBeyE2FW7cJl5301m31Y4ZwTsVfCg/1HTkcvT8EaYY3CSEZ4/MpAZ40vRQdjKVTPNMcXGwWjZuV3IYqaT/1se7SZ/a6KQtZrBRXM4pxnXzfm1MPCR/gU7uPjKyNp940NWCOPB+TjmGO19nhlAGo+8Uy2ky/+eBhWYvEKHCHaV++jA4aCW92RhZxp/Rc4NdVSGiiQ6rWYpOalS0sHXbJzXSxvwZdynQLSRREO8Q49Vyckbx3PPCpwM+RiM6jwX2Rqq93ZH8gB19wAlRu/2cv51+Ai3vJKSzPUdhaGgkV582xyNr8xL4TElPS04g/8ug+sNiVUfZikO9660lxP9gkQVRAvVeohl9XVH5Lk548o4KPwx/o+jvuIJCwmX2Mib41715U+fdNhLJxofalyP2RRlUgOsJvKCncduFFdwT6ivfdTDBW4crcbKMsxQ0pcaDQEaWm9UdWezlo2Q2u4rwztTOypzTjJBbgQXs9swgMsjIA+MMr5TPwegCwmnxbtWf5WFKQh3+X4yHXEk1I7CKbryHjMlkUXJjC6vCBhFrdd848i3kewiLphyNUUajgKDEBwJxHQIJz1kDtXGHgjEaaJ7yb9lRpjr7n0GGgmVDTirO2Odgi60oO8oGRyFmbNFt82hNxvDin2tT5aLxclkHhHbBjDO/RCjKqVuyXHwIp2//6xgIl8z/Dhy4KrR9pMxivR7+1S6BLWlMIHmd7J9zhtVPpZYH4a9RcKtFVe1m3f16HSniTKohC+ApPhWaRXW2jc+UzuaJ9mc5oAPj0Zlgm4BdM6fiGMCK2F+SSzsOAIFU9IG9LjcAfr4bdsFYwIOV8u/Kq4aBWzcu2wn1G+M0VNUyFuyAoXiJK417d/YErh2thQdpKI8UTfzY+ cVpGmwl3 KUt3wGtoosSho3d0mgvepd1gkRVF4lzXrfGGrn39zq2f7L9YVFZeBK33ixos1CkwYMC0eN2XJxCG4A68wlII9I/oe1pqRRTeYMlT+Dz3dwIkGEdaR3RJjG9hEZtWMhIcUFxG3iDrQ0ZWyiiLFU/Fs0FVCzXMwHo7r8T/ot457bf/422EZ9ao+1lzukVBuss1Zyu0R 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 SET_FEATURE mailbox command. CXL spec 3.1 section 8.2.9.6 describes optional device specific features. CXL devices supports features with changeable attributes. The settings of a feature can be optionally modified using Set Feature command. Signed-off-by: Shiju Jose --- drivers/cxl/core/mbox.c | 14 ++++++++++++++ drivers/cxl/cxlmem.h | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index f43189b6859a..056576862b8a 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1335,6 +1335,20 @@ int cxl_get_feature(struct cxl_memdev_state *mds, } EXPORT_SYMBOL_NS_GPL(cxl_get_feature, CXL); +int cxl_set_feature(struct cxl_memdev_state *mds, void *feat_in, size_t size) +{ + struct cxl_mbox_cmd mbox_cmd; + + mbox_cmd = (struct cxl_mbox_cmd) { + .opcode = CXL_MBOX_OP_SET_FEATURE, + .size_in = size, + .payload_in = feat_in, + }; + + return cxl_internal_send_cmd(mds, &mbox_cmd); +} +EXPORT_SYMBOL_NS_GPL(cxl_set_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 eaecc3234cfd..2223ef3d3140 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -531,6 +531,7 @@ enum cxl_opcode { CXL_MBOX_OP_GET_LOG = 0x0401, CXL_MBOX_OP_GET_SUPPORTED_FEATURES = 0x0500, CXL_MBOX_OP_GET_FEATURE = 0x0501, + CXL_MBOX_OP_SET_FEATURE = 0x0502, CXL_MBOX_OP_IDENTIFY = 0x4000, CXL_MBOX_OP_GET_PARTITION_INFO = 0x4100, CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101, @@ -778,6 +779,31 @@ struct cxl_mbox_get_feat_in { u8 selection; } __packed; +/* Set Feature CXL 3.1 Spec 8.2.9.6.3 */ +/* + * Set Feature input payload + * CXL rev 3.1 section 8.2.9.6.3 Table 8-101 + */ +/* Set Feature : Payload in flags */ +#define CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK GENMASK(2, 0) +enum cxl_set_feat_flag_data_transfer { + CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER, + CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER, + CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER, + CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER, + CXL_SET_FEAT_FLAG_ABORT_DATA_TRANSFER, + CXL_SET_FEAT_FLAG_DATA_TRANSFER_MAX +}; +#define CXL_SET_FEAT_FLAG_MOD_VALUE_SAVED_ACROSS_RESET BIT(3) + +struct cxl_mbox_set_feat_in { + uuid_t uuid; + __le32 flags; + __le16 offset; + u8 version; + u8 rsvd[9]; +} __packed; + /* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in { __le64 offset; @@ -914,6 +940,7 @@ int cxl_get_supported_features(struct cxl_memdev_state *mds, void *feats_out); int cxl_get_feature(struct cxl_memdev_state *mds, struct cxl_mbox_get_feat_in *pi, void *feat_out); +int cxl_set_feature(struct cxl_memdev_state *mds, void *feat_in, size_t size); 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);