x86/cpu: Provide an AMD/HYGON specific topology parser
authorThomas Gleixner <tglx@linutronix.de>
Tue, 13 Feb 2024 21:04:11 +0000 (22:04 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 15 Feb 2024 21:07:37 +0000 (22:07 +0100)
commitf7fb3b2dd92c633871b7037773b89531c488a371
treec77e56d9f51aca22d37b98ebe8a301e9c6e9f0c0
parent7e3ec6286753b404666af9a58d283690302c9321
x86/cpu: Provide an AMD/HYGON specific topology parser

AMD/HYGON uses various methods for topology evaluation:

  - Leaf 0x80000008 and 0x8000001e based with an optional leaf 0xb,
    which is the preferred variant for modern CPUs.

    Leaf 0xb will be superseded by leaf 0x80000026 soon, which is just
    another variant of the Intel 0x1f leaf for whatever reasons.

  - Subleaf 0x80000008 and NODEID_MSR base

  - Legacy fallback

That code is following the principle of random bits and pieces all over the
place which results in multiple evaluations and impenetrable code flows in
the same way as the Intel parsing did.

Provide a sane implementation by clearly separating the three variants and
bringing them in the proper preference order in one place.

This provides the parsing for both AMD and HYGON because there is no point
in having a separate HYGON parser which only differs by 3 lines of
code. Any further divergence between AMD and HYGON can be handled in
different functions, while still sharing the existing parsers.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Juergen Gross <jgross@suse.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Tested-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Tested-by: Wang Wendy <wendy.wang@intel.com>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://lore.kernel.org/r/20240212153625.020038641@linutronix.de
arch/x86/include/asm/topology.h
arch/x86/kernel/cpu/Makefile
arch/x86/kernel/cpu/amd.c
arch/x86/kernel/cpu/cacheinfo.c
arch/x86/kernel/cpu/cpu.h
arch/x86/kernel/cpu/debugfs.c
arch/x86/kernel/cpu/topology.h
arch/x86/kernel/cpu/topology_amd.c [new file with mode: 0644]
arch/x86/kernel/cpu/topology_common.c