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: 14024298 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F55C1DE3A8; Thu, 20 Mar 2025 18:05:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742493935; cv=none; b=cF7it1hFNfD2Zk4+j7k5O1Uy01qr+oCk3XkMTn6he32IgwhatiYVd3Bi7jd75qYQxEZQPqBtfYRAN9wjr6rb2/vNHSMHwtxmMXsLYUJdMi+TKS5uCtZ4/mSdaFUV6WogWAOPUNq48vlGbiqaa5cliuBl3R35mN6NvoZS5jEcHSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742493935; c=relaxed/simple; bh=GtKULYl0mYctQnoh3gUdY0HmdBwjuAmD9xWw0mVxGPM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YN5eWHpj03ShKbWeN7bQejlXDKyzxhCF0w6/tqp4GESJl4Xi2oxS2hdn0oIHzGdkXkOS0dtjhUhf2UQVzf7MiViJicFlBFlkoFhA1dDFtAdzOPqtLcWGFvzhG53+m1uMfX7rlg+XBqfCS8Vs8hT5/J7u5HctM3QaXrVsLUjEz0Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: lhrpeml100003.china.huawei.com (7.191.160.210) To frapeml500007.china.huawei.com (7.182.85.172) 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,