mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 07:04:24 +00:00
586e19c88a
[ Upstream commita6a5006dad
] The performance monitoring infrastructure, perfmon, is to support collection of information about key events occurring during operation of the remapping hardware, to aid performance tuning and debug. Each remapping hardware unit has capability registers that indicate support for performance monitoring features and enumerate the capabilities. Add alloc_iommu_pmu() to retrieve IOMMU perfmon capability information for each iommu unit. The information is stored in the iommu->pmu data structure. Capability registers are read-only, so it's safe to prefetch and store them in the pmu structure. This could avoid unnecessary VMEXIT when this code is running in the virtualization environment. Add free_iommu_pmu() to free the saved capability information when freeing the iommu unit. Add a kernel config option for the IOMMU perfmon feature. Unless a user explicitly uses the perf tool to monitor the IOMMU perfmon event, there isn't any impact for the existing IOMMU. Enable it by default. Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Link: https://lore.kernel.org/r/20230128200428.1459118-3-kan.liang@linux.intel.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de> Stable-dep-of:70bad345e6
("iommu: Fix compilation without CONFIG_IOMMU_INTEL") Signed-off-by: Sasha Levin <sashal@kernel.org>
40 lines
1 KiB
C
40 lines
1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
* PERFCFGOFF_REG, PERFFRZOFF_REG
|
|
* PERFOVFOFF_REG, PERFCNTROFF_REG
|
|
*/
|
|
#define IOMMU_PMU_NUM_OFF_REGS 4
|
|
#define IOMMU_PMU_OFF_REGS_STEP 4
|
|
|
|
#define IOMMU_PMU_CFG_OFFSET 0x100
|
|
#define IOMMU_PMU_CFG_CNTRCAP_OFFSET 0x80
|
|
#define IOMMU_PMU_CFG_CNTREVCAP_OFFSET 0x84
|
|
#define IOMMU_PMU_CFG_SIZE 0x8
|
|
#define IOMMU_PMU_CFG_FILTERS_OFFSET 0x4
|
|
|
|
#define IOMMU_PMU_CAP_REGS_STEP 8
|
|
|
|
#define iommu_cntrcap_pcc(p) ((p) & 0x1)
|
|
#define iommu_cntrcap_cw(p) (((p) >> 8) & 0xff)
|
|
#define iommu_cntrcap_ios(p) (((p) >> 16) & 0x1)
|
|
#define iommu_cntrcap_egcnt(p) (((p) >> 28) & 0xf)
|
|
|
|
#define iommu_event_select(p) ((p) & 0xfffffff)
|
|
#define iommu_event_group(p) (((p) >> 28) & 0xf)
|
|
|
|
#ifdef CONFIG_INTEL_IOMMU_PERF_EVENTS
|
|
int alloc_iommu_pmu(struct intel_iommu *iommu);
|
|
void free_iommu_pmu(struct intel_iommu *iommu);
|
|
#else
|
|
static inline int
|
|
alloc_iommu_pmu(struct intel_iommu *iommu)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void
|
|
free_iommu_pmu(struct intel_iommu *iommu)
|
|
{
|
|
}
|
|
#endif /* CONFIG_INTEL_IOMMU_PERF_EVENTS */
|