[PATCH] iommuv2/amd: Add quirk for AMD 15H_M10 IOMMUv2 PerformanceCounters

From: Steven L. Kinney
Date: Fri Nov 16 2012 - 16:27:47 EST


Add AMD PCI device definition that will identify devices that relate to the
IOMMUv2 PC PCI quirk added for potential non-enable by BIOS.

On AMD family 15h models 10h-1Fh BIOS may not enable performance counters in
IOMMUv2's EFR. Add a quirk to enable the counters when this happens.

Signed-off-by: Steven L. Kinney <steven.kinney@xxxxxxx>
---
arch/x86/kernel/quirks.c | 17 +++++++++++++++++
include/linux/pci_ids.h | 2 ++
2 files changed, 19 insertions(+)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 1b27de5..9ea518b 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -567,3 +567,20 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F5,
quirk_amd_nb_node);

#endif
+
+#if defined(CONFIG_PCI) && defined(CONFIG_AMD_IOMMU_V2_PC)
+
+static void amd_force_iommu_v2_pc(struct pci_dev *dev)
+{
+ u32 val;
+
+ pci_read_config_dword(dev, 0x70, &val);
+ val |= (1<<9);
+ pci_write_config_dword(dev, 0x70, val);
+ dev_printk(KERN_DEBUG, &dev->dev, "Enabled IOMMUv2 PC\n");
+}
+
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M10H_IOMMU,
+ amd_force_iommu_v2_pc);
+
+#endif
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 9d36b82..70e20a3 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -396,6 +396,8 @@
/* AMD RD890 Chipset */
#define PCI_DEVICE_ID_RD890_IOMMU 0x5a23

+#define PCI_DEVICE_ID_AMD_15H_M10H_IOMMU 0x1419
+
#define PCI_VENDOR_ID_ADL 0x1005
#define PCI_DEVICE_ID_ADL_2301 0x2301

--
1.7.9.5


--dDRMvlgZJXvWKvBx
Content-Type: text/plain; charset="us-ascii"; name=
"0002-iommuv2-amd-enable-performance-counters-on-family-15h-models-10h-1Fh"
Content-Disposition: attachment; filename=
"0002-iommuv2-amd-enable-performance-counters-on-family-15h-models-10h-1Fh"
Content-Description: 0002-iommuv2-amd-enable-performance-counters-on-family-15h-models-10h-1Fh