From patchwork Fri Aug 16 16:42:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13766606 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 C5702C531DC for ; Fri, 16 Aug 2024 16:44:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 838158D009A; Fri, 16 Aug 2024 12:43:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 796638D007E; Fri, 16 Aug 2024 12:43:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DD6F8D009A; Fri, 16 Aug 2024 12:43:58 -0400 (EDT) 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 308038D007E for ; Fri, 16 Aug 2024 12:43:58 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E4F0FA0011 for ; Fri, 16 Aug 2024 16:43:57 +0000 (UTC) X-FDA: 82458680514.27.5E0F6DF Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf15.hostedemail.com (Postfix) with ESMTP id EEAEFA001F for ; Fri, 16 Aug 2024 16:43:55 +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=1723826575; a=rsa-sha256; cv=none; b=b4KVCdEa6tYnw4FG0b7wCHgtMm4oVWNPDu7cQ/6moJ3ZFscajS2oe4bM7RCiE6v2sWvS6X 1k5yjzfmVCx9bEosYFrUJiC+OEqdSljGv8ctJzQukXclockhHJLDFUpP8CuV427DpqfiLr KBcxusg7eS5yaTFH+rV3kuefWn6BUGE= 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=1723826575; 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=wj2GoLc0vZfGtCTkuzUOTZtR6hso48BikQ3190WNIC4=; b=Dw1Mgkxnz8xRh+jm+J6mO56+t3T3qj16f7Ux81t0z/457gEbx4gwWnAnKhDOtu3U342b8E K1NqlZTx5VJVH5ISEWUiT7+ULr1/fmiGByuxyLs1TjpMH4YsO8hQrHakP2EmtmPi1KZrmW deJxnssOiA01IP3bR/C4PeRGJ3dq3TE= Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Wlnml4kNZz6K95v; Sat, 17 Aug 2024 00:40:55 +0800 (CST) Received: from lhrpeml500006.china.huawei.com (unknown [7.191.161.198]) by mail.maildlp.com (Postfix) with ESMTPS id E7E63140680; Sat, 17 Aug 2024 00:43:53 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.48.148.43) by lhrpeml500006.china.huawei.com (7.191.161.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 16 Aug 2024 17:43:52 +0100 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 13/14] cxl/mbox: Add support for PERFORM_MAINTENANCE mailbox command Date: Fri, 16 Aug 2024 17:42:36 +0100 Message-ID: <20240816164238.1902-14-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20240816164238.1902-1-shiju.jose@huawei.com> References: <20240816164238.1902-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.48.148.43] X-ClientProxiedBy: lhrpeml100005.china.huawei.com (7.191.160.25) To lhrpeml500006.china.huawei.com (7.191.161.198) X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EEAEFA001F X-Stat-Signature: i58c1xd3rgk51uiy3ki7gs9zzb3sy158 X-Rspam-User: X-HE-Tag: 1723826635-289213 X-HE-Meta: U2FsdGVkX18RZ08NeMPiNH1dHdM9u69m0H27+u7paUMO8qha9Zgqr8aPvteDvLgl5jOFUbDX3ROo4ETbhMqf0bvXHoNQtkLLd3NKa+r3B0oM71lW5+w9CMR8+Djvpi1WHuBGK38ISHQaoZw13CLe56IGUiY4OAWBnHY/5oZrgtdNyEePAb1ebqlmK0DUIrehBzwg0bGGJAfncRPWFSHjSjrONantp7Er9Yej8dBImPM5AhxaPRaxXhS+YWgiT/P3WfIl9WZObuN61vPgNeEpAwKgOuHYG/r+nYxsF0h2CBGPWnhHIHUFFLuK/9vvNfaBCC2FAgIRfACtlLBcjLDHRhwKz0TKCrb6Yo4G0O/FZBPHfCuBx8ATvg0gCmraL2wAlN73ERGjuA4cO/0XrgU53ZPfyzuEqD+VYtF9nVAm+Bb6pwOvg/m8UozvyfbfqLrukGAR0xk6F34LImjdcDvyGYMo4UWjqYjHS8uBPew7XDZWe9cB+O2nPk93IR68LD2pGY64Wtunvr3QEEJ1W3P0frFJNXx6h/2/ZkDksWvAJVjaadM8CpzLxm5qSKdJ+Lz4deaJZaTlrVIKaFe8sqmXMa3PFkU9LuANjZTgwAVKG7NspfbXkh8f+95cLAchq/tITA4MRo7hXlVJYZIzrWxYWLj6DyzOPUvqVlkeQmlIaLA87LqdEF+81R3LtXEHuQSyzCgD6wfi6p8APyMI7iDsVkChk0TAZpyOZ/ECW3RJJt+WxL9qQG/5BvIhTVWrny7V9QspAg0loVW1m+c5qZ+/3Y3MpgLhi7wKbYYbIEIoXF9kpi5F0MWebuBVljgsXt4TL3CD/34+jbqHtGRMslx9l/61Ko9TWYz5MNXLm3H/3j/+10QrvH9ujFXPGwEPHMNEcF9Pe2X1lRsgTdtJ+CnCh+YJ7jgk9HMZe5CmnNfC734iCZMPoRuxPy//gm4612UzfK/enLBkSrxX2v82fvR URUj+883 sjBzbjK+VemYyGoxP7qszJmffv9XjvD708q07XxnxBFcFS/BIKwh2WAb7ET5xlVPnB13SK9nUOtOB1Oq7XUIXyC30NbZA05AupAvLDtJ2OjD2MhxYHSlAuFiOajluQgz67MDljUjIHAXi5MkJBZBbDBP7ScXAojBC0MD+a8Qg1SrClXIQrrprfyh88OvvXOOEDsXf2lT37Bu40EA7HXnWtHQV78aVh+xmqheyv77SMbWIhqUC3rpf4i9Rqk/wxdUtRgdfVWal6Smtpdk= 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 --- drivers/cxl/core/mbox.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 17 +++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index f79269add159..1665365a1e26 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1504,6 +1504,45 @@ 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_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(mds->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 > mds->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(mds, &mbox_cmd); + if (rc < 0) + return rc; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(cxl_do_maintenance, 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 c6f6e38bdbcb..f525eb330dea 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -534,6 +534,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, @@ -811,6 +812,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; + /* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in { __le64 offset; @@ -955,6 +969,9 @@ 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); 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);