blob: 02a858eddd8d44ff1a9c9c6257e5d12077aaf9d4 [file] [log] [blame]
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
Dean Nelson45d9ca42008-04-22 14:46:56 -05006 * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved.
Dean Nelson89eb8eb2005-03-23 19:50:00 -07007 */
8
Dean Nelson89eb8eb2005-03-23 19:50:00 -07009/*
10 * Cross Partition Communication (XPC) partition support.
11 *
12 * This is the part of XPC that detects the presence/absence of
13 * other partitions. It provides a heartbeat and monitors the
14 * heartbeats of other partitions.
15 *
16 */
17
Dean Nelson89eb8eb2005-03-23 19:50:00 -070018#include <linux/kernel.h>
19#include <linux/sysctl.h>
20#include <linux/cache.h>
21#include <linux/mmzone.h>
22#include <linux/nodemask.h>
Jes Sorensen65ed0b32005-06-21 17:15:03 -070023#include <asm/uncached.h>
Dean Nelson89eb8eb2005-03-23 19:50:00 -070024#include <asm/sn/bte.h>
25#include <asm/sn/intr.h>
26#include <asm/sn/sn_sal.h>
27#include <asm/sn/nodepda.h>
28#include <asm/sn/addrs.h>
Dean Nelson45d9ca42008-04-22 14:46:56 -050029#include "xpc.h"
Dean Nelson89eb8eb2005-03-23 19:50:00 -070030
Dean Nelson89eb8eb2005-03-23 19:50:00 -070031/* XPC is exiting flag */
32int xpc_exiting;
33
Dean Nelson89eb8eb2005-03-23 19:50:00 -070034/* SH_IPI_ACCESS shub register value on startup */
35static u64 xpc_sh1_IPI_access;
36static u64 xpc_sh2_IPI_access0;
37static u64 xpc_sh2_IPI_access1;
38static u64 xpc_sh2_IPI_access2;
39static u64 xpc_sh2_IPI_access3;
40
Dean Nelson89eb8eb2005-03-23 19:50:00 -070041/* original protection values for each node */
Jack Steiner24ee0a62005-09-12 12:15:43 -050042u64 xpc_prot_vec[MAX_NUMNODES];
Dean Nelson89eb8eb2005-03-23 19:50:00 -070043
Dean Nelson4b38fcd2005-10-25 14:09:51 -050044/* this partition's reserved page pointers */
Dean Nelson89eb8eb2005-03-23 19:50:00 -070045struct xpc_rsvd_page *xpc_rsvd_page;
Dean Nelson4b38fcd2005-10-25 14:09:51 -050046static u64 *xpc_part_nasids;
47static u64 *xpc_mach_nasids;
Dean Nelson89eb8eb2005-03-23 19:50:00 -070048struct xpc_vars *xpc_vars;
49struct xpc_vars_part *xpc_vars_part;
50
Dean Nelson4b38fcd2005-10-25 14:09:51 -050051static int xp_nasid_mask_bytes; /* actual size in bytes of nasid mask */
52static int xp_nasid_mask_words; /* actual size in words of nasid mask */
53
Dean Nelsonbc63d382008-07-29 22:34:04 -070054struct xpc_partition *xpc_partitions;
Dean Nelson89eb8eb2005-03-23 19:50:00 -070055
Dean Nelson89eb8eb2005-03-23 19:50:00 -070056/*
Dean Nelson4b38fcd2005-10-25 14:09:51 -050057 * Generic buffer used to store a local copy of portions of a remote
58 * partition's reserved page (either its header and part_nasids mask,
59 * or its vars).
Dean Nelson89eb8eb2005-03-23 19:50:00 -070060 */
Dean Nelson7682a4c2006-08-08 15:03:29 -050061char *xpc_remote_copy_buffer;
62void *xpc_remote_copy_buffer_base;
Dean Nelson89eb8eb2005-03-23 19:50:00 -070063
Dean Nelson89eb8eb2005-03-23 19:50:00 -070064/*
Jes Sorensen7aa6ba42006-02-17 05:18:43 -050065 * Guarantee that the kmalloc'd memory is cacheline aligned.
66 */
Dean Nelson7682a4c2006-08-08 15:03:29 -050067void *
Jes Sorensen7aa6ba42006-02-17 05:18:43 -050068xpc_kmalloc_cacheline_aligned(size_t size, gfp_t flags, void **base)
69{
70 /* see if kmalloc will give us cachline aligned memory by default */
71 *base = kmalloc(size, flags);
Dean Nelson2c2b94f2008-04-22 14:50:17 -050072 if (*base == NULL)
Jes Sorensen7aa6ba42006-02-17 05:18:43 -050073 return NULL;
Dean Nelson2c2b94f2008-04-22 14:50:17 -050074
75 if ((u64)*base == L1_CACHE_ALIGN((u64)*base))
Jes Sorensen7aa6ba42006-02-17 05:18:43 -050076 return *base;
Dean Nelson2c2b94f2008-04-22 14:50:17 -050077
Jes Sorensen7aa6ba42006-02-17 05:18:43 -050078 kfree(*base);
79
80 /* nope, we'll have to do it ourselves */
81 *base = kmalloc(size + L1_CACHE_BYTES, flags);
Dean Nelson2c2b94f2008-04-22 14:50:17 -050082 if (*base == NULL)
Jes Sorensen7aa6ba42006-02-17 05:18:43 -050083 return NULL;
Dean Nelson2c2b94f2008-04-22 14:50:17 -050084
Dean Nelson4a3ad2d2008-04-22 14:48:01 -050085 return (void *)L1_CACHE_ALIGN((u64)*base);
Jes Sorensen7aa6ba42006-02-17 05:18:43 -050086}
87
Jes Sorensen7aa6ba42006-02-17 05:18:43 -050088/*
Dean Nelson89eb8eb2005-03-23 19:50:00 -070089 * Given a nasid, get the physical address of the partition's reserved page
90 * for that nasid. This function returns 0 on any error.
91 */
92static u64
Dean Nelson27929022005-10-25 14:11:53 -050093xpc_get_rsvd_page_pa(int nasid)
Dean Nelson89eb8eb2005-03-23 19:50:00 -070094{
95 bte_result_t bte_res;
96 s64 status;
97 u64 cookie = 0;
98 u64 rp_pa = nasid; /* seed with nasid */
99 u64 len = 0;
Dean Nelson27929022005-10-25 14:11:53 -0500100 u64 buf = buf;
101 u64 buf_len = 0;
102 void *buf_base = NULL;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700103
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700104 while (1) {
105
106 status = sn_partition_reserved_page_pa(buf, &cookie, &rp_pa,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500107 &len);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700108
109 dev_dbg(xpc_part, "SAL returned with status=%li, cookie="
110 "0x%016lx, address=0x%016lx, len=0x%016lx\n",
111 status, cookie, rp_pa, len);
112
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500113 if (status != SALRET_MORE_PASSES)
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700114 break;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700115
Dean Nelson27929022005-10-25 14:11:53 -0500116 if (L1_CACHE_ALIGN(len) > buf_len) {
Jesper Juhlcbf283c2006-04-20 10:11:09 -0700117 kfree(buf_base);
Dean Nelson27929022005-10-25 14:11:53 -0500118 buf_len = L1_CACHE_ALIGN(len);
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500119 buf = (u64)xpc_kmalloc_cacheline_aligned(buf_len,
120 GFP_KERNEL,
121 &buf_base);
Dean Nelson27929022005-10-25 14:11:53 -0500122 if (buf_base == NULL) {
123 dev_err(xpc_part, "unable to kmalloc "
124 "len=0x%016lx\n", buf_len);
125 status = SALRET_ERROR;
126 break;
127 }
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700128 }
129
Dean Nelson7682a4c2006-08-08 15:03:29 -0500130 bte_res = xp_bte_copy(rp_pa, buf, buf_len,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500131 (BTE_NOTIFY | BTE_WACQUIRE), NULL);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700132 if (bte_res != BTE_SUCCESS) {
133 dev_dbg(xpc_part, "xp_bte_copy failed %i\n", bte_res);
134 status = SALRET_ERROR;
135 break;
136 }
137 }
138
Jesper Juhlcbf283c2006-04-20 10:11:09 -0700139 kfree(buf_base);
Dean Nelson27929022005-10-25 14:11:53 -0500140
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500141 if (status != SALRET_OK)
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700142 rp_pa = 0;
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500143
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700144 dev_dbg(xpc_part, "reserved page at phys address 0x%016lx\n", rp_pa);
145 return rp_pa;
146}
147
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700148/*
149 * Fill the partition reserved page with the information needed by
150 * other partitions to discover we are alive and establish initial
151 * communications.
152 */
153struct xpc_rsvd_page *
154xpc_rsvd_page_init(void)
155{
156 struct xpc_rsvd_page *rp;
157 AMO_t *amos_page;
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500158 u64 rp_pa, nasid_array = 0;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700159 int i, ret;
160
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700161 /* get the local reserved page's address */
162
Dean Nelson27929022005-10-25 14:11:53 -0500163 preempt_disable();
164 rp_pa = xpc_get_rsvd_page_pa(cpuid_to_nasid(smp_processor_id()));
165 preempt_enable();
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700166 if (rp_pa == 0) {
167 dev_err(xpc_part, "SAL failed to locate the reserved page\n");
168 return NULL;
169 }
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500170 rp = (struct xpc_rsvd_page *)__va(rp_pa);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700171
172 if (rp->partid != sn_partition_id) {
173 dev_err(xpc_part, "the reserved page's partid of %d should be "
174 "%d\n", rp->partid, sn_partition_id);
175 return NULL;
176 }
177
178 rp->version = XPC_RP_VERSION;
179
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500180 /* establish the actual sizes of the nasid masks */
181 if (rp->SAL_version == 1) {
182 /* SAL_version 1 didn't set the nasids_size field */
183 rp->nasids_size = 128;
184 }
185 xp_nasid_mask_bytes = rp->nasids_size;
186 xp_nasid_mask_words = xp_nasid_mask_bytes / 8;
187
188 /* setup the pointers to the various items in the reserved page */
189 xpc_part_nasids = XPC_RP_PART_NASIDS(rp);
190 xpc_mach_nasids = XPC_RP_MACH_NASIDS(rp);
191 xpc_vars = XPC_RP_VARS(rp);
192 xpc_vars_part = XPC_RP_VARS_PART(rp);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700193
194 /*
195 * Before clearing xpc_vars, see if a page of AMOs had been previously
196 * allocated. If not we'll need to allocate one and set permissions
197 * so that cross-partition AMOs are allowed.
198 *
199 * The allocated AMO page needs MCA reporting to remain disabled after
200 * XPC has unloaded. To make this work, we keep a copy of the pointer
201 * to this page (i.e., amos_page) in the struct xpc_vars structure,
202 * which is pointed to by the reserved page, and re-use that saved copy
203 * on subsequent loads of XPC. This AMO page is never freed, and its
204 * memory protections are never restricted.
205 */
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500206 amos_page = xpc_vars->amos_page;
207 if (amos_page == NULL) {
Dean Nelsone4a064d2008-04-25 15:22:19 -0500208 amos_page = (AMO_t *)TO_AMO(uncached_alloc_page(0, 1));
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700209 if (amos_page == NULL) {
210 dev_err(xpc_part, "can't allocate page of AMOs\n");
211 return NULL;
212 }
213
214 /*
215 * Open up AMO-R/W to cpu. This is done for Shub 1.1 systems
216 * when xpc_allow_IPI_ops() is called via xpc_hb_init().
217 */
218 if (!enable_shub_wars_1_1()) {
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500219 ret = sn_change_memprotect(ia64_tpa((u64)amos_page),
220 PAGE_SIZE,
221 SN_MEMPROT_ACCESS_CLASS_1,
222 &nasid_array);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700223 if (ret != 0) {
224 dev_err(xpc_part, "can't change memory "
225 "protections\n");
Jes Sorensen65ed0b32005-06-21 17:15:03 -0700226 uncached_free_page(__IA64_UNCACHED_OFFSET |
Dean Nelsone4a064d2008-04-25 15:22:19 -0500227 TO_PHYS((u64)amos_page), 1);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700228 return NULL;
229 }
230 }
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500231 } else if (!IS_AMO_ADDRESS((u64)amos_page)) {
Dean Nelson3a7d5552005-04-04 13:14:00 -0700232 /*
233 * EFI's XPBOOT can also set amos_page in the reserved page,
234 * but it happens to leave it as an uncached physical address
235 * and we need it to be an uncached virtual, so we'll have to
236 * convert it.
237 */
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500238 if (!IS_AMO_PHYS_ADDRESS((u64)amos_page)) {
Dean Nelson3a7d5552005-04-04 13:14:00 -0700239 dev_err(xpc_part, "previously used amos_page address "
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500240 "is bad = 0x%p\n", (void *)amos_page);
Dean Nelson3a7d5552005-04-04 13:14:00 -0700241 return NULL;
242 }
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500243 amos_page = (AMO_t *)TO_AMO((u64)amos_page);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700244 }
245
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500246 /* clear xpc_vars */
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700247 memset(xpc_vars, 0, sizeof(struct xpc_vars));
248
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700249 xpc_vars->version = XPC_V_VERSION;
250 xpc_vars->act_nasid = cpuid_to_nasid(0);
251 xpc_vars->act_phys_cpuid = cpu_physical_id(0);
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500252 xpc_vars->vars_part_pa = __pa(xpc_vars_part);
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500253 xpc_vars->amos_page_pa = ia64_tpa((u64)amos_page);
254 xpc_vars->amos_page = amos_page; /* save for next load of XPC */
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700255
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500256 /* clear xpc_vars_part */
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500257 memset((u64 *)xpc_vars_part, 0, sizeof(struct xpc_vars_part) *
Dean Nelsonbc63d382008-07-29 22:34:04 -0700258 xp_max_npartitions);
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500259
Dean Nelsona607c382005-09-01 14:01:37 -0500260 /* initialize the activate IRQ related AMO variables */
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500261 for (i = 0; i < xp_nasid_mask_words; i++)
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500262 (void)xpc_IPI_init(XPC_ACTIVATE_IRQ_AMOS + i);
Dean Nelsona607c382005-09-01 14:01:37 -0500263
264 /* initialize the engaged remote partitions related AMO variables */
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500265 (void)xpc_IPI_init(XPC_ENGAGED_PARTITIONS_AMO);
266 (void)xpc_IPI_init(XPC_DISENGAGE_REQUEST_AMO);
Dean Nelsona607c382005-09-01 14:01:37 -0500267
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500268 /* timestamp of when reserved page was setup by XPC */
Dean Nelsona607c382005-09-01 14:01:37 -0500269 rp->stamp = CURRENT_TIME;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700270
271 /*
272 * This signifies to the remote partition that our reserved
273 * page is initialized.
274 */
Dave Jones821fe942005-06-25 14:54:29 -0700275 rp->vars_pa = __pa(xpc_vars);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700276
277 return rp;
278}
279
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700280/*
281 * Change protections to allow IPI operations (and AMO operations on
282 * Shub 1.1 systems).
283 */
284void
285xpc_allow_IPI_ops(void)
286{
287 int node;
288 int nasid;
289
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500290 /* >>> Change SH_IPI_ACCESS code to use SAL call once it is available */
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700291
292 if (is_shub2()) {
293 xpc_sh2_IPI_access0 =
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500294 (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS0));
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700295 xpc_sh2_IPI_access1 =
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500296 (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS1));
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700297 xpc_sh2_IPI_access2 =
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500298 (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS2));
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700299 xpc_sh2_IPI_access3 =
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500300 (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS3));
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700301
302 for_each_online_node(node) {
303 nasid = cnodeid_to_nasid(node);
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500304 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS0),
305 -1UL);
306 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS1),
307 -1UL);
308 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS2),
309 -1UL);
310 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS3),
311 -1UL);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700312 }
313
314 } else {
315 xpc_sh1_IPI_access =
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500316 (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH1_IPI_ACCESS));
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700317
318 for_each_online_node(node) {
319 nasid = cnodeid_to_nasid(node);
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500320 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS),
321 -1UL);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700322
323 /*
324 * Since the BIST collides with memory operations on
325 * SHUB 1.1 sn_change_memprotect() cannot be used.
326 */
327 if (enable_shub_wars_1_1()) {
328 /* open up everything */
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500329 xpc_prot_vec[node] = (u64)HUB_L((u64 *)
330 GLOBAL_MMR_ADDR
331 (nasid,
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500332 SH1_MD_DQLP_MMR_DIR_PRIVEC0));
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500333 HUB_S((u64 *)
334 GLOBAL_MMR_ADDR(nasid,
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500335 SH1_MD_DQLP_MMR_DIR_PRIVEC0),
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500336 -1UL);
337 HUB_S((u64 *)
338 GLOBAL_MMR_ADDR(nasid,
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500339 SH1_MD_DQRP_MMR_DIR_PRIVEC0),
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500340 -1UL);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700341 }
342 }
343 }
344}
345
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700346/*
347 * Restrict protections to disallow IPI operations (and AMO operations on
348 * Shub 1.1 systems).
349 */
350void
351xpc_restrict_IPI_ops(void)
352{
353 int node;
354 int nasid;
355
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500356 /* >>> Change SH_IPI_ACCESS code to use SAL call once it is available */
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700357
358 if (is_shub2()) {
359
360 for_each_online_node(node) {
361 nasid = cnodeid_to_nasid(node);
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500362 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS0),
363 xpc_sh2_IPI_access0);
364 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS1),
365 xpc_sh2_IPI_access1);
366 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS2),
367 xpc_sh2_IPI_access2);
368 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS3),
369 xpc_sh2_IPI_access3);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700370 }
371
372 } else {
373
374 for_each_online_node(node) {
375 nasid = cnodeid_to_nasid(node);
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500376 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS),
377 xpc_sh1_IPI_access);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700378
379 if (enable_shub_wars_1_1()) {
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500380 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid,
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500381 SH1_MD_DQLP_MMR_DIR_PRIVEC0),
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500382 xpc_prot_vec[node]);
383 HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid,
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500384 SH1_MD_DQRP_MMR_DIR_PRIVEC0),
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500385 xpc_prot_vec[node]);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700386 }
387 }
388 }
389}
390
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700391/*
392 * At periodic intervals, scan through all active partitions and ensure
393 * their heartbeat is still active. If not, the partition is deactivated.
394 */
395void
396xpc_check_remote_hb(void)
397{
398 struct xpc_vars *remote_vars;
399 struct xpc_partition *part;
Dean Nelson64d032b2008-05-12 14:02:03 -0700400 short partid;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700401 bte_result_t bres;
402
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500403 remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700404
Dean Nelsonbc63d382008-07-29 22:34:04 -0700405 for (partid = 0; partid < xp_max_npartitions; partid++) {
Dean Nelsona607c382005-09-01 14:01:37 -0500406
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500407 if (xpc_exiting)
Dean Nelsona607c382005-09-01 14:01:37 -0500408 break;
Dean Nelsona607c382005-09-01 14:01:37 -0500409
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500410 if (partid == sn_partition_id)
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700411 continue;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700412
413 part = &xpc_partitions[partid];
414
415 if (part->act_state == XPC_P_INACTIVE ||
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500416 part->act_state == XPC_P_DEACTIVATING) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700417 continue;
418 }
419
420 /* pull the remote_hb cache line */
421 bres = xp_bte_copy(part->remote_vars_pa,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500422 (u64)remote_vars,
423 XPC_RP_VARS_SIZE,
424 (BTE_NOTIFY | BTE_WACQUIRE), NULL);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700425 if (bres != BTE_SUCCESS) {
426 XPC_DEACTIVATE_PARTITION(part,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500427 xpc_map_bte_errors(bres));
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700428 continue;
429 }
430
431 dev_dbg(xpc_part, "partid = %d, heartbeat = %ld, last_heartbeat"
Dean Nelson780d09e2005-11-09 14:41:57 -0600432 " = %ld, heartbeat_offline = %ld, HB_mask = 0x%lx\n",
433 partid, remote_vars->heartbeat, part->last_heartbeat,
434 remote_vars->heartbeat_offline,
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700435 remote_vars->heartbeating_to_mask);
436
437 if (((remote_vars->heartbeat == part->last_heartbeat) &&
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500438 (remote_vars->heartbeat_offline == 0)) ||
439 !xpc_hb_allowed(sn_partition_id, remote_vars)) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700440
Dean Nelson65c17b82008-05-12 14:02:02 -0700441 XPC_DEACTIVATE_PARTITION(part, xpNoHeartbeat);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700442 continue;
443 }
444
445 part->last_heartbeat = remote_vars->heartbeat;
446 }
447}
448
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700449/*
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500450 * Get a copy of a portion of the remote partition's rsvd page.
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700451 *
452 * remote_rp points to a buffer that is cacheline aligned for BTE copies and
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500453 * is large enough to contain a copy of their reserved page header and
454 * part_nasids mask.
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700455 */
Dean Nelson65c17b82008-05-12 14:02:02 -0700456static enum xp_retval
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700457xpc_get_remote_rp(int nasid, u64 *discovered_nasids,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500458 struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa)
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700459{
460 int bres, i;
461
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700462 /* get the reserved page's physical address */
463
Dean Nelson27929022005-10-25 14:11:53 -0500464 *remote_rp_pa = xpc_get_rsvd_page_pa(nasid);
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500465 if (*remote_rp_pa == 0)
Dean Nelson65c17b82008-05-12 14:02:02 -0700466 return xpNoRsvdPageAddr;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700467
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500468 /* pull over the reserved page header and part_nasids mask */
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500469 bres = xp_bte_copy(*remote_rp_pa, (u64)remote_rp,
470 XPC_RP_HEADER_SIZE + xp_nasid_mask_bytes,
471 (BTE_NOTIFY | BTE_WACQUIRE), NULL);
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500472 if (bres != BTE_SUCCESS)
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700473 return xpc_map_bte_errors(bres);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700474
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700475 if (discovered_nasids != NULL) {
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500476 u64 *remote_part_nasids = XPC_RP_PART_NASIDS(remote_rp);
477
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500478 for (i = 0; i < xp_nasid_mask_words; i++)
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500479 discovered_nasids[i] |= remote_part_nasids[i];
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700480 }
481
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700482 /* check that the partid is for another partition */
483
Dean Nelsonbc63d382008-07-29 22:34:04 -0700484 if (remote_rp->partid < 0 || remote_rp->partid >= xp_max_npartitions)
Dean Nelson65c17b82008-05-12 14:02:02 -0700485 return xpInvalidPartid;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700486
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500487 if (remote_rp->partid == sn_partition_id)
Dean Nelson65c17b82008-05-12 14:02:02 -0700488 return xpLocalPartid;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700489
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700490 if (XPC_VERSION_MAJOR(remote_rp->version) !=
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500491 XPC_VERSION_MAJOR(XPC_RP_VERSION)) {
Dean Nelson65c17b82008-05-12 14:02:02 -0700492 return xpBadVersion;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700493 }
494
Dean Nelson65c17b82008-05-12 14:02:02 -0700495 return xpSuccess;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700496}
497
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700498/*
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500499 * Get a copy of the remote partition's XPC variables from the reserved page.
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700500 *
501 * remote_vars points to a buffer that is cacheline aligned for BTE copies and
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500502 * assumed to be of size XPC_RP_VARS_SIZE.
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700503 */
Dean Nelson65c17b82008-05-12 14:02:02 -0700504static enum xp_retval
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700505xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars)
506{
507 int bres;
508
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500509 if (remote_vars_pa == 0)
Dean Nelson65c17b82008-05-12 14:02:02 -0700510 return xpVarsNotSet;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700511
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700512 /* pull over the cross partition variables */
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500513 bres = xp_bte_copy(remote_vars_pa, (u64)remote_vars, XPC_RP_VARS_SIZE,
514 (BTE_NOTIFY | BTE_WACQUIRE), NULL);
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500515 if (bres != BTE_SUCCESS)
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700516 return xpc_map_bte_errors(bres);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700517
518 if (XPC_VERSION_MAJOR(remote_vars->version) !=
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500519 XPC_VERSION_MAJOR(XPC_V_VERSION)) {
Dean Nelson65c17b82008-05-12 14:02:02 -0700520 return xpBadVersion;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700521 }
522
Dean Nelson65c17b82008-05-12 14:02:02 -0700523 return xpSuccess;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700524}
525
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700526/*
Dean Nelsona607c382005-09-01 14:01:37 -0500527 * Update the remote partition's info.
528 */
529static void
530xpc_update_partition_info(struct xpc_partition *part, u8 remote_rp_version,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500531 struct timespec *remote_rp_stamp, u64 remote_rp_pa,
532 u64 remote_vars_pa, struct xpc_vars *remote_vars)
Dean Nelsona607c382005-09-01 14:01:37 -0500533{
534 part->remote_rp_version = remote_rp_version;
Tony Luckb9ae3bd2007-05-10 11:47:38 -0700535 dev_dbg(xpc_part, " remote_rp_version = 0x%016x\n",
Dean Nelsona607c382005-09-01 14:01:37 -0500536 part->remote_rp_version);
537
538 part->remote_rp_stamp = *remote_rp_stamp;
539 dev_dbg(xpc_part, " remote_rp_stamp (tv_sec = 0x%lx tv_nsec = 0x%lx\n",
540 part->remote_rp_stamp.tv_sec, part->remote_rp_stamp.tv_nsec);
541
542 part->remote_rp_pa = remote_rp_pa;
543 dev_dbg(xpc_part, " remote_rp_pa = 0x%016lx\n", part->remote_rp_pa);
544
545 part->remote_vars_pa = remote_vars_pa;
546 dev_dbg(xpc_part, " remote_vars_pa = 0x%016lx\n",
547 part->remote_vars_pa);
548
549 part->last_heartbeat = remote_vars->heartbeat;
550 dev_dbg(xpc_part, " last_heartbeat = 0x%016lx\n",
551 part->last_heartbeat);
552
553 part->remote_vars_part_pa = remote_vars->vars_part_pa;
554 dev_dbg(xpc_part, " remote_vars_part_pa = 0x%016lx\n",
555 part->remote_vars_part_pa);
556
557 part->remote_act_nasid = remote_vars->act_nasid;
558 dev_dbg(xpc_part, " remote_act_nasid = 0x%x\n",
559 part->remote_act_nasid);
560
561 part->remote_act_phys_cpuid = remote_vars->act_phys_cpuid;
562 dev_dbg(xpc_part, " remote_act_phys_cpuid = 0x%x\n",
563 part->remote_act_phys_cpuid);
564
565 part->remote_amos_page_pa = remote_vars->amos_page_pa;
566 dev_dbg(xpc_part, " remote_amos_page_pa = 0x%lx\n",
567 part->remote_amos_page_pa);
568
569 part->remote_vars_version = remote_vars->version;
570 dev_dbg(xpc_part, " remote_vars_version = 0x%x\n",
571 part->remote_vars_version);
572}
573
Dean Nelsona607c382005-09-01 14:01:37 -0500574/*
Dean Nelsone54af722005-10-25 14:07:43 -0500575 * Prior code has determined the nasid which generated an IPI. Inspect
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700576 * that nasid to determine if its partition needs to be activated or
577 * deactivated.
578 *
579 * A partition is consider "awaiting activation" if our partition
580 * flags indicate it is not active and it has a heartbeat. A
581 * partition is considered "awaiting deactivation" if our partition
582 * flags indicate it is active but it has no heartbeat or it is not
583 * sending its heartbeat to us.
584 *
585 * To determine the heartbeat, the remote nasid must have a properly
586 * initialized reserved page.
587 */
588static void
589xpc_identify_act_IRQ_req(int nasid)
590{
591 struct xpc_rsvd_page *remote_rp;
592 struct xpc_vars *remote_vars;
Dean Nelsona607c382005-09-01 14:01:37 -0500593 u64 remote_rp_pa;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700594 u64 remote_vars_pa;
Dean Nelsona607c382005-09-01 14:01:37 -0500595 int remote_rp_version;
596 int reactivate = 0;
597 int stamp_diff;
598 struct timespec remote_rp_stamp = { 0, 0 };
Dean Nelson64d032b2008-05-12 14:02:03 -0700599 short partid;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700600 struct xpc_partition *part;
Dean Nelson65c17b82008-05-12 14:02:02 -0700601 enum xp_retval ret;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700602
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700603 /* pull over the reserved page structure */
604
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500605 remote_rp = (struct xpc_rsvd_page *)xpc_remote_copy_buffer;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700606
Dean Nelsona607c382005-09-01 14:01:37 -0500607 ret = xpc_get_remote_rp(nasid, NULL, remote_rp, &remote_rp_pa);
Dean Nelson65c17b82008-05-12 14:02:02 -0700608 if (ret != xpSuccess) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700609 dev_warn(xpc_part, "unable to get reserved page from nasid %d, "
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500610 "which sent interrupt, reason=%d\n", nasid, ret);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700611 return;
612 }
613
614 remote_vars_pa = remote_rp->vars_pa;
Dean Nelsona607c382005-09-01 14:01:37 -0500615 remote_rp_version = remote_rp->version;
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500616 if (XPC_SUPPORTS_RP_STAMP(remote_rp_version))
Dean Nelsona607c382005-09-01 14:01:37 -0500617 remote_rp_stamp = remote_rp->stamp;
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500618
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700619 partid = remote_rp->partid;
620 part = &xpc_partitions[partid];
621
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700622 /* pull over the cross partition variables */
623
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500624 remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700625
626 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars);
Dean Nelson65c17b82008-05-12 14:02:02 -0700627 if (ret != xpSuccess) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700628
629 dev_warn(xpc_part, "unable to get XPC variables from nasid %d, "
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500630 "which sent interrupt, reason=%d\n", nasid, ret);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700631
632 XPC_DEACTIVATE_PARTITION(part, ret);
633 return;
634 }
635
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700636 part->act_IRQ_rcvd++;
637
638 dev_dbg(xpc_part, "partid for nasid %d is %d; IRQs = %d; HB = "
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500639 "%ld:0x%lx\n", (int)nasid, (int)partid, part->act_IRQ_rcvd,
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700640 remote_vars->heartbeat, remote_vars->heartbeating_to_mask);
641
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500642 if (xpc_partition_disengaged(part) &&
643 part->act_state == XPC_P_INACTIVE) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700644
Dean Nelsona607c382005-09-01 14:01:37 -0500645 xpc_update_partition_info(part, remote_rp_version,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500646 &remote_rp_stamp, remote_rp_pa,
647 remote_vars_pa, remote_vars);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700648
Dean Nelsona607c382005-09-01 14:01:37 -0500649 if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)) {
650 if (xpc_partition_disengage_requested(1UL << partid)) {
651 /*
652 * Other side is waiting on us to disengage,
653 * even though we already have.
654 */
655 return;
656 }
657 } else {
658 /* other side doesn't support disengage requests */
659 xpc_clear_partition_disengage_request(1UL << partid);
660 }
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700661
662 xpc_activate_partition(part);
Dean Nelsona607c382005-09-01 14:01:37 -0500663 return;
664 }
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700665
Dean Nelsona607c382005-09-01 14:01:37 -0500666 DBUG_ON(part->remote_rp_version == 0);
667 DBUG_ON(part->remote_vars_version == 0);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700668
Dean Nelsona607c382005-09-01 14:01:37 -0500669 if (!XPC_SUPPORTS_RP_STAMP(part->remote_rp_version)) {
670 DBUG_ON(XPC_SUPPORTS_DISENGAGE_REQUEST(part->
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500671 remote_vars_version));
Dean Nelsona607c382005-09-01 14:01:37 -0500672
673 if (!XPC_SUPPORTS_RP_STAMP(remote_rp_version)) {
674 DBUG_ON(XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars->
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500675 version));
Dean Nelsona607c382005-09-01 14:01:37 -0500676 /* see if the other side rebooted */
677 if (part->remote_amos_page_pa ==
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500678 remote_vars->amos_page_pa &&
679 xpc_hb_allowed(sn_partition_id, remote_vars)) {
Dean Nelsona607c382005-09-01 14:01:37 -0500680 /* doesn't look that way, so ignore the IPI */
681 return;
682 }
683 }
684
685 /*
686 * Other side rebooted and previous XPC didn't support the
687 * disengage request, so we don't need to do anything special.
688 */
689
690 xpc_update_partition_info(part, remote_rp_version,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500691 &remote_rp_stamp, remote_rp_pa,
692 remote_vars_pa, remote_vars);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700693 part->reactivate_nasid = nasid;
Dean Nelson65c17b82008-05-12 14:02:02 -0700694 XPC_DEACTIVATE_PARTITION(part, xpReactivating);
Dean Nelsona607c382005-09-01 14:01:37 -0500695 return;
696 }
697
698 DBUG_ON(!XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version));
699
700 if (!XPC_SUPPORTS_RP_STAMP(remote_rp_version)) {
701 DBUG_ON(!XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars->version));
702
703 /*
704 * Other side rebooted and previous XPC did support the
705 * disengage request, but the new one doesn't.
706 */
707
708 xpc_clear_partition_engaged(1UL << partid);
709 xpc_clear_partition_disengage_request(1UL << partid);
710
711 xpc_update_partition_info(part, remote_rp_version,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500712 &remote_rp_stamp, remote_rp_pa,
713 remote_vars_pa, remote_vars);
Dean Nelsona607c382005-09-01 14:01:37 -0500714 reactivate = 1;
715
716 } else {
717 DBUG_ON(!XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars->version));
718
719 stamp_diff = xpc_compare_stamps(&part->remote_rp_stamp,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500720 &remote_rp_stamp);
Dean Nelsona607c382005-09-01 14:01:37 -0500721 if (stamp_diff != 0) {
722 DBUG_ON(stamp_diff >= 0);
723
724 /*
725 * Other side rebooted and the previous XPC did support
726 * the disengage request, as does the new one.
727 */
728
729 DBUG_ON(xpc_partition_engaged(1UL << partid));
730 DBUG_ON(xpc_partition_disengage_requested(1UL <<
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500731 partid));
Dean Nelsona607c382005-09-01 14:01:37 -0500732
733 xpc_update_partition_info(part, remote_rp_version,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500734 &remote_rp_stamp,
735 remote_rp_pa, remote_vars_pa,
736 remote_vars);
Dean Nelsona607c382005-09-01 14:01:37 -0500737 reactivate = 1;
738 }
739 }
740
Dean Nelson246c7e32005-12-22 14:32:56 -0600741 if (part->disengage_request_timeout > 0 &&
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500742 !xpc_partition_disengaged(part)) {
Dean Nelsona607c382005-09-01 14:01:37 -0500743 /* still waiting on other side to disengage from us */
744 return;
745 }
746
747 if (reactivate) {
748 part->reactivate_nasid = nasid;
Dean Nelson65c17b82008-05-12 14:02:02 -0700749 XPC_DEACTIVATE_PARTITION(part, xpReactivating);
Dean Nelsona607c382005-09-01 14:01:37 -0500750
751 } else if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version) &&
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500752 xpc_partition_disengage_requested(1UL << partid)) {
Dean Nelson65c17b82008-05-12 14:02:02 -0700753 XPC_DEACTIVATE_PARTITION(part, xpOtherGoingDown);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700754 }
755}
756
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700757/*
758 * Loop through the activation AMO variables and process any bits
759 * which are set. Each bit indicates a nasid sending a partition
760 * activation or deactivation request.
761 *
762 * Return #of IRQs detected.
763 */
764int
765xpc_identify_act_IRQ_sender(void)
766{
767 int word, bit;
768 u64 nasid_mask;
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500769 u64 nasid; /* remote nasid */
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700770 int n_IRQs_detected = 0;
771 AMO_t *act_amos;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700772
Dean Nelsona607c382005-09-01 14:01:37 -0500773 act_amos = xpc_vars->amos_page + XPC_ACTIVATE_IRQ_AMOS;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700774
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700775 /* scan through act AMO variable looking for non-zero entries */
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500776 for (word = 0; word < xp_nasid_mask_words; word++) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700777
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500778 if (xpc_exiting)
Dean Nelsona607c382005-09-01 14:01:37 -0500779 break;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700780
781 nasid_mask = xpc_IPI_receive(&act_amos[word]);
782 if (nasid_mask == 0) {
783 /* no IRQs from nasids in this variable */
784 continue;
785 }
786
787 dev_dbg(xpc_part, "AMO[%d] gave back 0x%lx\n", word,
788 nasid_mask);
789
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700790 /*
791 * If this nasid has been added to the machine since
792 * our partition was reset, this will retain the
793 * remote nasid in our reserved pages machine mask.
794 * This is used in the event of module reload.
795 */
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500796 xpc_mach_nasids[word] |= nasid_mask;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700797
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700798 /* locate the nasid(s) which sent interrupts */
799
800 for (bit = 0; bit < (8 * sizeof(u64)); bit++) {
801 if (nasid_mask & (1UL << bit)) {
802 n_IRQs_detected++;
803 nasid = XPC_NASID_FROM_W_B(word, bit);
804 dev_dbg(xpc_part, "interrupt from nasid %ld\n",
805 nasid);
806 xpc_identify_act_IRQ_req(nasid);
807 }
808 }
809 }
810 return n_IRQs_detected;
811}
812
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700813/*
Dean Nelsona607c382005-09-01 14:01:37 -0500814 * See if the other side has responded to a partition disengage request
815 * from us.
816 */
817int
818xpc_partition_disengaged(struct xpc_partition *part)
819{
Dean Nelson64d032b2008-05-12 14:02:03 -0700820 short partid = XPC_PARTID(part);
Dean Nelsona607c382005-09-01 14:01:37 -0500821 int disengaged;
822
Dean Nelsona607c382005-09-01 14:01:37 -0500823 disengaged = (xpc_partition_engaged(1UL << partid) == 0);
824 if (part->disengage_request_timeout) {
825 if (!disengaged) {
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500826 if (time_before(jiffies,
827 part->disengage_request_timeout)) {
Dean Nelsona607c382005-09-01 14:01:37 -0500828 /* timelimit hasn't been reached yet */
829 return 0;
830 }
831
832 /*
833 * Other side hasn't responded to our disengage
834 * request in a timely fashion, so assume it's dead.
835 */
836
Dean Nelson1ecaded2006-01-06 09:48:21 -0600837 dev_info(xpc_part, "disengage from remote partition %d "
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500838 "timed out\n", partid);
Dean Nelson1ecaded2006-01-06 09:48:21 -0600839 xpc_disengage_request_timedout = 1;
Dean Nelsona607c382005-09-01 14:01:37 -0500840 xpc_clear_partition_engaged(1UL << partid);
841 disengaged = 1;
842 }
843 part->disengage_request_timeout = 0;
844
845 /* cancel the timer function, provided it's not us */
846 if (!in_interrupt()) {
847 del_singleshot_timer_sync(&part->
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500848 disengage_request_timer);
Dean Nelsona607c382005-09-01 14:01:37 -0500849 }
850
851 DBUG_ON(part->act_state != XPC_P_DEACTIVATING &&
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500852 part->act_state != XPC_P_INACTIVE);
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500853 if (part->act_state != XPC_P_INACTIVE)
Dean Nelsona607c382005-09-01 14:01:37 -0500854 xpc_wakeup_channel_mgr(part);
Dean Nelsona607c382005-09-01 14:01:37 -0500855
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500856 if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version))
Dean Nelsona607c382005-09-01 14:01:37 -0500857 xpc_cancel_partition_disengage_request(part);
Dean Nelsona607c382005-09-01 14:01:37 -0500858 }
859 return disengaged;
860}
861
Dean Nelsona607c382005-09-01 14:01:37 -0500862/*
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700863 * Mark specified partition as active.
864 */
Dean Nelson65c17b82008-05-12 14:02:02 -0700865enum xp_retval
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700866xpc_mark_partition_active(struct xpc_partition *part)
867{
868 unsigned long irq_flags;
Dean Nelson65c17b82008-05-12 14:02:02 -0700869 enum xp_retval ret;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700870
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700871 dev_dbg(xpc_part, "setting partition %d to ACTIVE\n", XPC_PARTID(part));
872
873 spin_lock_irqsave(&part->act_lock, irq_flags);
874 if (part->act_state == XPC_P_ACTIVATING) {
875 part->act_state = XPC_P_ACTIVE;
Dean Nelson65c17b82008-05-12 14:02:02 -0700876 ret = xpSuccess;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700877 } else {
Dean Nelson65c17b82008-05-12 14:02:02 -0700878 DBUG_ON(part->reason == xpSuccess);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700879 ret = part->reason;
880 }
881 spin_unlock_irqrestore(&part->act_lock, irq_flags);
882
883 return ret;
884}
885
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700886/*
887 * Notify XPC that the partition is down.
888 */
889void
890xpc_deactivate_partition(const int line, struct xpc_partition *part,
Dean Nelson65c17b82008-05-12 14:02:02 -0700891 enum xp_retval reason)
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700892{
893 unsigned long irq_flags;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700894
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700895 spin_lock_irqsave(&part->act_lock, irq_flags);
896
897 if (part->act_state == XPC_P_INACTIVE) {
898 XPC_SET_REASON(part, reason, line);
899 spin_unlock_irqrestore(&part->act_lock, irq_flags);
Dean Nelson65c17b82008-05-12 14:02:02 -0700900 if (reason == xpReactivating) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700901 /* we interrupt ourselves to reactivate partition */
902 xpc_IPI_send_reactivate(part);
903 }
904 return;
905 }
906 if (part->act_state == XPC_P_DEACTIVATING) {
Dean Nelson65c17b82008-05-12 14:02:02 -0700907 if ((part->reason == xpUnloading && reason != xpUnloading) ||
908 reason == xpReactivating) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700909 XPC_SET_REASON(part, reason, line);
910 }
911 spin_unlock_irqrestore(&part->act_lock, irq_flags);
912 return;
913 }
914
915 part->act_state = XPC_P_DEACTIVATING;
916 XPC_SET_REASON(part, reason, line);
917
918 spin_unlock_irqrestore(&part->act_lock, irq_flags);
919
Dean Nelsona607c382005-09-01 14:01:37 -0500920 if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)) {
921 xpc_request_partition_disengage(part);
922 xpc_IPI_send_disengage(part);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700923
Dean Nelsona607c382005-09-01 14:01:37 -0500924 /* set a timelimit on the disengage request */
925 part->disengage_request_timeout = jiffies +
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500926 (xpc_disengage_request_timelimit * HZ);
Dean Nelsona607c382005-09-01 14:01:37 -0500927 part->disengage_request_timer.expires =
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500928 part->disengage_request_timeout;
Dean Nelsona607c382005-09-01 14:01:37 -0500929 add_timer(&part->disengage_request_timer);
930 }
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700931
Dean Nelsone54af722005-10-25 14:07:43 -0500932 dev_dbg(xpc_part, "bringing partition %d down, reason = %d\n",
933 XPC_PARTID(part), reason);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700934
Dean Nelsona607c382005-09-01 14:01:37 -0500935 xpc_partition_going_down(part, reason);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700936}
937
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700938/*
Dean Nelsona607c382005-09-01 14:01:37 -0500939 * Mark specified partition as inactive.
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700940 */
941void
942xpc_mark_partition_inactive(struct xpc_partition *part)
943{
944 unsigned long irq_flags;
945
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700946 dev_dbg(xpc_part, "setting partition %d to INACTIVE\n",
947 XPC_PARTID(part));
948
949 spin_lock_irqsave(&part->act_lock, irq_flags);
950 part->act_state = XPC_P_INACTIVE;
951 spin_unlock_irqrestore(&part->act_lock, irq_flags);
952 part->remote_rp_pa = 0;
953}
954
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700955/*
956 * SAL has provided a partition and machine mask. The partition mask
957 * contains a bit for each even nasid in our partition. The machine
958 * mask contains a bit for each even nasid in the entire machine.
959 *
960 * Using those two bit arrays, we can determine which nasids are
961 * known in the machine. Each should also have a reserved page
962 * initialized if they are available for partitioning.
963 */
964void
965xpc_discovery(void)
966{
967 void *remote_rp_base;
968 struct xpc_rsvd_page *remote_rp;
969 struct xpc_vars *remote_vars;
Dean Nelsona607c382005-09-01 14:01:37 -0500970 u64 remote_rp_pa;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700971 u64 remote_vars_pa;
972 int region;
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500973 int region_size;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700974 int max_regions;
975 int nasid;
976 struct xpc_rsvd_page *rp;
Dean Nelson64d032b2008-05-12 14:02:03 -0700977 short partid;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700978 struct xpc_partition *part;
979 u64 *discovered_nasids;
Dean Nelson65c17b82008-05-12 14:02:02 -0700980 enum xp_retval ret;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700981
Dean Nelson4b38fcd2005-10-25 14:09:51 -0500982 remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE +
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500983 xp_nasid_mask_bytes,
984 GFP_KERNEL, &remote_rp_base);
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500985 if (remote_rp == NULL)
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700986 return;
Dean Nelson2c2b94f2008-04-22 14:50:17 -0500987
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500988 remote_vars = (struct xpc_vars *)remote_rp;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700989
Jes Sorensen7aa6ba42006-02-17 05:18:43 -0500990 discovered_nasids = kzalloc(sizeof(u64) * xp_nasid_mask_words,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500991 GFP_KERNEL);
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700992 if (discovered_nasids == NULL) {
993 kfree(remote_rp_base);
994 return;
995 }
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700996
Dean Nelson4a3ad2d2008-04-22 14:48:01 -0500997 rp = (struct xpc_rsvd_page *)xpc_rsvd_page;
Dean Nelson89eb8eb2005-03-23 19:50:00 -0700998
999 /*
1000 * The term 'region' in this context refers to the minimum number of
1001 * nodes that can comprise an access protection grouping. The access
1002 * protection is in regards to memory, IOI and IPI.
1003 */
Dean Nelson4b38fcd2005-10-25 14:09:51 -05001004 max_regions = 64;
1005 region_size = sn_region_size;
1006
1007 switch (region_size) {
1008 case 128:
1009 max_regions *= 2;
1010 case 64:
1011 max_regions *= 2;
1012 case 32:
1013 max_regions *= 2;
1014 region_size = 16;
1015 DBUG_ON(!is_shub2());
1016 }
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001017
1018 for (region = 0; region < max_regions; region++) {
1019
Dean Nelson2c2b94f2008-04-22 14:50:17 -05001020 if (xpc_exiting)
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001021 break;
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001022
1023 dev_dbg(xpc_part, "searching region %d\n", region);
1024
Dean Nelson4b38fcd2005-10-25 14:09:51 -05001025 for (nasid = (region * region_size * 2);
Dean Nelson4a3ad2d2008-04-22 14:48:01 -05001026 nasid < ((region + 1) * region_size * 2); nasid += 2) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001027
Dean Nelson2c2b94f2008-04-22 14:50:17 -05001028 if (xpc_exiting)
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001029 break;
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001030
1031 dev_dbg(xpc_part, "checking nasid %d\n", nasid);
1032
Dean Nelson4b38fcd2005-10-25 14:09:51 -05001033 if (XPC_NASID_IN_ARRAY(nasid, xpc_part_nasids)) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001034 dev_dbg(xpc_part, "PROM indicates Nasid %d is "
1035 "part of the local partition; skipping "
1036 "region\n", nasid);
1037 break;
1038 }
1039
Dean Nelson4b38fcd2005-10-25 14:09:51 -05001040 if (!(XPC_NASID_IN_ARRAY(nasid, xpc_mach_nasids))) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001041 dev_dbg(xpc_part, "PROM indicates Nasid %d was "
1042 "not on Numa-Link network at reset\n",
1043 nasid);
1044 continue;
1045 }
1046
1047 if (XPC_NASID_IN_ARRAY(nasid, discovered_nasids)) {
1048 dev_dbg(xpc_part, "Nasid %d is part of a "
1049 "partition which was previously "
1050 "discovered\n", nasid);
1051 continue;
1052 }
1053
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001054 /* pull over the reserved page structure */
1055
1056 ret = xpc_get_remote_rp(nasid, discovered_nasids,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -05001057 remote_rp, &remote_rp_pa);
Dean Nelson65c17b82008-05-12 14:02:02 -07001058 if (ret != xpSuccess) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001059 dev_dbg(xpc_part, "unable to get reserved page "
1060 "from nasid %d, reason=%d\n", nasid,
1061 ret);
1062
Dean Nelson65c17b82008-05-12 14:02:02 -07001063 if (ret == xpLocalPartid)
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001064 break;
Dean Nelson2c2b94f2008-04-22 14:50:17 -05001065
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001066 continue;
1067 }
1068
1069 remote_vars_pa = remote_rp->vars_pa;
1070
1071 partid = remote_rp->partid;
1072 part = &xpc_partitions[partid];
1073
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001074 /* pull over the cross partition variables */
1075
1076 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars);
Dean Nelson65c17b82008-05-12 14:02:02 -07001077 if (ret != xpSuccess) {
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001078 dev_dbg(xpc_part, "unable to get XPC variables "
1079 "from nasid %d, reason=%d\n", nasid,
1080 ret);
1081
1082 XPC_DEACTIVATE_PARTITION(part, ret);
1083 continue;
1084 }
1085
1086 if (part->act_state != XPC_P_INACTIVE) {
1087 dev_dbg(xpc_part, "partition %d on nasid %d is "
1088 "already activating\n", partid, nasid);
1089 break;
1090 }
1091
1092 /*
1093 * Register the remote partition's AMOs with SAL so it
1094 * can handle and cleanup errors within that address
1095 * range should the remote partition go down. We don't
1096 * unregister this range because it is difficult to
1097 * tell when outstanding writes to the remote partition
1098 * are finished and thus when it is thus safe to
1099 * unregister. This should not result in wasted space
1100 * in the SAL xp_addr_region table because we should
1101 * get the same page for remote_act_amos_pa after
1102 * module reloads and system reboots.
1103 */
Dean Nelson4a3ad2d2008-04-22 14:48:01 -05001104 if (sn_register_xp_addr_region
1105 (remote_vars->amos_page_pa, PAGE_SIZE, 1) < 0) {
1106 dev_dbg(xpc_part,
1107 "partition %d failed to "
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001108 "register xp_addr region 0x%016lx\n",
1109 partid, remote_vars->amos_page_pa);
1110
Dean Nelson65c17b82008-05-12 14:02:02 -07001111 XPC_SET_REASON(part, xpPhysAddrRegFailed,
Dean Nelson4a3ad2d2008-04-22 14:48:01 -05001112 __LINE__);
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001113 break;
1114 }
1115
1116 /*
1117 * The remote nasid is valid and available.
1118 * Send an interrupt to that nasid to notify
1119 * it that we are ready to begin activation.
1120 */
1121 dev_dbg(xpc_part, "sending an interrupt to AMO 0x%lx, "
1122 "nasid %d, phys_cpuid 0x%x\n",
1123 remote_vars->amos_page_pa,
1124 remote_vars->act_nasid,
1125 remote_vars->act_phys_cpuid);
1126
Dean Nelsona607c382005-09-01 14:01:37 -05001127 if (XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars->
Dean Nelson4a3ad2d2008-04-22 14:48:01 -05001128 version)) {
Dean Nelsona607c382005-09-01 14:01:37 -05001129 part->remote_amos_page_pa =
Dean Nelson4a3ad2d2008-04-22 14:48:01 -05001130 remote_vars->amos_page_pa;
Dean Nelsona607c382005-09-01 14:01:37 -05001131 xpc_mark_partition_disengaged(part);
1132 xpc_cancel_partition_disengage_request(part);
1133 }
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001134 xpc_IPI_send_activate(remote_vars);
1135 }
1136 }
1137
1138 kfree(discovered_nasids);
1139 kfree(remote_rp_base);
1140}
1141
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001142/*
1143 * Given a partid, get the nasids owned by that partition from the
Dean Nelson3a7d5552005-04-04 13:14:00 -07001144 * remote partition's reserved page.
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001145 */
Dean Nelson65c17b82008-05-12 14:02:02 -07001146enum xp_retval
Dean Nelson64d032b2008-05-12 14:02:03 -07001147xpc_initiate_partid_to_nasids(short partid, void *nasid_mask)
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001148{
1149 struct xpc_partition *part;
1150 u64 part_nasid_pa;
1151 int bte_res;
1152
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001153 part = &xpc_partitions[partid];
Dean Nelson2c2b94f2008-04-22 14:50:17 -05001154 if (part->remote_rp_pa == 0)
Dean Nelson65c17b82008-05-12 14:02:02 -07001155 return xpPartitionDown;
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001156
Dean Nelson4b38fcd2005-10-25 14:09:51 -05001157 memset(nasid_mask, 0, XP_NASID_MASK_BYTES);
1158
Dean Nelson4a3ad2d2008-04-22 14:48:01 -05001159 part_nasid_pa = (u64)XPC_RP_PART_NASIDS(part->remote_rp_pa);
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001160
Dean Nelson4a3ad2d2008-04-22 14:48:01 -05001161 bte_res = xp_bte_copy(part_nasid_pa, (u64)nasid_mask,
1162 xp_nasid_mask_bytes, (BTE_NOTIFY | BTE_WACQUIRE),
1163 NULL);
Dean Nelson89eb8eb2005-03-23 19:50:00 -07001164
1165 return xpc_map_bte_errors(bte_res);
1166}