From patchwork Wed Oct 9 12:41:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13828317 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 EF370CEDD89 for ; Wed, 9 Oct 2024 12:43:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 999746B00EC; Wed, 9 Oct 2024 08:43:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FBA16B00ED; Wed, 9 Oct 2024 08:43:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 727A36B00EE; Wed, 9 Oct 2024 08:43:49 -0400 (EDT) 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 48CBB6B00EC for ; Wed, 9 Oct 2024 08:43:49 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 963711C708B for ; Wed, 9 Oct 2024 12:43:46 +0000 (UTC) X-FDA: 82654030578.22.9093A1E Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf23.hostedemail.com (Postfix) with ESMTP id 17458140003 for ; Wed, 9 Oct 2024 12:43:46 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.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=1728477800; a=rsa-sha256; cv=none; b=4CUrTk1zOEpB546IlVgRfYP66twvwMp77mrOGLJQ8gvtRVc21FHgL27R6OZvMDf1mU9U/R 2VHd7MQVSqeXQ1EWUiJ6CeMhiqGo5lEwPztSCQw9RFCmAd4zij24pY4cEWk/iuZuamLz23 xGigMkQdyAiijgBt882E/GByu04p53o= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.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=1728477800; 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=+5mjIzbeAbCrusCOBOCtKGbNzFUSuXmFZDHBTFoArCc=; b=3w05daDvHIZGF2fZPU6asiaqAqiydRL5Qd7JyZyKqXNt2gPzYA1FGF4cf6gKALpsWNbMZo 62yEr7WaG8IBzSZ5g2RpxKfWYISNM9fagjB2rnr8ZwuyPosObBL0MG0MyZ0esfNCAkVqLo Jw8ZzCcnhBjoUfXdiHBlrHwrdIgpIj4= Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XNsxq5HVdz6GD5L; Wed, 9 Oct 2024 20:43:27 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 79C74140133; Wed, 9 Oct 2024 20:43:45 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.48.152.209) 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; Wed, 9 Oct 2024 14:43:43 +0200 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 16/18] cxl/mbox: Add support for PERFORM_MAINTENANCE mailbox command Date: Wed, 9 Oct 2024 13:41:17 +0100 Message-ID: <20241009124120.1124-17-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20241009124120.1124-1-shiju.jose@huawei.com> References: <20241009124120.1124-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.48.152.209] X-ClientProxiedBy: lhrpeml500003.china.huawei.com (7.191.162.67) To frapeml500007.china.huawei.com (7.182.85.172) X-Rspam-User: X-Stat-Signature: dmumcufi31r1jt4aai1su4ri55e6uffg X-Rspamd-Queue-Id: 17458140003 X-Rspamd-Server: rspam02 X-HE-Tag: 1728477826-72145 X-HE-Meta: U2FsdGVkX1/+tJBZwFgspe1rkN20lYDrm0CzJx1GmB2gzw9zoLpf6WuEcTmxzBBhILoaQxLw1J0qMbfE5S/KtokQVVnChRIQiUV835J4vW4VOpHsMKlrASK2D/J7/vQ3KJnKkWga50UiG8nk6cBK51TEiV0Dbty4CD+jjMnaK6Wbi3qdjzQYVSsAz5iOaqSm65Z1rbN4OrDSbeYgyct++ZQdU6KXekVP6thzIfR4iwuDgRHpBEf/g7oBKZVBRD1zZmTPZRDP4gXCE41D0L6ESP/JymISxb2S/u6XEDErxuyGG35/Ax25cvbJEx4CywrjXlUi8AME7PJDJD+OSHgFBMRkqq1NapY7McAJE58kTu1+0sJtlhiaSnHToPuFLA5fmDKyT+QM4a8OHGvI04LrbrUr2ybuKLnZNTEV7dTiW000/VWKIkwSgvjDYYWS0rmouENFqlwIL6BWQVSlgT886yxEaBmgbiFE599lG55vWzCz2v0PFAsw3m6ofpTvJZmduBBasqup6eCT+0ZKubXi/hgJ54PGQt1G+T03d8gT0khfZ4AgA6D8ux0yfYE2J+nABLCQvhEN36ofsvdjweqkDG0Jgt46fuIjZwztyCR2d3tdYWz7jntmB/I0OW3V/KqcCK0/sYfOXYGePsmLGUg0gcOxkOgIAmUJUdgZfP0XPh9eygYescEwLg6raQG15c+drRx7YwFKahxZegQQBFXuDNmrXpwKJh8/zaIIv/TYyr4CuIMNxxAyAq2jMnrkbczbgz8+cqIkEQ5h33zSb7awrkvPAGYgaAvz9cRv3Fy21/sA+k0htPNE3CaQ01fagy/W2D6qfrKCQ6NlGZzaP1HhDUYRIOjcDab3xTVD4gw55lZf4XRMg2oEtqMCQJ4ZoNy4l+l+jdZOJ+PiYf8LW0I2xq++cl4d01sL+cIOp+r0utqcwjlZjI/v4ubq0SQhK8k/NX7Igw7F6RgN0GqhPSl 15kPJJKk dbIgU/jSg4sRW6Stj5hk/VJu4ekhOz7tIJCxSrxrbO6Y1CnK3lCCjitIQxlbu/44uhXBGRdmh5X2f1O7Kk8N8bTnxTZmCJVzL2wEdUatKpLgw7dfF4DMv5Q1uFkqlmNZ7hM7SYDDyUpsVxLn9ciuEjrI7cPRzV5r3djZ6u+bz/IlQcIkyI6zwulgNqAFmaO3Y5jTMLViNYPwMcw+4vTKtd9iVnjUyjHi9pKPpidwcV8zmkmDb6/9ahYklBaxSaA+TEbOeXMpzdAB7ebE= 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. Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- drivers/cxl/core/mbox.c | 40 ++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 17 +++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 30c44ab11347..a6f69864c504 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1084,6 +1084,46 @@ int cxl_set_feature(struct cxl_memdev_state *mds, } 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; + int rc = 0; + + 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, + }; + + rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd); + if (rc < 0) + return rc; + + return 0; +} +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 e1156ea93fe7..1cd50ada551b 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -531,6 +531,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, @@ -907,6 +908,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); @@ -984,4 +998,7 @@ int cxl_set_feature(struct cxl_memdev_state *mds, 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__ */