platform/x86: ISST: Use numa node id for cpu pci dev mapping
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Wed, 16 Jun 2021 22:13:29 +0000 (15:13 -0700)
committerHans de Goede <hdegoede@redhat.com>
Fri, 18 Jun 2021 13:29:36 +0000 (15:29 +0200)
commitaa2ddd24257213bdfd2f65058531810ac57455dc
tree06ad820d2ea132fee02dbd9d401f63b5edc6f691
parent1e42de8e53d32bbd7a732df49d872a30b4f888b4
platform/x86: ISST: Use numa node id for cpu pci dev mapping

There is a problem in mapping CPU to a PCI device instance when the
bus numbers are reused in different packages. This was observed on
some Sapphire Rapids systems.

The current implementation reads bus number assigned to a CPU package
via MSR 0x128. This allows to establish relationship between a CPU
and a PCI device. This allows to update power related parameters to a
MMIO offset in a PCI device space which is unique to a CPU. But if
two packages uses same bus number then this mapping will not be unique.

When bus number is reused, PCI device will use different domain number
or segment number. So we need to be aware of this domain information
while matching CPU to PCI bus number. This domain information is not
available via any MSR. So need to use ACPI numa node information.

There is an interface already available in the Linux to read numa
node for a CPU and a PCI device. This change uses this interface
to check the numa node of a match PCI device with bus number.
If the bus number and numa node matches with the CPU's assigned
bus number and numa node, the matched PCI device instance will be
returned to the caller.

It is possible that before Sapphire Rapids, the numa node is not
defined for the Speed Select PCI device in some OEM systems. In this
case to restore old behavior, return the last matched PCI device
for domain 0 unlsess there are more than one matches.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20210616221329.1909276-2-srinivas.pandruvada@linux.intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/intel_speed_select_if/isst_if_common.c