xref: /openbmc/linux/arch/x86/include/asm/uv/uv_hub.h (revision 7a6d94f0)
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  *
87a6d94f0SMike Travis  * (C) Copyright 2020 Hewlett Packard Enterprise Development LP
95f40f7d9SDimitri Sivanich  * Copyright (C) 2007-2014 Silicon Graphics, Inc. All rights reserved.
10bb898558SAl Viro  */
11bb898558SAl Viro 
1205e4d316SH. Peter Anvin #ifndef _ASM_X86_UV_UV_HUB_H
1305e4d316SH. Peter Anvin #define _ASM_X86_UV_UV_HUB_H
14bb898558SAl Viro 
15bc5d9940SJack Steiner #ifdef CONFIG_X86_64
16bb898558SAl Viro #include <linux/numa.h>
17bb898558SAl Viro #include <linux/percpu.h>
18c08b6accSMike Travis #include <linux/timer.h>
198dc579e8SJack Steiner #include <linux/io.h>
20906f3b20SMike Travis #include <linux/topology.h>
21bb898558SAl Viro #include <asm/types.h>
22bb898558SAl Viro #include <asm/percpu.h>
234fb7d087SMike Travis #include <asm/uv/uv.h>
2466666e50SJack Steiner #include <asm/uv/uv_mmrs.h>
25c85375cdSMike Travis #include <asm/uv/bios.h>
2602dd0a06SRobin Holt #include <asm/irq_vectors.h>
2702dd0a06SRobin Holt #include <asm/io_apic.h>
28bb898558SAl Viro 
29bb898558SAl Viro 
30bb898558SAl Viro /*
31bb898558SAl Viro  * Addressing Terminology
32bb898558SAl Viro  *
33bb898558SAl Viro  *	M       - The low M bits of a physical address represent the offset
34bb898558SAl Viro  *		  into the blade local memory. RAM memory on a blade is physically
35bb898558SAl Viro  *		  contiguous (although various IO spaces may punch holes in
36bb898558SAl Viro  *		  it)..
37bb898558SAl Viro  *
38bb898558SAl Viro  *	N	- Number of bits in the node portion of a socket physical
39bb898558SAl Viro  *		  address.
40bb898558SAl Viro  *
41bb898558SAl Viro  *	NASID   - network ID of a router, Mbrick or Cbrick. Nasid values of
42bb898558SAl Viro  *		  routers always have low bit of 1, C/MBricks have low bit
43bb898558SAl Viro  *		  equal to 0. Most addressing macros that target UV hub chips
44bb898558SAl Viro  *		  right shift the NASID by 1 to exclude the always-zero bit.
45bb898558SAl Viro  *		  NASIDs contain up to 15 bits.
46bb898558SAl Viro  *
47bb898558SAl Viro  *	GNODE   - NASID right shifted by 1 bit. Most mmrs contain gnodes instead
48bb898558SAl Viro  *		  of nasids.
49bb898558SAl Viro  *
50bb898558SAl Viro  *	PNODE   - the low N bits of the GNODE. The PNODE is the most useful variant
51bb898558SAl Viro  *		  of the nasid for socket usage.
52bb898558SAl Viro  *
536a469e46SJack Steiner  *	GPA	- (global physical address) a socket physical address converted
546a469e46SJack Steiner  *		  so that it can be used by the GRU as a global address. Socket
556a469e46SJack Steiner  *		  physical addresses 1) need additional NASID (node) bits added
566a469e46SJack Steiner  *		  to the high end of the address, and 2) unaliased if the
576a469e46SJack Steiner  *		  partition does not have a physical address 0. In addition, on
586a469e46SJack Steiner  *		  UV2 rev 1, GPAs need the gnode left shifted to bits 39 or 40.
596a469e46SJack Steiner  *
60bb898558SAl Viro  *
61bb898558SAl Viro  *  NumaLink Global Physical Address Format:
62bb898558SAl Viro  *  +--------------------------------+---------------------+
63bb898558SAl Viro  *  |00..000|      GNODE             |      NodeOffset     |
64bb898558SAl Viro  *  +--------------------------------+---------------------+
65bb898558SAl Viro  *          |<-------53 - M bits --->|<--------M bits ----->
66bb898558SAl Viro  *
67bb898558SAl Viro  *	M - number of node offset bits (35 .. 40)
68bb898558SAl Viro  *
69bb898558SAl Viro  *
70bb898558SAl Viro  *  Memory/UV-HUB Processor Socket Address Format:
71bb898558SAl Viro  *  +----------------+---------------+---------------------+
72bb898558SAl Viro  *  |00..000000000000|   PNODE       |      NodeOffset     |
73bb898558SAl Viro  *  +----------------+---------------+---------------------+
74bb898558SAl Viro  *                   <--- N bits --->|<--------M bits ----->
75bb898558SAl Viro  *
76bb898558SAl Viro  *	M - number of node offset bits (35 .. 40)
77bb898558SAl Viro  *	N - number of PNODE bits (0 .. 10)
78bb898558SAl Viro  *
79bb898558SAl Viro  *		Note: M + N cannot currently exceed 44 (x86_64) or 46 (IA64).
80bb898558SAl Viro  *		The actual values are configuration dependent and are set at
81bb898558SAl Viro  *		boot time. M & N values are set by the hardware/BIOS at boot.
82bb898558SAl Viro  *
83bb898558SAl Viro  *
84bb898558SAl Viro  * APICID format
85bb898558SAl Viro  *	NOTE!!!!!! This is the current format of the APICID. However, code
86bb898558SAl Viro  *	should assume that this will change in the future. Use functions
87bb898558SAl Viro  *	in this file for all APICID bit manipulations and conversion.
88bb898558SAl Viro  *
89bb898558SAl Viro  *		1111110000000000
90bb898558SAl Viro  *		5432109876543210
912a919596SJack Steiner  *		pppppppppplc0cch	Nehalem-EX (12 bits in hdw reg)
922a919596SJack Steiner  *		ppppppppplcc0cch	Westmere-EX (12 bits in hdw reg)
932a919596SJack Steiner  *		pppppppppppcccch	SandyBridge (15 bits in hdw reg)
94bb898558SAl Viro  *		sssssssssss
95bb898558SAl Viro  *
96bb898558SAl Viro  *			p  = pnode bits
97bb898558SAl Viro  *			l =  socket number on board
98bb898558SAl Viro  *			c  = core
99bb898558SAl Viro  *			h  = hyperthread
100bb898558SAl Viro  *			s  = bits that are in the SOCKET_ID CSR
101bb898558SAl Viro  *
1022a919596SJack Steiner  *	Note: Processor may support fewer bits in the APICID register. The ACPI
103bb898558SAl Viro  *	      tables hold all 16 bits. Software needs to be aware of this.
104bb898558SAl Viro  *
105bb898558SAl Viro  *	      Unless otherwise specified, all references to APICID refer to
106bb898558SAl Viro  *	      the FULL value contained in ACPI tables, not the subset in the
107bb898558SAl Viro  *	      processor APICID register.
108bb898558SAl Viro  */
109bb898558SAl Viro 
110bb898558SAl Viro /*
111bb898558SAl Viro  * Maximum number of bricks in all partitions and in all coherency domains.
112bb898558SAl Viro  * This is the total number of bricks accessible in the numalink fabric. It
113bb898558SAl Viro  * includes all C & M bricks. Routers are NOT included.
114bb898558SAl Viro  *
115bb898558SAl Viro  * This value is also the value of the maximum number of non-router NASIDs
116bb898558SAl Viro  * in the numalink fabric.
117bb898558SAl Viro  *
118bb898558SAl Viro  * NOTE: a brick may contain 1 or 2 OS nodes. Don't get these confused.
119bb898558SAl Viro  */
120bb898558SAl Viro #define UV_MAX_NUMALINK_BLADES	16384
121bb898558SAl Viro 
122bb898558SAl Viro /*
123bb898558SAl Viro  * Maximum number of C/Mbricks within a software SSI (hardware may support
124bb898558SAl Viro  * more).
125bb898558SAl Viro  */
126bb898558SAl Viro #define UV_MAX_SSI_BLADES	256
127bb898558SAl Viro 
128bb898558SAl Viro /*
129bb898558SAl Viro  * The largest possible NASID of a C or M brick (+ 2)
130bb898558SAl Viro  */
1311d21e6e3SRobin Holt #define UV_MAX_NASID_VALUE	(UV_MAX_NUMALINK_BLADES * 2)
132bb898558SAl Viro 
133c85375cdSMike Travis /* GAM (globally addressed memory) range table */
134c85375cdSMike Travis struct uv_gam_range_s {
135c85375cdSMike Travis 	u32	limit;		/* PA bits 56:26 (GAM_RANGE_SHFT) */
136c85375cdSMike Travis 	u16	nasid;		/* node's global physical address */
137c85375cdSMike Travis 	s8	base;		/* entry index of node's base addr */
138c85375cdSMike Travis 	u8	reserved;
139c85375cdSMike Travis };
140c85375cdSMike Travis 
141bb898558SAl Viro /*
142bb898558SAl Viro  * The following defines attributes of the HUB chip. These attributes are
1430045ddd2SMike Travis  * frequently referenced and are kept in a common per hub struct.
1440045ddd2SMike Travis  * After setup, the struct is read only, so it should be readily
1450045ddd2SMike Travis  * available in the L3 cache on the cpu socket for the node.
146bb898558SAl Viro  */
147bb898558SAl Viro struct uv_hub_info_s {
148647128f1SMike Travis 	unsigned int		hub_type;
149647128f1SMike Travis 	unsigned char		hub_revision;
150bb898558SAl Viro 	unsigned long		global_mmr_base;
1511de329c1SMike Travis 	unsigned long		global_mmr_shift;
152bb898558SAl Viro 	unsigned long		gpa_mask;
1536e27b91cSMike Travis 	unsigned short		*socket_to_node;
1546e27b91cSMike Travis 	unsigned short		*socket_to_pnode;
1556e27b91cSMike Travis 	unsigned short		*pnode_to_socket;
156c85375cdSMike Travis 	struct uv_gam_range_s	*gr_table;
1571de329c1SMike Travis 	unsigned short		min_socket;
1581de329c1SMike Travis 	unsigned short		min_pnode;
159c85375cdSMike Travis 	unsigned char		m_val;
160c85375cdSMike Travis 	unsigned char		n_val;
161c85375cdSMike Travis 	unsigned char		gr_table_len;
1622a919596SJack Steiner 	unsigned char		apic_pnode_shift;
1631de329c1SMike Travis 	unsigned char		gpa_shift;
1646c779442SMike Travis 	unsigned char		nasid_shift;
1656a469e46SJack Steiner 	unsigned char		m_shift;
1666a469e46SJack Steiner 	unsigned char		n_lshift;
1671de329c1SMike Travis 	unsigned int		gnode_extra;
168bb898558SAl Viro 	unsigned long		gnode_upper;
169bb898558SAl Viro 	unsigned long		lowmem_remap_top;
170bb898558SAl Viro 	unsigned long		lowmem_remap_base;
1711de329c1SMike Travis 	unsigned long		global_gru_base;
1721de329c1SMike Travis 	unsigned long		global_gru_shift;
173bb898558SAl Viro 	unsigned short		pnode;
174bb898558SAl Viro 	unsigned short		pnode_mask;
175bb898558SAl Viro 	unsigned short		coherency_domain_number;
176bb898558SAl Viro 	unsigned short		numa_blade_id;
177906f3b20SMike Travis 	unsigned short		nr_possible_cpus;
178906f3b20SMike Travis 	unsigned short		nr_online_cpus;
179906f3b20SMike Travis 	short			memory_nid;
180bb898558SAl Viro };
1817f1baa06SMike Travis 
1820045ddd2SMike Travis /* CPU specific info with a pointer to the hub common info struct */
1830045ddd2SMike Travis struct uv_cpu_info_s {
1840045ddd2SMike Travis 	void			*p_uv_hub_info;
1850045ddd2SMike Travis 	unsigned char		blade_cpu_id;
186c4d98077SMike Travis 	void			*reserved;
1870045ddd2SMike Travis };
1880045ddd2SMike Travis DECLARE_PER_CPU(struct uv_cpu_info_s, __uv_cpu_info);
1890045ddd2SMike Travis 
1900045ddd2SMike Travis #define uv_cpu_info		this_cpu_ptr(&__uv_cpu_info)
1910045ddd2SMike Travis #define uv_cpu_info_per(cpu)	(&per_cpu(__uv_cpu_info, cpu))
1920045ddd2SMike 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 
211647128f1SMike Travis static inline int uv_hub_type(void)
212647128f1SMike Travis {
213647128f1SMike Travis 	return uv_hub_info->hub_type;
214647128f1SMike Travis }
215647128f1SMike Travis 
216647128f1SMike Travis static inline __init void uv_hub_type_set(int uvmask)
217647128f1SMike Travis {
218647128f1SMike Travis 	uv_hub_info->hub_type = uvmask;
219647128f1SMike Travis }
220647128f1SMike Travis 
221647128f1SMike Travis 
2222a919596SJack Steiner /*
2230045ddd2SMike Travis  * HUB revision ranges for each UV HUB architecture.
2242a919596SJack Steiner  * This is a software convention - NOT the hardware revision numbers in
2252a919596SJack Steiner  * the hub chip.
2262a919596SJack Steiner  */
2272a919596SJack Steiner #define UV2_HUB_REVISION_BASE		3
2286edbd471SMike Travis #define UV3_HUB_REVISION_BASE		5
229eb1e3461SMike Travis #define UV4_HUB_REVISION_BASE		7
2308078d195SMike Travis #define UV4A_HUB_REVISION_BASE		8	/* UV4 (fixed) rev 2 */
2316c779442SMike Travis #define UV5_HUB_REVISION_BASE		9
2322a919596SJack Steiner 
233647128f1SMike Travis static inline int is_uv(int uvmask) { return uv_hub_type() & uvmask; }
234647128f1SMike Travis static inline int is_uv1_hub(void) { return 0; }
235647128f1SMike Travis static inline int is_uv2_hub(void) { return is_uv(UV2); }
236647128f1SMike Travis static inline int is_uv3_hub(void) { return is_uv(UV3); }
237647128f1SMike Travis static inline int is_uv4a_hub(void) { return is_uv(UV4A); }
238647128f1SMike Travis static inline int is_uv4_hub(void) { return is_uv(UV4); }
2396c779442SMike Travis static inline int is_uv5_hub(void) { return is_uv(UV5); }
2406edbd471SMike Travis 
241647128f1SMike Travis /*
242647128f1SMike Travis  * UV4A is a revision of UV4.  So on UV4A, both is_uv4_hub() and
243647128f1SMike Travis  * is_uv4a_hub() return true, While on UV4, only is_uv4_hub()
244647128f1SMike Travis  * returns true.  So to get true results, first test if is UV4A,
245647128f1SMike Travis  * then test if is UV4.
246647128f1SMike Travis  */
2476edbd471SMike Travis 
248647128f1SMike Travis /* UVX class: UV2,3,4 */
249647128f1SMike Travis static inline int is_uvx_hub(void) { return is_uv(UVX); }
2508078d195SMike Travis 
251647128f1SMike Travis /* UVY class: UV5,..? */
2526c779442SMike Travis static inline int is_uvy_hub(void) { return is_uv(UVY); }
253eb1e3461SMike Travis 
254647128f1SMike Travis /* Any UV Hubbed System */
255647128f1SMike Travis static inline int is_uv_hub(void) { return is_uv(UV_ANY); }
2562a919596SJack Steiner 
257c8f730b1SRuss Anderson union uvh_apicid {
258c8f730b1SRuss Anderson     unsigned long       v;
259c8f730b1SRuss Anderson     struct uvh_apicid_s {
260c8f730b1SRuss Anderson         unsigned long   local_apic_mask  : 24;
261c8f730b1SRuss Anderson         unsigned long   local_apic_shift :  5;
262c8f730b1SRuss Anderson         unsigned long   unused1          :  3;
263c8f730b1SRuss Anderson         unsigned long   pnode_mask       : 24;
264c8f730b1SRuss Anderson         unsigned long   pnode_shift      :  5;
265c8f730b1SRuss Anderson         unsigned long   unused2          :  3;
266c8f730b1SRuss Anderson     } s;
267c8f730b1SRuss Anderson };
268c8f730b1SRuss Anderson 
269bb898558SAl Viro /*
270bb898558SAl Viro  * Local & Global MMR space macros.
271bb898558SAl Viro  *	Note: macros are intended to be used ONLY by inline functions
272bb898558SAl Viro  *	in this file - not by other kernel code.
273bb898558SAl Viro  *		n -  NASID (full 15-bit global nasid)
274bb898558SAl Viro  *		g -  GNODE (full 15-bit global nasid, right shifted 1)
275bb898558SAl Viro  *		p -  PNODE (local part of nsids, right shifted 1)
276bb898558SAl Viro  */
2776c779442SMike Travis #define UV_NASID_TO_PNODE(n)		\
2786c779442SMike Travis 		(((n) >> uv_hub_info->nasid_shift) & uv_hub_info->pnode_mask)
279c4ed3f04SJack Steiner #define UV_PNODE_TO_GNODE(p)		((p) |uv_hub_info->gnode_extra)
2806c779442SMike Travis #define UV_PNODE_TO_NASID(p)		\
2816c779442SMike Travis 		(UV_PNODE_TO_GNODE(p) << uv_hub_info->nasid_shift)
282bb898558SAl Viro 
2832a919596SJack Steiner #define UV2_LOCAL_MMR_BASE		0xfa000000UL
2842a919596SJack Steiner #define UV2_GLOBAL_MMR32_BASE		0xfc000000UL
2852a919596SJack Steiner #define UV2_LOCAL_MMR_SIZE		(32UL * 1024 * 1024)
2862a919596SJack Steiner #define UV2_GLOBAL_MMR32_SIZE		(32UL * 1024 * 1024)
2872a919596SJack Steiner 
2886edbd471SMike Travis #define UV3_LOCAL_MMR_BASE		0xfa000000UL
2896edbd471SMike Travis #define UV3_GLOBAL_MMR32_BASE		0xfc000000UL
2906edbd471SMike Travis #define UV3_LOCAL_MMR_SIZE		(32UL * 1024 * 1024)
2916edbd471SMike Travis #define UV3_GLOBAL_MMR32_SIZE		(32UL * 1024 * 1024)
2926edbd471SMike Travis 
293eb1e3461SMike Travis #define UV4_LOCAL_MMR_BASE		0xfa000000UL
294c4d98077SMike Travis #define UV4_GLOBAL_MMR32_BASE		0
295eb1e3461SMike Travis #define UV4_LOCAL_MMR_SIZE		(32UL * 1024 * 1024)
296c4d98077SMike Travis #define UV4_GLOBAL_MMR32_SIZE		0
297eb1e3461SMike Travis 
2986c779442SMike Travis #define UV5_LOCAL_MMR_BASE		0xfa000000UL
2996c779442SMike Travis #define UV5_GLOBAL_MMR32_BASE		0
3006c779442SMike Travis #define UV5_LOCAL_MMR_SIZE		(32UL * 1024 * 1024)
3016c779442SMike Travis #define UV5_GLOBAL_MMR32_SIZE		0
3026c779442SMike Travis 
303eb1e3461SMike Travis #define UV_LOCAL_MMR_BASE		(				\
3046c779442SMike Travis 					is_uv(UV2) ? UV2_LOCAL_MMR_BASE : \
3056c779442SMike Travis 					is_uv(UV3) ? UV3_LOCAL_MMR_BASE : \
3066c779442SMike Travis 					is_uv(UV4) ? UV4_LOCAL_MMR_BASE : \
3076c779442SMike Travis 					is_uv(UV5) ? UV5_LOCAL_MMR_BASE : \
3086c779442SMike Travis 					0)
309eb1e3461SMike Travis 
310eb1e3461SMike Travis #define UV_GLOBAL_MMR32_BASE		(				\
3116c779442SMike Travis 					is_uv(UV2) ? UV2_GLOBAL_MMR32_BASE : \
3126c779442SMike Travis 					is_uv(UV3) ? UV3_GLOBAL_MMR32_BASE : \
3136c779442SMike Travis 					is_uv(UV4) ? UV4_GLOBAL_MMR32_BASE : \
3146c779442SMike Travis 					is_uv(UV5) ? UV5_GLOBAL_MMR32_BASE : \
3156c779442SMike Travis 					0)
316eb1e3461SMike Travis 
317eb1e3461SMike Travis #define UV_LOCAL_MMR_SIZE		(				\
3186c779442SMike Travis 					is_uv(UV2) ? UV2_LOCAL_MMR_SIZE : \
3196c779442SMike Travis 					is_uv(UV3) ? UV3_LOCAL_MMR_SIZE : \
3206c779442SMike Travis 					is_uv(UV4) ? UV4_LOCAL_MMR_SIZE : \
3216c779442SMike Travis 					is_uv(UV5) ? UV5_LOCAL_MMR_SIZE : \
3226c779442SMike Travis 					0)
323eb1e3461SMike Travis 
324eb1e3461SMike Travis #define UV_GLOBAL_MMR32_SIZE		(				\
3256c779442SMike Travis 					is_uv(UV2) ? UV2_GLOBAL_MMR32_SIZE : \
3266c779442SMike Travis 					is_uv(UV3) ? UV3_GLOBAL_MMR32_SIZE : \
3276c779442SMike Travis 					is_uv(UV4) ? UV4_GLOBAL_MMR32_SIZE : \
3286c779442SMike Travis 					is_uv(UV5) ? UV5_GLOBAL_MMR32_SIZE : \
3296c779442SMike Travis 					0)
330eb1e3461SMike Travis 
331bb898558SAl Viro #define UV_GLOBAL_MMR64_BASE		(uv_hub_info->global_mmr_base)
332bb898558SAl Viro 
33356abcf24SJack Steiner #define UV_GLOBAL_GRU_MMR_BASE		0x4000000
33456abcf24SJack Steiner 
335bb898558SAl Viro #define UV_GLOBAL_MMR32_PNODE_SHIFT	15
3361de329c1SMike Travis #define _UV_GLOBAL_MMR64_PNODE_SHIFT	26
3371de329c1SMike Travis #define UV_GLOBAL_MMR64_PNODE_SHIFT	(uv_hub_info->global_mmr_shift)
338bb898558SAl Viro 
339bb898558SAl Viro #define UV_GLOBAL_MMR32_PNODE_BITS(p)	((p) << (UV_GLOBAL_MMR32_PNODE_SHIFT))
340bb898558SAl Viro 
341bb898558SAl Viro #define UV_GLOBAL_MMR64_PNODE_BITS(p)					\
34267e83f30SJack Steiner 	(((unsigned long)(p)) << UV_GLOBAL_MMR64_PNODE_SHIFT)
343bb898558SAl Viro 
344c8f730b1SRuss Anderson #define UVH_APICID		0x002D0E00L
345bb898558SAl Viro #define UV_APIC_PNODE_SHIFT	6
346bb898558SAl Viro 
3477f1baa06SMike Travis /* Local Bus from cpu's perspective */
3487f1baa06SMike Travis #define LOCAL_BUS_BASE		0x1c00000
3497f1baa06SMike Travis #define LOCAL_BUS_SIZE		(4 * 1024 * 1024)
3507f1baa06SMike Travis 
3517f1baa06SMike Travis /*
3527f1baa06SMike Travis  * System Controller Interface Reg
3537f1baa06SMike Travis  *
3547f1baa06SMike Travis  * Note there are NO leds on a UV system.  This register is only
3557f1baa06SMike Travis  * used by the system controller to monitor system-wide operation.
3567f1baa06SMike Travis  * There are 64 regs per node.  With Nahelem cpus (2 cores per node,
3577f1baa06SMike Travis  * 8 cpus per core, 2 threads per cpu) there are 32 cpu threads on
3587f1baa06SMike Travis  * a node.
3597f1baa06SMike Travis  *
3607f1baa06SMike Travis  * The window is located at top of ACPI MMR space
3617f1baa06SMike Travis  */
3627f1baa06SMike Travis #define SCIR_WINDOW_COUNT	64
3637f1baa06SMike Travis #define SCIR_LOCAL_MMR_BASE	(LOCAL_BUS_BASE + \
3647f1baa06SMike Travis 				 LOCAL_BUS_SIZE - \
3657f1baa06SMike Travis 				 SCIR_WINDOW_COUNT)
3667f1baa06SMike Travis 
3677f1baa06SMike Travis #define SCIR_CPU_HEARTBEAT	0x01	/* timer interrupt */
3687f1baa06SMike Travis #define SCIR_CPU_ACTIVITY	0x02	/* not idle */
3697f1baa06SMike Travis #define SCIR_CPU_HB_INTERVAL	(HZ)	/* once per second */
3707f1baa06SMike Travis 
3718661984fSDimitri Sivanich /* Loop through all installed blades */
3728661984fSDimitri Sivanich #define for_each_possible_blade(bid)		\
3738661984fSDimitri Sivanich 	for ((bid) = 0; (bid) < uv_num_possible_blades(); (bid)++)
3748661984fSDimitri Sivanich 
375bb898558SAl Viro /*
376bb898558SAl Viro  * Macros for converting between kernel virtual addresses, socket local physical
377bb898558SAl Viro  * addresses, and UV global physical addresses.
378bb898558SAl Viro  *	Note: use the standard __pa() & __va() macros for converting
379bb898558SAl Viro  *	      between socket virtual and socket physical addresses.
380bb898558SAl Viro  */
381bb898558SAl Viro 
382c85375cdSMike Travis /* global bits offset - number of local address bits in gpa for this UV arch */
383c85375cdSMike Travis static inline unsigned int uv_gpa_shift(void)
384c85375cdSMike Travis {
385c85375cdSMike Travis 	return uv_hub_info->gpa_shift;
386c85375cdSMike Travis }
387c85375cdSMike Travis #define	_uv_gpa_shift
388c85375cdSMike Travis 
389c85375cdSMike Travis /* Find node that has the address range that contains global address  */
390c85375cdSMike Travis static inline struct uv_gam_range_s *uv_gam_range(unsigned long pa)
391c85375cdSMike Travis {
392c85375cdSMike Travis 	struct uv_gam_range_s *gr = uv_hub_info->gr_table;
393c85375cdSMike Travis 	unsigned long pal = (pa & uv_hub_info->gpa_mask) >> UV_GAM_RANGE_SHFT;
394c85375cdSMike Travis 	int i, num = uv_hub_info->gr_table_len;
395c85375cdSMike Travis 
396c85375cdSMike Travis 	if (gr) {
397c85375cdSMike Travis 		for (i = 0; i < num; i++, gr++) {
398c85375cdSMike Travis 			if (pal < gr->limit)
399c85375cdSMike Travis 				return gr;
400c85375cdSMike Travis 		}
401c85375cdSMike Travis 	}
402c85375cdSMike Travis 	pr_crit("UV: GAM Range for 0x%lx not found at %p!\n", pa, gr);
403c85375cdSMike Travis 	BUG();
404c85375cdSMike Travis }
405c85375cdSMike Travis 
406c85375cdSMike Travis /* Return base address of node that contains global address  */
407c85375cdSMike Travis static inline unsigned long uv_gam_range_base(unsigned long pa)
408c85375cdSMike Travis {
409c85375cdSMike Travis 	struct uv_gam_range_s *gr = uv_gam_range(pa);
410c85375cdSMike Travis 	int base = gr->base;
411c85375cdSMike Travis 
412c85375cdSMike Travis 	if (base < 0)
413c85375cdSMike Travis 		return 0UL;
414c85375cdSMike Travis 
415c85375cdSMike Travis 	return uv_hub_info->gr_table[base].limit;
416c85375cdSMike Travis }
417c85375cdSMike Travis 
418c85375cdSMike Travis /* socket phys RAM --> UV global NASID (UV4+) */
419c85375cdSMike Travis static inline unsigned long uv_soc_phys_ram_to_nasid(unsigned long paddr)
420c85375cdSMike Travis {
421c85375cdSMike Travis 	return uv_gam_range(paddr)->nasid;
422c85375cdSMike Travis }
423c85375cdSMike Travis #define	_uv_soc_phys_ram_to_nasid
424c85375cdSMike Travis 
425c85375cdSMike Travis /* socket virtual --> UV global NASID (UV4+) */
426c85375cdSMike Travis static inline unsigned long uv_gpa_nasid(void *v)
427c85375cdSMike Travis {
428c85375cdSMike Travis 	return uv_soc_phys_ram_to_nasid(__pa(v));
429c85375cdSMike Travis }
430c85375cdSMike Travis 
431bb898558SAl Viro /* socket phys RAM --> UV global physical address */
432bb898558SAl Viro static inline unsigned long uv_soc_phys_ram_to_gpa(unsigned long paddr)
433bb898558SAl Viro {
434c85375cdSMike Travis 	unsigned int m_val = uv_hub_info->m_val;
435c85375cdSMike Travis 
436bb898558SAl Viro 	if (paddr < uv_hub_info->lowmem_remap_top)
437189f67c4SJack Steiner 		paddr |= uv_hub_info->lowmem_remap_base;
438ad483005SMike Travis 
439ad483005SMike Travis 	if (m_val) {
4406a469e46SJack Steiner 		paddr |= uv_hub_info->gnode_upper;
441c85375cdSMike Travis 		paddr = ((paddr << uv_hub_info->m_shift)
442c85375cdSMike Travis 						>> uv_hub_info->m_shift) |
443c85375cdSMike Travis 			((paddr >> uv_hub_info->m_val)
444c85375cdSMike Travis 						<< uv_hub_info->n_lshift);
445ad483005SMike Travis 	} else {
446c85375cdSMike Travis 		paddr |= uv_soc_phys_ram_to_nasid(paddr)
447c85375cdSMike Travis 						<< uv_hub_info->gpa_shift;
448ad483005SMike Travis 	}
4496a469e46SJack Steiner 	return paddr;
450bb898558SAl Viro }
451bb898558SAl Viro 
452bb898558SAl Viro /* socket virtual --> UV global physical address */
453bb898558SAl Viro static inline unsigned long uv_gpa(void *v)
454bb898558SAl Viro {
455189f67c4SJack Steiner 	return uv_soc_phys_ram_to_gpa(__pa(v));
456bb898558SAl Viro }
457bb898558SAl Viro 
458fae419f2SRobin Holt /* Top two bits indicate the requested address is in MMR space.  */
459fae419f2SRobin Holt static inline int
460fae419f2SRobin Holt uv_gpa_in_mmr_space(unsigned long gpa)
461fae419f2SRobin Holt {
462fae419f2SRobin Holt 	return (gpa >> 62) == 0x3UL;
463fae419f2SRobin Holt }
464fae419f2SRobin Holt 
465729d69e6SRobin Holt /* UV global physical address --> socket phys RAM */
466729d69e6SRobin Holt static inline unsigned long uv_gpa_to_soc_phys_ram(unsigned long gpa)
467729d69e6SRobin Holt {
4685a51467bSRuss Anderson 	unsigned long paddr;
469729d69e6SRobin Holt 	unsigned long remap_base = uv_hub_info->lowmem_remap_base;
470729d69e6SRobin Holt 	unsigned long remap_top =  uv_hub_info->lowmem_remap_top;
471c85375cdSMike Travis 	unsigned int m_val = uv_hub_info->m_val;
472729d69e6SRobin Holt 
473c85375cdSMike Travis 	if (m_val)
4746a469e46SJack Steiner 		gpa = ((gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift) |
4756a469e46SJack Steiner 			((gpa >> uv_hub_info->n_lshift) << uv_hub_info->m_val);
476c85375cdSMike Travis 
4775a51467bSRuss Anderson 	paddr = gpa & uv_hub_info->gpa_mask;
478729d69e6SRobin Holt 	if (paddr >= remap_base && paddr < remap_base + remap_top)
479729d69e6SRobin Holt 		paddr -= remap_base;
480729d69e6SRobin Holt 	return paddr;
481729d69e6SRobin Holt }
482729d69e6SRobin Holt 
483906f3b20SMike Travis /* gpa -> gnode */
4841d21e6e3SRobin Holt static inline unsigned long uv_gpa_to_gnode(unsigned long gpa)
4851d21e6e3SRobin Holt {
486c85375cdSMike Travis 	unsigned int n_lshift = uv_hub_info->n_lshift;
487c85375cdSMike Travis 
488c85375cdSMike Travis 	if (n_lshift)
489c85375cdSMike Travis 		return gpa >> n_lshift;
490c85375cdSMike Travis 
491c85375cdSMike Travis 	return uv_gam_range(gpa)->nasid >> 1;
4921d21e6e3SRobin Holt }
4931d21e6e3SRobin Holt 
4941d21e6e3SRobin Holt /* gpa -> pnode */
4951d21e6e3SRobin Holt static inline int uv_gpa_to_pnode(unsigned long gpa)
4961d21e6e3SRobin Holt {
497906f3b20SMike Travis 	return uv_gpa_to_gnode(gpa) & uv_hub_info->pnode_mask;
4981d21e6e3SRobin Holt }
4991d21e6e3SRobin Holt 
5006a469e46SJack Steiner /* gpa -> node offset */
5016a469e46SJack Steiner static inline unsigned long uv_gpa_to_offset(unsigned long gpa)
5026a469e46SJack Steiner {
503c85375cdSMike Travis 	unsigned int m_shift = uv_hub_info->m_shift;
504c85375cdSMike Travis 
505c85375cdSMike Travis 	if (m_shift)
506c85375cdSMike Travis 		return (gpa << m_shift) >> m_shift;
507c85375cdSMike Travis 
508c85375cdSMike Travis 	return (gpa & uv_hub_info->gpa_mask) - uv_gam_range_base(gpa);
509c85375cdSMike Travis }
510c85375cdSMike Travis 
511c85375cdSMike Travis /* Convert socket to node */
512c85375cdSMike Travis static inline int _uv_socket_to_node(int socket, unsigned short *s2nid)
513c85375cdSMike Travis {
514c85375cdSMike Travis 	return s2nid ? s2nid[socket - uv_hub_info->min_socket] : socket;
515c85375cdSMike Travis }
516c85375cdSMike Travis 
517c85375cdSMike Travis static inline int uv_socket_to_node(int socket)
518c85375cdSMike Travis {
519c85375cdSMike Travis 	return _uv_socket_to_node(socket, uv_hub_info->socket_to_node);
5206a469e46SJack Steiner }
5216a469e46SJack Steiner 
522bb898558SAl Viro /* pnode, offset --> socket virtual */
523bb898558SAl Viro static inline void *uv_pnode_offset_to_vaddr(int pnode, unsigned long offset)
524bb898558SAl Viro {
525c85375cdSMike Travis 	unsigned int m_val = uv_hub_info->m_val;
526c85375cdSMike Travis 	unsigned long base;
527c85375cdSMike Travis 	unsigned short sockid, node, *p2s;
528bb898558SAl Viro 
529c85375cdSMike Travis 	if (m_val)
530c85375cdSMike Travis 		return __va(((unsigned long)pnode << m_val) | offset);
5316e27b91cSMike Travis 
532c85375cdSMike Travis 	p2s = uv_hub_info->pnode_to_socket;
533c85375cdSMike Travis 	sockid = p2s ? p2s[pnode - uv_hub_info->min_pnode] : pnode;
534c85375cdSMike Travis 	node = uv_socket_to_node(sockid);
535c85375cdSMike Travis 
536c85375cdSMike Travis 	/* limit address of previous socket is our base, except node 0 is 0 */
537c85375cdSMike Travis 	if (!node)
538c85375cdSMike Travis 		return __va((unsigned long)offset);
539c85375cdSMike Travis 
540c85375cdSMike Travis 	base = (unsigned long)(uv_hub_info->gr_table[node - 1].limit);
541c85375cdSMike Travis 	return __va(base << UV_GAM_RANGE_SHFT | offset);
5426e27b91cSMike Travis }
5436e27b91cSMike Travis 
5446e27b91cSMike Travis /* Extract/Convert a PNODE from an APICID (full apicid, not processor subset) */
545bb898558SAl Viro static inline int uv_apicid_to_pnode(int apicid)
546bb898558SAl Viro {
5476e27b91cSMike Travis 	int pnode = apicid >> uv_hub_info->apic_pnode_shift;
5486e27b91cSMike Travis 	unsigned short *s2pn = uv_hub_info->socket_to_pnode;
5496e27b91cSMike Travis 
5506e27b91cSMike Travis 	return s2pn ? s2pn[pnode - uv_hub_info->min_socket] : pnode;
551bb898558SAl Viro }
552bb898558SAl Viro 
5532a919596SJack Steiner /*
554bb898558SAl Viro  * Access global MMRs using the low memory MMR32 space. This region supports
555bb898558SAl Viro  * faster MMR access but not all MMRs are accessible in this space.
556bb898558SAl Viro  */
55739d30770SMike Travis static inline unsigned long *uv_global_mmr32_address(int pnode, unsigned long offset)
558bb898558SAl Viro {
559bb898558SAl Viro 	return __va(UV_GLOBAL_MMR32_BASE |
560bb898558SAl Viro 		       UV_GLOBAL_MMR32_PNODE_BITS(pnode) | offset);
561bb898558SAl Viro }
562bb898558SAl Viro 
56339d30770SMike Travis static inline void uv_write_global_mmr32(int pnode, unsigned long offset, unsigned long val)
564bb898558SAl Viro {
5658dc579e8SJack Steiner 	writeq(val, uv_global_mmr32_address(pnode, offset));
566bb898558SAl Viro }
567bb898558SAl Viro 
56839d30770SMike Travis static inline unsigned long uv_read_global_mmr32(int pnode, unsigned long offset)
569bb898558SAl Viro {
5708dc579e8SJack Steiner 	return readq(uv_global_mmr32_address(pnode, offset));
571bb898558SAl Viro }
572bb898558SAl Viro 
573bb898558SAl Viro /*
574bb898558SAl Viro  * Access Global MMR space using the MMR space located at the top of physical
575bb898558SAl Viro  * memory.
576bb898558SAl Viro  */
577a289cc7cSRandy Dunlap static inline volatile void __iomem *uv_global_mmr64_address(int pnode, unsigned long offset)
578bb898558SAl Viro {
579bb898558SAl Viro 	return __va(UV_GLOBAL_MMR64_BASE |
580bb898558SAl Viro 		    UV_GLOBAL_MMR64_PNODE_BITS(pnode) | offset);
581bb898558SAl Viro }
582bb898558SAl Viro 
58339d30770SMike Travis static inline void uv_write_global_mmr64(int pnode, unsigned long offset, unsigned long val)
584bb898558SAl Viro {
5858dc579e8SJack Steiner 	writeq(val, uv_global_mmr64_address(pnode, offset));
586bb898558SAl Viro }
587bb898558SAl Viro 
58839d30770SMike Travis static inline unsigned long uv_read_global_mmr64(int pnode, unsigned long offset)
589bb898558SAl Viro {
5908dc579e8SJack Steiner 	return readq(uv_global_mmr64_address(pnode, offset));
591bb898558SAl Viro }
592bb898558SAl Viro 
59339d30770SMike Travis static inline void uv_write_global_mmr8(int pnode, unsigned long offset, unsigned char val)
59439d30770SMike Travis {
59539d30770SMike Travis 	writeb(val, uv_global_mmr64_address(pnode, offset));
59639d30770SMike Travis }
59739d30770SMike Travis 
59839d30770SMike Travis static inline unsigned char uv_read_global_mmr8(int pnode, unsigned long offset)
59939d30770SMike Travis {
60039d30770SMike Travis 	return readb(uv_global_mmr64_address(pnode, offset));
60139d30770SMike Travis }
60239d30770SMike Travis 
60356abcf24SJack Steiner /*
604bb898558SAl Viro  * Access hub local MMRs. Faster than using global space but only local MMRs
605bb898558SAl Viro  * are accessible.
606bb898558SAl Viro  */
607bb898558SAl Viro static inline unsigned long *uv_local_mmr_address(unsigned long offset)
608bb898558SAl Viro {
609bb898558SAl Viro 	return __va(UV_LOCAL_MMR_BASE | offset);
610bb898558SAl Viro }
611bb898558SAl Viro 
612bb898558SAl Viro static inline unsigned long uv_read_local_mmr(unsigned long offset)
613bb898558SAl Viro {
6148dc579e8SJack Steiner 	return readq(uv_local_mmr_address(offset));
615bb898558SAl Viro }
616bb898558SAl Viro 
617bb898558SAl Viro static inline void uv_write_local_mmr(unsigned long offset, unsigned long val)
618bb898558SAl Viro {
6198dc579e8SJack Steiner 	writeq(val, uv_local_mmr_address(offset));
620bb898558SAl Viro }
621bb898558SAl Viro 
6227f1baa06SMike Travis static inline unsigned char uv_read_local_mmr8(unsigned long offset)
6237f1baa06SMike Travis {
6248dc579e8SJack Steiner 	return readb(uv_local_mmr_address(offset));
6257f1baa06SMike Travis }
6267f1baa06SMike Travis 
6277f1baa06SMike Travis static inline void uv_write_local_mmr8(unsigned long offset, unsigned char val)
6287f1baa06SMike Travis {
6298dc579e8SJack Steiner 	writeb(val, uv_local_mmr_address(offset));
6307f1baa06SMike Travis }
6317f1baa06SMike Travis 
632bb898558SAl Viro /* Blade-local cpu number of current cpu. Numbered 0 .. <# cpus on the blade> */
633bb898558SAl Viro static inline int uv_blade_processor_id(void)
634bb898558SAl Viro {
6355627a825SMike Travis 	return uv_cpu_info->blade_cpu_id;
636bb898558SAl Viro }
637bb898558SAl Viro 
6385627a825SMike Travis /* Blade-local cpu number of cpu N. Numbered 0 .. <# cpus on the blade> */
6395627a825SMike Travis static inline int uv_cpu_blade_processor_id(int cpu)
6405627a825SMike Travis {
6415627a825SMike Travis 	return uv_cpu_info_per(cpu)->blade_cpu_id;
6425627a825SMike Travis }
6435627a825SMike Travis 
6449b9ee172Ssteve.wahl@hpe.com /* Blade number to Node number (UV2..UV4 is 1:1) */
645906f3b20SMike Travis static inline int uv_blade_to_node(int blade)
646906f3b20SMike Travis {
647906f3b20SMike Travis 	return blade;
648906f3b20SMike Travis }
649906f3b20SMike Travis 
650bb898558SAl Viro /* Blade number of current cpu. Numnbered 0 .. <#blades -1> */
651bb898558SAl Viro static inline int uv_numa_blade_id(void)
652bb898558SAl Viro {
653bb898558SAl Viro 	return uv_hub_info->numa_blade_id;
654bb898558SAl Viro }
655bb898558SAl Viro 
656906f3b20SMike Travis /*
657906f3b20SMike Travis  * Convert linux node number to the UV blade number.
6589b9ee172Ssteve.wahl@hpe.com  * .. Currently for UV2 thru UV4 the node and the blade are identical.
659906f3b20SMike Travis  * .. If this changes then you MUST check references to this function!
660906f3b20SMike Travis  */
661906f3b20SMike Travis static inline int uv_node_to_blade_id(int nid)
662906f3b20SMike Travis {
663906f3b20SMike Travis 	return nid;
664906f3b20SMike Travis }
665906f3b20SMike Travis 
666de0038bfSRandy Dunlap /* Convert a CPU number to the UV blade number */
667bb898558SAl Viro static inline int uv_cpu_to_blade_id(int cpu)
668bb898558SAl Viro {
669906f3b20SMike Travis 	return uv_node_to_blade_id(cpu_to_node(cpu));
670bb898558SAl Viro }
671bb898558SAl Viro 
672bb898558SAl Viro /* Convert a blade id to the PNODE of the blade */
673bb898558SAl Viro static inline int uv_blade_to_pnode(int bid)
674bb898558SAl Viro {
675906f3b20SMike Travis 	return uv_hub_info_list(uv_blade_to_node(bid))->pnode;
676bb898558SAl Viro }
677bb898558SAl Viro 
6786c7184b7SJack Steiner /* Nid of memory node on blade. -1 if no blade-local memory */
6796c7184b7SJack Steiner static inline int uv_blade_to_memory_nid(int bid)
6806c7184b7SJack Steiner {
681906f3b20SMike Travis 	return uv_hub_info_list(uv_blade_to_node(bid))->memory_nid;
6826c7184b7SJack Steiner }
6836c7184b7SJack Steiner 
684bb898558SAl Viro /* Determine the number of possible cpus on a blade */
685bb898558SAl Viro static inline int uv_blade_nr_possible_cpus(int bid)
686bb898558SAl Viro {
687906f3b20SMike Travis 	return uv_hub_info_list(uv_blade_to_node(bid))->nr_possible_cpus;
688bb898558SAl Viro }
689bb898558SAl Viro 
690bb898558SAl Viro /* Determine the number of online cpus on a blade */
691bb898558SAl Viro static inline int uv_blade_nr_online_cpus(int bid)
692bb898558SAl Viro {
693906f3b20SMike Travis 	return uv_hub_info_list(uv_blade_to_node(bid))->nr_online_cpus;
694bb898558SAl Viro }
695bb898558SAl Viro 
696bb898558SAl Viro /* Convert a cpu id to the PNODE of the blade containing the cpu */
697bb898558SAl Viro static inline int uv_cpu_to_pnode(int cpu)
698bb898558SAl Viro {
699906f3b20SMike Travis 	return uv_cpu_hub_info(cpu)->pnode;
700bb898558SAl Viro }
701bb898558SAl Viro 
702bb898558SAl Viro /* Convert a linux node number to the PNODE of the blade */
703bb898558SAl Viro static inline int uv_node_to_pnode(int nid)
704bb898558SAl Viro {
705906f3b20SMike Travis 	return uv_hub_info_list(nid)->pnode;
706bb898558SAl Viro }
707bb898558SAl Viro 
708bb898558SAl Viro /* Maximum possible number of blades */
709906f3b20SMike Travis extern short uv_possible_blades;
710bb898558SAl Viro static inline int uv_num_possible_blades(void)
711bb898558SAl Viro {
712bb898558SAl Viro 	return uv_possible_blades;
713bb898558SAl Viro }
714bb898558SAl Viro 
7150d12ef0cSMike Travis /* Per Hub NMI support */
7160d12ef0cSMike Travis extern void uv_nmi_setup(void);
717abdf1df6Stravis@sgi.com extern void uv_nmi_setup_hubless(void);
7180d12ef0cSMike Travis 
71997d21003Smike.travis@hpe.com /* BIOS/Kernel flags exchange MMR */
72097d21003Smike.travis@hpe.com #define UVH_BIOS_KERNEL_MMR		UVH_SCRATCH5
72197d21003Smike.travis@hpe.com #define UVH_BIOS_KERNEL_MMR_ALIAS	UVH_SCRATCH5_ALIAS
72297d21003Smike.travis@hpe.com #define UVH_BIOS_KERNEL_MMR_ALIAS_2	UVH_SCRATCH5_ALIAS_2
72397d21003Smike.travis@hpe.com 
72497d21003Smike.travis@hpe.com /* TSC sync valid, set by BIOS */
72597d21003Smike.travis@hpe.com #define UVH_TSC_SYNC_MMR	UVH_BIOS_KERNEL_MMR
72697d21003Smike.travis@hpe.com #define UVH_TSC_SYNC_SHIFT	10
72797d21003Smike.travis@hpe.com #define UVH_TSC_SYNC_SHIFT_UV2K	16	/* UV2/3k have different bits */
72897d21003Smike.travis@hpe.com #define UVH_TSC_SYNC_MASK	3	/* 0011 */
72997d21003Smike.travis@hpe.com #define UVH_TSC_SYNC_VALID	3	/* 0011 */
7306a7cf55eSMike Travis #define UVH_TSC_SYNC_UNKNOWN	0	/* 0000 */
73197d21003Smike.travis@hpe.com 
7320d12ef0cSMike Travis /* BMC sets a bit this MMR non-zero before sending an NMI */
73397d21003Smike.travis@hpe.com #define UVH_NMI_MMR		UVH_BIOS_KERNEL_MMR
73497d21003Smike.travis@hpe.com #define UVH_NMI_MMR_CLEAR	UVH_BIOS_KERNEL_MMR_ALIAS
7350d12ef0cSMike Travis #define UVH_NMI_MMR_SHIFT	63
7360d12ef0cSMike Travis #define UVH_NMI_MMR_TYPE	"SCRATCH5"
7370d12ef0cSMike Travis 
7380d12ef0cSMike Travis struct uv_hub_nmi_s {
7390d12ef0cSMike Travis 	raw_spinlock_t	nmi_lock;
7400d12ef0cSMike Travis 	atomic_t	in_nmi;		/* flag this node in UV NMI IRQ */
7410d12ef0cSMike Travis 	atomic_t	cpu_owner;	/* last locker of this struct */
7420d12ef0cSMike Travis 	atomic_t	read_mmr_count;	/* count of MMR reads */
7430d12ef0cSMike Travis 	atomic_t	nmi_count;	/* count of true UV NMIs */
7440d12ef0cSMike Travis 	unsigned long	nmi_value;	/* last value read from NMI MMR */
745abdf1df6Stravis@sgi.com 	bool		hub_present;	/* false means UV hubless system */
746abdf1df6Stravis@sgi.com 	bool		pch_owner;	/* indicates this hub owns PCH */
7470d12ef0cSMike Travis };
7480d12ef0cSMike Travis 
7490d12ef0cSMike Travis struct uv_cpu_nmi_s {
7500d12ef0cSMike Travis 	struct uv_hub_nmi_s	*hub;
751e1632170SChristoph Lameter 	int			state;
752e1632170SChristoph Lameter 	int			pinging;
7530d12ef0cSMike Travis 	int			queries;
7540d12ef0cSMike Travis 	int			pings;
7550d12ef0cSMike Travis };
7560d12ef0cSMike Travis 
757e1632170SChristoph Lameter DECLARE_PER_CPU(struct uv_cpu_nmi_s, uv_cpu_nmi);
758e1632170SChristoph Lameter 
7597c52198bSGeorge Beshers #define uv_hub_nmi			this_cpu_read(uv_cpu_nmi.hub)
760e1632170SChristoph Lameter #define uv_cpu_nmi_per(cpu)		(per_cpu(uv_cpu_nmi, cpu))
7610d12ef0cSMike Travis #define uv_hub_nmi_per(cpu)		(uv_cpu_nmi_per(cpu).hub)
7620d12ef0cSMike Travis 
7630d12ef0cSMike Travis /* uv_cpu_nmi_states */
7640d12ef0cSMike Travis #define	UV_NMI_STATE_OUT		0
7650d12ef0cSMike Travis #define	UV_NMI_STATE_IN			1
7660d12ef0cSMike Travis #define	UV_NMI_STATE_DUMP		2
7670d12ef0cSMike Travis #define	UV_NMI_STATE_DUMP_DONE		3
7680d12ef0cSMike Travis 
7697a1110e8SJack Steiner /*
7707a1110e8SJack Steiner  * Get the minimum revision number of the hub chips within the partition.
771eb1e3461SMike Travis  * (See UVx_HUB_REVISION_BASE above for specific values.)
7727a1110e8SJack Steiner  */
7737a1110e8SJack Steiner static inline int uv_get_min_hub_revision_id(void)
7747a1110e8SJack Steiner {
7752a919596SJack Steiner 	return uv_hub_info->hub_revision;
7767a1110e8SJack Steiner }
7777a1110e8SJack Steiner 
778bc5d9940SJack Steiner #endif /* CONFIG_X86_64 */
7797f1baa06SMike Travis #endif /* _ASM_X86_UV_UV_HUB_H */
780