mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
Allow the PMT class to read discovery headers from either PCI MMIO or
ACPI-provided entries, depending on the discovery source. The new
source-aware fetch helper caches the canonical discovery header for both
paths, capping PCI MMIO reads to the mapped resource size, while keeping
the mapped PCI discovery table available for users such as crashlog.
Split intel_pmt_populate_entry() into source-specific resolvers:
- pmt_resolve_access_pci(): handles both ACCESS_LOCAL and ACCESS_BARID
for PCI-backed devices and sets entry->pcidev. Same existing
functionality.
- pmt_resolve_access_acpi(): handles only ACCESS_BARID for ACPI-backed
devices, rejecting ACCESS_LOCAL which has no valid semantics without
a physical discovery resource.
This maintains existing PCI behavior and makes no functional changes
for PCI devices.
Assisted-by: GitHub-Copilot:claude-opus-4.7
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Link: https://patch.msgid.link/4b33b04ffaf0943b67d330f48b5d1dfcb6d1be5d.1781294741.git.david.e.box@linux.intel.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
90 lines
2.3 KiB
C
90 lines
2.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _INTEL_PMT_CLASS_H
|
|
#define _INTEL_PMT_CLASS_H
|
|
|
|
#include <linux/intel_vsec.h>
|
|
#include <linux/xarray.h>
|
|
#include <linux/types.h>
|
|
#include <linux/bits.h>
|
|
#include <linux/err.h>
|
|
#include <linux/io.h>
|
|
|
|
#include "telemetry.h"
|
|
|
|
/* PMT access types */
|
|
#define ACCESS_BARID 2
|
|
#define ACCESS_LOCAL 3
|
|
|
|
/* PMT discovery base address/offset register layout */
|
|
#define GET_BIR(v) ((v) & GENMASK(2, 0))
|
|
#define GET_ADDRESS(v) ((v) & GENMASK(31, 3))
|
|
|
|
struct device;
|
|
struct pci_dev;
|
|
extern struct class intel_pmt_class;
|
|
|
|
struct telem_endpoint {
|
|
struct device *dev;
|
|
struct telem_header header;
|
|
struct pmt_callbacks *cb;
|
|
void __iomem *base;
|
|
bool present;
|
|
struct kref kref;
|
|
};
|
|
|
|
struct intel_pmt_header {
|
|
u32 base_offset;
|
|
u32 size;
|
|
u32 guid;
|
|
u8 access_type;
|
|
u8 telem_type;
|
|
};
|
|
|
|
struct intel_pmt_entry {
|
|
struct telem_endpoint *ep;
|
|
struct pci_dev *pcidev;
|
|
struct intel_pmt_header header;
|
|
u32 disc_header[PMT_DISC_DWORDS];
|
|
struct bin_attribute pmt_bin_attr;
|
|
const struct attribute_group *attr_grp;
|
|
struct kobject *kobj;
|
|
void __iomem *disc_table;
|
|
void __iomem *base;
|
|
struct pmt_callbacks *cb;
|
|
unsigned long base_addr;
|
|
size_t size;
|
|
u64 feature_flags;
|
|
u32 guid;
|
|
u32 num_rmids; /* Number of Resource Monitoring IDs */
|
|
int devid;
|
|
};
|
|
|
|
struct intel_pmt_namespace {
|
|
const char *name;
|
|
struct xarray *xa;
|
|
int (*pmt_header_decode)(struct intel_pmt_entry *entry,
|
|
struct device *dev);
|
|
int (*pmt_pre_decode)(struct intel_vsec_device *ivdev,
|
|
struct intel_pmt_entry *entry);
|
|
int (*pmt_post_decode)(struct intel_vsec_device *ivdev,
|
|
struct intel_pmt_entry *entry);
|
|
int (*pmt_add_endpoint)(struct intel_vsec_device *ivdev,
|
|
struct intel_pmt_entry *entry);
|
|
};
|
|
|
|
int pmt_telem_read_mmio(struct device *dev, struct pmt_callbacks *cb, u32 guid, void *buf,
|
|
void __iomem *addr, loff_t off, u32 count);
|
|
bool intel_pmt_is_early_client_hw(struct device *dev);
|
|
int intel_pmt_dev_create(struct intel_pmt_entry *entry,
|
|
struct intel_pmt_namespace *ns,
|
|
struct intel_vsec_device *dev, int idx);
|
|
void intel_pmt_dev_destroy(struct intel_pmt_entry *entry,
|
|
struct intel_pmt_namespace *ns);
|
|
#if IS_ENABLED(CONFIG_INTEL_PMT_DISCOVERY)
|
|
void intel_pmt_get_features(struct intel_pmt_entry *entry);
|
|
#else
|
|
static inline void intel_pmt_get_features(struct intel_pmt_entry *entry) {}
|
|
#endif
|
|
|
|
#endif
|