From 6b9da3f63f041807ed8ba32072a73ea43d7e7dd3 Mon Sep 17 00:00:00 2001 From: Dave Hansen Date: Tue, 22 Sep 2026 20:32:09 -0700 Subject: [PATCH 03/75] x86/platform/uv: Remove the unused GPA conversion helpers A UV "global physical address" is a socket physical address with the owning node's NASID bits pasted on top, so that the GRU could reach memory on another blade over NumaLink. carries a full set of inline helpers to convert in both directions: uv_gpa(), uv_gpa_nasid(), uv_soc_phys_ram_to_gpa(), uv_soc_phys_ram_to_nasid(), uv_gpa_to_soc_phys_ram(), uv_gpa_to_gnode(), uv_gpa_to_pnode(), uv_gpa_to_offset(), uv_gpa_in_mmr_space(), uv_gpa_shift(), uv_pnode_offset_to_vaddr() plus uv_gam_range()/uv_gam_range_base() which walk the GAM range table to find the node owning an address. The GRU driver and the XP/XPC/XPNET stack on top of it were the only users: commit dbf69afe320e ("misc: sgi-xp: Remove SGI XP drivers") commit 85de4712bccf ("misc: sgi-gru: Remove SGI GRU driver") Since then nothing converts to or from a GPA, and the whole block is only reachable from itself. Remove it. The GAM range table itself stays: x2apic_uv_x.c still parses it out of the UV systab to work out the NASID/PNODE layout, so struct uv_gam_range_s, uv_hub_info->gr_table and UV_GAM_RANGE_SHFT all keep their users. No functional change intended. --- arch/x86/include/asm/uv/uv_hub.h | 156 ------------------------------- 1 file changed, 156 deletions(-) diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h index ea877fd83114c..765abfec7311b 100644 --- a/arch/x86/include/asm/uv/uv_hub.h +++ b/arch/x86/include/asm/uv/uv_hub.h @@ -373,142 +373,6 @@ union uvh_apicid { #define for_each_possible_blade(bid) \ for ((bid) = 0; (bid) < uv_num_possible_blades(); (bid)++) -/* - * Macros for converting between kernel virtual addresses, socket local physical - * addresses, and UV global physical addresses. - * Note: use the standard __pa() & __va() macros for converting - * between socket virtual and socket physical addresses. - */ - -/* global bits offset - number of local address bits in gpa for this UV arch */ -static inline unsigned int uv_gpa_shift(void) -{ - return uv_hub_info->gpa_shift; -} -#define _uv_gpa_shift - -/* Find node that has the address range that contains global address */ -static inline struct uv_gam_range_s *uv_gam_range(unsigned long pa) -{ - struct uv_gam_range_s *gr = uv_hub_info->gr_table; - unsigned long pal = (pa & uv_hub_info->gpa_mask) >> UV_GAM_RANGE_SHFT; - int i, num = uv_hub_info->gr_table_len; - - if (gr) { - for (i = 0; i < num; i++, gr++) { - if (pal < gr->limit) - return gr; - } - } - pr_crit("UV: GAM Range for 0x%lx not found at %p!\n", pa, gr); - BUG(); -} - -/* Return base address of node that contains global address */ -static inline unsigned long uv_gam_range_base(unsigned long pa) -{ - struct uv_gam_range_s *gr = uv_gam_range(pa); - int base = gr->base; - - if (base < 0) - return 0UL; - - return uv_hub_info->gr_table[base].limit; -} - -/* socket phys RAM --> UV global NASID (UV4+) */ -static inline unsigned long uv_soc_phys_ram_to_nasid(unsigned long paddr) -{ - return uv_gam_range(paddr)->nasid; -} -#define _uv_soc_phys_ram_to_nasid - -/* socket virtual --> UV global NASID (UV4+) */ -static inline unsigned long uv_gpa_nasid(void *v) -{ - return uv_soc_phys_ram_to_nasid(__pa(v)); -} - -/* socket phys RAM --> UV global physical address */ -static inline unsigned long uv_soc_phys_ram_to_gpa(unsigned long paddr) -{ - unsigned int m_val = uv_hub_info->m_val; - - if (paddr < uv_hub_info->lowmem_remap_top) - paddr |= uv_hub_info->lowmem_remap_base; - - if (m_val) { - paddr |= uv_hub_info->gnode_upper; - paddr = ((paddr << uv_hub_info->m_shift) - >> uv_hub_info->m_shift) | - ((paddr >> uv_hub_info->m_val) - << uv_hub_info->n_lshift); - } else { - paddr |= uv_soc_phys_ram_to_nasid(paddr) - << uv_hub_info->gpa_shift; - } - return paddr; -} - -/* socket virtual --> UV global physical address */ -static inline unsigned long uv_gpa(void *v) -{ - return uv_soc_phys_ram_to_gpa(__pa(v)); -} - -/* Top two bits indicate the requested address is in MMR space. */ -static inline int -uv_gpa_in_mmr_space(unsigned long gpa) -{ - return (gpa >> 62) == 0x3UL; -} - -/* UV global physical address --> socket phys RAM */ -static inline unsigned long uv_gpa_to_soc_phys_ram(unsigned long gpa) -{ - unsigned long paddr; - unsigned long remap_base = uv_hub_info->lowmem_remap_base; - unsigned long remap_top = uv_hub_info->lowmem_remap_top; - unsigned int m_val = uv_hub_info->m_val; - - if (m_val) - gpa = ((gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift) | - ((gpa >> uv_hub_info->n_lshift) << uv_hub_info->m_val); - - paddr = gpa & uv_hub_info->gpa_mask; - if (paddr >= remap_base && paddr < remap_base + remap_top) - paddr -= remap_base; - return paddr; -} - -/* gpa -> gnode */ -static inline unsigned long uv_gpa_to_gnode(unsigned long gpa) -{ - unsigned int n_lshift = uv_hub_info->n_lshift; - - if (n_lshift) - return gpa >> n_lshift; - - return uv_gam_range(gpa)->nasid >> 1; -} - -/* gpa -> pnode */ -static inline int uv_gpa_to_pnode(unsigned long gpa) -{ - return uv_gpa_to_gnode(gpa) & uv_hub_info->pnode_mask; -} - -/* gpa -> node offset */ -static inline unsigned long uv_gpa_to_offset(unsigned long gpa) -{ - unsigned int m_shift = uv_hub_info->m_shift; - - if (m_shift) - return (gpa << m_shift) >> m_shift; - - return (gpa & uv_hub_info->gpa_mask) - uv_gam_range_base(gpa); -} - /* Convert socket to node */ static inline int _uv_socket_to_node(int socket, unsigned short *s2nid) { @@ -527,26 +391,6 @@ static inline int uv_pnode_to_socket(int pnode) return p2s ? p2s[pnode - uv_hub_info->min_pnode] : pnode; } -/* pnode, offset --> socket virtual */ -static inline void *uv_pnode_offset_to_vaddr(int pnode, unsigned long offset) -{ - unsigned int m_val = uv_hub_info->m_val; - unsigned long base; - unsigned short sockid; - - if (m_val) - return __va(((unsigned long)pnode << m_val) | offset); - - sockid = uv_pnode_to_socket(pnode); - - /* limit address of previous socket is our base, except node 0 is 0 */ - if (sockid == 0) - return __va((unsigned long)offset); - - base = (unsigned long)(uv_hub_info->gr_table[sockid - 1].limit); - return __va(base << UV_GAM_RANGE_SHFT | offset); -} - /* Extract/Convert a PNODE from an APICID (full apicid, not processor subset) */ static inline int uv_apicid_to_pnode(int apicid) { -- 2.43.0