1bb898558SAl Viro /* 2bb898558SAl Viro * This file is subject to the terms and conditions of the GNU General Public 3bb898558SAl Viro * License. See the file "COPYING" in the main directory of this archive 4bb898558SAl Viro * for more details. 5bb898558SAl Viro * 6bb898558SAl Viro * SGI UV architectural definitions 7bb898558SAl Viro * 85f40f7d9SDimitri Sivanich * Copyright (C) 2007-2014 Silicon Graphics, Inc. All rights reserved. 9bb898558SAl Viro */ 10bb898558SAl Viro 1105e4d316SH. Peter Anvin #ifndef _ASM_X86_UV_UV_HUB_H 1205e4d316SH. Peter Anvin #define _ASM_X86_UV_UV_HUB_H 13bb898558SAl Viro 14bc5d9940SJack Steiner #ifdef CONFIG_X86_64 15bb898558SAl Viro #include <linux/numa.h> 16bb898558SAl Viro #include <linux/percpu.h> 17c08b6accSMike Travis #include <linux/timer.h> 188dc579e8SJack Steiner #include <linux/io.h> 19906f3b20SMike Travis #include <linux/topology.h> 20bb898558SAl Viro #include <asm/types.h> 21bb898558SAl Viro #include <asm/percpu.h> 2266666e50SJack Steiner #include <asm/uv/uv_mmrs.h> 2302dd0a06SRobin Holt #include <asm/irq_vectors.h> 2402dd0a06SRobin Holt #include <asm/io_apic.h> 25bb898558SAl Viro 26bb898558SAl Viro 27bb898558SAl Viro /* 28bb898558SAl Viro * Addressing Terminology 29bb898558SAl Viro * 30bb898558SAl Viro * M - The low M bits of a physical address represent the offset 31bb898558SAl Viro * into the blade local memory. RAM memory on a blade is physically 32bb898558SAl Viro * contiguous (although various IO spaces may punch holes in 33bb898558SAl Viro * it).. 34bb898558SAl Viro * 35bb898558SAl Viro * N - Number of bits in the node portion of a socket physical 36bb898558SAl Viro * address. 37bb898558SAl Viro * 38bb898558SAl Viro * NASID - network ID of a router, Mbrick or Cbrick. Nasid values of 39bb898558SAl Viro * routers always have low bit of 1, C/MBricks have low bit 40bb898558SAl Viro * equal to 0. Most addressing macros that target UV hub chips 41bb898558SAl Viro * right shift the NASID by 1 to exclude the always-zero bit. 42bb898558SAl Viro * NASIDs contain up to 15 bits. 43bb898558SAl Viro * 44bb898558SAl Viro * GNODE - NASID right shifted by 1 bit. Most mmrs contain gnodes instead 45bb898558SAl Viro * of nasids. 46bb898558SAl Viro * 47bb898558SAl Viro * PNODE - the low N bits of the GNODE. The PNODE is the most useful variant 48bb898558SAl Viro * of the nasid for socket usage. 49bb898558SAl Viro * 506a469e46SJack Steiner * GPA - (global physical address) a socket physical address converted 516a469e46SJack Steiner * so that it can be used by the GRU as a global address. Socket 526a469e46SJack Steiner * physical addresses 1) need additional NASID (node) bits added 536a469e46SJack Steiner * to the high end of the address, and 2) unaliased if the 546a469e46SJack Steiner * partition does not have a physical address 0. In addition, on 556a469e46SJack Steiner * UV2 rev 1, GPAs need the gnode left shifted to bits 39 or 40. 566a469e46SJack Steiner * 57bb898558SAl Viro * 58bb898558SAl Viro * NumaLink Global Physical Address Format: 59bb898558SAl Viro * +--------------------------------+---------------------+ 60bb898558SAl Viro * |00..000| GNODE | NodeOffset | 61bb898558SAl Viro * +--------------------------------+---------------------+ 62bb898558SAl Viro * |<-------53 - M bits --->|<--------M bits -----> 63bb898558SAl Viro * 64bb898558SAl Viro * M - number of node offset bits (35 .. 40) 65bb898558SAl Viro * 66bb898558SAl Viro * 67bb898558SAl Viro * Memory/UV-HUB Processor Socket Address Format: 68bb898558SAl Viro * +----------------+---------------+---------------------+ 69bb898558SAl Viro * |00..000000000000| PNODE | NodeOffset | 70bb898558SAl Viro * +----------------+---------------+---------------------+ 71bb898558SAl Viro * <--- N bits --->|<--------M bits -----> 72bb898558SAl Viro * 73bb898558SAl Viro * M - number of node offset bits (35 .. 40) 74bb898558SAl Viro * N - number of PNODE bits (0 .. 10) 75bb898558SAl Viro * 76bb898558SAl Viro * Note: M + N cannot currently exceed 44 (x86_64) or 46 (IA64). 77bb898558SAl Viro * The actual values are configuration dependent and are set at 78bb898558SAl Viro * boot time. M & N values are set by the hardware/BIOS at boot. 79bb898558SAl Viro * 80bb898558SAl Viro * 81bb898558SAl Viro * APICID format 82bb898558SAl Viro * NOTE!!!!!! This is the current format of the APICID. However, code 83bb898558SAl Viro * should assume that this will change in the future. Use functions 84bb898558SAl Viro * in this file for all APICID bit manipulations and conversion. 85bb898558SAl Viro * 86bb898558SAl Viro * 1111110000000000 87bb898558SAl Viro * 5432109876543210 882a919596SJack Steiner * pppppppppplc0cch Nehalem-EX (12 bits in hdw reg) 892a919596SJack Steiner * ppppppppplcc0cch Westmere-EX (12 bits in hdw reg) 902a919596SJack Steiner * pppppppppppcccch SandyBridge (15 bits in hdw reg) 91bb898558SAl Viro * sssssssssss 92bb898558SAl Viro * 93bb898558SAl Viro * p = pnode bits 94bb898558SAl Viro * l = socket number on board 95bb898558SAl Viro * c = core 96bb898558SAl Viro * h = hyperthread 97bb898558SAl Viro * s = bits that are in the SOCKET_ID CSR 98bb898558SAl Viro * 992a919596SJack Steiner * Note: Processor may support fewer bits in the APICID register. The ACPI 100bb898558SAl Viro * tables hold all 16 bits. Software needs to be aware of this. 101bb898558SAl Viro * 102bb898558SAl Viro * Unless otherwise specified, all references to APICID refer to 103bb898558SAl Viro * the FULL value contained in ACPI tables, not the subset in the 104bb898558SAl Viro * processor APICID register. 105bb898558SAl Viro */ 106bb898558SAl Viro 107bb898558SAl Viro 108bb898558SAl Viro /* 109bb898558SAl Viro * Maximum number of bricks in all partitions and in all coherency domains. 110bb898558SAl Viro * This is the total number of bricks accessible in the numalink fabric. It 111bb898558SAl Viro * includes all C & M bricks. Routers are NOT included. 112bb898558SAl Viro * 113bb898558SAl Viro * This value is also the value of the maximum number of non-router NASIDs 114bb898558SAl Viro * in the numalink fabric. 115bb898558SAl Viro * 116bb898558SAl Viro * NOTE: a brick may contain 1 or 2 OS nodes. Don't get these confused. 117bb898558SAl Viro */ 118bb898558SAl Viro #define UV_MAX_NUMALINK_BLADES 16384 119bb898558SAl Viro 120bb898558SAl Viro /* 121bb898558SAl Viro * Maximum number of C/Mbricks within a software SSI (hardware may support 122bb898558SAl Viro * more). 123bb898558SAl Viro */ 124bb898558SAl Viro #define UV_MAX_SSI_BLADES 256 125bb898558SAl Viro 126bb898558SAl Viro /* 127bb898558SAl Viro * The largest possible NASID of a C or M brick (+ 2) 128bb898558SAl Viro */ 1291d21e6e3SRobin Holt #define UV_MAX_NASID_VALUE (UV_MAX_NUMALINK_BLADES * 2) 130bb898558SAl Viro 131d38bb135SMike Travis /* System Controller Interface Reg info */ 1327f1baa06SMike Travis struct uv_scir_s { 1337f1baa06SMike Travis struct timer_list timer; 1347f1baa06SMike Travis unsigned long offset; 1357f1baa06SMike Travis unsigned long last; 1367f1baa06SMike Travis unsigned long idle_on; 1377f1baa06SMike Travis unsigned long idle_off; 1387f1baa06SMike Travis unsigned char state; 1397f1baa06SMike Travis unsigned char enabled; 1407f1baa06SMike Travis }; 1417f1baa06SMike Travis 142bb898558SAl Viro /* 143bb898558SAl Viro * The following defines attributes of the HUB chip. These attributes are 1440045ddd2SMike Travis * frequently referenced and are kept in a common per hub struct. 1450045ddd2SMike Travis * After setup, the struct is read only, so it should be readily 1460045ddd2SMike Travis * available in the L3 cache on the cpu socket for the node. 147bb898558SAl Viro */ 148bb898558SAl Viro struct uv_hub_info_s { 149bb898558SAl Viro unsigned long global_mmr_base; 1501de329c1SMike Travis unsigned long global_mmr_shift; 151bb898558SAl Viro unsigned long gpa_mask; 1526e27b91cSMike Travis unsigned short *socket_to_node; 1536e27b91cSMike Travis unsigned short *socket_to_pnode; 1546e27b91cSMike Travis unsigned short *pnode_to_socket; 1551de329c1SMike Travis unsigned short min_socket; 1561de329c1SMike Travis unsigned short min_pnode; 1572a919596SJack Steiner unsigned char hub_revision; 1582a919596SJack Steiner unsigned char apic_pnode_shift; 1591de329c1SMike Travis unsigned char gpa_shift; 1606a469e46SJack Steiner unsigned char m_shift; 1616a469e46SJack Steiner unsigned char n_lshift; 1621de329c1SMike Travis unsigned int gnode_extra; 163bb898558SAl Viro unsigned long gnode_upper; 164bb898558SAl Viro unsigned long lowmem_remap_top; 165bb898558SAl Viro unsigned long lowmem_remap_base; 1661de329c1SMike Travis unsigned long global_gru_base; 1671de329c1SMike Travis unsigned long global_gru_shift; 168bb898558SAl Viro unsigned short pnode; 169bb898558SAl Viro unsigned short pnode_mask; 170bb898558SAl Viro unsigned short coherency_domain_number; 171bb898558SAl Viro unsigned short numa_blade_id; 172bb898558SAl Viro unsigned char m_val; 173bb898558SAl Viro unsigned char n_val; 174906f3b20SMike Travis unsigned short nr_possible_cpus; 175906f3b20SMike Travis unsigned short nr_online_cpus; 176906f3b20SMike Travis short memory_nid; 177bb898558SAl Viro }; 1787f1baa06SMike Travis 1790045ddd2SMike Travis /* CPU specific info with a pointer to the hub common info struct */ 1800045ddd2SMike Travis struct uv_cpu_info_s { 1810045ddd2SMike Travis void *p_uv_hub_info; 1820045ddd2SMike Travis unsigned char blade_cpu_id; 1830045ddd2SMike Travis struct uv_scir_s scir; 1840045ddd2SMike Travis }; 1850045ddd2SMike Travis DECLARE_PER_CPU(struct uv_cpu_info_s, __uv_cpu_info); 1860045ddd2SMike Travis 1870045ddd2SMike Travis #define uv_cpu_info this_cpu_ptr(&__uv_cpu_info) 1880045ddd2SMike Travis #define uv_cpu_info_per(cpu) (&per_cpu(__uv_cpu_info, cpu)) 1890045ddd2SMike Travis 190d38bb135SMike Travis #define uv_scir_info (&uv_cpu_info->scir) 191d38bb135SMike Travis #define uv_cpu_scir_info(cpu) (&uv_cpu_info_per(cpu)->scir) 192d38bb135SMike Travis 1933edcf2ffSMike Travis /* Node specific hub common info struct */ 1943edcf2ffSMike Travis extern void **__uv_hub_info_list; 1953edcf2ffSMike Travis static inline struct uv_hub_info_s *uv_hub_info_list(int node) 1963edcf2ffSMike Travis { 1973edcf2ffSMike Travis return (struct uv_hub_info_s *)__uv_hub_info_list[node]; 1983edcf2ffSMike Travis } 1993edcf2ffSMike Travis 2003edcf2ffSMike Travis static inline struct uv_hub_info_s *_uv_hub_info(void) 2013edcf2ffSMike Travis { 2023edcf2ffSMike Travis return (struct uv_hub_info_s *)uv_cpu_info->p_uv_hub_info; 2033edcf2ffSMike Travis } 2043edcf2ffSMike Travis #define uv_hub_info _uv_hub_info() 2053edcf2ffSMike Travis 2063edcf2ffSMike Travis static inline struct uv_hub_info_s *uv_cpu_hub_info(int cpu) 2073edcf2ffSMike Travis { 2083edcf2ffSMike Travis return (struct uv_hub_info_s *)uv_cpu_info_per(cpu)->p_uv_hub_info; 2093edcf2ffSMike Travis } 2103edcf2ffSMike Travis 2113edcf2ffSMike Travis #define UV_HUB_INFO_VERSION 0x7150 2123edcf2ffSMike Travis extern int uv_hub_info_version(void); 2133edcf2ffSMike Travis static inline int uv_hub_info_check(int version) 2143edcf2ffSMike Travis { 2153edcf2ffSMike Travis if (uv_hub_info_version() == version) 2163edcf2ffSMike Travis return 0; 2173edcf2ffSMike Travis 2183edcf2ffSMike Travis pr_crit("UV: uv_hub_info version(%x) mismatch, expecting(%x)\n", 2193edcf2ffSMike Travis uv_hub_info_version(), version); 2203edcf2ffSMike Travis 2213edcf2ffSMike Travis BUG(); /* Catastrophic - cannot continue on unknown UV system */ 2223edcf2ffSMike Travis } 2233edcf2ffSMike Travis #define _uv_hub_info_check() uv_hub_info_check(UV_HUB_INFO_VERSION) 2243edcf2ffSMike Travis 2252a919596SJack Steiner /* 2260045ddd2SMike Travis * HUB revision ranges for each UV HUB architecture. 2272a919596SJack Steiner * This is a software convention - NOT the hardware revision numbers in 2282a919596SJack Steiner * the hub chip. 2292a919596SJack Steiner */ 2302a919596SJack Steiner #define UV1_HUB_REVISION_BASE 1 2312a919596SJack Steiner #define UV2_HUB_REVISION_BASE 3 2326edbd471SMike Travis #define UV3_HUB_REVISION_BASE 5 233eb1e3461SMike Travis #define UV4_HUB_REVISION_BASE 7 2342a919596SJack Steiner 235e0ee1c97SMike Travis #ifdef UV1_HUB_IS_SUPPORTED 2362a919596SJack Steiner static inline int is_uv1_hub(void) 2372a919596SJack Steiner { 2382a919596SJack Steiner return uv_hub_info->hub_revision < UV2_HUB_REVISION_BASE; 2392a919596SJack Steiner } 240e0ee1c97SMike Travis #else 241e0ee1c97SMike Travis static inline int is_uv1_hub(void) 242e0ee1c97SMike Travis { 243e0ee1c97SMike Travis return 0; 244e0ee1c97SMike Travis } 245e0ee1c97SMike Travis #endif 2462a919596SJack Steiner 247e0ee1c97SMike Travis #ifdef UV2_HUB_IS_SUPPORTED 2482a919596SJack Steiner static inline int is_uv2_hub(void) 2492a919596SJack Steiner { 2506edbd471SMike Travis return ((uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE) && 2516edbd471SMike Travis (uv_hub_info->hub_revision < UV3_HUB_REVISION_BASE)); 2526edbd471SMike Travis } 253e0ee1c97SMike Travis #else 254e0ee1c97SMike Travis static inline int is_uv2_hub(void) 255e0ee1c97SMike Travis { 256e0ee1c97SMike Travis return 0; 257e0ee1c97SMike Travis } 258e0ee1c97SMike Travis #endif 2596edbd471SMike Travis 260e0ee1c97SMike Travis #ifdef UV3_HUB_IS_SUPPORTED 2616edbd471SMike Travis static inline int is_uv3_hub(void) 2626edbd471SMike Travis { 263eb1e3461SMike Travis return ((uv_hub_info->hub_revision >= UV3_HUB_REVISION_BASE) && 264eb1e3461SMike Travis (uv_hub_info->hub_revision < UV4_HUB_REVISION_BASE)); 2656edbd471SMike Travis } 266e0ee1c97SMike Travis #else 267e0ee1c97SMike Travis static inline int is_uv3_hub(void) 268e0ee1c97SMike Travis { 269e0ee1c97SMike Travis return 0; 270e0ee1c97SMike Travis } 271e0ee1c97SMike Travis #endif 2726edbd471SMike Travis 273eb1e3461SMike Travis #ifdef UV4_HUB_IS_SUPPORTED 274eb1e3461SMike Travis static inline int is_uv4_hub(void) 275eb1e3461SMike Travis { 276eb1e3461SMike Travis return uv_hub_info->hub_revision >= UV4_HUB_REVISION_BASE; 277eb1e3461SMike Travis } 278eb1e3461SMike Travis #else 279eb1e3461SMike Travis static inline int is_uv4_hub(void) 280eb1e3461SMike Travis { 281eb1e3461SMike Travis return 0; 282eb1e3461SMike Travis } 283eb1e3461SMike Travis #endif 284eb1e3461SMike Travis 2856edbd471SMike Travis static inline int is_uvx_hub(void) 2866edbd471SMike Travis { 287e0ee1c97SMike Travis if (uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE) 288e0ee1c97SMike Travis return uv_hub_info->hub_revision; 289e0ee1c97SMike Travis 290e0ee1c97SMike Travis return 0; 291e0ee1c97SMike Travis } 292e0ee1c97SMike Travis 293e0ee1c97SMike Travis static inline int is_uv_hub(void) 294e0ee1c97SMike Travis { 295e0ee1c97SMike Travis #ifdef UV1_HUB_IS_SUPPORTED 296e0ee1c97SMike Travis return uv_hub_info->hub_revision; 297e0ee1c97SMike Travis #endif 298e0ee1c97SMike Travis return is_uvx_hub(); 2992a919596SJack Steiner } 3002a919596SJack Steiner 301c8f730b1SRuss Anderson union uvh_apicid { 302c8f730b1SRuss Anderson unsigned long v; 303c8f730b1SRuss Anderson struct uvh_apicid_s { 304c8f730b1SRuss Anderson unsigned long local_apic_mask : 24; 305c8f730b1SRuss Anderson unsigned long local_apic_shift : 5; 306c8f730b1SRuss Anderson unsigned long unused1 : 3; 307c8f730b1SRuss Anderson unsigned long pnode_mask : 24; 308c8f730b1SRuss Anderson unsigned long pnode_shift : 5; 309c8f730b1SRuss Anderson unsigned long unused2 : 3; 310c8f730b1SRuss Anderson } s; 311c8f730b1SRuss Anderson }; 312c8f730b1SRuss Anderson 313bb898558SAl Viro /* 314bb898558SAl Viro * Local & Global MMR space macros. 315bb898558SAl Viro * Note: macros are intended to be used ONLY by inline functions 316bb898558SAl Viro * in this file - not by other kernel code. 317bb898558SAl Viro * n - NASID (full 15-bit global nasid) 318bb898558SAl Viro * g - GNODE (full 15-bit global nasid, right shifted 1) 319bb898558SAl Viro * p - PNODE (local part of nsids, right shifted 1) 320bb898558SAl Viro */ 321bb898558SAl Viro #define UV_NASID_TO_PNODE(n) (((n) >> 1) & uv_hub_info->pnode_mask) 322c4ed3f04SJack Steiner #define UV_PNODE_TO_GNODE(p) ((p) |uv_hub_info->gnode_extra) 323c4ed3f04SJack Steiner #define UV_PNODE_TO_NASID(p) (UV_PNODE_TO_GNODE(p) << 1) 324bb898558SAl Viro 3252a919596SJack Steiner #define UV1_LOCAL_MMR_BASE 0xf4000000UL 3262a919596SJack Steiner #define UV1_GLOBAL_MMR32_BASE 0xf8000000UL 3272a919596SJack Steiner #define UV1_LOCAL_MMR_SIZE (64UL * 1024 * 1024) 3282a919596SJack Steiner #define UV1_GLOBAL_MMR32_SIZE (64UL * 1024 * 1024) 3292a919596SJack Steiner 3302a919596SJack Steiner #define UV2_LOCAL_MMR_BASE 0xfa000000UL 3312a919596SJack Steiner #define UV2_GLOBAL_MMR32_BASE 0xfc000000UL 3322a919596SJack Steiner #define UV2_LOCAL_MMR_SIZE (32UL * 1024 * 1024) 3332a919596SJack Steiner #define UV2_GLOBAL_MMR32_SIZE (32UL * 1024 * 1024) 3342a919596SJack Steiner 3356edbd471SMike Travis #define UV3_LOCAL_MMR_BASE 0xfa000000UL 3366edbd471SMike Travis #define UV3_GLOBAL_MMR32_BASE 0xfc000000UL 3376edbd471SMike Travis #define UV3_LOCAL_MMR_SIZE (32UL * 1024 * 1024) 3386edbd471SMike Travis #define UV3_GLOBAL_MMR32_SIZE (32UL * 1024 * 1024) 3396edbd471SMike Travis 340eb1e3461SMike Travis #define UV4_LOCAL_MMR_BASE 0xfa000000UL 341eb1e3461SMike Travis #define UV4_GLOBAL_MMR32_BASE 0xfc000000UL 342eb1e3461SMike Travis #define UV4_LOCAL_MMR_SIZE (32UL * 1024 * 1024) 343eb1e3461SMike Travis #define UV4_GLOBAL_MMR32_SIZE (16UL * 1024 * 1024) 344eb1e3461SMike Travis 345eb1e3461SMike Travis #define UV_LOCAL_MMR_BASE ( \ 346eb1e3461SMike Travis is_uv1_hub() ? UV1_LOCAL_MMR_BASE : \ 347eb1e3461SMike Travis is_uv2_hub() ? UV2_LOCAL_MMR_BASE : \ 348eb1e3461SMike Travis is_uv3_hub() ? UV3_LOCAL_MMR_BASE : \ 349eb1e3461SMike Travis /*is_uv4_hub*/ UV4_LOCAL_MMR_BASE) 350eb1e3461SMike Travis 351eb1e3461SMike Travis #define UV_GLOBAL_MMR32_BASE ( \ 352eb1e3461SMike Travis is_uv1_hub() ? UV1_GLOBAL_MMR32_BASE : \ 353eb1e3461SMike Travis is_uv2_hub() ? UV2_GLOBAL_MMR32_BASE : \ 354eb1e3461SMike Travis is_uv3_hub() ? UV3_GLOBAL_MMR32_BASE : \ 355eb1e3461SMike Travis /*is_uv4_hub*/ UV4_GLOBAL_MMR32_BASE) 356eb1e3461SMike Travis 357eb1e3461SMike Travis #define UV_LOCAL_MMR_SIZE ( \ 358eb1e3461SMike Travis is_uv1_hub() ? UV1_LOCAL_MMR_SIZE : \ 359eb1e3461SMike Travis is_uv2_hub() ? UV2_LOCAL_MMR_SIZE : \ 360eb1e3461SMike Travis is_uv3_hub() ? UV3_LOCAL_MMR_SIZE : \ 361eb1e3461SMike Travis /*is_uv4_hub*/ UV4_LOCAL_MMR_SIZE) 362eb1e3461SMike Travis 363eb1e3461SMike Travis #define UV_GLOBAL_MMR32_SIZE ( \ 364eb1e3461SMike Travis is_uv1_hub() ? UV1_GLOBAL_MMR32_SIZE : \ 365eb1e3461SMike Travis is_uv2_hub() ? UV2_GLOBAL_MMR32_SIZE : \ 366eb1e3461SMike Travis is_uv3_hub() ? UV3_GLOBAL_MMR32_SIZE : \ 367eb1e3461SMike Travis /*is_uv4_hub*/ UV4_GLOBAL_MMR32_SIZE) 368eb1e3461SMike Travis 369bb898558SAl Viro #define UV_GLOBAL_MMR64_BASE (uv_hub_info->global_mmr_base) 370bb898558SAl Viro 37156abcf24SJack Steiner #define UV_GLOBAL_GRU_MMR_BASE 0x4000000 37256abcf24SJack Steiner 373bb898558SAl Viro #define UV_GLOBAL_MMR32_PNODE_SHIFT 15 3741de329c1SMike Travis #define _UV_GLOBAL_MMR64_PNODE_SHIFT 26 3751de329c1SMike Travis #define UV_GLOBAL_MMR64_PNODE_SHIFT (uv_hub_info->global_mmr_shift) 376bb898558SAl Viro 377bb898558SAl Viro #define UV_GLOBAL_MMR32_PNODE_BITS(p) ((p) << (UV_GLOBAL_MMR32_PNODE_SHIFT)) 378bb898558SAl Viro 379bb898558SAl Viro #define UV_GLOBAL_MMR64_PNODE_BITS(p) \ 38067e83f30SJack Steiner (((unsigned long)(p)) << UV_GLOBAL_MMR64_PNODE_SHIFT) 381bb898558SAl Viro 382c8f730b1SRuss Anderson #define UVH_APICID 0x002D0E00L 383bb898558SAl Viro #define UV_APIC_PNODE_SHIFT 6 384bb898558SAl Viro 3858191c9f6SDimitri Sivanich #define UV_APICID_HIBIT_MASK 0xffff0000 3868191c9f6SDimitri Sivanich 3877f1baa06SMike Travis /* Local Bus from cpu's perspective */ 3887f1baa06SMike Travis #define LOCAL_BUS_BASE 0x1c00000 3897f1baa06SMike Travis #define LOCAL_BUS_SIZE (4 * 1024 * 1024) 3907f1baa06SMike Travis 3917f1baa06SMike Travis /* 3927f1baa06SMike Travis * System Controller Interface Reg 3937f1baa06SMike Travis * 3947f1baa06SMike Travis * Note there are NO leds on a UV system. This register is only 3957f1baa06SMike Travis * used by the system controller to monitor system-wide operation. 3967f1baa06SMike Travis * There are 64 regs per node. With Nahelem cpus (2 cores per node, 3977f1baa06SMike Travis * 8 cpus per core, 2 threads per cpu) there are 32 cpu threads on 3987f1baa06SMike Travis * a node. 3997f1baa06SMike Travis * 4007f1baa06SMike Travis * The window is located at top of ACPI MMR space 4017f1baa06SMike Travis */ 4027f1baa06SMike Travis #define SCIR_WINDOW_COUNT 64 4037f1baa06SMike Travis #define SCIR_LOCAL_MMR_BASE (LOCAL_BUS_BASE + \ 4047f1baa06SMike Travis LOCAL_BUS_SIZE - \ 4057f1baa06SMike Travis SCIR_WINDOW_COUNT) 4067f1baa06SMike Travis 4077f1baa06SMike Travis #define SCIR_CPU_HEARTBEAT 0x01 /* timer interrupt */ 4087f1baa06SMike Travis #define SCIR_CPU_ACTIVITY 0x02 /* not idle */ 4097f1baa06SMike Travis #define SCIR_CPU_HB_INTERVAL (HZ) /* once per second */ 4107f1baa06SMike Travis 4118661984fSDimitri Sivanich /* Loop through all installed blades */ 4128661984fSDimitri Sivanich #define for_each_possible_blade(bid) \ 4138661984fSDimitri Sivanich for ((bid) = 0; (bid) < uv_num_possible_blades(); (bid)++) 4148661984fSDimitri Sivanich 415bb898558SAl Viro /* 416bb898558SAl Viro * Macros for converting between kernel virtual addresses, socket local physical 417bb898558SAl Viro * addresses, and UV global physical addresses. 418bb898558SAl Viro * Note: use the standard __pa() & __va() macros for converting 419bb898558SAl Viro * between socket virtual and socket physical addresses. 420bb898558SAl Viro */ 421bb898558SAl Viro 422bb898558SAl Viro /* socket phys RAM --> UV global physical address */ 423bb898558SAl Viro static inline unsigned long uv_soc_phys_ram_to_gpa(unsigned long paddr) 424bb898558SAl Viro { 425bb898558SAl Viro if (paddr < uv_hub_info->lowmem_remap_top) 426189f67c4SJack Steiner paddr |= uv_hub_info->lowmem_remap_base; 4276a469e46SJack Steiner paddr |= uv_hub_info->gnode_upper; 4286a469e46SJack Steiner paddr = ((paddr << uv_hub_info->m_shift) >> uv_hub_info->m_shift) | 4296a469e46SJack Steiner ((paddr >> uv_hub_info->m_val) << uv_hub_info->n_lshift); 4306a469e46SJack Steiner return paddr; 431bb898558SAl Viro } 432bb898558SAl Viro 433bb898558SAl Viro 434bb898558SAl Viro /* socket virtual --> UV global physical address */ 435bb898558SAl Viro static inline unsigned long uv_gpa(void *v) 436bb898558SAl Viro { 437189f67c4SJack Steiner return uv_soc_phys_ram_to_gpa(__pa(v)); 438bb898558SAl Viro } 439bb898558SAl Viro 440fae419f2SRobin Holt /* Top two bits indicate the requested address is in MMR space. */ 441fae419f2SRobin Holt static inline int 442fae419f2SRobin Holt uv_gpa_in_mmr_space(unsigned long gpa) 443fae419f2SRobin Holt { 444fae419f2SRobin Holt return (gpa >> 62) == 0x3UL; 445fae419f2SRobin Holt } 446fae419f2SRobin Holt 447729d69e6SRobin Holt /* UV global physical address --> socket phys RAM */ 448729d69e6SRobin Holt static inline unsigned long uv_gpa_to_soc_phys_ram(unsigned long gpa) 449729d69e6SRobin Holt { 4505a51467bSRuss Anderson unsigned long paddr; 451729d69e6SRobin Holt unsigned long remap_base = uv_hub_info->lowmem_remap_base; 452729d69e6SRobin Holt unsigned long remap_top = uv_hub_info->lowmem_remap_top; 453729d69e6SRobin Holt 4546a469e46SJack Steiner gpa = ((gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift) | 4556a469e46SJack Steiner ((gpa >> uv_hub_info->n_lshift) << uv_hub_info->m_val); 4565a51467bSRuss Anderson paddr = gpa & uv_hub_info->gpa_mask; 457729d69e6SRobin Holt if (paddr >= remap_base && paddr < remap_base + remap_top) 458729d69e6SRobin Holt paddr -= remap_base; 459729d69e6SRobin Holt return paddr; 460729d69e6SRobin Holt } 461729d69e6SRobin Holt 462729d69e6SRobin Holt 463906f3b20SMike Travis /* gpa -> gnode */ 4641d21e6e3SRobin Holt static inline unsigned long uv_gpa_to_gnode(unsigned long gpa) 4651d21e6e3SRobin Holt { 4666a469e46SJack Steiner return gpa >> uv_hub_info->n_lshift; 4671d21e6e3SRobin Holt } 4681d21e6e3SRobin Holt 4691d21e6e3SRobin Holt /* gpa -> pnode */ 4701d21e6e3SRobin Holt static inline int uv_gpa_to_pnode(unsigned long gpa) 4711d21e6e3SRobin Holt { 472906f3b20SMike Travis return uv_gpa_to_gnode(gpa) & uv_hub_info->pnode_mask; 4731d21e6e3SRobin Holt } 4741d21e6e3SRobin Holt 4756a469e46SJack Steiner /* gpa -> node offset */ 4766a469e46SJack Steiner static inline unsigned long uv_gpa_to_offset(unsigned long gpa) 4776a469e46SJack Steiner { 4786a469e46SJack Steiner return (gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift; 4796a469e46SJack Steiner } 4806a469e46SJack Steiner 481bb898558SAl Viro /* pnode, offset --> socket virtual */ 482bb898558SAl Viro static inline void *uv_pnode_offset_to_vaddr(int pnode, unsigned long offset) 483bb898558SAl Viro { 484bb898558SAl Viro return __va(((unsigned long)pnode << uv_hub_info->m_val) | offset); 485bb898558SAl Viro } 486bb898558SAl Viro 4876e27b91cSMike Travis /* Convert socket to node */ 4886e27b91cSMike Travis static inline int uv_socket_to_node(int socket) 4896e27b91cSMike Travis { 4906e27b91cSMike Travis unsigned short *s2nid = uv_hub_info->socket_to_node; 4916e27b91cSMike Travis 4926e27b91cSMike Travis return s2nid ? s2nid[socket - uv_hub_info->min_socket] : socket; 4936e27b91cSMike Travis } 4946e27b91cSMike Travis 4956e27b91cSMike Travis /* Extract/Convert a PNODE from an APICID (full apicid, not processor subset) */ 496bb898558SAl Viro static inline int uv_apicid_to_pnode(int apicid) 497bb898558SAl Viro { 4986e27b91cSMike Travis int pnode = apicid >> uv_hub_info->apic_pnode_shift; 4996e27b91cSMike Travis unsigned short *s2pn = uv_hub_info->socket_to_pnode; 5006e27b91cSMike Travis 5016e27b91cSMike Travis return s2pn ? s2pn[pnode - uv_hub_info->min_socket] : pnode; 502bb898558SAl Viro } 503bb898558SAl Viro 504906f3b20SMike Travis /* Convert an apicid to the socket number on the blade */ 5052a919596SJack Steiner static inline int uv_apicid_to_socket(int apicid) 5062a919596SJack Steiner { 5072a919596SJack Steiner if (is_uv1_hub()) 5082a919596SJack Steiner return (apicid >> (uv_hub_info->apic_pnode_shift - 1)) & 1; 5092a919596SJack Steiner else 5102a919596SJack Steiner return 0; 5112a919596SJack Steiner } 5122a919596SJack Steiner 5132a919596SJack Steiner /* 514bb898558SAl Viro * Access global MMRs using the low memory MMR32 space. This region supports 515bb898558SAl Viro * faster MMR access but not all MMRs are accessible in this space. 516bb898558SAl Viro */ 51739d30770SMike Travis static inline unsigned long *uv_global_mmr32_address(int pnode, unsigned long offset) 518bb898558SAl Viro { 519bb898558SAl Viro return __va(UV_GLOBAL_MMR32_BASE | 520bb898558SAl Viro UV_GLOBAL_MMR32_PNODE_BITS(pnode) | offset); 521bb898558SAl Viro } 522bb898558SAl Viro 52339d30770SMike Travis static inline void uv_write_global_mmr32(int pnode, unsigned long offset, unsigned long val) 524bb898558SAl Viro { 5258dc579e8SJack Steiner writeq(val, uv_global_mmr32_address(pnode, offset)); 526bb898558SAl Viro } 527bb898558SAl Viro 52839d30770SMike Travis static inline unsigned long uv_read_global_mmr32(int pnode, unsigned long offset) 529bb898558SAl Viro { 5308dc579e8SJack Steiner return readq(uv_global_mmr32_address(pnode, offset)); 531bb898558SAl Viro } 532bb898558SAl Viro 533bb898558SAl Viro /* 534bb898558SAl Viro * Access Global MMR space using the MMR space located at the top of physical 535bb898558SAl Viro * memory. 536bb898558SAl Viro */ 537a289cc7cSRandy Dunlap static inline volatile void __iomem *uv_global_mmr64_address(int pnode, unsigned long offset) 538bb898558SAl Viro { 539bb898558SAl Viro return __va(UV_GLOBAL_MMR64_BASE | 540bb898558SAl Viro UV_GLOBAL_MMR64_PNODE_BITS(pnode) | offset); 541bb898558SAl Viro } 542bb898558SAl Viro 54339d30770SMike Travis static inline void uv_write_global_mmr64(int pnode, unsigned long offset, unsigned long val) 544bb898558SAl Viro { 5458dc579e8SJack Steiner writeq(val, uv_global_mmr64_address(pnode, offset)); 546bb898558SAl Viro } 547bb898558SAl Viro 54839d30770SMike Travis static inline unsigned long uv_read_global_mmr64(int pnode, unsigned long offset) 549bb898558SAl Viro { 5508dc579e8SJack Steiner return readq(uv_global_mmr64_address(pnode, offset)); 551bb898558SAl Viro } 552bb898558SAl Viro 553bb898558SAl Viro /* 55456abcf24SJack Steiner * Global MMR space addresses when referenced by the GRU. (GRU does 55556abcf24SJack Steiner * NOT use socket addressing). 55656abcf24SJack Steiner */ 55756abcf24SJack Steiner static inline unsigned long uv_global_gru_mmr_address(int pnode, unsigned long offset) 55856abcf24SJack Steiner { 559e1e0138dSJack Steiner return UV_GLOBAL_GRU_MMR_BASE | offset | 560e1e0138dSJack Steiner ((unsigned long)pnode << uv_hub_info->m_val); 56156abcf24SJack Steiner } 56256abcf24SJack Steiner 56339d30770SMike Travis static inline void uv_write_global_mmr8(int pnode, unsigned long offset, unsigned char val) 56439d30770SMike Travis { 56539d30770SMike Travis writeb(val, uv_global_mmr64_address(pnode, offset)); 56639d30770SMike Travis } 56739d30770SMike Travis 56839d30770SMike Travis static inline unsigned char uv_read_global_mmr8(int pnode, unsigned long offset) 56939d30770SMike Travis { 57039d30770SMike Travis return readb(uv_global_mmr64_address(pnode, offset)); 57139d30770SMike Travis } 57239d30770SMike Travis 57356abcf24SJack Steiner /* 574bb898558SAl Viro * Access hub local MMRs. Faster than using global space but only local MMRs 575bb898558SAl Viro * are accessible. 576bb898558SAl Viro */ 577bb898558SAl Viro static inline unsigned long *uv_local_mmr_address(unsigned long offset) 578bb898558SAl Viro { 579bb898558SAl Viro return __va(UV_LOCAL_MMR_BASE | offset); 580bb898558SAl Viro } 581bb898558SAl Viro 582bb898558SAl Viro static inline unsigned long uv_read_local_mmr(unsigned long offset) 583bb898558SAl Viro { 5848dc579e8SJack Steiner return readq(uv_local_mmr_address(offset)); 585bb898558SAl Viro } 586bb898558SAl Viro 587bb898558SAl Viro static inline void uv_write_local_mmr(unsigned long offset, unsigned long val) 588bb898558SAl Viro { 5898dc579e8SJack Steiner writeq(val, uv_local_mmr_address(offset)); 590bb898558SAl Viro } 591bb898558SAl Viro 5927f1baa06SMike Travis static inline unsigned char uv_read_local_mmr8(unsigned long offset) 5937f1baa06SMike Travis { 5948dc579e8SJack Steiner return readb(uv_local_mmr_address(offset)); 5957f1baa06SMike Travis } 5967f1baa06SMike Travis 5977f1baa06SMike Travis static inline void uv_write_local_mmr8(unsigned long offset, unsigned char val) 5987f1baa06SMike Travis { 5998dc579e8SJack Steiner writeb(val, uv_local_mmr_address(offset)); 6007f1baa06SMike Travis } 6017f1baa06SMike Travis 602bb898558SAl Viro /* Blade-local cpu number of current cpu. Numbered 0 .. <# cpus on the blade> */ 603bb898558SAl Viro static inline int uv_blade_processor_id(void) 604bb898558SAl Viro { 6055627a825SMike Travis return uv_cpu_info->blade_cpu_id; 606bb898558SAl Viro } 607bb898558SAl Viro 6085627a825SMike Travis /* Blade-local cpu number of cpu N. Numbered 0 .. <# cpus on the blade> */ 6095627a825SMike Travis static inline int uv_cpu_blade_processor_id(int cpu) 6105627a825SMike Travis { 6115627a825SMike Travis return uv_cpu_info_per(cpu)->blade_cpu_id; 6125627a825SMike Travis } 6135627a825SMike Travis #define _uv_cpu_blade_processor_id 1 /* indicate function available */ 6145627a825SMike Travis 615906f3b20SMike Travis /* Blade number to Node number (UV1..UV4 is 1:1) */ 616906f3b20SMike Travis static inline int uv_blade_to_node(int blade) 617906f3b20SMike Travis { 618906f3b20SMike Travis return blade; 619906f3b20SMike Travis } 620906f3b20SMike Travis 621bb898558SAl Viro /* Blade number of current cpu. Numnbered 0 .. <#blades -1> */ 622bb898558SAl Viro static inline int uv_numa_blade_id(void) 623bb898558SAl Viro { 624bb898558SAl Viro return uv_hub_info->numa_blade_id; 625bb898558SAl Viro } 626bb898558SAl Viro 627906f3b20SMike Travis /* 628906f3b20SMike Travis * Convert linux node number to the UV blade number. 629906f3b20SMike Travis * .. Currently for UV1 thru UV4 the node and the blade are identical. 630906f3b20SMike Travis * .. If this changes then you MUST check references to this function! 631906f3b20SMike Travis */ 632906f3b20SMike Travis static inline int uv_node_to_blade_id(int nid) 633906f3b20SMike Travis { 634906f3b20SMike Travis return nid; 635906f3b20SMike Travis } 636906f3b20SMike Travis 637bb898558SAl Viro /* Convert a cpu number to the the UV blade number */ 638bb898558SAl Viro static inline int uv_cpu_to_blade_id(int cpu) 639bb898558SAl Viro { 640906f3b20SMike Travis return uv_node_to_blade_id(cpu_to_node(cpu)); 641bb898558SAl Viro } 642bb898558SAl Viro 643bb898558SAl Viro /* Convert a blade id to the PNODE of the blade */ 644bb898558SAl Viro static inline int uv_blade_to_pnode(int bid) 645bb898558SAl Viro { 646906f3b20SMike Travis return uv_hub_info_list(uv_blade_to_node(bid))->pnode; 647bb898558SAl Viro } 648bb898558SAl Viro 6496c7184b7SJack Steiner /* Nid of memory node on blade. -1 if no blade-local memory */ 6506c7184b7SJack Steiner static inline int uv_blade_to_memory_nid(int bid) 6516c7184b7SJack Steiner { 652906f3b20SMike Travis return uv_hub_info_list(uv_blade_to_node(bid))->memory_nid; 6536c7184b7SJack Steiner } 6546c7184b7SJack Steiner 655bb898558SAl Viro /* Determine the number of possible cpus on a blade */ 656bb898558SAl Viro static inline int uv_blade_nr_possible_cpus(int bid) 657bb898558SAl Viro { 658906f3b20SMike Travis return uv_hub_info_list(uv_blade_to_node(bid))->nr_possible_cpus; 659bb898558SAl Viro } 660bb898558SAl Viro 661bb898558SAl Viro /* Determine the number of online cpus on a blade */ 662bb898558SAl Viro static inline int uv_blade_nr_online_cpus(int bid) 663bb898558SAl Viro { 664906f3b20SMike Travis return uv_hub_info_list(uv_blade_to_node(bid))->nr_online_cpus; 665bb898558SAl Viro } 666bb898558SAl Viro 667bb898558SAl Viro /* Convert a cpu id to the PNODE of the blade containing the cpu */ 668bb898558SAl Viro static inline int uv_cpu_to_pnode(int cpu) 669bb898558SAl Viro { 670906f3b20SMike Travis return uv_cpu_hub_info(cpu)->pnode; 671bb898558SAl Viro } 672bb898558SAl Viro 673bb898558SAl Viro /* Convert a linux node number to the PNODE of the blade */ 674bb898558SAl Viro static inline int uv_node_to_pnode(int nid) 675bb898558SAl Viro { 676906f3b20SMike Travis return uv_hub_info_list(nid)->pnode; 677bb898558SAl Viro } 678bb898558SAl Viro 679bb898558SAl Viro /* Maximum possible number of blades */ 680906f3b20SMike Travis extern short uv_possible_blades; 681bb898558SAl Viro static inline int uv_num_possible_blades(void) 682bb898558SAl Viro { 683bb898558SAl Viro return uv_possible_blades; 684bb898558SAl Viro } 685bb898558SAl Viro 6860d12ef0cSMike Travis /* Per Hub NMI support */ 6870d12ef0cSMike Travis extern void uv_nmi_setup(void); 6880d12ef0cSMike Travis 6890d12ef0cSMike Travis /* BMC sets a bit this MMR non-zero before sending an NMI */ 6900d12ef0cSMike Travis #define UVH_NMI_MMR UVH_SCRATCH5 6910d12ef0cSMike Travis #define UVH_NMI_MMR_CLEAR UVH_SCRATCH5_ALIAS 6920d12ef0cSMike Travis #define UVH_NMI_MMR_SHIFT 63 6930d12ef0cSMike Travis #define UVH_NMI_MMR_TYPE "SCRATCH5" 6940d12ef0cSMike Travis 6950d12ef0cSMike Travis /* Newer SMM NMI handler, not present in all systems */ 6960d12ef0cSMike Travis #define UVH_NMI_MMRX UVH_EVENT_OCCURRED0 6970d12ef0cSMike Travis #define UVH_NMI_MMRX_CLEAR UVH_EVENT_OCCURRED0_ALIAS 698c443c03dSMike Travis #define UVH_NMI_MMRX_SHIFT UVH_EVENT_OCCURRED0_EXTIO_INT0_SHFT 6990d12ef0cSMike Travis #define UVH_NMI_MMRX_TYPE "EXTIO_INT0" 7000d12ef0cSMike Travis 7010d12ef0cSMike Travis /* Non-zero indicates newer SMM NMI handler present */ 7020d12ef0cSMike Travis #define UVH_NMI_MMRX_SUPPORTED UVH_EXTIO_INT0_BROADCAST 7030d12ef0cSMike Travis 7040d12ef0cSMike Travis /* Indicates to BIOS that we want to use the newer SMM NMI handler */ 7050d12ef0cSMike Travis #define UVH_NMI_MMRX_REQ UVH_SCRATCH5_ALIAS_2 7060d12ef0cSMike Travis #define UVH_NMI_MMRX_REQ_SHIFT 62 7070d12ef0cSMike Travis 7080d12ef0cSMike Travis struct uv_hub_nmi_s { 7090d12ef0cSMike Travis raw_spinlock_t nmi_lock; 7100d12ef0cSMike Travis atomic_t in_nmi; /* flag this node in UV NMI IRQ */ 7110d12ef0cSMike Travis atomic_t cpu_owner; /* last locker of this struct */ 7120d12ef0cSMike Travis atomic_t read_mmr_count; /* count of MMR reads */ 7130d12ef0cSMike Travis atomic_t nmi_count; /* count of true UV NMIs */ 7140d12ef0cSMike Travis unsigned long nmi_value; /* last value read from NMI MMR */ 7150d12ef0cSMike Travis }; 7160d12ef0cSMike Travis 7170d12ef0cSMike Travis struct uv_cpu_nmi_s { 7180d12ef0cSMike Travis struct uv_hub_nmi_s *hub; 719e1632170SChristoph Lameter int state; 720e1632170SChristoph Lameter int pinging; 7210d12ef0cSMike Travis int queries; 7220d12ef0cSMike Travis int pings; 7230d12ef0cSMike Travis }; 7240d12ef0cSMike Travis 725e1632170SChristoph Lameter DECLARE_PER_CPU(struct uv_cpu_nmi_s, uv_cpu_nmi); 726e1632170SChristoph Lameter 7277c52198bSGeorge Beshers #define uv_hub_nmi this_cpu_read(uv_cpu_nmi.hub) 728e1632170SChristoph Lameter #define uv_cpu_nmi_per(cpu) (per_cpu(uv_cpu_nmi, cpu)) 7290d12ef0cSMike Travis #define uv_hub_nmi_per(cpu) (uv_cpu_nmi_per(cpu).hub) 7300d12ef0cSMike Travis 7310d12ef0cSMike Travis /* uv_cpu_nmi_states */ 7320d12ef0cSMike Travis #define UV_NMI_STATE_OUT 0 7330d12ef0cSMike Travis #define UV_NMI_STATE_IN 1 7340d12ef0cSMike Travis #define UV_NMI_STATE_DUMP 2 7350d12ef0cSMike Travis #define UV_NMI_STATE_DUMP_DONE 3 7360d12ef0cSMike Travis 7377f1baa06SMike Travis /* Update SCIR state */ 7387f1baa06SMike Travis static inline void uv_set_scir_bits(unsigned char value) 7397f1baa06SMike Travis { 740d38bb135SMike Travis if (uv_scir_info->state != value) { 741d38bb135SMike Travis uv_scir_info->state = value; 742d38bb135SMike Travis uv_write_local_mmr8(uv_scir_info->offset, value); 7437f1baa06SMike Travis } 7447f1baa06SMike Travis } 74566666e50SJack Steiner 74639d30770SMike Travis static inline unsigned long uv_scir_offset(int apicid) 74739d30770SMike Travis { 74839d30770SMike Travis return SCIR_LOCAL_MMR_BASE | (apicid & 0x3f); 74939d30770SMike Travis } 75039d30770SMike Travis 7517f1baa06SMike Travis static inline void uv_set_cpu_scir_bits(int cpu, unsigned char value) 7527f1baa06SMike Travis { 753d38bb135SMike Travis if (uv_cpu_scir_info(cpu)->state != value) { 75439d30770SMike Travis uv_write_global_mmr8(uv_cpu_to_pnode(cpu), 755d38bb135SMike Travis uv_cpu_scir_info(cpu)->offset, value); 756d38bb135SMike Travis uv_cpu_scir_info(cpu)->state = value; 7577f1baa06SMike Travis } 7587f1baa06SMike Travis } 759bb898558SAl Viro 7608191c9f6SDimitri Sivanich extern unsigned int uv_apicid_hibits; 76156abcf24SJack Steiner static unsigned long uv_hub_ipi_value(int apicid, int vector, int mode) 76256abcf24SJack Steiner { 7638191c9f6SDimitri Sivanich apicid |= uv_apicid_hibits; 76456abcf24SJack Steiner return (1UL << UVH_IPI_INT_SEND_SHFT) | 76556abcf24SJack Steiner ((apicid) << UVH_IPI_INT_APIC_ID_SHFT) | 76656abcf24SJack Steiner (mode << UVH_IPI_INT_DELIVERY_MODE_SHFT) | 76756abcf24SJack Steiner (vector << UVH_IPI_INT_VECTOR_SHFT); 76856abcf24SJack Steiner } 76956abcf24SJack Steiner 77066666e50SJack Steiner static inline void uv_hub_send_ipi(int pnode, int apicid, int vector) 77166666e50SJack Steiner { 77266666e50SJack Steiner unsigned long val; 77302dd0a06SRobin Holt unsigned long dmode = dest_Fixed; 77402dd0a06SRobin Holt 77502dd0a06SRobin Holt if (vector == NMI_VECTOR) 77602dd0a06SRobin Holt dmode = dest_NMI; 77766666e50SJack Steiner 77856abcf24SJack Steiner val = uv_hub_ipi_value(apicid, vector, dmode); 77966666e50SJack Steiner uv_write_global_mmr64(pnode, UVH_IPI_INT, val); 78066666e50SJack Steiner } 78166666e50SJack Steiner 7827a1110e8SJack Steiner /* 7837a1110e8SJack Steiner * Get the minimum revision number of the hub chips within the partition. 784eb1e3461SMike Travis * (See UVx_HUB_REVISION_BASE above for specific values.) 7857a1110e8SJack Steiner */ 7867a1110e8SJack Steiner static inline int uv_get_min_hub_revision_id(void) 7877a1110e8SJack Steiner { 7882a919596SJack Steiner return uv_hub_info->hub_revision; 7897a1110e8SJack Steiner } 7907a1110e8SJack Steiner 791bc5d9940SJack Steiner #endif /* CONFIG_X86_64 */ 7927f1baa06SMike Travis #endif /* _ASM_X86_UV_UV_HUB_H */ 793