From patchwork Fri Oct 25 17:13:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13851089 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 9EA3DD149D7 for ; Fri, 25 Oct 2024 17:15:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80F0A6B00A7; Fri, 25 Oct 2024 13:15:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7970C6B00A9; Fri, 25 Oct 2024 13:15:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 611C66B00AA; Fri, 25 Oct 2024 13:15:04 -0400 (EDT) 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 385366B00A7 for ; Fri, 25 Oct 2024 13:15:04 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 052E5A0E32 for ; Fri, 25 Oct 2024 17:14:27 +0000 (UTC) X-FDA: 82712774718.14.2FF1776 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf18.hostedemail.com (Postfix) with ESMTP id 222DA1C0026 for ; Fri, 25 Oct 2024 17:14:52 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.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=1729876348; 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=AaxYIIM+Xr4sD5XOpCAuPHmhkp1+8cGL1+ntyK24f7k=; b=A24yeueSr/3kewQuahXc9qX/cb3vGHb9C+QKFG6RAw/UFR33oHv55RHizqvCxpBHvd0NjQ BeeYWtRnhDKoNNUEwd9qKiI2mtUiTjzUZ6qK8RN9q4kgx48DZyPmFFsm1JwzYF4E9hiq/d f9Fk9TYobPYTbxvsPCG5+sRiZ4g/BSY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729876348; a=rsa-sha256; cv=none; b=1oidluwV2f6mnEaDGTi9ESslObIRBVFwi5dheO/wd/m0u5QCQHvKYBCW9qXraQxFj1db3t Us8aNSb/08vmECocwbYqUE6nyRav4qU/0E+WVEU/EWmQa6SiWD0LEbIFML2lJKWEFf8HbW DbQgwzpfw0c8NfoMEDcQtOkyyEcQQOw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XZq6J4zZcz6LDDh; Sat, 26 Oct 2024 01:10:16 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 29D8B1402C7; Sat, 26 Oct 2024 01:15:00 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.48.151.104) 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, 25 Oct 2024 19:14:57 +0200 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v14 12/14] cxl/mbox: Add support for PERFORM_MAINTENANCE mailbox command Date: Fri, 25 Oct 2024 18:13:53 +0100 Message-ID: <20241025171356.1377-13-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20241025171356.1377-1-shiju.jose@huawei.com> References: <20241025171356.1377-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.48.151.104] X-ClientProxiedBy: lhrpeml500002.china.huawei.com (7.191.160.78) To frapeml500007.china.huawei.com (7.182.85.172) X-Rspamd-Queue-Id: 222DA1C0026 X-Stat-Signature: fhwsi7xhmxcaces6nxj917tkmudggkns X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729876492-839646 X-HE-Meta: U2FsdGVkX19+b+wfDpak9FNJZ8cCMr+pR8zVij3b/7YsybO0fIl1Mb8XlXk3cN5GGaGWQV0nLYB+SgeoadjSMj9AXvm7MgnbQdoXeXnrYir08S5HcmJtFXpVo+8X4HiBiDyVfio41rs/df9OMO8wJfbX4LFfBaRzjb+Bq1KNVXB3JR/ag+q9DnjXj36gcgxMdG8cnQ8stkIFU4F+PB6RjqNRXfHQbJr9tMVaYGoYM0ph+xk8rciaBFyEXdl1gzezxFf99AtfrkmOryZE/ztWmtGvmwqCbv1tBGojgimYDZkUs2TKUEguyc8HeFRCvFdhocvHuCInFyRHuYSMqVOthc4GcKgK0vSoU+SbJabJJPUCljKmsdLoOz2o+ugzrKCAelwI2lfBczRytJcONzBbZCqKkYMrpnPKSfChtk6FcHwCqNjEZdP1oXrQRxylPLAZ9OsxZpgQeC3fDDRrBaUpcpNoYZj/4s8ewQucWa99OlnXWKv/elNXYR6qRvO3iamT03tw2fwPPfZouv0g7sYUxGqk95/7217xYN/XiZDp1OQwzZMEHiKns72JKGdh9XsNom0cK3oUz6lEHQEi9JwgU/d44MrKYoYTzg8d4lUE6iwq36yXx36XLekBmzrWhP5mqKGkY+VW8/l4M7Ilndnft3oVGOiQNY1KoZ5tVSmC5785uLMJD6+1TFUG5WoTFBzUtJgV0F+L6U0EYqG7d5tugG9sDgpl7y8nEkZb5sluTCati1FCMI6aa2GosoHXsHKOlGKpGKis5xSzDFyVNL7VcJf10QuEXePoezt6IPUUZOJuMibWlAC5Eezx9OzkkbbO8JlHmIahVGJzFG16tSalEuZbxbIbaSuBcIQ7WqhueRnA9DI1ls8RrvuVwTxrXJFvMQX3Td6cMjaXo469uIyDBmlvwZ9Qo/Uehl9pjAHCZO170IzpSCjpZ27NqFw9ENOdsSJYqkyex6alh1hMbcu tHDPSEgK 3A2VE5mw8wyKIqckOgWA8FNrj1X7/nd1C/EJ+pocwC4CdeKJ9+s5lmgoOxIUJmADOy9GOa6JXNnuPlaxsnzZKyeRKQ/aa6RQBCoy9hXFgtWXV89nE8kQvCl7YWuxJg+2mui8dPNvZB61KCh2oW57v9IBBzl9I5KLx5FFyB78zEb3YQIm92FmXNcdWvvCD6Abwwln3sAnejidG/KMK+e5h52mk/syLZQ+r083nTOjV4DL726MBESxpe5+lJEbw/S9DVDITl6Mwh+EIHNn0FzVSxfy1hTxeyGxQXMS8lZ264dMKrBc= 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 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 4b9e62de164b..381cf9d61c85 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1084,6 +1084,41 @@ 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; + + 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 9259c5d70a65..28290f7c89f7 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -533,6 +533,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, @@ -909,6 +910,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); @@ -986,4 +1000,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__ */