Skip to contentSkip to conversation

iommuv2/amd: Enable Performance Counters On Family 15h Models 10h-1Fh

PATCH In review Steven Kinney 2 participants 3 messages Nov 26, 2012 – Dec 2, 2012 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommuv2/amd: Enable Performance Counters On Family 15h Models 10h-1Fh

From: "Steven L. Kinney" <[email protected]>

Add Kernel configuration selection for AMD IOMMUv2 performance counters.

Add a check that will determine the configuration of the AMD IOMMUv2 performance counter(s) and extend the IOMMUv2 MMIO Region to account for the additional PC register bank.

Add maximum IOMMUv2 bank/counter members to the amd_iommu structure that will hold the relevant data concerning the available PC bank and counter resources.

Add code to iommu_init_pci that will check for IOMMUv2 PC HW support and populate the max banks and counters into the amd_iommu structure.

Add exported functionality that will allow external drivers to obtain IOMMUv2 PC bank/counter resource information and manage the IOMMUv2 PC measurment configuration. Bank and counter assignment is managed outside of this driver; for example, within a perf IOMMUv2 PMU realization.

---
 drivers/iommu/Kconfig           |   10 +++++
 drivers/iommu/amd_iommu_init.c  |   86 +++++++++++++++++++++++++++++++++++++++
 drivers/iommu/amd_iommu_types.h |   13 +++++-
 3 files changed, 108 insertions(+), 1 deletion(-)
drivers/iommu/Kconfig +10 -0
index e39f9db..d732e31 100644
@@ -73,6 +73,16 @@ config AMD_IOMMU_V2
 	  hardware. Select this option if you want to use devices that support
 	  the PCI PRI and PASID interface.
 
+# AMD IOMMUv2 Performance Counter support
+config AMD_IOMMU_V2_PC
+	bool "AMD IOMMUv2 Performance Counters (EXPERIMENTAL)"
+	depends on AMD_IOMMU_V2
+	---help---
+	  This option enables support for AMD IOMMUv2 Performance Counters.
+	  Select this option if you want to enable IOMMUv2 Performance
+	  Counters support.
+	  If unsure, say N.
+
 # Intel IOMMU support
 config DMAR_TABLE
 	bool
drivers/iommu/amd_iommu_init.c +86 -0

95 lines not on this page · raw message

drivers/iommu/amd_iommu_types.h +12 -1
index c9aa3d0..6dc1f68 100644
@@ -38,7 +38,12 @@
 #define RLOOKUP_TABLE_ENTRY_SIZE	(sizeof(void *))
 
 /* Length of the MMIO region for the AMD IOMMU */
+#ifdef CONFIG_AMD_IOMMU_V2_PC
+#define MMIO_REGION_LENGTH       0x80000
+#define IOMMU_V2_PC_REG_OFFSET	 0x40000
+#else
 #define MMIO_REGION_LENGTH       0x4000
+#endif
 
 /* Capability offsets used by the driver */
 #define MMIO_CAP_HDR_OFFSET	0x00
@@ -77,7 +82,7 @@
 #define MMIO_STATUS_OFFSET	0x2020
 #define MMIO_PPR_HEAD_OFFSET	0x2030
 #define MMIO_PPR_TAIL_OFFSET	0x2038
-
+#define MMIO_CNTR_CONF_OFFSET	0x4000
 
 /* Extended Feature Bits */
 #define FEATURE_PREFETCH	(1ULL<<0)
@@ -584,6 +589,12 @@ struct amd_iommu {
 
 	/* The l2 indirect registers */
 	u32 stored_l2[0x83];
+
+#ifdef CONFIG_AMD_IOMMU_V2_PC
+	/* The maximum PC banks and counters/bank (PCSup=1) */
+	u8 max_banks;
+	u8 max_counters;
+#endif
 };
 
 struct devid_map {
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 4 lines · Steven Kinney

From: "Steven L. Kinney" <[email protected]>

Add Kernel configuration selection for AMD IOMMUv2 performance counters.

How can the counters be used?

Joerg

#2 lore raw

Hi Joerg,

I didn't want to expose the internals of the IOMMU, so I decided to export the function(s) so that the perf IOMMUv2 PMU can make call(s) into the IOMMU core to request PC resources. The perf_event_amd_iommuv2.h defines the prototype for the added PC functionality. I have the perf IOMMUv2 PMU working and counting IOMMUv2 PC events using this interface, but if you have a suggestion to make this implementation more robust, I will accommodate the suggestion. Also, if it would be helpful, I can submit the perf IOMMUv2 PMU patches.

BTW, I am resubmitting this patch since I caught a function signature error; was changing the code based on Boris's suggestion(s) and forgot to add the variable type (bool) concerning the 'is_write' parameter.

Hope all is well with you and the team; we miss you guys!

Regards,

Steve

-----Original Message-----
From: Joerg Roedel [mailto:[email protected]]
Sent: Sunday, December 02, 2012 7:30 AM
To: Kinney, Steven
Cc: Joerg Roedel; Kukjin Kim; Stephen Warren; Jiri Kosina; [email protected]; iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH 1/1] iommuv2/amd: Enable Performance Counters On Family 15h Models 10h-1Fh

Quoted 4 lines · Steven Kinney

From: "Steven L. Kinney" <[email protected]>

Add Kernel configuration selection for AMD IOMMUv2 performance counters.

How can the counters be used?

Joerg