From df2dd9c605ba46b0e7d307107ff5582f5e3be986 Mon Sep 17 00:00:00 2001 From: Dave Hansen Date: Tue, 22 Sep 2026 21:17:30 -0700 Subject: [PATCH 11/75] x86/platform/uv: Remove the unused GAM range lookup table build_uv_gr_table() coalesces the GAM (globally addressed memory) range entries handed over by the UV BIOS into a compact per-socket lookup table, _gr_table[], which it then hangs off the per-hub info struct. Its only consumer was uv_gam_range(), the helper that turned a socket physical address into the NASID of the node that owns it. That helper existed purely to serve uv_soc_phys_ram_to_nasid() and uv_gpa(), which were removed earlier in this series once the last GRU and XP users went away. Nothing reads gr_table[] or gr_table_len any more, so the table is built at boot and then never looked at. Remove build_uv_gr_table(), the _gr_table[]/_gr_table_len statics, the matching uv_hub_info_s fields and struct uv_gam_range_s. Note that this also drops the "UV: GAM Range ..." boot messages. That output was a rendering of the coalesced table rather than of anything the BIOS reported; the underlying GAM range entries are still printed in full by decode_gam_rng_tbl() under "UV: GAM Range Table...", so no BIOS supplied information is lost. No functional change intended. --- arch/x86/include/asm/uv/uv_hub.h | 10 --- arch/x86/kernel/apic/x2apic_uv_x.c | 104 +---------------------------- 2 files changed, 1 insertion(+), 113 deletions(-) diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h index 93c7b057991cf..71124a309ef37 100644 --- a/arch/x86/include/asm/uv/uv_hub.h +++ b/arch/x86/include/asm/uv/uv_hub.h @@ -107,14 +107,6 @@ * processor APICID register. */ -/* GAM (globally addressed memory) range table */ -struct uv_gam_range_s { - u32 limit; /* PA bits 56:26 (GAM_RANGE_SHFT) */ - u16 nasid; /* node's global physical address */ - s8 base; /* entry index of node's base addr */ - u8 reserved; -}; - /* * The following defines attributes of the HUB chip. These attributes are * frequently referenced and are kept in a common per hub struct. @@ -130,12 +122,10 @@ struct uv_hub_info_s { unsigned short *socket_to_node; unsigned short *socket_to_pnode; unsigned short *pnode_to_socket; - struct uv_gam_range_s *gr_table; unsigned short min_socket; unsigned short min_pnode; unsigned char m_val; unsigned char n_val; - unsigned char gr_table_len; unsigned char apic_pnode_shift; unsigned char gpa_shift; unsigned char nasid_shift; diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c index 46a841471ba08..42a27b2fa6420 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -499,7 +499,7 @@ EXPORT_SYMBOL(sn_rtc_cycles_per_second); /* The following values are used for the per node hub info struct */ static __initdata unsigned short _min_socket, _max_socket; -static __initdata unsigned short _min_pnode, _max_pnode, _gr_table_len; +static __initdata unsigned short _min_pnode, _max_pnode; static __initdata struct uv_gam_range_entry *uv_gre_table; static __initdata struct uv_gam_parameters *uv_gp_table; static __initdata unsigned short *_socket_to_node; @@ -507,8 +507,6 @@ static __initdata unsigned short *_socket_to_pnode; static __initdata unsigned short *_pnode_to_socket; static __initdata unsigned short *_node_to_socket; -static __initdata struct uv_gam_range_s *_gr_table; - #define SOCK_EMPTY ((unsigned short)~0) /* Default UV memory block size is 2GB */ @@ -556,102 +554,6 @@ static __init void set_block_size(void) } } -/* Build GAM range lookup table: */ -static __init void build_uv_gr_table(void) -{ - struct uv_gam_range_entry *gre = uv_gre_table; - struct uv_gam_range_s *grt; - unsigned long last_limit = 0, ram_limit = 0; - int bytes, i, sid, lsid = -1, indx = 0, lindx = -1; - - if (!gre) - return; - - bytes = _gr_table_len * sizeof(struct uv_gam_range_s); - grt = kzalloc(bytes, GFP_KERNEL); - if (WARN_ON_ONCE(!grt)) - return; - _gr_table = grt; - - for (; gre->type != UV_GAM_RANGE_TYPE_UNUSED; gre++) { - if (gre->type == UV_GAM_RANGE_TYPE_HOLE) { - if (!ram_limit) { - /* Mark hole between RAM/non-RAM: */ - ram_limit = last_limit; - last_limit = gre->limit; - lsid++; - continue; - } - last_limit = gre->limit; - pr_info("UV: extra hole in GAM RE table @%d\n", (int)(gre - uv_gre_table)); - continue; - } - if (_max_socket < gre->sockid) { - pr_err("UV: GAM table sockid(%d) too large(>%d) @%d\n", gre->sockid, _max_socket, (int)(gre - uv_gre_table)); - continue; - } - sid = gre->sockid - _min_socket; - if (lsid < sid) { - /* New range: */ - grt = &_gr_table[indx]; - grt->base = lindx; - grt->nasid = gre->nasid; - grt->limit = last_limit = gre->limit; - lsid = sid; - lindx = indx++; - continue; - } - /* Update range: */ - if (lsid == sid && !ram_limit) { - /* .. if contiguous: */ - if (grt->limit == last_limit) { - grt->limit = last_limit = gre->limit; - continue; - } - } - /* Non-contiguous RAM range: */ - if (!ram_limit) { - grt++; - grt->base = lindx; - grt->nasid = gre->nasid; - grt->limit = last_limit = gre->limit; - continue; - } - /* Non-contiguous/non-RAM: */ - grt++; - /* base is this entry */ - grt->base = grt - _gr_table; - grt->nasid = gre->nasid; - grt->limit = last_limit = gre->limit; - lsid++; - } - - /* Shorten table if possible */ - grt++; - i = grt - _gr_table; - if (i < _gr_table_len) { - void *ret; - - bytes = i * sizeof(struct uv_gam_range_s); - ret = krealloc(_gr_table, bytes, GFP_KERNEL); - if (ret) { - _gr_table = ret; - _gr_table_len = i; - } - } - - /* Display resultant GAM range table: */ - for (i = 0, grt = _gr_table; i < _gr_table_len; i++, grt++) { - unsigned long start, end; - int gb = grt->base; - - start = gb < 0 ? 0 : (unsigned long)_gr_table[gb].limit << UV_GAM_RANGE_SHFT; - end = (unsigned long)grt->limit << UV_GAM_RANGE_SHFT; - - pr_info("UV: GAM Range %2d %04x 0x%013lx-0x%013lx (%d)\n", i, grt->nasid, start, end, gb); - } -} - static int uv_wakeup_secondary(u32 phys_apicid, unsigned long start_rip, unsigned int cpu) { unsigned long val; @@ -1144,8 +1046,6 @@ static void __init uv_init_hub_info(struct uv_hub_info_s *hi) hi->pnode_to_socket = _pnode_to_socket; hi->socket_to_node = _socket_to_node; hi->socket_to_pnode = _socket_to_pnode; - hi->gr_table_len = _gr_table_len; - hi->gr_table = _gr_table; uv_cpuid.gnode_shift = max_t(unsigned int, uv_cpuid.gnode_shift, mn.n_val); hi->gnode_extra = (uv_node_id & ~((1 << uv_cpuid.gnode_shift) - 1)) >> 1; @@ -1241,7 +1141,6 @@ static void __init decode_gam_rng_tbl(unsigned long ptr) _max_socket = sock_max; _min_pnode = pnode_min; _max_pnode = pnode_max; - _gr_table_len = index; pr_info("UV: GRT: %d entries, sockets(min:%x,max:%x), pnodes(min:%x,max:%x), gap_end(%d)\n", index, _min_socket, _max_socket, _min_pnode, _max_pnode, fls64(gend)); @@ -1603,7 +1502,6 @@ static void __init uv_system_init_hub(void) } build_socket_tables(); - build_uv_gr_table(); set_block_size(); uv_init_hub_info(&hub_info); /* If UV2 or UV3 may need to get # blades from HW */ -- 2.43.0