···4646 * PNODE - the low N bits of the GNODE. The PNODE is the most useful variant4747 * of the nasid for socket usage.4848 *4949+ * GPA - (global physical address) a socket physical address converted5050+ * so that it can be used by the GRU as a global address. Socket5151+ * physical addresses 1) need additional NASID (node) bits added5252+ * to the high end of the address, and 2) unaliased if the5353+ * partition does not have a physical address 0. In addition, on5454+ * UV2 rev 1, GPAs need the gnode left shifted to bits 39 or 40.5555+ *4956 *5057 * NumaLink Global Physical Address Format:5158 * +--------------------------------+---------------------+···148141 unsigned int gnode_extra;149142 unsigned char hub_revision;150143 unsigned char apic_pnode_shift;144144+ unsigned char m_shift;145145+ unsigned char n_lshift;151146 unsigned long gnode_upper;152147 unsigned long lowmem_remap_top;153148 unsigned long lowmem_remap_base;···184175static inline int is_uv2_hub(void)185176{186177 return uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE;178178+}179179+180180+static inline int is_uv2_1_hub(void)181181+{182182+ return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE;183183+}184184+185185+static inline int is_uv2_2_hub(void)186186+{187187+ return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE + 1;187188}188189189190union uvh_apicid {···295276{296277 if (paddr < uv_hub_info->lowmem_remap_top)297278 paddr |= uv_hub_info->lowmem_remap_base;298298- return paddr | uv_hub_info->gnode_upper;279279+ paddr |= uv_hub_info->gnode_upper;280280+ paddr = ((paddr << uv_hub_info->m_shift) >> uv_hub_info->m_shift) |281281+ ((paddr >> uv_hub_info->m_val) << uv_hub_info->n_lshift);282282+ return paddr;299283}300284301285···322300 unsigned long remap_base = uv_hub_info->lowmem_remap_base;323301 unsigned long remap_top = uv_hub_info->lowmem_remap_top;324302303303+ gpa = ((gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift) |304304+ ((gpa >> uv_hub_info->n_lshift) << uv_hub_info->m_val);305305+ gpa = gpa & uv_hub_info->gpa_mask;325306 if (paddr >= remap_base && paddr < remap_base + remap_top)326307 paddr -= remap_base;327308 return paddr;328309}329310330311331331-/* gnode -> pnode */312312+/* gpa -> pnode */332313static inline unsigned long uv_gpa_to_gnode(unsigned long gpa)333314{334334- return gpa >> uv_hub_info->m_val;315315+ return gpa >> uv_hub_info->n_lshift;335316}336317337318/* gpa -> pnode */···343318 unsigned long n_mask = (1UL << uv_hub_info->n_val) - 1;344319345320 return uv_gpa_to_gnode(gpa) & n_mask;321321+}322322+323323+/* gpa -> node offset*/324324+static inline unsigned long uv_gpa_to_offset(unsigned long gpa)325325+{326326+ return (gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift;346327}347328348329/* pnode, offset --> socket virtual */
···115115116116/* base pnode in this partition */117117static int uv_base_pnode __read_mostly;118118-/* position of pnode (which is nasid>>1): */119119-static int uv_nshift __read_mostly;120120-static unsigned long uv_mmask __read_mostly;121118122119static DEFINE_PER_CPU(struct ptc_stats, ptcstats);123120static DEFINE_PER_CPU(struct bau_control, bau_control);···14321435{14331436 int i;14341437 int cpu;14351435- unsigned long pa;14381438+ unsigned long gpa;14361439 unsigned long m;14371440 unsigned long n;14381441 size_t dsize;···14481451 bau_desc = kmalloc_node(dsize, GFP_KERNEL, node);14491452 BUG_ON(!bau_desc);1450145314511451- pa = uv_gpa(bau_desc); /* need the real nasid*/14521452- n = pa >> uv_nshift;14531453- m = pa & uv_mmask;14541454+ gpa = uv_gpa(bau_desc);14551455+ n = uv_gpa_to_gnode(gpa);14561456+ m = uv_gpa_to_offset(gpa);1454145714551458 /* the 14-bit pnode */14561459 write_mmr_descriptor_base(pnode, (n << UV_DESC_PSHIFT | m));···15221525 bcp->queue_last = pqp + (DEST_Q_SIZE - 1);15231526 }15241527 /*15251525- * need the pnode of where the memory was really allocated15281528+ * need the gnode of where the memory was really allocated15261529 */15271527- pn = uv_gpa(pqp) >> uv_nshift;15301530+ pn = uv_gpa_to_gnode(uv_gpa(pqp));15281531 first = uv_physnodeaddr(pqp);15291532 pn_first = ((unsigned long)pn << UV_PAYLOADQ_PNODE_SHIFT) | first;15301533 last = uv_physnodeaddr(pqp + (DEST_Q_SIZE - 1));···18341837 zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu));18351838 }1836183918371837- uv_nshift = uv_hub_info->m_val;18381838- uv_mmask = (1UL << uv_hub_info->m_val) - 1;18391840 nuvhubs = uv_num_possible_blades();18401841 spin_lock_init(&disable_lock);18411842 congested_cycles = usec_2_cycles(congested_respns_us);