From patchwork Thu Nov 30 19:23:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13474885 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 9FAFEC4167B for ; Thu, 30 Nov 2023 19:23:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E384B6B047F; Thu, 30 Nov 2023 14:23:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E0E596B0480; 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 C88806B0481; Thu, 30 Nov 2023 14:23:32 -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 B323C6B047F for ; Thu, 30 Nov 2023 14:23:32 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 790FF140304 for ; Thu, 30 Nov 2023 19:23:32 +0000 (UTC) X-FDA: 81515594664.19.B5D8102 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf12.hostedemail.com (Postfix) with ESMTP id 7D8A94001E for ; Thu, 30 Nov 2023 19:23:30 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.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=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=/+/qxcZVYIyP+lYomX8dlpIjimgBpP2BzY65gZnyfu8=; b=AzB7djRB5BT9BIQu6sDhyfzMM90SeLwRyJUaC7NUo4p/rG/A7cUcQQAR9mzDLcbNxcnCDL 9jzgUqqpnC4vtL/SSDdBD9Y9n/sWxqFZd/1XCMdUxIMSBeLOhI+Fd0o2WBeAnerlCioZlc plfGmxTB5G5IzCjT5BvC+6HNrNgxNtk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701372210; a=rsa-sha256; cv=none; b=wbdNE2LNmzUtRGTgfxtiOUnkS8U6B3cj7VIba0h59G+osrPhIS7u8fG3A/9K/kvQ8dfJ/B c1B4xZcRcgG3ql+NEeo3OmWoFZ0YbQgChFfjCv26GIxCemqk82fycZCmQc3dKbOFfduYTl cvID9/B/ddeYB6XdjWgOYh7MYnBDXaY= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.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.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Sh5fR60KMz6D9Gb; Fri, 1 Dec 2023 03:21:51 +0800 (CST) Received: from lhrpeml500006.china.huawei.com (unknown [7.191.161.198]) by mail.maildlp.com (Postfix) with ESMTPS id 9F8081402CD; Fri, 1 Dec 2023 03:23:28 +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:27 +0000 From: To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 03/11] cxl/mbox: Add SET_FEATURE mailbox command Date: Fri, 1 Dec 2023 03:23:05 +0800 Message-ID: <20231130192314.1220-4-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-Stat-Signature: tuy4zmbci4afzq3hewm7m348ss9hxdux X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7D8A94001E X-Rspam-User: X-HE-Tag: 1701372210-646417 X-HE-Meta: U2FsdGVkX18PN6ABSlrjo2VxJ0PeDutqhbxjNogZAwxWr+Xm4i1qOR7B0DkoAPUC5JgDO2GF0E8HbVIiGw1ThF3RaeQO8NoE0SgJKNNNQYr6zi1yXzU54TUkGMvEYCQSo+U9QY+QpC0QjG2xK8TSxfqA8wHoZkeWQfk6E98gXwR6kcxXw3OYSnyBGyARPF4nLDvKslpb6RsXHlDw0iRaUca6XLtpWJt17tksbP2IXq5IfzEwZ8CSSCN1q94YNXvusuK9lSRDz95O87/CYGTvAkyYAuC4klO3h8vzCwk/s5VQ0xd+ES8YrlkaIuSgtrUx5WXkXwWiSLDZrwd8jKW+noxFyhJq+xn5araDpG1IOGrwGwtlM6hWOrk73liDZle9WQSxZ3wSWpUZKMmTVGI8s4rA0ZESKqthYC9MA2C1Y+MxzvsLxPM/7ICz6rSBv+YshrHtF1CYtx2QLY4xzwsADYZDjMcwdGejw+x8CG/vG2vq5yaKeibh03y6oXy4m9cR1xKr7kuKVkOBP/WKW4B8UGFDjKTcbiGTCwUgi0QIPVRuNAw7A4mGSePwpb8dKFWtTTr2adCFGsqcQjQ5uuckCLDCmJViCafCn7ZKscqOAubqSnvzQio90CNQyo0GLU/9F+7Au1laAId67pbJNvyrzQG6gQj+hFcDaTZAhRWV+LUrKKEitkdTn5D4XdC728I5BS/UQwpd6E3NIWLwTFi5BwqWNv3RWaCYFXyQ2MuDuCdAaais9pV2/MkTuYV/T8IY+ZWreC8gDfHaO2x8+tIFxXt7np9EJxqwj49VK5FZPQ7fYG5OEGo99JcmW1IW0hiXu74NsN1kHhwFBd8VVGEFlfZtRozr09mQIzQVWtRgGkE/pCc7Nr494nMMbWDjXP79ZI4GjedqvyQX5EvvnaZAF6lw9uxCkld7q6ZVVWLE6rWblRgCB1E5vFnAOrSabbR19ekoBQ9YbyMrnoHtIQB UA8+YTdp 4GWmSRdBH3hwQiQsLT0ccGgIvA3Z40Yl9EuYEzr0KDcZ+sgNpk/q5owj9pctyIettOEdI3+EeewjvRBwnao/TuTPGbISqT3off1ZBIGiZxseiBJXpEhcmyzQHAlgihV+/WkzJUVaC1x/9UyFxP8bfMqaLipzzeG5t+wMQDsBeOxqGTLMS3D249Wo5wmULvbYQS1+g+fVU664iHk49HMKyWCk3aBPnIUzv8Puwbdx87LL8SQk= 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.0 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 a50c874edebc..7f379cbb71a0 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1348,6 +1348,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 92c1f2a44713..46131dcd0900 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -508,6 +508,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, @@ -817,6 +818,31 @@ struct cxl_mbox_get_feat_in { u8 selection; } __packed; +/* Set Feature CXL 3.0 Spec 8.2.9.6.3 */ +/* + * Set Feature input payload + * CXL rev 3.0 section 8.2.9.6.3; Table 8-81 + */ +/* 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 = 0x0, + CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER = 0x1, + CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER = 0x2, + CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER = 0x3, + CXL_SET_FEAT_FLAG_ABORT_DATA_TRANSFER = 0x4, + 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; @@ -949,6 +975,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);