Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/x86/amd/hsmp: Check HSMP support on AMD family of processors

HSMP interface is supported only on few x86 processors from AMD.
Accessing HSMP registers on rest of the platforms might cause
unexpected behaviour. So add a check.

Also unavailability of this interface on rest of the processors
is not an error. Hence, use pr_info() instead of the pr_err() to
log the message.

Signed-off-by: Suma Hegde <suma.hegde@amd.com>
Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
Link: https://lore.kernel.org/r/20240603081512.142909-1-suma.hegde@amd.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Suma Hegde and committed by
Hans de Goede
77f1972b 306aec7e

+43 -7
+43 -7
drivers/platform/x86/amd/hsmp.c
··· 907 907 return ret; 908 908 } 909 909 910 + /* 911 + * This check is only needed for backward compatibility of previous platforms. 912 + * All new platforms are expected to support ACPI based probing. 913 + */ 914 + static bool legacy_hsmp_support(void) 915 + { 916 + if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) 917 + return false; 918 + 919 + switch (boot_cpu_data.x86) { 920 + case 0x19: 921 + switch (boot_cpu_data.x86_model) { 922 + case 0x00 ... 0x1F: 923 + case 0x30 ... 0x3F: 924 + case 0x90 ... 0x9F: 925 + case 0xA0 ... 0xAF: 926 + return true; 927 + default: 928 + return false; 929 + } 930 + case 0x1A: 931 + switch (boot_cpu_data.x86_model) { 932 + case 0x00 ... 0x1F: 933 + return true; 934 + default: 935 + return false; 936 + } 937 + default: 938 + return false; 939 + } 940 + 941 + return false; 942 + } 943 + 910 944 static int __init hsmp_plt_init(void) 911 945 { 912 946 int ret = -ENODEV; 913 - 914 - if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD || boot_cpu_data.x86 < 0x19) { 915 - pr_err("HSMP is not supported on Family:%x model:%x\n", 916 - boot_cpu_data.x86, boot_cpu_data.x86_model); 917 - return ret; 918 - } 919 947 920 948 /* 921 949 * amd_nb_num() returns number of SMN/DF interfaces present in the system ··· 958 930 return ret; 959 931 960 932 if (!plat_dev.is_acpi_device) { 961 - ret = hsmp_plat_dev_register(); 933 + if (legacy_hsmp_support()) { 934 + /* Not ACPI device, but supports HSMP, register a plat_dev */ 935 + ret = hsmp_plat_dev_register(); 936 + } else { 937 + /* Not ACPI, Does not support HSMP */ 938 + pr_info("HSMP is not supported on Family:%x model:%x\n", 939 + boot_cpu_data.x86, boot_cpu_data.x86_model); 940 + ret = -ENODEV; 941 + } 962 942 if (ret) 963 943 platform_driver_unregister(&amd_hsmp_driver); 964 944 }