From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "David E. Box" <david.e.box@linux.intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
platform-driver-x86@vger.kernel.org,
srinivas.pandruvada@linux.intel.com,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
tony.luck@intel.com, xi.pardee@linux.intel.com,
Hans de Goede <hdegoede@redhat.com>
Subject: Re: [PATCH 14/15] platform/x86/intel/pmt/telemetry: Add API to retrieve telemetry regions by feature
Date: Tue, 20 May 2025 18:05:50 +0300 (EEST) [thread overview]
Message-ID: <8433cbaf-253b-cc7f-77d4-fa48142aa603@linux.intel.com> (raw)
In-Reply-To: <20250430212106.369208-15-david.e.box@linux.intel.com>
On Wed, 30 Apr 2025, David E. Box wrote:
> Introduce a new API, intel_pmt_get_regions_by_feature(), that gathers
> telemetry regions based on a provided capability flag. This API enables
> retrieval of regions with various capabilities (for example, RMID-based
> telemetry) and provides a unified interface for accessing them. Resource
> management is handled via reference counting using
> intel_pmt_put_feature_group().
>
> Signed-off-by: David E. Box <david.e.box@linux.intel.com>
> ---
> drivers/platform/x86/intel/pmt/telemetry.c | 89 +++++++++++++++++++++-
> include/linux/intel_vsec.h | 15 ++++
> 2 files changed, 103 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c
> index 58d06749e417..d071dca4a689 100644
> --- a/drivers/platform/x86/intel/pmt/telemetry.c
> +++ b/drivers/platform/x86/intel/pmt/telemetry.c
> @@ -9,16 +9,20 @@
> */
>
> #include <linux/auxiliary_bus.h>
> +#include <linux/bitops.h>
> +#include <linux/err.h>
> #include <linux/intel_pmt_features.h>
> #include <linux/intel_vsec.h>
> #include <linux/kernel.h>
> #include <linux/kref.h>
> #include <linux/module.h>
> +#include <linux/mutex.h>
> +#include <linux/overflow.h>
> #include <linux/pci.h>
> #include <linux/slab.h>
> #include <linux/types.h>
> #include <linux/uaccess.h>
> -#include <linux/overflow.h>
> +#include <linux/xarray.h>
>
> #include "class.h"
>
> @@ -209,6 +213,88 @@ int pmt_telem_get_endpoint_info(int devid, struct telem_endpoint_info *info)
> }
> EXPORT_SYMBOL_NS_GPL(pmt_telem_get_endpoint_info, "INTEL_PMT_TELEMETRY");
>
> +static int pmt_copy_region(struct telemetry_region *region,
> + struct intel_pmt_entry *entry)
> +{
> +
> + struct oobmsm_plat_info *plat_info;
> +
> + plat_info = intel_vsec_get_mapping(entry->ep->pcidev);
> + if (IS_ERR(plat_info))
> + return PTR_ERR(plat_info);
> +
> + region->plat_info = *plat_info;
> + region->guid = entry->guid;
> + region->addr = entry->ep->base;
> + region->size = entry->size;
> + region->num_rmids = entry->num_rmids;
> +
> + return 0;
> +}
> +
> +static void pmt_feature_group_release(struct kref *kref)
> +{
> + struct pmt_feature_group *feature_group;
> +
> + feature_group = container_of(kref, struct pmt_feature_group, kref);
> + kfree(feature_group);
> +}
> +
> +struct pmt_feature_group *intel_pmt_get_regions_by_feature(enum pmt_feature_id id)
> +{
> + struct pmt_feature_group *feature_group;
> + struct telemetry_region *region;
> + struct intel_pmt_entry *entry;
> + unsigned long idx;
> + int count = 0;
> + size_t size;
> +
> + if (!pmt_feature_id_is_valid(id))
> + return ERR_PTR(-EINVAL);
> +
> + guard(mutex)(&ep_lock);
> + xa_for_each(&telem_array, idx, entry) {
> + if (entry->feature_flags & BIT(id))
> + count++;
> + }
> +
> + if (!count)
> + return ERR_PTR(-ENOENT);
> +
> + size = struct_size(feature_group, regions, count);
> + feature_group = kzalloc(size, GFP_KERNEL);
> + if (!feature_group)
> + return ERR_PTR(-ENOMEM);
> +
> + feature_group->count = count;
> +
> + region = feature_group->regions;
> + xa_for_each(&telem_array, idx, entry) {
> + int ret;
> +
> + if (!(entry->feature_flags & BIT(id)))
> + continue;
> +
> + ret = pmt_copy_region(region, entry);
> + if (ret) {
> + kfree(feature_group);
Use __free() instead.
> + return ERR_PTR(ret);
> + }
> + region++;
> + }
> +
> + kref_init(&feature_group->kref);
> +
> + return feature_group;
> +}
> +EXPORT_SYMBOL(intel_pmt_get_regions_by_feature);
> +
> +void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group)
> +{
> + kref_put(&feature_group->kref, pmt_feature_group_release);
> +}
> +EXPORT_SYMBOL(intel_pmt_put_feature_group);
> +
> int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count)
> {
> u32 offset, size;
> @@ -353,3 +439,4 @@ MODULE_AUTHOR("David E. Box <david.e.box@linux.intel.com>");
> MODULE_DESCRIPTION("Intel PMT Telemetry driver");
> MODULE_LICENSE("GPL v2");
> MODULE_IMPORT_NS("INTEL_PMT");
> +MODULE_IMPORT_NS("INTEL_VSEC");
> diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h
> index f63e67398a8e..f41d2ec974fd 100644
> --- a/include/linux/intel_vsec.h
> +++ b/include/linux/intel_vsec.h
> @@ -220,4 +220,19 @@ static inline struct oobmsm_plat_info *intel_vsec_get_mapping(struct pci_dev *pd
> return ERR_PTR(-ENODEV);
> }
> #endif
> +
> +#if IS_ENABLED(CONFIG_INTEL_PMT_TELEMETRY)
> +struct pmt_feature_group *
> +intel_pmt_get_regions_by_feature(enum pmt_feature_id id);
> +
> +void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group);
> +#else
> +static inline struct pmt_feature_group *
> +intel_pmt_get_regions_by_feature(enum pmt_feature_id id)
> +{ return ERR_PTR(-ENODEV); }
Please add include for ERR_PTR().
Change this to follow the normal function coding style even if it takes
2 lines more that way. :-)
> +
> +static inline void
> +intel_pmt_put_feature_group(struct pmt_feature_group *feature_group) {}
> +#endif
> +
> #endif
>
--
i.
next prev parent reply other threads:[~2025-05-20 15:05 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 21:20 [PATCH 00/15] Intel VSEC/PMT: Introduce Discovery Driver David E. Box
2025-04-30 21:20 ` [PATCH 01/15] MAINTAINERS: Add link to documentation of Intel PMT ABI David E. Box
2025-04-30 21:20 ` [PATCH 02/15] platform/x86/intel/vsec: Add private data for per-device data David E. Box
2025-04-30 21:20 ` [PATCH 03/15] platform/x86/intel/vsec: Create wrapper to walk PCI config space David E. Box
2025-04-30 21:20 ` [PATCH 04/15] platform/x86/intel/vsec: Add device links to enforce dependencies David E. Box
2025-05-20 13:51 ` Ilpo Järvinen
2025-06-16 16:04 ` David E. Box
2025-04-30 21:20 ` [PATCH 05/15] platform/x86/intel/vsec: Skip absent features during initialization David E. Box
2025-04-30 21:20 ` [PATCH 06/15] platform/x86/intel/vsec: Skip driverless features David E. Box
2025-04-30 21:20 ` [PATCH 07/15] platform/x86/intel/vsec: Add new Discovery feature David E. Box
2025-05-20 14:01 ` Ilpo Järvinen
2025-04-30 21:20 ` [PATCH 08/15] platform/x86/intel/pmt: Add PMT Discovery driver David E. Box
2025-05-20 14:32 ` Ilpo Järvinen
2025-05-20 20:59 ` David E. Box
2025-04-30 21:20 ` [PATCH 09/15] docs: Add ABI documentation for intel_pmt feature directories David E. Box
2025-05-20 14:51 ` Ilpo Järvinen
2025-04-30 21:20 ` [PATCH 10/15] platform/x86/intel/tpmi: Relocate platform info to intel_vsec.h David E. Box
2025-05-20 14:54 ` Ilpo Järvinen
2025-04-30 21:21 ` [PATCH 11/15] platform/x86/intel/vsec: Set OOBMSM to CPU mapping David E. Box
2025-04-30 21:21 ` [PATCH 12/15] platform/x86/intel/tpmi: Get OOBMSM CPU mapping from TPMI David E. Box
2025-04-30 21:21 ` [PATCH 13/15] platform/x86/intel/pmt/discovery: Get telemetry attributes David E. Box
2025-04-30 21:21 ` [PATCH 14/15] platform/x86/intel/pmt/telemetry: Add API to retrieve telemetry regions by feature David E. Box
2025-05-20 15:05 ` Ilpo Järvinen [this message]
2025-04-30 21:21 ` [PATCH 15/15] platform/x86/intel/pmt: KUNIT test for PMT Enhanced Discovery API David E. Box
2025-05-16 15:30 ` [PATCH 00/15] Intel VSEC/PMT: Introduce Discovery Driver Luck, Tony
2025-05-19 17:22 ` Luck, Tony
2025-05-19 17:32 ` Ilpo Järvinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8433cbaf-253b-cc7f-77d4-fa48142aa603@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=david.e.box@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=tony.luck@intel.com \
--cc=xi.pardee@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.