From patchwork Fri Nov 22 18:04:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13883515 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 CA994E69185 for ; Fri, 22 Nov 2024 18:05:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE01E6B00B1; Fri, 22 Nov 2024 13:05:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B90BB6B00B2; Fri, 22 Nov 2024 13:05:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2C2E6B00B3; Fri, 22 Nov 2024 13:05:25 -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 800366B00B1 for ; Fri, 22 Nov 2024 13:05:25 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3E0771C850D for ; Fri, 22 Nov 2024 18:05:25 +0000 (UTC) X-FDA: 82814506110.25.467DC5E Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf15.hostedemail.com (Postfix) with ESMTP id 782A7A000D for ; Fri, 22 Nov 2024 18:04:27 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.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=1732298655; a=rsa-sha256; cv=none; b=ZHAs2aQAkg/KFpUmCBFI6GTrf+l+6qMPjVjG+kIto4KKHYyQx5m47nkdOuanwTQ9fyvkoY A7/L5qP2huryoCYXw2AIfrajzeKbh6fJyNrQu7jSgMP/tq0q8OIS89Cx1L/NygQK6vmKgz VXDj0Ve9is+JDpuSAWB5KsYEtR1x17w= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.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=1732298655; 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=/ofvd9IAyEDOrxeSz7+2tEoNAKHQKkKkzMo8s067JvA=; b=4sfE4kxqXl/5bHEQv8eHOCqTp5Mstp3NqetBfqP0UjiOXVyLuHyvd6Wwo3tgB3jWjXJDiA gGuyrZf0k6NKxC9k7Co0avxXaTAE4pHCTf0q3D3eMs1KdTkbpCMiYuIDbD33mZIvFTbxaL YdbU/3qhEROUbYQ7Vqzsl8MHWbqcfIU= Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Xw2y95mzhz6K96r; Sat, 23 Nov 2024 02:02:57 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 255B4140B3C; Sat, 23 Nov 2024 02:05:21 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.126.171.16) by frapeml500007.china.huawei.com (7.182.85.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 22 Nov 2024 19:05:19 +0100 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v17 16/18] cxl/mbox: Add support for PERFORM_MAINTENANCE mailbox command Date: Fri, 22 Nov 2024 18:04:13 +0000 Message-ID: <20241122180416.1932-17-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20241122180416.1932-1-shiju.jose@huawei.com> References: <20241122180416.1932-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.126.171.16] X-ClientProxiedBy: lhrpeml500002.china.huawei.com (7.191.160.78) To frapeml500007.china.huawei.com (7.182.85.172) X-Rspam-User: X-Rspamd-Queue-Id: 782A7A000D X-Rspamd-Server: rspam11 X-Stat-Signature: 9pabuhjonxqt1u9jf3o3ise7fp7tgw38 X-HE-Tag: 1732298667-450970 X-HE-Meta: U2FsdGVkX1+votYDPCvktzqMFsS2q9zHBblNGqT1u+QXYxOjjeqhn+kg1m/zMLZ6xsQH2Ogs4mkFivJYKscsigZmsg8rspWoXMU/U0SJ4JbWIa8RwFOsDFlW2Edf59yqARpKFViUAtaCZht1+3Xu/HoRFzMxYKaY9TZe2jXxTF66IgXwkTUSob7yCL++56doz9GGnBD7WP6hvEB/Zlm7BCZbRVxgQBvo+bBHRdFQBss/0VE5rTUNJagvulqM9dBfCIIR276zfsshWjqI987HEQZOEv+MZbC5Z+hLSzU5MwVwiTKmBUktQfzZK42Nqgb3qf8MH98MTvdO+So870+QNAjRa7r4cBm2xGoNCsXFcrn43UPANypYH6tUZ7N8rgUeMb3eymD+/3bi+JcGicrlRj7DWK0Qmv0QlXsW1+vdMvB54PUM2cVmpncY8VWc7fSUGROR2V5VvoDdHrKaYUyVp6F2yP5vmtm/idcDFLlhOW7oro+5+QEkYv4hza6BxMe6G41LPShT8IMkRN/joAVBJnZgNPkH19KvLJUANJEdegW5X+iWXHOQ6JuBNWnX0/JAAqwww1yiKrLG71ZQyYHO43Deh6Q3i4d67PW8d4ACbN3xWKBODTkE5/SuXq9nxYQQuWZORPd6w420OYOYq24zO0nPGnGwN1UCLyzj9URtpR00j44sEGuc/VmlV/B4dFIfVWsQs/5lELETs4depUZfBWFGvIMM47poglxbToIMkZEsMT1tTO1DmpvVd9FS2OX6zMRwUuPyhhKdRAWsUgWUj0iO2erxQuI6UjQRBw6K0ztx4QEP+iknUsLOpoGz7ljO5FXt3s4Zi/baXrlp5VEXmEhEiM5QNQ5zoK5M4iQDV5F9oTtAaghgJ6/kFZFxZ7SFxmQ0VV7pcyHC9mTTYB3mtFYRtZBhga8gnlcKrrJaANTTDZAaYtRXr1obTDOvzadWB2nIOPrqkBaA9xcc1y/ v+o3xSV6 bkyzHP1bW2CDvPgURdkcLmUYUuyWJSedee8HFKceWQO3+Uo8V2vZiBrfWVB93D7/Ijo/UKDObBnYyjCjGfjE2los2jpyYjokFih8m0UcEceunBovjhg3pOGExqCi1F2bvfyjY/xckfk7WRcxtFfl2U3RqEomMJUccsjj+W7owGknwy/K2g1jqFY7xF26BqV1/inR4BTWLKV13p1opzdje8iU2iLuDPzNVWtVe9/8wGmPBeUzE3vs+egRr6RxhxTFyXQ2xcxbqqettfAlTQm1FV5913FQnWoaFDi3q 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 PERFORM_MAINTENANCE mailbox command. CXL spec 3.1 section 8.2.9.7.1 describes the Perform Maintenance command. This command requests the device to execute the maintenance operation specified by the maintenance operation class and the maintenance operation subclass. Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Signed-off-by: Shiju Jose --- drivers/cxl/core/mbox.c | 35 +++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 17 +++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 117205f45d7c..22e3f8ec1533 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1085,6 +1085,41 @@ int cxl_set_feature(struct cxl_dev_state *cxlds, } EXPORT_SYMBOL_NS_GPL(cxl_set_feature, CXL); +int cxl_do_maintenance(struct cxl_memdev_state *mds, + u8 class, u8 subclass, + void *data_in, size_t data_in_size) +{ + struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox; + struct cxl_memdev_maintenance_pi { + struct cxl_mbox_do_maintenance_hdr hdr; + u8 data[]; + } __packed; + struct cxl_mbox_cmd mbox_cmd; + size_t hdr_size; + + struct cxl_memdev_maintenance_pi *pi __free(kfree) = + kmalloc(cxl_mbox->payload_size, GFP_KERNEL); + pi->hdr.op_class = class; + pi->hdr.op_subclass = subclass; + hdr_size = sizeof(pi->hdr); + /* + * Check minimum mbox payload size is available for + * the maintenance data transfer. + */ + if (hdr_size + data_in_size > cxl_mbox->payload_size) + return -ENOMEM; + + memcpy(pi->data, data_in, data_in_size); + mbox_cmd = (struct cxl_mbox_cmd) { + .opcode = CXL_MBOX_OP_DO_MAINTENANCE, + .size_in = hdr_size + data_in_size, + .payload_in = pi, + }; + + return cxl_internal_send_cmd(cxl_mbox, &mbox_cmd); +} +EXPORT_SYMBOL_NS_GPL(cxl_do_maintenance, CXL); + /** * cxl_enumerate_cmds() - Enumerate commands for a device. * @mds: The driver data for the operation diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 56cba1e97d65..b30e743f33fa 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -493,6 +493,7 @@ enum cxl_opcode { CXL_MBOX_OP_GET_SUPPORTED_FEATURES = 0x0500, CXL_MBOX_OP_GET_FEATURE = 0x0501, CXL_MBOX_OP_SET_FEATURE = 0x0502, + CXL_MBOX_OP_DO_MAINTENANCE = 0x0600, CXL_MBOX_OP_IDENTIFY = 0x4000, CXL_MBOX_OP_GET_PARTITION_INFO = 0x4100, CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101, @@ -882,6 +883,19 @@ struct cxl_mbox_set_feat_hdr { u8 rsvd[9]; } __packed; +/* + * Perform Maintenance CXL 3.1 Spec 8.2.9.7.1 + */ + +/* + * Perform Maintenance input payload + * CXL rev 3.1 section 8.2.9.7.1 Table 8-102 + */ +struct cxl_mbox_do_maintenance_hdr { + u8 op_class; + u8 op_subclass; +} __packed; + int cxl_internal_send_cmd(struct cxl_mailbox *cxl_mbox, struct cxl_mbox_cmd *cmd); int cxl_dev_state_identify(struct cxl_memdev_state *mds); @@ -959,4 +973,7 @@ int cxl_set_feature(struct cxl_dev_state *cxlds, const uuid_t feat_uuid, u8 feat_version, void *feat_data, size_t feat_data_size, u8 feat_flag); +int cxl_do_maintenance(struct cxl_memdev_state *mds, + u8 class, u8 subclass, + void *data_in, size_t data_in_size); #endif /* __CXL_MEM_H__ */