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 Dec 4, 2012 – Dec 6, 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]>

-Fix compile error 'is_write' s/b 'bool is_write' for function signature 'amd_iommu_v2_get_set_pc_reg_val'.

-Remove whitespace at end of file; missed by ~/scripts/checkpatch.

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  |   85 +++++++++++++++++++++++++++++++++++++++
 drivers/iommu/amd_iommu_types.h |   13 +++++-
 3 files changed, 107 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 +85 -0

94 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
 drivers/iommu/Kconfig           |   10 +++++
 drivers/iommu/amd_iommu_init.c  |   85 +++++++++++++++++++++++++++++++++++++++
 drivers/iommu/amd_iommu_types.h |   13 +++++-
 3 files changed, 107 insertions(+), 1 deletion(-)

So first of all, this patch alone doesn't make sense. You should submit it in a patch-set that enabled IOMMUv2 performance counters for the end-user. This means together with the PMU implementation and tools support.

Further I don't see how this patch is specific to Family 15h Models 10h-1Fh as described in the subject-line.

Any comments on these two points?

Cheers,

Joerg

#2 lore raw

Hi Joerg,

I see your point(s). First, to the second point, I should (and will) add a check to the AMD Family/Model coupled to this change. Also, I will append the patch(es) to include the perf IOMMU PMU so that this change is put into context.

Thanks for your time and advise.

Best Regards,

Steve

-----Original Message-----
From: Joerg Roedel [mailto:[email protected]]
Sent: Thursday, December 06, 2012 4:33 AM
To: Kinney, Steven
Cc: Hiroshi DOYU; Stephen Warren; Jiri Kosina; Kukjin Kim; [email protected]; [email protected]
Subject: Re: [PATCH 1/1] iommuv2/amd: Enable Performance Counters On Family 15h Models 10h-1Fh

Quoted 4 lines · Steven Kinney
 drivers/iommu/Kconfig           |   10 +++++
 drivers/iommu/amd_iommu_init.c  |   85 +++++++++++++++++++++++++++++++++++++++
 drivers/iommu/amd_iommu_types.h |   13 +++++-
 3 files changed, 107 insertions(+), 1 deletion(-)

So first of all, this patch alone doesn't make sense. You should submit it in a patch-set that enabled IOMMUv2 performance counters for the end-user. This means together with the PMU implementation and tools support.

Further I don't see how this patch is specific to Family 15h Models 10h-1Fh as described in the subject-line.

Any comments on these two points?

Cheers,

Joerg