From patchwork Thu Mar 20 18:04:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 14024289 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 AD71DC28B30 for ; Thu, 20 Mar 2025 18:05:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D0F7280001; Thu, 20 Mar 2025 14:05:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 35B19280008; Thu, 20 Mar 2025 14:05:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D7CE280001; Thu, 20 Mar 2025 14:05:36 -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 EE22C280008 for ; Thu, 20 Mar 2025 14:05:35 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EA048C17A4 for ; Thu, 20 Mar 2025 18:05:36 +0000 (UTC) X-FDA: 83242707072.29.7919F45 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf13.hostedemail.com (Postfix) with ESMTP id D830220033 for ; Thu, 20 Mar 2025 18:05:34 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.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=1742493935; 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=gaAOGuRqYXlQTQgfqR9nvFlvFmOEr0LkvQ9J+1PlBs4=; b=om1VOAtrzqG+e98qVtDV2C3j04EqeBw+XYsxDaFDPiHFcfs5pxMFJTu/0f94l5my84hmBG E3fNvlovvmYDyr5NXEwIvVe5I/yl1axP1p+TMEjMPOjKb5rtK/UD3jsP7gCzETgi7ybCmL 168HlxO40MNApqpkdrc9eyL4jqf9YBA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.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=1742493935; a=rsa-sha256; cv=none; b=K0hRqB9EpmgHNRsIcbHq9DvcX6KWbDdkpmK1BoVOi0eGhZHGVqELTbpeQxN1okyvjhHvTH i+MemSfD44xOfXlXNLYzaTKU/sDxe+oRFDPO9zDu7QazIw9jvzSvZzZ4K/LFZnrimBobMA qLVB1js++2ZmeA+SNdZNNAk9dMuM5wY= Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4ZJYMD2qYjz6K99G; Fri, 21 Mar 2025 02:02:32 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id E283B14050D; Fri, 21 Mar 2025 02:05:30 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.48.156.145) 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; Thu, 20 Mar 2025 19:05:28 +0100 From: To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 1/8] cxl: Add helper function to retrieve a feature entry Date: Thu, 20 Mar 2025 18:04:38 +0000 Message-ID: <20250320180450.539-2-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20250320180450.539-1-shiju.jose@huawei.com> References: <20250320180450.539-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.48.156.145] X-ClientProxiedBy: lhrpeml100003.china.huawei.com (7.191.160.210) To frapeml500007.china.huawei.com (7.182.85.172) X-Rspam-User: X-Rspamd-Queue-Id: D830220033 X-Rspamd-Server: rspam03 X-Stat-Signature: 4ahp3ja5n8hntwqzx964516i537qgjbt X-HE-Tag: 1742493934-410946 X-HE-Meta: U2FsdGVkX1/px5OjkSWNnvnpIzeZVlaVh4hGr0kZ8PG7bs3Pk+U+ZWTT9zTDiApTPm4dzagjN4EEKl+3Z/f/ecVdDfcxLgryYrzSYGiAOTKA3+hnmRym8GP79fHm0yAOLP9mp15PP2Pp2EoOJZFZWSbIiE0cYGwc9uRHa1ttz28+0H2LcO1QxVrH+FRPChelMV2mG10WJJvfaAZyqMPbeHxBmtkCqNHdCb5T0wBx2o/aNKS2XsUkF3bz8Be4KbpInUSiPAJT6EvzYRqiSP98zGvx/Y3Ly9i36revw28gWaoy7ZlE74AQqBToCeguDw69zpiDRrL9T+cA0MISZPX/n1Zx+6zBt3e7228hzUincVuo6o2ydG6rG12Vugmk7+mzjuTwCsjLNQZ/U/6p82g4L5TT5zONFOjscMdDyibVoUsB8RNLr2/v0Bz+CGCIZJ3dh/5/DoAttprWzt3fdiuLmSp8UtwIsKYdkmucwWOneK5DH6qmzjoJjkSlQ54C2cBjzqGukjouu2wvFwaoqFa422bUIJVX5h1lTAl41jRq4Bm/tjW15/OoueA4hccJc9X6bFvnH4/XSd4p2crmsHH8lTnxSwZ2DLwNy/0PXalmrDaTqICmJbx4Pb14GP/z3DQw8CmYYYfWoL83qeVdds97yc2Yldt3/kMraqUZfIhwJjEFDZAiJU5glr6rvVOZymrtr2Uay1OQmk4OOtQe3IAZAPz+sISqIArmFP9yYPMnD3G0EjS8zfsZJWcbRzhVT8oq+L/ER6RSfyp1+luW9duIMhjPwrzRkr9vA5cInoUUvxEfmE+smmAfhOZRCTvE0JJ9AW3zkS5CCsVtirCmOHYf5PRbYXRW0KU8PY7uWl8tgyON/ny2lOBPjqBdzitUhfvw1CBEwgiuW3ZUq74ZGKeUv7UmQVPa9RA+v1oqBizLT+SOCwUv6jkNVKyADsg7/QvfpIBI7n8qzkzlxkksUuV pKA3zHH2 CuSQtiaaJFP3jjD5R228sfa3WkMWL+Xtg3fTPEm9RGS/42NNoKst00qXL5NKIjIJwslkurFN2ZjKxER3M0OjBQ+Es9GWeDk8EO7w4MflfWm5H2b4336Al/CmCkQ6xNKpht80GQaZLx/MTXuKtvs6Y8nckaOCpHL/WnkQRSc/L3Fk76bd+FYmko7LpUTAucdcttyaCs1+JtGHjmOUFeDH0Opelkg4QIPnnXtFfvZwgdPOn4ns= 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 helper function to retrieve a feature entry from the supported features list, if supported. Reviewed-by: Jonathan Cameron Reviewed-by: Fan Ni Signed-off-by: Shiju Jose --- drivers/cxl/core/core.h | 2 ++ drivers/cxl/core/features.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index 1803aedb25ca..16bc717376fc 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -123,6 +123,8 @@ int cxl_ras_init(void); void cxl_ras_exit(void); #ifdef CONFIG_CXL_FEATURES +struct cxl_feat_entry *cxl_get_feature_entry(struct cxl_dev_state *cxlds, + const uuid_t *feat_uuid); size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, enum cxl_get_feat_selection selection, void *feat_out, size_t feat_out_size, u16 offset, diff --git a/drivers/cxl/core/features.c b/drivers/cxl/core/features.c index 048ba4fc3538..202c8c21930c 100644 --- a/drivers/cxl/core/features.c +++ b/drivers/cxl/core/features.c @@ -203,6 +203,29 @@ int devm_cxl_setup_features(struct cxl_dev_state *cxlds) } EXPORT_SYMBOL_NS_GPL(devm_cxl_setup_features, "CXL"); +struct cxl_feat_entry *cxl_get_feature_entry(struct cxl_dev_state *cxlds, + const uuid_t *feat_uuid) +{ + struct cxl_features_state *cxlfs = to_cxlfs(cxlds); + struct cxl_feat_entry *feat_entry; + int count; + + if (!cxlfs || !cxlfs->entries || !cxlfs->entries->num_features) + return NULL; + + /* + * Retrieve the feature entry from the supported features list, + * if the feature is supported. + */ + feat_entry = cxlfs->entries->ent; + for (count = 0; count < cxlfs->entries->num_features; count++, feat_entry++) { + if (uuid_equal(&feat_entry->uuid, feat_uuid)) + return feat_entry; + } + + return NULL; +} + size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, enum cxl_get_feat_selection selection, void *feat_out, size_t feat_out_size, u16 offset,