From patchwork Wed Nov 13 18:26:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13874093 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 597C8D637A3 for ; Wed, 13 Nov 2024 18:27:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 342926B00A1; Wed, 13 Nov 2024 13:27:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F3506B00A2; Wed, 13 Nov 2024 13:27:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 193EE6B00A3; Wed, 13 Nov 2024 13:27:35 -0500 (EST) 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 E035E6B00A1 for ; Wed, 13 Nov 2024 13:27:34 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9FD1780AF3 for ; Wed, 13 Nov 2024 18:27:34 +0000 (UTC) X-FDA: 82781903526.23.B680E8F Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf02.hostedemail.com (Postfix) with ESMTP id E21A580013 for ; Wed, 13 Nov 2024 18:26:10 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.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=1731522278; 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=6fNLtNxvmXghsVsW07B+ytYcWJ/yqUb9mNxOUEB3idA=; b=AwBJqy5cF/tqAsWoy8xvD4BAzf9UOmG3v85LgpPF8UzrfraB1y90VG4BXGdhK56Ek2HRQp Tc/SQUZh/c4VXhh+WAPqTnKLKqSUNnfg+Fxw1Ics8ymks7XBT0g2L+Fthmk/L8Q5t5xPtm MGLl6BiBVWSKDrknpRlUuU2HD9it6J8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731522278; a=rsa-sha256; cv=none; b=AKswuOviHeVDXPZlYonqqI1ftL3tEf6zmwYUc+8M0bMa/mgg/v0gvIGcwxO1Qx3v8fUb5k XBbcwmbeRl/8cDTCR6iX4YaRaKA6IZU+sX5/ux/rzQsEGIbrsBXlY3yiQ710PmSU3BeEjS MxxMyhXrhMO/QHiYxChfGdXKippQe2I= Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XpWs063mkz6K6PY; Thu, 14 Nov 2024 02:24:20 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 0028D140B30; Thu, 14 Nov 2024 02:27:31 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.126.168.134) 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, 13 Nov 2024 19:27:28 +0100 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v16 05/14] cxl/mbox: Add GET_FEATURE mailbox command Date: Wed, 13 Nov 2024 18:26:56 +0000 Message-ID: <20241113182707.656-6-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20241113182707.656-1-shiju.jose@huawei.com> References: <20241113182707.656-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.126.168.134] X-ClientProxiedBy: lhrpeml100011.china.huawei.com (7.191.174.247) To frapeml500007.china.huawei.com (7.182.85.172) X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E21A580013 X-Stat-Signature: mbefb86nb1mx7upqbxnaze7adyknfy3u X-Rspam-User: X-HE-Tag: 1731522370-529723 X-HE-Meta: U2FsdGVkX18BsXcfNAHP8yI02z/BKWAkKzlkaXApz6/9eaUnm88jxorAuL0tzthGQskJOu7I1mRe09TtDSvSCr5PSvIcIc24V5yCBu45ybP8uwKaBpRbadt/2PaqXh7gDLvkAdjDekqzewfEMiptk3k81MCnDnF2ma1xRRPmsKDe7LQVb9UW+z9x7SZVofDJRKULTGaHXaVsHlrSgvyz+ZiNAc1azCoOk/jBIPwJCLFnW0W/4q7CHgKz8Fq/i9uPzncetY56wkmU31zI0PahFHqh/pH0IqwY0EEcADnluQ8H+YCgDGa4XRo4Zf0z0RbuuNu5HVyrx2uNmDkV+VWXsc+WiZeGk3K1+zUOfLQQUUx7l86NiT973yhL08/mmo5TLO5IDa8Mgu1D/rvsB93LqMYQQh7aJ15p+la+ijVXW2alog010XheG6y+rk+RbDCc3610IuiY1MniwEmhFbwPsYFJZNFCJK/M1qxPlYuRokPCC4sEEaXQEFKPkSlgPQO/GqhsVjsIXbVwQNVRkMwT1K7YeZUzl/rehFni/slWLBZy7Myl4Eg22sUtd2lpTH6JlrQRoxcgXSo+vOhygFiXQ24sxHrGIfKC4COu2fslrSGW3J/DyKN0M7LOCIsXgoKZlDR91iATYgqSQV6Ij2SHEx7fBtKr1XTsXeuJd2yyE/GZnRkKl/UgIeIHuZneQESt5Vft+sN78UVt7ze0jeLm0U1te3jsd1k44Q7qs1czyZ8ip2M/Z32xTplBaV3zHi15/FexVAp0Zvaz7rPJpJfef54tO0pQnQyiJUY1F6bPSn7IRSFtKI5+LBQYHXyviRv+hM7+qxBp1fRxOt2c5ewR5tTTfk2YfEZ3O8ZvPXJOQvZ5N+AIkoDNcqzIdX2bZzx9+h6YcOh6iP06TggaPvvH6knH8juu+gam24brsrv3yyEZSo4Qsy5CT9xLB7Catl2tPjkH+j7OyuiQwhCRUYQ OOIKFRjl kHbGJvojLcwyuG9xHYvM3pXYSAnjkdpeXGmjiRNw9tigzshDQUjNYnAAOMjEhol0YqQ4z5ysoaA/86joQ3LuVHt7YJ5h4mTFLsCtH4gt7yiv+mrzHP0zp+mGR7mXllZki0Hm1IN3IwSmEZ3SJFQ26fJY1bppr6y4Srx0xtF36QDZRSuJuOmBqqsg//ZxwZ/dhBGH3GZVYMiohcFhdrMq1P7W2P39wqCJyUc1HfOSVjBIYf1b2i69qXsvgpBMioHyzS0t9mkrscAPSNnVnh9tA54zlptfZ2AgkP+ruvb4JPeyrV3cnNVWjHJKMvA== 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 GET_FEATURE mailbox command. CXL spec 3.1 section 8.2.9.6 describes optional device specific features. The settings of a feature can be retrieved using Get Feature command. CXL spec 3.1 section 8.2.9.6.2 describes Get Feature command. Reviewed-by: Fan Ni Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Signed-off-by: Shiju Jose --- drivers/cxl/core/mbox.c | 41 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 26 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 6548eda4bf6d..a66fe7427338 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -972,6 +972,47 @@ int cxl_get_supported_feature_entry(struct cxl_memdev_state *mds, const uuid_t * } EXPORT_SYMBOL_NS_GPL(cxl_get_supported_feature_entry, CXL); +size_t cxl_get_feature(struct cxl_memdev_state *mds, const uuid_t feat_uuid, + enum cxl_get_feat_selection selection, + void *feat_out, size_t feat_out_size) +{ + struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox; + size_t data_to_rd_size, size_out; + struct cxl_mbox_get_feat_in pi; + struct cxl_mbox_cmd mbox_cmd; + size_t data_rcvd_size = 0; + int rc; + + if (!feat_out || !feat_out_size) + return 0; + + size_out = min(feat_out_size, cxl_mbox->payload_size); + pi.uuid = feat_uuid; + pi.selection = selection; + do { + data_to_rd_size = min(feat_out_size - data_rcvd_size, + cxl_mbox->payload_size); + pi.offset = cpu_to_le16(data_rcvd_size); + pi.count = cpu_to_le16(data_to_rd_size); + + mbox_cmd = (struct cxl_mbox_cmd) { + .opcode = CXL_MBOX_OP_GET_FEATURE, + .size_in = sizeof(pi), + .payload_in = &pi, + .size_out = size_out, + .payload_out = feat_out + data_rcvd_size, + .min_out = data_to_rd_size, + }; + rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd); + if (rc < 0 || !mbox_cmd.size_out) + return 0; + data_rcvd_size += mbox_cmd.size_out; + } while (data_rcvd_size < feat_out_size); + + return data_rcvd_size; +} +EXPORT_SYMBOL_NS_GPL(cxl_get_feature, 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 f88b10188632..0c152719669a 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -531,6 +531,7 @@ enum cxl_opcode { CXL_MBOX_OP_CLEAR_LOG = 0x0403, CXL_MBOX_OP_GET_SUP_LOG_SUBLIST = 0x0405, CXL_MBOX_OP_GET_SUPPORTED_FEATURES = 0x0500, + CXL_MBOX_OP_GET_FEATURE = 0x0501, CXL_MBOX_OP_IDENTIFY = 0x4000, CXL_MBOX_OP_GET_PARTITION_INFO = 0x4100, CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101, @@ -856,6 +857,28 @@ struct cxl_mbox_get_sup_feats_out { struct cxl_feat_entry ents[] __counted_by_le(supported_feats); } __packed; +/* + * Get Feature CXL 3.1 Spec 8.2.9.6.2 + */ + +/* + * Get Feature input payload + * CXL rev 3.1 section 8.2.9.6.2 Table 8-99 + */ +enum cxl_get_feat_selection { + CXL_GET_FEAT_SEL_CURRENT_VALUE, + CXL_GET_FEAT_SEL_DEFAULT_VALUE, + CXL_GET_FEAT_SEL_SAVED_VALUE, + CXL_GET_FEAT_SEL_MAX +}; + +struct cxl_mbox_get_feat_in { + uuid_t uuid; + __le16 offset; + __le16 count; + u8 selection; +} __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); @@ -919,4 +942,7 @@ void cxl_dpa_debug(struct seq_file *file, struct cxl_dev_state *cxlds); int cxl_get_supported_features(struct cxl_memdev_state *mds); int cxl_get_supported_feature_entry(struct cxl_memdev_state *mds, const uuid_t *feat_uuid, struct cxl_feat_entry *feat_entry_out); +size_t cxl_get_feature(struct cxl_memdev_state *mds, const uuid_t feat_uuid, + enum cxl_get_feat_selection selection, + void *feat_out, size_t feat_out_size); #endif /* __CXL_MEM_H__ */