From patchwork Mon Jan 6 12:10:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13927266 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 9D3D2E77199 for ; Mon, 6 Jan 2025 12:12:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC1C86B00C3; Mon, 6 Jan 2025 07:12:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B71BE6B00C4; Mon, 6 Jan 2025 07:12:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99EE36B00C5; Mon, 6 Jan 2025 07:12:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 739196B00C3 for ; Mon, 6 Jan 2025 07:12:14 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3E06A1A14C2 for ; Mon, 6 Jan 2025 12:12:14 +0000 (UTC) X-FDA: 82976914188.07.B30D198 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf03.hostedemail.com (Postfix) with ESMTP id 47F2A20015 for ; Mon, 6 Jan 2025 12:12:12 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.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=1736165532; 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=qj8fIk87XTq15wXSZ/E4RmOjYBPumyWticVac73XBVc=; b=kV5vrgM9gYtMLmpqwAHXyKFv6KYfIi9hQ4LD0YYeqEQFDvFJXAR2al/HwpcaqrRVHoT9hW egJik/GjAY6Kfm9xMP+W/K4i5ivUouyWuNkzTFre6U4MbXn1XgN7Lf7XePDysesQ4xirAI /bQk4ZuZ998RUiNroDyjcdUIXbyCqFE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736165532; a=rsa-sha256; cv=none; b=iYNDasI9EjqawgKdnYO8INuIyL8fTY+mirROwI+svo+bIDgwwhiuaxF/D8fhXA4Hwi9iry rna/gzSFGr8nc61YAqGj42cODLARDRH9uEn0DW1RnBimF8UA5Gt+T5AzO2c0sNKV405XZE xRkZnDIy0DRDXTLB8Ffg0u9SF9rZS7o= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.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.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4YRY0t65wvz6LD8R; Mon, 6 Jan 2025 20:10:38 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 9E970140CF4; Mon, 6 Jan 2025 20:12:10 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.126.170.95) 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; Mon, 6 Jan 2025 13:12:08 +0100 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v18 17/19] cxl/mbox: Add support for PERFORM_MAINTENANCE mailbox command Date: Mon, 6 Jan 2025 12:10:13 +0000 Message-ID: <20250106121017.1620-18-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20250106121017.1620-1-shiju.jose@huawei.com> References: <20250106121017.1620-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.126.170.95] X-ClientProxiedBy: lhrpeml100011.china.huawei.com (7.191.174.247) To frapeml500007.china.huawei.com (7.182.85.172) X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 47F2A20015 X-Stat-Signature: od9xsd3ngbfj75ebbzk6h3ksy73tschf X-Rspam-User: X-HE-Tag: 1736165532-149676 X-HE-Meta: U2FsdGVkX1/l3XRbj218/xlJp1N6nV4PQpa0rhDNgq13f2EzS4P/qdDBNGLx23mPOLWCK59RPXR4ASJGe4fsh7DrCDi0SCDHnR8r82ECT71eTRf3j/holxkacmo0pQmZpUTPx7IHRRrR4h40uYqKSjR/kf/EbLOQDMnUwMCLsDDfVMElVSjE9IUIU/sbq+hAv1fBbY8H7eShCxK0DQ13SgpTTOv6Y+GHLNeJGhcjRPCvVbm7s5nQauhn9u8S/xJKp9Vfv0L1Ytdo2tw3nc1TJU6F+GUcs5dQXoeAMT0Ojv+FO+vAguXNCX9Y08htOrEPV3oeT0gPsTsdGgR2rLHzLg8OXIuT7/AqBlqYH5dB9X9xMRy8XBCc+ogzQG1Uc7EydmwMSngugi352mILOLD/uWIktgDdQGC7zTmC+AZJ5nZlag8kRcLuCSpLR2mb+RF0dG3a0J5Alu6wpkPRrTQ1uiPmo1qxkT2vq/2xwwdOGrko15yUsf1fh5R1VJ37CKCp4FMQqxI8SkYBMEYeS76U1VvmB+Qp7+Tx8c9Ofx5MEe/OUh5csvU8qSvragtKnf884t1BJ7d+pOKFu2I8vzi+xBfJ/VN1QAvbuq4+rPsofYRcFoe7njhMuAq2CAAtlMWyAnj9Tx+zBaovvHZSl29mZOuRHoJJnpmP+FMJ2bZAlS5Houjcm24jGqd73gs7SSuZBQZw+1LvL8UA3ENnfhKTr0IBgrAVlpmGpfMyttOJ4aJ9l0wYd+Ig0rikrQxlg3hu8IgEQPU0vMw++4EDfLKUOk27zy6/4+0Q8LTn3gkknHR7nAts1kp1o9FkyPLKsncpPuKZJp5ceenmNoipjaZTFzaVgaabfnscym2az6wWE934mhPQ0xbhbXpGPMHIqKxRpPA/NXk4EIkNbeEVLUpBpVRVnN8nelhTnbS24E0geVf8IZqKhNT4kUOyi3pZ9migpceLj9FqwTrSk4bnU2Z vRNL59gp HmMlfYu+ODfMuyrN2cG5t9W7PT8FxhJPxjPRUzeA3mfskPix2JZfnL3oS9+4uOyN29835Au9M6aD9tcgjmR6F5poyWyYZvou/PzcbuEyTpgBw9NmORfi6xK9Me8+I7XfQUjiEj71lqgjsYxnMQWG1gH74QJioBov2QtZe+gkPK70nhE08PW4G40Qq7ss1k+YlyHrkCwyHGTTUWMbG2vYEiCSeHC71+0SoOYhRTzFCgX3N6b4uAFfyTE7a5YAixpM66l5ru+Oo+Mc3nr42hWZD8bmwYteO1oUXAZN8 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 | 34 ++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 17 +++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 0b4946205910..bdea003172d8 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -832,6 +832,40 @@ static const uuid_t log_uuid[] = { [VENDOR_DEBUG_UUID] = DEFINE_CXL_VENDOR_DEBUG_UUID, }; +int cxl_do_maintenance(struct cxl_mailbox *cxl_mbox, + u8 class, u8 subclass, + void *data_in, size_t data_in_size) +{ + 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 2b02e47cd7e7..7ad75ab739e5 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, @@ -776,6 +777,19 @@ enum { CXL_PMEM_SEC_PASS_USER, }; +/* + * 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); @@ -842,4 +856,7 @@ struct cxl_hdm { struct seq_file; struct dentry *cxl_debugfs_create_dir(const char *dir); void cxl_dpa_debug(struct seq_file *file, struct cxl_dev_state *cxlds); +int cxl_do_maintenance(struct cxl_mailbox *cxl_mbox, + u8 class, u8 subclass, + void *data_in, size_t data_in_size); #endif /* __CXL_MEM_H__ */