• Kan Liang's avatar
    perf/x86/intel/uncore: Fix a kernel WARNING triggered by maxcpus=1 · 4a0e3ff3
    Kan Liang authored
    A kernel WARNING may be triggered when setting maxcpus=1.
    
    The uncore counters are Die-scope. When probing a PCI device, only the
    BUS information can be retrieved. The uncore driver has to maintain a
    mapping table used to calculate the logical Die ID from a given BUS#.
    
    Before the patch ba9506be, the mapping table stores the mapping
    information from the BUS# -> a Physical Socket ID. To calculate the
    logical die ID, perf does,
    - In snbep_pci2phy_map_init(), retrieve the BUS# -> a Physical Socket ID
      from the UBOX PCI configure space.
    - Calculate the mapping information (a BUS# -> a Physical Socket ID) for
      the other PCI BUS.
    - In the uncore_pci_probe(), get the physical Socket ID from a given BUS
      and the mapping table.
    - Calculate the logical Die ID
    
    Since only the logical Die ID is required, with the patch ba9506be,
    the mapping table stores the mapping information from the BUS# -> a
    logical Die ID. Now perf does,
    - In snbep_pci2phy_map_init(), retrieve the BUS# -> a Physical Socket ID
      from the UBOX PCI configure space.
    - Calculate the logical Die ID
    - Calculate the mapping information (a BUS# -> a logical Die ID) for the
      other PCI BUS.
    - In the uncore_pci_probe(), get the logical die ID from a given BUS and
      the mapping table.
    
    When calculating the logical Die ID, -1 may be returned, especially when
    maxcpus=1. Here, -1 means the logical Die ID is not found. But when
    calculating the mapping information for the other PCI BUS, -1 indicates
    that it's the other PCI BUS that requires the calculation of the
    mapping. The driver will mistakenly do the calculation.
    
    Uses the -ENODEV to indicate the case which the logical Die ID is not
    found. The driver will not mess up the mapping table anymore.
    
    Fixes: ba9506be ("perf/x86/intel/uncore: Store the logical die id instead of the physical die id.")
    Reported-by: default avatarJohn Donnelly <john.p.donnelly@oracle.com>
    Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Acked-by: default avatarJohn Donnelly <john.p.donnelly@oracle.com>
    Tested-by: default avatarJohn Donnelly <john.p.donnelly@oracle.com>
    Link: https://lkml.kernel.org/r/1622037527-156028-1-git-send-email-kan.liang@linux.intel.com
    4a0e3ff3
uncore_snbep.c 160 KB