perf/x86/intel/uncore: Make uncore_discovery clean for 64 bit addresses
authorSteve Wahl <steve.wahl@hpe.com>
Fri, 18 Feb 2022 17:54:18 +0000 (11:54 -0600)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 1 Mar 2022 15:19:01 +0000 (16:19 +0100)
Support 64-bit BAR size for discovery, and do not truncate return from
generic_uncore_mmio_box_ctl() to 32 bits.

Signed-off-by: Steve Wahl <steve.wahl@hpe.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Link: https://lore.kernel.org/r/20220218175418.421268-1-steve.wahl@hpe.com
arch/x86/events/intel/uncore_discovery.c
arch/x86/events/intel/uncore_discovery.h

index 6ddadb482f68d6cb3f56103fb045afbf5ff0d487..61185d16fba264207692f38838352bc61f7f51ba 100644 (file)
@@ -210,15 +210,21 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
        void __iomem *io_addr;
        resource_size_t addr;
        unsigned long size;
-       u32 val;
+       u32 val, val2;
        int i;
 
        pci_read_config_dword(dev, bar_offset, &val);
 
-       if (val & UNCORE_DISCOVERY_MASK)
+       if (val & ~PCI_BASE_ADDRESS_MEM_MASK & ~PCI_BASE_ADDRESS_MEM_TYPE_64)
                return -EINVAL;
 
-       addr = (resource_size_t)(val & ~UNCORE_DISCOVERY_MASK);
+       addr = (resource_size_t)(val & PCI_BASE_ADDRESS_MEM_MASK);
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
+       if ((val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64) {
+               pci_read_config_dword(dev, bar_offset + 4, &val2);
+               addr |= ((resource_size_t)val2) << 32;
+       }
+#endif
        size = UNCORE_DISCOVERY_GLOBAL_MAP_SIZE;
        io_addr = ioremap(addr, size);
        if (!io_addr)
@@ -444,7 +450,7 @@ static struct intel_uncore_ops generic_uncore_pci_ops = {
 
 #define UNCORE_GENERIC_MMIO_SIZE               0x4000
 
-static unsigned int generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
+static u64 generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
 {
        struct intel_uncore_type *type = box->pmu->type;
 
@@ -456,7 +462,7 @@ static unsigned int generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
 
 void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box)
 {
-       unsigned int box_ctl = generic_uncore_mmio_box_ctl(box);
+       u64 box_ctl = generic_uncore_mmio_box_ctl(box);
        struct intel_uncore_type *type = box->pmu->type;
        resource_size_t addr;
 
index cfaf558bdb6b3b6e3e54a73c9df86c0ded96aac0..f4439357779a3e91a1255da7cfd00d1e684bbaf8 100644 (file)
@@ -18,8 +18,6 @@
 #define UNCORE_DISCOVERY_BIR_BASE              0x10
 /* Discovery table BAR step */
 #define UNCORE_DISCOVERY_BIR_STEP              0x4
-/* Mask of the discovery table offset */
-#define UNCORE_DISCOVERY_MASK                  0xf
 /* Global discovery table size */
 #define UNCORE_DISCOVERY_GLOBAL_MAP_SIZE       0x20