From patchwork Fri Jul 26 16:05:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13742933 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 0DDABC3DA49 for ; Fri, 26 Jul 2024 16:07:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1ED36B00A4; Fri, 26 Jul 2024 12:07:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA6F86B00A5; Fri, 26 Jul 2024 12:07:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FAF06B00A6; Fri, 26 Jul 2024 12:07:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7F3736B00A4 for ; Fri, 26 Jul 2024 12:07:01 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 29020A5B80 for ; Fri, 26 Jul 2024 16:07:01 +0000 (UTC) X-FDA: 82382382642.14.94638DB Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf06.hostedemail.com (Postfix) with ESMTP id 018EE180015 for ; Fri, 26 Jul 2024 16:06:58 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.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=1722009963; 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=qOxyXcQ9s/DpG7Eydv5kUdTpCGUhfXb660koQZnjpig=; b=fMmjGg6PcK3uFwGtsVrP04cf6jzcqtTqRI22FBKZjgHl40IJbWjTRoxfDiSdAzvD1IjwBr meU6CNbb4BllWm20Vo2jYUs5pMoThScHtoWQjjHL1niJFbNpVjsoGaOwu5iXVnOLKtuU+v z0nvJmYs/eCW9PFJ2jfWBoQxSMITUwM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722009963; a=rsa-sha256; cv=none; b=JvdO8EBp1w+eK8xwuip9I/zVcipAqsWe/gooEZuFls0OipXAa4+FVaFe5k7PoOx6Xw5eQH SuEIKhAml5RWwAU8sltMyGi8K7GaVMUgLyoL6i4+mk7fOo+7eXTQRqBhD4Vmp8kktDSnKs yOziKRYddxPvAXMZFX2/iWxrTFV2b5k= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.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 4WVsyc2n3lz6K6SH; Sat, 27 Jul 2024 00:04:40 +0800 (CST) Received: from lhrpeml500006.china.huawei.com (unknown [7.191.161.198]) by mail.maildlp.com (Postfix) with ESMTPS id 2064A140B38; Sat, 27 Jul 2024 00:06:57 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.126.173.33) 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, 26 Jul 2024 17:06:55 +0100 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 05/11] cxl/mbox: Add GET_FEATURE mailbox command Date: Fri, 26 Jul 2024 17:05:49 +0100 Message-ID: <20240726160556.2079-6-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20240726160556.2079-1-shiju.jose@huawei.com> References: <20240726160556.2079-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.126.173.33] X-ClientProxiedBy: lhrpeml100003.china.huawei.com (7.191.160.210) To lhrpeml500006.china.huawei.com (7.191.161.198) X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 018EE180015 X-Stat-Signature: oggo4j3qjrbum4mqgfruuacetykcg54j X-Rspam-User: X-HE-Tag: 1722010018-62892 X-HE-Meta: U2FsdGVkX191iUcbiQMd3pCbsMgs0crcO0I1N1DU33yESarFcp/X3uxcNcMN2K989+1FDBrq52+86vQ5PwFpgDynxulsl7CjiVBOi4e3/wbvZnLODUFG0Dpv3x6Rylk2JN3nXQx5pYigrmxD5IvBp5Gq/+yvLLYlqFCObMNzYQK5CXFRwa6mV1v1kWkb31BVdyIhoiqLs8r+fPatCX4TWO+nChwyUAV5T0scC+bLeqQSHFHrOIICIv6MCXcSQFa9HclONjjD9V1J3CjNhmr8X3A0RqO4VuQH00iD4MtDRx349f7l30cvNPX0jnT4z+qfc0wm1UssnS4pbqsYVeJXeRUuIjj7QpptqCqq3WgyBsoz8O8vlaOxpjGQ4WV9+EoufNckSahMI4k7dD93RM6V9dOKkPzMulUy5uCqeA+eHyynr/IsGJaWLcXtCoYXpPOaweWzxrtII+AH8oeTP1M5ZVJ+LuHK/+ud/KW0tglzjYO7LahxhICVz4FazdtH/V7NBf9ThO08MSQqelTUOzA0oqTmluvWdqXl56YPhiPCXlpPlbIydPkbnXoU6B0MsdxyqPa+GYLyNWhNigK+yuCNhe2BcX10+1do1RY5GNYDS4/CwJos1NYZ9Jucqky0dhG1qIN0JIN5G8OCwu4qtd5j4A/PkaY9vr5xOYyo7DNRjwMEWw2cYqyYFo+PijA4r/lB1u2TPQRJO5K/uvuUkS36dEfiJ0nAkbBST7u2Zw6OfWA6Hp7/Rvb2YJPUbPpv4vjffJaRjCMp8QW+z+eNeW7IhzY87E1+x7N5jnCHRJUPVj4dSpTq3uUEyu7v+6If/LxX4UbFMhbcwoxpjxJO/t8DCtPbGVeihIRocjYIhmly19gvRc3bqYJtoz5hoWnQUNF2kHsadczo4YWlthW+Ev7qJEKhQbyV8w9UWuKq5mzZZ6vvu2uYrgSwfA2A9pd+dqxly1OfR8rLNxg3Fy4sw29 BbMx1Pca zB6nZ1cQR6grbYM4X0RvuUberRq4O8ItMNSR3XsmdtwWEbUpDxndTJEZ95Fs2pgrqDvONBimk6dORDRcPJcpzAaLDzvH+yZTUcqAjc3yUSyNqLWx9B37xajHLR3mWRLI0QzZN/ZiNF/4ia9aFFxOiHRgxuuVLSVrVQaFIIq0wxQIkTA9Re+GcSJDWogHH1eDvCj9gLgSha7l4I3BNvsZvacRNusdBqtMSAmrhqPBxN85gFO8EhIPsr90DaPgP9q7fDKblIArkKAjQszo= 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. Signed-off-by: Shiju Jose --- drivers/cxl/core/mbox.c | 40 ++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 27 +++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 9b9b1d26454e..989843bbf123 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1351,6 +1351,46 @@ int cxl_get_supported_features(struct cxl_memdev_state *mds, } EXPORT_SYMBOL_NS_GPL(cxl_get_supported_features, 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) +{ + 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, mds->payload_size); + pi.uuid = feat_uuid; + pi.selection = selection; + do { + data_to_rd_size = min(feat_out_size - data_rcvd_size, mds->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(mds, &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); + 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 b0e1565b9d2e..c70d2797e4c5 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, @@ -757,6 +758,28 @@ struct cxl_mbox_get_supp_feats_out { struct cxl_mbox_supp_feat_entry feat_entries[]; } __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; + /* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in { __le64 offset; @@ -891,6 +914,10 @@ int cxl_set_timestamp(struct cxl_memdev_state *mds); int cxl_get_supported_features(struct cxl_memdev_state *mds, u32 count, u16 start_index, struct cxl_mbox_get_supp_feats_out *feats_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); 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);