These patches support upcoming UV systems that do not have a UV HUB.
* Save OEM_ID from ACPI MADT probe * Return UV Hubless System Type * Add return code to UV BIOS Init function * Setup UV functions for Hubless UV Systems * Add UV Hubbed/Hubless Proc FS Files * Decode UVsystab Info * Account for UV Hubless in is_uvX_hub Ops
--
Save the OEM_ID and OEM_TABLE_ID passed to the apic driver probe function for later use. Also, convert the char list arg passed from the kernel to a true null-terminated string.
Signed-off-by: Mike Travis mike.travis@hpe.com Reviewed-by: Steve Wahl steve.wahl@hpe.com Reviewed-by: Dimitri Sivanich dimitri.sivanich@hpe.com --- arch/x86/kernel/apic/x2apic_uv_x.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
--- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c +++ linux/arch/x86/kernel/apic/x2apic_uv_x.c @@ -28,6 +28,7 @@ #include <linux/reboot.h> #include <linux/memory.h> #include <linux/numa.h> +#include <linux/acpi.h>
#include <asm/uv/uv_mmrs.h> #include <asm/uv/uv_hub.h> @@ -51,6 +52,10 @@ static u64 gru_dist_base, gru_first_no static u64 gru_dist_lmask, gru_dist_umask; static union uvh_apicid uvh_apicid;
+/* Unpack OEM/TABLE ID's to be NULL terminated strings */ +static u8 oem_id[ACPI_OEM_ID_SIZE + 1]; +static u8 oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1]; + /* Information derived from CPUID: */ static struct { unsigned int apicid_shift; @@ -268,11 +273,20 @@ static void __init uv_set_apicid_hibit(v } }
-static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id) +static void __init uv_stringify(int len, char *to, char *from) +{ + /* Relies on 'to' being NULL chars so result will be NULL terminated */ + strncpy(to, from, len-1); +} + +static int __init uv_acpi_madt_oem_check(char *_oem_id, char *_oem_table_id) { int pnodeid; int uv_apic;
+ uv_stringify(sizeof(oem_id), oem_id, _oem_id); + uv_stringify(sizeof(oem_table_id), oem_table_id, _oem_table_id); + if (strncmp(oem_id, "SGI", 3) != 0) { if (strncmp(oem_id, "NSGI", 4) == 0) { uv_hubless_system = true;
--
Return the type of UV hubless system for UV specific code that depends on that. Use a define to indicate the change in arg type for this function in uv.h. Add a function to convert UV system type to bit pattern needed for is_uv_hubless().
Signed-off-by: Mike Travis mike.travis@hpe.com Reviewed-by: Steve Wahl steve.wahl@hpe.com Reviewed-by: Dimitri Sivanich dimitri.sivanich@hpe.com --- arch/x86/include/asm/uv/uv.h | 13 +++++++++++-- arch/x86/kernel/apic/x2apic_uv_x.c | 29 +++++++++++++++++++---------- 2 files changed, 30 insertions(+), 12 deletions(-)
--- linux.orig/arch/x86/include/asm/uv/uv.h +++ linux/arch/x86/include/asm/uv/uv.h @@ -12,13 +12,21 @@ struct mm_struct; #ifdef CONFIG_X86_UV #include <linux/efi.h>
+static inline int uv(int uvtype) +{ + /* uv(0) is "any" */ + if (uvtype >= 0 && uvtype <= 30) + return 1 << uvtype; + return 1; +} extern enum uv_system_type get_uv_system_type(void); static inline bool is_early_uv_system(void) { return !((efi.uv_systab == EFI_INVALID_TABLE_ADDR) || !efi.uv_systab); } extern int is_uv_system(void); -extern int is_uv_hubless(void); +extern int _is_uv_hubless(int uvtype); +#define is_uv_hubless _is_uv_hubless extern void uv_cpu_init(void); extern void uv_nmi_init(void); extern void uv_system_init(void); @@ -30,7 +38,8 @@ extern const struct cpumask *uv_flush_tl static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; } static inline bool is_early_uv_system(void) { return 0; } static inline int is_uv_system(void) { return 0; } -static inline int is_uv_hubless(void) { return 0; } +static inline int _is_uv_hubless(int uv) { return 0; } +#define is_uv_hubless _is_uv_hubless static inline void uv_cpu_init(void) { } static inline void uv_system_init(void) { } static inline const struct cpumask * --- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c +++ linux/arch/x86/kernel/apic/x2apic_uv_x.c @@ -46,7 +46,7 @@ DEFINE_PER_CPU(int, x2apic_extra_bits);
static enum uv_system_type uv_system_type; -static bool uv_hubless_system; +static int uv_hubless_system; static u64 gru_start_paddr, gru_end_paddr; static u64 gru_dist_base, gru_first_node_paddr = -1LL, gru_last_node_paddr; static u64 gru_dist_lmask, gru_dist_umask; @@ -288,11 +288,20 @@ static int __init uv_acpi_madt_oem_check uv_stringify(sizeof(oem_table_id), oem_table_id, _oem_table_id);
if (strncmp(oem_id, "SGI", 3) != 0) { - if (strncmp(oem_id, "NSGI", 4) == 0) { - uv_hubless_system = true; - pr_info("UV: OEM IDs %s/%s, HUBLESS\n", - oem_id, oem_table_id); - } + if (strncmp(oem_id, "NSGI", 4) != 0) + return 0; + + /* UV4 Hubless, CH, (0x11:UV4+Any) */ + if (strncmp(oem_id, "NSGI4", 5) == 0) + uv_hubless_system = 0x11; + + /* UV3 Hubless, UV300/MC990X w/o hub (0x9:UV3+Any) */ + else + uv_hubless_system = 0x9; + + pr_info("UV: OEM IDs %s/%s, HUBLESS(0x%x)\n", + oem_id, oem_table_id, uv_hubless_system); + return 0; }
@@ -370,11 +379,11 @@ int is_uv_system(void) } EXPORT_SYMBOL_GPL(is_uv_system);
-int is_uv_hubless(void) +int _is_uv_hubless(int uvtype) { - return uv_hubless_system; + return (uv_hubless_system & uvtype); } -EXPORT_SYMBOL_GPL(is_uv_hubless); +EXPORT_SYMBOL_GPL(_is_uv_hubless);
void **__uv_hub_info_list; EXPORT_SYMBOL_GPL(__uv_hub_info_list); @@ -1612,7 +1621,7 @@ static void __init uv_system_init_hub(vo */ void __init uv_system_init(void) { - if (likely(!is_uv_system() && !is_uv_hubless())) + if (likely(!is_uv_system() && !is_uv_hubless(1))) return;
if (is_uv_system())
--
static inline bool is_early_uv_system(void) { return !((efi.uv_systab == EFI_INVALID_TABLE_ADDR) || !efi.uv_systab);
No need for the inner braces here.
But woudn't this be nicer as:
return efi.uv_systab != EFI_INVALID_TABLE_ADDR && efi.uv_systab;
anyway?
+#define is_uv_hubless _is_uv_hubless
Why the weird macro indirection?
-static inline int is_uv_hubless(void) { return 0; } +static inline int _is_uv_hubless(int uv) { return 0; } +#define is_uv_hubless _is_uv_hubless
And here again.
On 9/2/2019 11:49 PM, Christoph Hellwig wrote:
static inline bool is_early_uv_system(void) { return !((efi.uv_systab == EFI_INVALID_TABLE_ADDR) || !efi.uv_systab);
No need for the inner braces here.
But woudn't this be nicer as:
return efi.uv_systab != EFI_INVALID_TABLE_ADDR && efi.uv_systab;
anyway?
Yes, good catch. It somehow evolved to this but your suggestion is much more clear.
+#define is_uv_hubless _is_uv_hubless
Why the weird macro indirection?
-static inline int is_uv_hubless(void) { return 0; } +static inline int _is_uv_hubless(int uv) { return 0; } +#define is_uv_hubless _is_uv_hubless
And here again.
Sorry, I should have explained this better. The problem arises because we have a number of UV specific kernel modules that support multiple distributions. And with back porting to earlier distros we cannot rely on the KERNEL_VERSION macro to define whether the source is being built for an earlier kernel. So this allows an ifdef on the function name to discover if the kernel is before or after these changes.
The primary motivation is to avoid referencing the hub structures when there aren't any, thus avoiding any NULL dereferences. (Similar to patch 8/8.)
On Tue, Sep 03, 2019 at 07:12:28AM -0700, Mike Travis wrote:
+#define is_uv_hubless _is_uv_hubless
Why the weird macro indirection?
-static inline int is_uv_hubless(void) { return 0; } +static inline int _is_uv_hubless(int uv) { return 0; } +#define is_uv_hubless _is_uv_hubless
And here again.
Sorry, I should have explained this better. The problem arises because we have a number of UV specific kernel modules that support multiple distributions. And with back porting to earlier distros we cannot rely on the KERNEL_VERSION macro to define whether the source is being built for an earlier kernel. So this allows an ifdef on the function name to discover if the kernel is before or after these changes.
And none of these matter for upstream. We'd rather not make the code more convouluted than required. If you actually really cared about these modules you would simply submit them upstream.
On 9/3/2019 8:41 AM, Christoph Hellwig wrote:
On Tue, Sep 03, 2019 at 07:12:28AM -0700, Mike Travis wrote:
+#define is_uv_hubless _is_uv_hubless
Why the weird macro indirection?
-static inline int is_uv_hubless(void) { return 0; } +static inline int _is_uv_hubless(int uv) { return 0; } +#define is_uv_hubless _is_uv_hubless
And here again.
Sorry, I should have explained this better. The problem arises because we have a number of UV specific kernel modules that support multiple distributions. And with back porting to earlier distros we cannot rely on the KERNEL_VERSION macro to define whether the source is being built for an earlier kernel. So this allows an ifdef on the function name to discover if the kernel is before or after these changes.
And none of these matter for upstream. We'd rather not make the code more convouluted than required. If you actually really cared about these modules you would simply submit them upstream.
That is always being considered for everything we include into the community kernel source. The problem is a couple of the kernel modules (hwperf being the prime example) is much more tied to hardware and BIOS/FW updates so has to be updated much more often than the current submittal/acceptance process allows. We do opensource these modules but they are built from single source directories and have to be released as a module into a package that can be installed on different distros. There is not a source version for each kernel version.
I have seen this method (declare the function with a leading underscore and a #define for the function reference) which is why I'm assuming it's a standard kernel practice? (I'll find some examples if necessary?)
On Tue, Sep 03, 2019 at 11:49:53AM -0700, Mike Travis wrote:
That is always being considered for everything we include into the community kernel source. The problem is a couple of the kernel modules (hwperf being the prime example) is much more tied to hardware and BIOS/FW updates so has to be updated much more often than the current submittal/acceptance process allows. We do opensource these modules but they are built from single source directories and have to be released as a module into a package that can be installed on different distros. There is not a source version for each kernel version.
Well, tought luck then. We do not support interface for out of tree modules only. I actually found a few in uv and will send patches to drop that dead weight.
I have seen this method (declare the function with a leading underscore and a #define for the function reference) which is why I'm assuming it's a standard kernel practice? (I'll find some examples if necessary?)
No, it isn't.
Add a return code to the UV BIOS init function that indicates the successful initialization of the kernel/BIOS callback interface.
Signed-off-by: Mike Travis mike.travis@hpe.com Reviewed-by: Steve Wahl steve.wahl@hpe.com Reviewed-by: Dimitri Sivanich dimitri.sivanich@hpe.com --- arch/x86/include/asm/uv/bios.h | 2 +- arch/x86/platform/uv/bios_uv.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
--- linux.orig/arch/x86/include/asm/uv/bios.h +++ linux/arch/x86/include/asm/uv/bios.h @@ -138,7 +138,7 @@ extern s64 uv_bios_change_memprotect(u64 extern s64 uv_bios_reserved_page_pa(u64, u64 *, u64 *, u64 *); extern int uv_bios_set_legacy_vga_target(bool decode, int domain, int bus);
-extern void uv_bios_init(void); +extern int uv_bios_init(void);
extern unsigned long sn_rtc_cycles_per_second; extern int uv_type; --- linux.orig/arch/x86/platform/uv/bios_uv.c +++ linux/arch/x86/platform/uv/bios_uv.c @@ -182,20 +182,20 @@ int uv_bios_set_legacy_vga_target(bool d } EXPORT_SYMBOL_GPL(uv_bios_set_legacy_vga_target);
-void uv_bios_init(void) +int uv_bios_init(void) { uv_systab = NULL; if ((efi.uv_systab == EFI_INVALID_TABLE_ADDR) || !efi.uv_systab || efi_runtime_disabled()) { pr_crit("UV: UVsystab: missing\n"); - return; + return -EEXIST; }
uv_systab = ioremap(efi.uv_systab, sizeof(struct uv_systab)); if (!uv_systab || strncmp(uv_systab->signature, UV_SYSTAB_SIG, 4)) { pr_err("UV: UVsystab: bad signature!\n"); iounmap(uv_systab); - return; + return -EINVAL; }
/* Starting with UV4 the UV systab size is variable */ @@ -206,8 +206,9 @@ void uv_bios_init(void) uv_systab = ioremap(efi.uv_systab, size); if (!uv_systab) { pr_err("UV: UVsystab: ioremap(%d) failed!\n", size); - return; + return -EFAULT; } } pr_info("UV: UVsystab: Revision:%x\n", uv_systab->revision); + return 0; }
--
Add more support for UV systems that do not contain a UV Hub (AKA "hubless"). This update adds support for additional functions required:
Use PCH NMI handler instead of a UV Hub NMI handler.
Initialize the UV BIOS callback interface used to support specific UV functions.
Signed-off-by: Mike Travis mike.travis@hpe.com Reviewed-by: Steve Wahl steve.wahl@hpe.com Reviewed-by: Dimitri Sivanich dimitri.sivanich@hpe.com --- arch/x86/kernel/apic/x2apic_uv_x.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
--- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c +++ linux/arch/x86/kernel/apic/x2apic_uv_x.c @@ -1477,6 +1477,20 @@ static void __init build_socket_tables(v } }
+/* Initialize UV hubless systems */ +static __init int uv_system_init_hubless(void) +{ + int rc; + + /* Setup PCH NMI handler */ + uv_nmi_setup_hubless(); + + /* Init kernel/BIOS interface */ + rc = uv_bios_init(); + + return rc; +} + static void __init uv_system_init_hub(void) { struct uv_hub_info_s hub_info = {0}; @@ -1616,8 +1630,8 @@ static void __init uv_system_init_hub(vo }
/* - * There is a small amount of UV specific code needed to initialize a - * UV system that does not have a "UV HUB" (referred to as "hubless"). + * There is a different code path needed to initialize a UV system that does + * not have a "UV HUB" (referred to as "hubless"). */ void __init uv_system_init(void) { @@ -1627,7 +1641,7 @@ void __init uv_system_init(void) if (is_uv_system()) uv_system_init_hub(); else - uv_nmi_setup_hubless(); + uv_system_init_hubless(); }
apic_driver(apic_x2apic_uv_x);
--
Indicate to UV user utilities that UV hubless support is available on this system via the existing /proc infterface. The current interface is maintained with the addition of a new /proc leaves ("hubbed" and "hubless") that contain the specific type of UV arch this one is.
Signed-off-by: Mike Travis mike.travis@hpe.com Reviewed-by: Steve Wahl steve.wahl@hpe.com Reviewed-by: Dimitri Sivanich dimitri.sivanich@hpe.com --- arch/x86/include/asm/uv/uv.h | 6 ++ arch/x86/kernel/apic/x2apic_uv_x.c | 93 ++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 1 deletion(-)
--- linux.orig/arch/x86/include/asm/uv/uv.h +++ linux/arch/x86/include/asm/uv/uv.h @@ -12,6 +12,8 @@ struct mm_struct; #ifdef CONFIG_X86_UV #include <linux/efi.h>
+#define UV_PROC_NODE "sgi_uv" + static inline int uv(int uvtype) { /* uv(0) is "any" */ @@ -25,6 +27,8 @@ static inline bool is_early_uv_system(vo return !((efi.uv_systab == EFI_INVALID_TABLE_ADDR) || !efi.uv_systab); } extern int is_uv_system(void); +extern int _is_uv_hubbed(int uvtype); +#define is_uv_hubbed _is_uv_hubbed extern int _is_uv_hubless(int uvtype); #define is_uv_hubless _is_uv_hubless extern void uv_cpu_init(void); @@ -38,6 +42,8 @@ extern const struct cpumask *uv_flush_tl static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; } static inline bool is_early_uv_system(void) { return 0; } static inline int is_uv_system(void) { return 0; } +static inline int _is_uv_hubbed(int uv) { return 0; } +#define is_uv_hubbed _is_uv_hubbed static inline int _is_uv_hubless(int uv) { return 0; } #define is_uv_hubless _is_uv_hubless static inline void uv_cpu_init(void) { } --- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c +++ linux/arch/x86/kernel/apic/x2apic_uv_x.c @@ -46,6 +46,7 @@ DEFINE_PER_CPU(int, x2apic_extra_bits);
static enum uv_system_type uv_system_type; +static int uv_hubbed_system; static int uv_hubless_system; static u64 gru_start_paddr, gru_end_paddr; static u64 gru_dist_base, gru_first_node_paddr = -1LL, gru_last_node_paddr; @@ -329,6 +330,24 @@ static int __init uv_acpi_madt_oem_check if (uv_hub_info->hub_revision == 0) goto badbios;
+ switch (uv_hub_info->hub_revision) { + case UV4_HUB_REVISION_BASE: + uv_hubbed_system = 0x11; + break; + + case UV3_HUB_REVISION_BASE: + uv_hubbed_system = 0x9; + break; + + case UV2_HUB_REVISION_BASE: + uv_hubbed_system = 0x5; + break; + + case UV1_HUB_REVISION_BASE: + uv_hubbed_system = 0x3; + break; + } + pnodeid = early_get_pnodeid(); early_get_apic_socketid_shift();
@@ -379,6 +398,12 @@ int is_uv_system(void) } EXPORT_SYMBOL_GPL(is_uv_system);
+int _is_uv_hubbed(int uvtype) +{ + return (uv_hubbed_system & uvtype); +} +EXPORT_SYMBOL_GPL(_is_uv_hubbed); + int _is_uv_hubless(int uvtype) { return (uv_hubless_system & uvtype); @@ -1477,6 +1502,68 @@ static void __init build_socket_tables(v } }
+/* Setup user proc fs files */ +static int proc_hubbed_show(struct seq_file *file, void *data) +{ + seq_printf(file, "0x%x\n", uv_hubbed_system); + return 0; +} + +static int proc_hubless_show(struct seq_file *file, void *data) +{ + seq_printf(file, "0x%x\n", uv_hubless_system); + return 0; +} + +static int proc_oemid_show(struct seq_file *file, void *data) +{ + seq_printf(file, "%s/%s\n", oem_id, oem_table_id); + return 0; +} + +static int proc_hubbed_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_hubbed_show, (void *)NULL); +} + +static int proc_hubless_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_hubless_show, (void *)NULL); +} + +static int proc_oemid_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_oemid_show, (void *)NULL); +} + +/* (The open function is set to the hubbed or hubless version) */ +static struct file_operations proc_version_fops = { + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static const struct file_operations proc_oemid_fops = { + .open = proc_oemid_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static __init void uv_setup_proc_files(int hubless) +{ + struct proc_dir_entry *pde; + char *name = hubless ? "hubless" : "hubbed"; + + pde = proc_mkdir(UV_PROC_NODE, NULL); + proc_create(name, 0, pde, &proc_version_fops); + if (hubless) + proc_version_fops.open = proc_hubless_open; + else + proc_version_fops.open = proc_hubbed_open; + proc_create(name, 0, pde, &proc_oemid_fops); +} + /* Initialize UV hubless systems */ static __init int uv_system_init_hubless(void) { @@ -1488,6 +1575,10 @@ static __init int uv_system_init_hubless /* Init kernel/BIOS interface */ rc = uv_bios_init();
+ /* Create user access node if UVsystab available */ + if (rc >= 0) + uv_setup_proc_files(1); + return rc; }
@@ -1616,7 +1707,7 @@ static void __init uv_system_init_hub(vo uv_nmi_setup(); uv_cpu_init(); uv_scir_register_cpu_notifier(); - proc_mkdir("sgi_uv", NULL); + uv_setup_proc_files(0);
/* Register Legacy VGA I/O redirection handler: */ pci_register_set_vga_state(uv_set_vga_state);
--
+extern int _is_uv_hubbed(int uvtype); +#define is_uv_hubbed _is_uv_hubbed
+static inline int _is_uv_hubbed(int uv) { return 0; } +#define is_uv_hubbed _is_uv_hubbed
Another two instances of these weird indirections..
Decode the hubless UVsystab passed from BIOS to the kernel saving pertinent info in a similar manner that hubbed UVsystabs are decoded.
Signed-off-by: Mike Travis mike.travis@hpe.com Reviewed-by: Steve Wahl steve.wahl@hpe.com Reviewed-by: Dimitri Sivanich dimitri.sivanich@hpe.com --- arch/x86/kernel/apic/x2apic_uv_x.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
--- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c +++ linux/arch/x86/kernel/apic/x2apic_uv_x.c @@ -1323,7 +1323,8 @@ static int __init decode_uv_systab(void) struct uv_systab *st; int i;
- if (uv_hub_info->hub_revision < UV4_HUB_REVISION_BASE) + /* Select only UV4 (hubbed or hubless) and higher */ + if (is_uv_hubbed(-2) < uv(4) && is_uv_hubless(-2) < uv(4)) return 0; /* No extended UVsystab required */
st = uv_systab; @@ -1574,8 +1575,19 @@ static __init int uv_system_init_hubless
/* Init kernel/BIOS interface */ rc = uv_bios_init(); + if (rc < 0) { + pr_err("UV: BIOS init error:%d\n", rc); + return rc; + } + + /* Process UVsystab */ + rc = decode_uv_systab(); + if (rc < 0) { + pr_err("UV: UVsystab decode error:%d\n", rc); + return rc; + }
- /* Create user access node if UVsystab available */ + /* Create user access node */ if (rc >= 0) uv_setup_proc_files(1);
--
On Mon, Sep 02, 2019 at 07:18:21PM -0500, Mike Travis wrote:
Decode the hubless UVsystab passed from BIOS to the kernel saving pertinent info in a similar manner that hubbed UVsystabs are decoded.
Signed-off-by: Mike Travis mike.travis@hpe.com Reviewed-by: Steve Wahl steve.wahl@hpe.com Reviewed-by: Dimitri Sivanich dimitri.sivanich@hpe.com
arch/x86/kernel/apic/x2apic_uv_x.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.
</formletter>
Same thing goes for all of the patches in this series...
Change to checking for EFI Boot type from previous check on if this is a KDUMP kernel. This allows for KDUMP kernels that can handle EFI reboots.
Signed-off-by: Mike Travis mike.travis@hpe.com Reviewed-by: Steve Wahl steve.wahl@hpe.com Reviewed-by: Dimitri Sivanich dimitri.sivanich@hpe.com --- arch/x86/kernel/apic/x2apic_uv_x.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
--- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c +++ linux/arch/x86/kernel/apic/x2apic_uv_x.c @@ -29,6 +29,7 @@ #include <linux/memory.h> #include <linux/numa.h> #include <linux/acpi.h> +#include <linux/efi.h>
#include <asm/uv/uv_mmrs.h> #include <asm/uv/uv_hub.h> @@ -1503,6 +1504,14 @@ static void __init build_socket_tables(v } }
+/* Check which reboot to use */ +static void check_efi_reboot(void) +{ + /* If EFI reboot not available, use ACPI reboot */ + if (!efi_enabled(EFI_BOOT)) + reboot_type = BOOT_ACPI; +} + /* Setup user proc fs files */ static int proc_hubbed_show(struct seq_file *file, void *data) { @@ -1591,6 +1600,8 @@ static __init int uv_system_init_hubless if (rc >= 0) uv_setup_proc_files(1);
+ check_efi_reboot(); + return rc; }
@@ -1724,12 +1735,7 @@ static void __init uv_system_init_hub(vo /* Register Legacy VGA I/O redirection handler: */ pci_register_set_vga_state(uv_set_vga_state);
- /* - * For a kdump kernel the reset must be BOOT_ACPI, not BOOT_EFI, as - * EFI is not enabled in the kdump kernel: - */ - if (is_kdump_kernel()) - reboot_type = BOOT_ACPI; + check_efi_reboot(); }
/*
--
The references in the is_uvX_hub() function uses the hub_info pointer which will be NULL when the system is hubless. This change avoids that NULL dereference. It is also an optimization in performance.
Signed-off-by: Mike Travis mike.travis@hpe.com Reviewed-by: Steve Wahl steve.wahl@hpe.com Reviewed-by: Dimitri Sivanich dimitri.sivanich@hpe.com --- arch/x86/include/asm/uv/.uv_hub.h.swp |binary arch/x86/include/asm/uv/uv_hub.h | 60 ++++++++++++--------------------------- 1 file changed, 19 insertions(+), 41 deletions(-)
Binary files linux.orig/arch/x86/include/asm/uv/.uv_hub.h.swp and linux/arch/x86/include/asm/uv/.uv_hub.h.swp differ --- linux.orig/arch/x86/include/asm/uv/uv_hub.h +++ linux/arch/x86/include/asm/uv/uv_hub.h @@ -19,6 +19,7 @@ #include <linux/topology.h> #include <asm/types.h> #include <asm/percpu.h> +#include <asm/uv/uv.h> #include <asm/uv/uv_mmrs.h> #include <asm/uv/bios.h> #include <asm/irq_vectors.h> @@ -243,83 +244,60 @@ static inline int uv_hub_info_check(int #define UV4_HUB_REVISION_BASE 7 #define UV4A_HUB_REVISION_BASE 8 /* UV4 (fixed) rev 2 */
-#ifdef UV1_HUB_IS_SUPPORTED static inline int is_uv1_hub(void) { - return uv_hub_info->hub_revision < UV2_HUB_REVISION_BASE; -} +#ifdef UV1_HUB_IS_SUPPORTED + return is_uv_hubbed(uv(1)); #else -static inline int is_uv1_hub(void) -{ return 0; -} #endif +}
-#ifdef UV2_HUB_IS_SUPPORTED static inline int is_uv2_hub(void) { - return ((uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE) && - (uv_hub_info->hub_revision < UV3_HUB_REVISION_BASE)); -} +#ifdef UV2_HUB_IS_SUPPORTED + return is_uv_hubbed(uv(2)); #else -static inline int is_uv2_hub(void) -{ return 0; -} #endif +}
-#ifdef UV3_HUB_IS_SUPPORTED static inline int is_uv3_hub(void) { - return ((uv_hub_info->hub_revision >= UV3_HUB_REVISION_BASE) && - (uv_hub_info->hub_revision < UV4_HUB_REVISION_BASE)); -} +#ifdef UV3_HUB_IS_SUPPORTED + return is_uv_hubbed(uv(3)); #else -static inline int is_uv3_hub(void) -{ return 0; -} #endif +}
/* First test "is UV4A", then "is UV4" */ -#ifdef UV4A_HUB_IS_SUPPORTED -static inline int is_uv4a_hub(void) -{ - return (uv_hub_info->hub_revision >= UV4A_HUB_REVISION_BASE); -} -#else static inline int is_uv4a_hub(void) { +#ifdef UV4A_HUB_IS_SUPPORTED + if (is_uv_hubbed(uv(4))) + return (uv_hub_info->hub_revision == UV4A_HUB_REVISION_BASE); +#endif return 0; } -#endif
-#ifdef UV4_HUB_IS_SUPPORTED static inline int is_uv4_hub(void) { - return uv_hub_info->hub_revision >= UV4_HUB_REVISION_BASE; -} +#ifdef UV4_HUB_IS_SUPPORTED + return is_uv_hubbed(uv(4)); #else -static inline int is_uv4_hub(void) -{ return 0; -} #endif +}
static inline int is_uvx_hub(void) { - if (uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE) - return uv_hub_info->hub_revision; - - return 0; + return (is_uv_hubbed(-2) >= uv(2)); }
static inline int is_uv_hub(void) { -#ifdef UV1_HUB_IS_SUPPORTED - return uv_hub_info->hub_revision; -#endif - return is_uvx_hub(); + return is_uv1_hub() || is_uvx_hub(); }
union uvh_apicid {
--
On Mon, Sep 02, 2019 at 07:18:23PM -0500, Mike Travis wrote:
+#ifdef UV1_HUB_IS_SUPPORTED
All these ifdefs are dead code, please just remove them.
Also it seems like at least the various mmr macros just check for a specific version, I think you are much better off just using a switch statement for the possible revisions there.
return (uv_hub_info->hub_revision == UV4A_HUB_REVISION_BASE);
And none of these braces are required.
On 9/3/2019 9:19 AM, Christoph Hellwig wrote:
On Mon, Sep 02, 2019 at 07:18:23PM -0500, Mike Travis wrote:
+#ifdef UV1_HUB_IS_SUPPORTED
All these ifdefs are dead code, please just remove them.
Those ifdefs are not dead code and are being actively used. Plus UV1 support is dead and I think the last running system died about a year ago and no support or parts are available. So undef'ing these macros will simplify and reduce the size of the object code.
Also it seems like at least the various mmr macros just check for a specific version, I think you are much better off just using a switch statement for the possible revisions there.
return (uv_hub_info->hub_revision == UV4A_HUB_REVISION_BASE);
The problem is those revision bases can change if a UV HUB revision changes. That is why there are ranges and why I'm converting them to "uv_type". Some UV kernel source code still needs to know the exact HUB revision, like (again) hwperf.
And none of these braces are required.
Sure, I can take those out now, but usually I then get bit by checkpatches which then says "parenthesis's are required".
On 9/3/2019 11:58 AM, Mike Travis wrote:
On 9/3/2019 9:19 AM, Christoph Hellwig wrote:
On Mon, Sep 02, 2019 at 07:18:23PM -0500, Mike Travis wrote:
+#ifdef UV1_HUB_IS_SUPPORTED
All these ifdefs are dead code, please just remove them.
Those ifdefs are not dead code and are being actively used. Plus UV1 support is dead and I think the last running system died about a year ago and no support or parts are available. So undef'ing these macros will simplify and reduce the size of the object code.
I forgot to add that if we do undef one of those "is supported" the code will eventually be removed, thus simplifying the source even more. So including the ifdef's in the source make that code easier to find.
Also it seems like at least the various mmr macros just check for a specific version, I think you are much better off just using a switch statement for the possible revisions there.
+ return (uv_hub_info->hub_revision == UV4A_HUB_REVISION_BASE);
The problem is those revision bases can change if a UV HUB revision changes. That is why there are ranges and why I'm converting them to "uv_type". Some UV kernel source code still needs to know the exact HUB revision, like (again) hwperf.
And none of these braces are required.
Sure, I can take those out now, but usually I then get bit by checkpatches which then says "parenthesis's are required".
On Tue, Sep 03, 2019 at 11:58:49AM -0700, Mike Travis wrote:
Those ifdefs are not dead code and are being actively used. Plus UV1 support is dead and I think the last running system died about a year ago and no support or parts are available. So undef'ing these macros will simplify and reduce the size of the object code.
I'm not complaining about removing some ifdefs, that is always good. I complain about keeping the others that are dead. And if Hub 1 is dead please drop all the checks and support code for it.
A patch against current mainline to show what I mean is below.
---
From e84506399fa9436d47b33491d3e38e9dc3c718c7 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig hch@lst.de Date: Tue, 3 Sep 2019 18:05:37 +0200 Subject: x86/uv: Remove the dead UV?_HUB_IS_SUPPORTED defines
These are always set, so remove them and the dead code for the case where they are not defined.
Signed-off-by: Christoph Hellwig hch@lst.de --- arch/x86/include/asm/uv/uv_hub.h | 38 ------------------------------- arch/x86/include/asm/uv/uv_mmrs.h | 7 ------ 2 files changed, 45 deletions(-)
diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h index 6eed0b379412..f71eb659f0de 100644 --- a/arch/x86/include/asm/uv/uv_hub.h +++ b/arch/x86/include/asm/uv/uv_hub.h @@ -229,68 +229,33 @@ static inline struct uv_hub_info_s *uv_cpu_hub_info(int cpu) #define UV4_HUB_REVISION_BASE 7 #define UV4A_HUB_REVISION_BASE 8 /* UV4 (fixed) rev 2 */
-#ifdef UV1_HUB_IS_SUPPORTED static inline int is_uv1_hub(void) { return uv_hub_info->hub_revision < UV2_HUB_REVISION_BASE; } -#else -static inline int is_uv1_hub(void) -{ - return 0; -} -#endif
-#ifdef UV2_HUB_IS_SUPPORTED static inline int is_uv2_hub(void) { return ((uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE) && (uv_hub_info->hub_revision < UV3_HUB_REVISION_BASE)); } -#else -static inline int is_uv2_hub(void) -{ - return 0; -} -#endif
-#ifdef UV3_HUB_IS_SUPPORTED static inline int is_uv3_hub(void) { return ((uv_hub_info->hub_revision >= UV3_HUB_REVISION_BASE) && (uv_hub_info->hub_revision < UV4_HUB_REVISION_BASE)); } -#else -static inline int is_uv3_hub(void) -{ - return 0; -} -#endif
/* First test "is UV4A", then "is UV4" */ -#ifdef UV4A_HUB_IS_SUPPORTED static inline int is_uv4a_hub(void) { return (uv_hub_info->hub_revision >= UV4A_HUB_REVISION_BASE); } -#else -static inline int is_uv4a_hub(void) -{ - return 0; -} -#endif
-#ifdef UV4_HUB_IS_SUPPORTED static inline int is_uv4_hub(void) { return uv_hub_info->hub_revision >= UV4_HUB_REVISION_BASE; } -#else -static inline int is_uv4_hub(void) -{ - return 0; -} -#endif
static inline int is_uvx_hub(void) { @@ -302,10 +267,7 @@ static inline int is_uvx_hub(void)
static inline int is_uv_hub(void) { -#ifdef UV1_HUB_IS_SUPPORTED return uv_hub_info->hub_revision; -#endif - return is_uvx_hub(); }
union uvh_apicid { diff --git a/arch/x86/include/asm/uv/uv_mmrs.h b/arch/x86/include/asm/uv/uv_mmrs.h index 62c79e26a59a..9ee5ed6e8b34 100644 --- a/arch/x86/include/asm/uv/uv_mmrs.h +++ b/arch/x86/include/asm/uv/uv_mmrs.h @@ -99,13 +99,6 @@ #define UV3_HUB_PART_NUMBER_X 0x4321 #define UV4_HUB_PART_NUMBER 0x99a1
-/* Compat: Indicate which UV Hubs are supported. */ -#define UV1_HUB_IS_SUPPORTED 1 -#define UV2_HUB_IS_SUPPORTED 1 -#define UV3_HUB_IS_SUPPORTED 1 -#define UV4_HUB_IS_SUPPORTED 1 -#define UV4A_HUB_IS_SUPPORTED 1 - /* Error function to catch undefined references */ extern unsigned long uv_undefined(char *str);
Hi Christoph,
I can do these and leave some comments as markers to find the code to remove later. The real problem is uv_mmrs.h is a generated file and the scripts cannot be easily redone. Basically they copy in the verilog definition files from the UV HUB design files and create kernel compatible files that also then generate run-time checking of hardware specifics like MMR addresses and field definitions. The change to remove those "is supported defines" takes a higher level process that cannot be done within this short release cycle. We are racing to include this support in the next linux release for pending new hardware introductions.
Also that script is in a state of flux for the next UV arch and processor updates so changing anything at this moment is highly disruptive. Is there a specific reason why this UV only code that does not touch anything else in the kernel and only affects our productivity and system performance appears to be such a problem with you? And why now, at this moment, and after 10 years does it suddenly seem so important? I'm all for clean up but not disruption.
Bottom line, I agree to all these changes and I promise to tend to them in the next release cycle. But please let us get through this cycle without this much chaos?
Thanks, Mike
On 9/3/2019 11:52 PM, Christoph Hellwig wrote:
On Tue, Sep 03, 2019 at 11:58:49AM -0700, Mike Travis wrote:
Those ifdefs are not dead code and are being actively used. Plus UV1 support is dead and I think the last running system died about a year ago and no support or parts are available. So undef'ing these macros will simplify and reduce the size of the object code.
I'm not complaining about removing some ifdefs, that is always good. I complain about keeping the others that are dead. And if Hub 1 is dead please drop all the checks and support code for it.
A patch against current mainline to show what I mean is below.
From e84506399fa9436d47b33491d3e38e9dc3c718c7 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig hch@lst.de Date: Tue, 3 Sep 2019 18:05:37 +0200 Subject: x86/uv: Remove the dead UV?_HUB_IS_SUPPORTED defines
These are always set, so remove them and the dead code for the case where they are not defined.
Signed-off-by: Christoph Hellwig hch@lst.de
arch/x86/include/asm/uv/uv_hub.h | 38 ------------------------------- arch/x86/include/asm/uv/uv_mmrs.h | 7 ------ 2 files changed, 45 deletions(-)
diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h index 6eed0b379412..f71eb659f0de 100644 --- a/arch/x86/include/asm/uv/uv_hub.h +++ b/arch/x86/include/asm/uv/uv_hub.h @@ -229,68 +229,33 @@ static inline struct uv_hub_info_s *uv_cpu_hub_info(int cpu) #define UV4_HUB_REVISION_BASE 7 #define UV4A_HUB_REVISION_BASE 8 /* UV4 (fixed) rev 2 */ -#ifdef UV1_HUB_IS_SUPPORTED static inline int is_uv1_hub(void) { return uv_hub_info->hub_revision < UV2_HUB_REVISION_BASE; } -#else -static inline int is_uv1_hub(void) -{
- return 0;
-} -#endif -#ifdef UV2_HUB_IS_SUPPORTED static inline int is_uv2_hub(void) { return ((uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE) && (uv_hub_info->hub_revision < UV3_HUB_REVISION_BASE)); } -#else -static inline int is_uv2_hub(void) -{
- return 0;
-} -#endif -#ifdef UV3_HUB_IS_SUPPORTED static inline int is_uv3_hub(void) { return ((uv_hub_info->hub_revision >= UV3_HUB_REVISION_BASE) && (uv_hub_info->hub_revision < UV4_HUB_REVISION_BASE)); } -#else -static inline int is_uv3_hub(void) -{
- return 0;
-} -#endif /* First test "is UV4A", then "is UV4" */ -#ifdef UV4A_HUB_IS_SUPPORTED static inline int is_uv4a_hub(void) { return (uv_hub_info->hub_revision >= UV4A_HUB_REVISION_BASE); } -#else -static inline int is_uv4a_hub(void) -{
- return 0;
-} -#endif -#ifdef UV4_HUB_IS_SUPPORTED static inline int is_uv4_hub(void) { return uv_hub_info->hub_revision >= UV4_HUB_REVISION_BASE; } -#else -static inline int is_uv4_hub(void) -{
- return 0;
-} -#endif static inline int is_uvx_hub(void) { @@ -302,10 +267,7 @@ static inline int is_uvx_hub(void) static inline int is_uv_hub(void) { -#ifdef UV1_HUB_IS_SUPPORTED return uv_hub_info->hub_revision; -#endif
- return is_uvx_hub(); }
union uvh_apicid { diff --git a/arch/x86/include/asm/uv/uv_mmrs.h b/arch/x86/include/asm/uv/uv_mmrs.h index 62c79e26a59a..9ee5ed6e8b34 100644 --- a/arch/x86/include/asm/uv/uv_mmrs.h +++ b/arch/x86/include/asm/uv/uv_mmrs.h @@ -99,13 +99,6 @@ #define UV3_HUB_PART_NUMBER_X 0x4321 #define UV4_HUB_PART_NUMBER 0x99a1 -/* Compat: Indicate which UV Hubs are supported. */ -#define UV1_HUB_IS_SUPPORTED 1 -#define UV2_HUB_IS_SUPPORTED 1 -#define UV3_HUB_IS_SUPPORTED 1 -#define UV4_HUB_IS_SUPPORTED 1 -#define UV4A_HUB_IS_SUPPORTED 1
- /* Error function to catch undefined references */ extern unsigned long uv_undefined(char *str);
* Mike Travis mike.travis@hpe.com wrote:
These patches support upcoming UV systems that do not have a UV HUB.
- Save OEM_ID from ACPI MADT probe
- Return UV Hubless System Type
- Add return code to UV BIOS Init function
- Setup UV functions for Hubless UV Systems
- Add UV Hubbed/Hubless Proc FS Files
- Decode UVsystab Info
- Account for UV Hubless in is_uvX_hub Ops
Beyond addressing Christoph's feedback, please also make sure the series applies cleanly to tip:master, because right now it doesn't.
Thanks,
Ingo
On 9/3/2019 12:47 AM, Ingo Molnar wrote:
- Mike Travis mike.travis@hpe.com wrote:
These patches support upcoming UV systems that do not have a UV HUB.
- Save OEM_ID from ACPI MADT probe
- Return UV Hubless System Type
- Add return code to UV BIOS Init function
- Setup UV functions for Hubless UV Systems
- Add UV Hubbed/Hubless Proc FS Files
- Decode UVsystab Info
- Account for UV Hubless in is_uvX_hub Ops
Beyond addressing Christoph's feedback, please also make sure the series applies cleanly to tip:master, because right now it doesn't.
Thanks,
Ingo
I will do this, and retest. Currently we are using the latest upstream version but obviously that thinking is flawed, since we are hoping to get into the next merge period.
I also noticed that the MAINTAINERS list for UV is out of date, I will tend to that too.
Thanks, Mike
* Mike Travis mike.travis@hpe.com wrote:
On 9/3/2019 12:47 AM, Ingo Molnar wrote:
- Mike Travis mike.travis@hpe.com wrote:
These patches support upcoming UV systems that do not have a UV HUB.
- Save OEM_ID from ACPI MADT probe
- Return UV Hubless System Type
- Add return code to UV BIOS Init function
- Setup UV functions for Hubless UV Systems
- Add UV Hubbed/Hubless Proc FS Files
- Decode UVsystab Info
- Account for UV Hubless in is_uvX_hub Ops
Beyond addressing Christoph's feedback, please also make sure the series applies cleanly to tip:master, because right now it doesn't.
Thanks,
Ingo
I will do this, and retest. Currently we are using the latest upstream version but obviously that thinking is flawed, since we are hoping to get into the next merge period.
You are really cutting it close timing-wise ... unless by 'next' you mean not v5.4 but v5.5?
I also noticed that the MAINTAINERS list for UV is out of date, I will tend to that too.
Thanks!
Ingo
linux-stable-mirror@lists.linaro.org