Vishal Verma 48d4180939 ACPI: HMAT: Fix initiator registration for single-initiator systems
In a system with a single initiator node, and one or more memory-only
'target' nodes, the memory-only node(s) would fail to register their
initiator node correctly. i.e. in sysfs:

  # ls /sys/devices/system/node/node0/access0/targets/
  node0

Where as the correct behavior should be:

  # ls /sys/devices/system/node/node0/access0/targets/
  node0 node1

This happened because hmat_register_target_initiators() uses list_sort()
to sort the initiator list, but the sort comparision function
(initiator_cmp()) is overloaded to also set the node mask's bits.

In a system with a single initiator, the list is singular, and list_sort
elides the comparision helper call. Thus the node mask never gets set,
and the subsequent search for the best initiator comes up empty.

Add a new helper to consume the sorted initiator list, and generate the
nodemask, decoupling it from the overloaded initiator_cmp() comparision
callback. This prevents the singular list corner case naturally, and
makes the code easier to follow as well.

Cc: <stable@vger.kernel.org>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Liu Shixin <liushixin2@huawei.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Chris Piper <chris.d.piper@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: https://lore.kernel.org/r/20221116-acpi_hmat_fix-v2-2-3712569be691@intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2022-11-18 23:55:40 -08:00
..
2022-05-27 21:24:19 -07:00
2022-10-03 20:09:22 +02:00
2022-04-05 10:24:38 +02:00
2022-10-05 10:38:24 -07:00
2020-11-09 19:25:20 +01:00
2022-05-25 15:37:07 +02:00
2022-10-05 10:38:24 -07:00
2022-01-22 08:33:37 +02:00
2022-10-03 13:19:53 -07:00
2022-09-30 20:05:16 +02:00
2020-11-09 19:08:06 +01:00
2022-10-03 20:09:22 +02:00
2022-09-09 09:26:22 +02:00
2020-11-09 19:08:06 +01:00