Skip to content

Commit 71a412e

Browse files
swahlhpePeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Make uncore_discovery clean for 64 bit addresses
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Kan Liang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 161a9a3 commit 71a412e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

arch/x86/events/intel/uncore_discovery.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,21 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
210210
void __iomem *io_addr;
211211
resource_size_t addr;
212212
unsigned long size;
213-
u32 val;
213+
u32 val, val2;
214214
int i;
215215

216216
pci_read_config_dword(dev, bar_offset, &val);
217217

218-
if (val & UNCORE_DISCOVERY_MASK)
218+
if (val & ~PCI_BASE_ADDRESS_MEM_MASK & ~PCI_BASE_ADDRESS_MEM_TYPE_64)
219219
return -EINVAL;
220220

221-
addr = (resource_size_t)(val & ~UNCORE_DISCOVERY_MASK);
221+
addr = (resource_size_t)(val & PCI_BASE_ADDRESS_MEM_MASK);
222+
#ifdef CONFIG_PHYS_ADDR_T_64BIT
223+
if ((val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64) {
224+
pci_read_config_dword(dev, bar_offset + 4, &val2);
225+
addr |= ((resource_size_t)val2) << 32;
226+
}
227+
#endif
222228
size = UNCORE_DISCOVERY_GLOBAL_MAP_SIZE;
223229
io_addr = ioremap(addr, size);
224230
if (!io_addr)
@@ -444,7 +450,7 @@ static struct intel_uncore_ops generic_uncore_pci_ops = {
444450

445451
#define UNCORE_GENERIC_MMIO_SIZE 0x4000
446452

447-
static unsigned int generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
453+
static u64 generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
448454
{
449455
struct intel_uncore_type *type = box->pmu->type;
450456

@@ -456,7 +462,7 @@ static unsigned int generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
456462

457463
void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box)
458464
{
459-
unsigned int box_ctl = generic_uncore_mmio_box_ctl(box);
465+
u64 box_ctl = generic_uncore_mmio_box_ctl(box);
460466
struct intel_uncore_type *type = box->pmu->type;
461467
resource_size_t addr;
462468

arch/x86/events/intel/uncore_discovery.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#define UNCORE_DISCOVERY_BIR_BASE 0x10
1919
/* Discovery table BAR step */
2020
#define UNCORE_DISCOVERY_BIR_STEP 0x4
21-
/* Mask of the discovery table offset */
22-
#define UNCORE_DISCOVERY_MASK 0xf
2321
/* Global discovery table size */
2422
#define UNCORE_DISCOVERY_GLOBAL_MAP_SIZE 0x20
2523

0 commit comments

Comments
 (0)