Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1 | /* |
| 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 Nelson | 45d9ca4 | 2008-04-22 14:46:56 -0500 | [diff] [blame] | 6 | * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 9 | /* |
| 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 18 | #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 Sorensen | 65ed0b3 | 2005-06-21 17:15:03 -0700 | [diff] [blame] | 23 | #include <asm/uncached.h> |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 24 | #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 Nelson | 45d9ca4 | 2008-04-22 14:46:56 -0500 | [diff] [blame] | 29 | #include "xpc.h" |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 30 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 31 | /* XPC is exiting flag */ |
| 32 | int xpc_exiting; |
| 33 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 34 | /* SH_IPI_ACCESS shub register value on startup */ |
| 35 | static u64 xpc_sh1_IPI_access; |
| 36 | static u64 xpc_sh2_IPI_access0; |
| 37 | static u64 xpc_sh2_IPI_access1; |
| 38 | static u64 xpc_sh2_IPI_access2; |
| 39 | static u64 xpc_sh2_IPI_access3; |
| 40 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 41 | /* original protection values for each node */ |
Jack Steiner | 24ee0a6 | 2005-09-12 12:15:43 -0500 | [diff] [blame] | 42 | u64 xpc_prot_vec[MAX_NUMNODES]; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 43 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 44 | /* this partition's reserved page pointers */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 45 | struct xpc_rsvd_page *xpc_rsvd_page; |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 46 | static u64 *xpc_part_nasids; |
| 47 | static u64 *xpc_mach_nasids; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 48 | struct xpc_vars *xpc_vars; |
| 49 | struct xpc_vars_part *xpc_vars_part; |
| 50 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 51 | static int xp_nasid_mask_bytes; /* actual size in bytes of nasid mask */ |
| 52 | static int xp_nasid_mask_words; /* actual size in words of nasid mask */ |
| 53 | |
Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame^] | 54 | struct xpc_partition *xpc_partitions; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 55 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 56 | /* |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 57 | * 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 60 | */ |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 61 | char *xpc_remote_copy_buffer; |
| 62 | void *xpc_remote_copy_buffer_base; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 63 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 64 | /* |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 65 | * Guarantee that the kmalloc'd memory is cacheline aligned. |
| 66 | */ |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 67 | void * |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 68 | xpc_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 Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 72 | if (*base == NULL) |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 73 | return NULL; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 74 | |
| 75 | if ((u64)*base == L1_CACHE_ALIGN((u64)*base)) |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 76 | return *base; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 77 | |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 78 | kfree(*base); |
| 79 | |
| 80 | /* nope, we'll have to do it ourselves */ |
| 81 | *base = kmalloc(size + L1_CACHE_BYTES, flags); |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 82 | if (*base == NULL) |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 83 | return NULL; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 84 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 85 | return (void *)L1_CACHE_ALIGN((u64)*base); |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 86 | } |
| 87 | |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 88 | /* |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 89 | * 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 | */ |
| 92 | static u64 |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 93 | xpc_get_rsvd_page_pa(int nasid) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 94 | { |
| 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 Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 100 | u64 buf = buf; |
| 101 | u64 buf_len = 0; |
| 102 | void *buf_base = NULL; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 103 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 104 | while (1) { |
| 105 | |
| 106 | status = sn_partition_reserved_page_pa(buf, &cookie, &rp_pa, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 107 | &len); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 108 | |
| 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 Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 113 | if (status != SALRET_MORE_PASSES) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 114 | break; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 115 | |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 116 | if (L1_CACHE_ALIGN(len) > buf_len) { |
Jesper Juhl | cbf283c | 2006-04-20 10:11:09 -0700 | [diff] [blame] | 117 | kfree(buf_base); |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 118 | buf_len = L1_CACHE_ALIGN(len); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 119 | buf = (u64)xpc_kmalloc_cacheline_aligned(buf_len, |
| 120 | GFP_KERNEL, |
| 121 | &buf_base); |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 122 | 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 130 | bte_res = xp_bte_copy(rp_pa, buf, buf_len, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 131 | (BTE_NOTIFY | BTE_WACQUIRE), NULL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 132 | 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 Juhl | cbf283c | 2006-04-20 10:11:09 -0700 | [diff] [blame] | 139 | kfree(buf_base); |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 140 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 141 | if (status != SALRET_OK) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 142 | rp_pa = 0; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 143 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 144 | dev_dbg(xpc_part, "reserved page at phys address 0x%016lx\n", rp_pa); |
| 145 | return rp_pa; |
| 146 | } |
| 147 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 148 | /* |
| 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 | */ |
| 153 | struct xpc_rsvd_page * |
| 154 | xpc_rsvd_page_init(void) |
| 155 | { |
| 156 | struct xpc_rsvd_page *rp; |
| 157 | AMO_t *amos_page; |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 158 | u64 rp_pa, nasid_array = 0; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 159 | int i, ret; |
| 160 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 161 | /* get the local reserved page's address */ |
| 162 | |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 163 | preempt_disable(); |
| 164 | rp_pa = xpc_get_rsvd_page_pa(cpuid_to_nasid(smp_processor_id())); |
| 165 | preempt_enable(); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 166 | if (rp_pa == 0) { |
| 167 | dev_err(xpc_part, "SAL failed to locate the reserved page\n"); |
| 168 | return NULL; |
| 169 | } |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 170 | rp = (struct xpc_rsvd_page *)__va(rp_pa); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 171 | |
| 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 Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 180 | /* 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 193 | |
| 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 Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 206 | amos_page = xpc_vars->amos_page; |
| 207 | if (amos_page == NULL) { |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 208 | amos_page = (AMO_t *)TO_AMO(uncached_alloc_page(0, 1)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 209 | 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 Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 219 | ret = sn_change_memprotect(ia64_tpa((u64)amos_page), |
| 220 | PAGE_SIZE, |
| 221 | SN_MEMPROT_ACCESS_CLASS_1, |
| 222 | &nasid_array); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 223 | if (ret != 0) { |
| 224 | dev_err(xpc_part, "can't change memory " |
| 225 | "protections\n"); |
Jes Sorensen | 65ed0b3 | 2005-06-21 17:15:03 -0700 | [diff] [blame] | 226 | uncached_free_page(__IA64_UNCACHED_OFFSET | |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 227 | TO_PHYS((u64)amos_page), 1); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 228 | return NULL; |
| 229 | } |
| 230 | } |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 231 | } else if (!IS_AMO_ADDRESS((u64)amos_page)) { |
Dean Nelson | 3a7d555 | 2005-04-04 13:14:00 -0700 | [diff] [blame] | 232 | /* |
| 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 Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 238 | if (!IS_AMO_PHYS_ADDRESS((u64)amos_page)) { |
Dean Nelson | 3a7d555 | 2005-04-04 13:14:00 -0700 | [diff] [blame] | 239 | dev_err(xpc_part, "previously used amos_page address " |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 240 | "is bad = 0x%p\n", (void *)amos_page); |
Dean Nelson | 3a7d555 | 2005-04-04 13:14:00 -0700 | [diff] [blame] | 241 | return NULL; |
| 242 | } |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 243 | amos_page = (AMO_t *)TO_AMO((u64)amos_page); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 246 | /* clear xpc_vars */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 247 | memset(xpc_vars, 0, sizeof(struct xpc_vars)); |
| 248 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 249 | 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 Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 252 | xpc_vars->vars_part_pa = __pa(xpc_vars_part); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 253 | xpc_vars->amos_page_pa = ia64_tpa((u64)amos_page); |
| 254 | xpc_vars->amos_page = amos_page; /* save for next load of XPC */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 255 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 256 | /* clear xpc_vars_part */ |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 257 | memset((u64 *)xpc_vars_part, 0, sizeof(struct xpc_vars_part) * |
Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame^] | 258 | xp_max_npartitions); |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 259 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 260 | /* initialize the activate IRQ related AMO variables */ |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 261 | for (i = 0; i < xp_nasid_mask_words; i++) |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 262 | (void)xpc_IPI_init(XPC_ACTIVATE_IRQ_AMOS + i); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 263 | |
| 264 | /* initialize the engaged remote partitions related AMO variables */ |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 265 | (void)xpc_IPI_init(XPC_ENGAGED_PARTITIONS_AMO); |
| 266 | (void)xpc_IPI_init(XPC_DISENGAGE_REQUEST_AMO); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 267 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 268 | /* timestamp of when reserved page was setup by XPC */ |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 269 | rp->stamp = CURRENT_TIME; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 270 | |
| 271 | /* |
| 272 | * This signifies to the remote partition that our reserved |
| 273 | * page is initialized. |
| 274 | */ |
Dave Jones | 821fe94 | 2005-06-25 14:54:29 -0700 | [diff] [blame] | 275 | rp->vars_pa = __pa(xpc_vars); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 276 | |
| 277 | return rp; |
| 278 | } |
| 279 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 280 | /* |
| 281 | * Change protections to allow IPI operations (and AMO operations on |
| 282 | * Shub 1.1 systems). |
| 283 | */ |
| 284 | void |
| 285 | xpc_allow_IPI_ops(void) |
| 286 | { |
| 287 | int node; |
| 288 | int nasid; |
| 289 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 290 | /* >>> Change SH_IPI_ACCESS code to use SAL call once it is available */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 291 | |
| 292 | if (is_shub2()) { |
| 293 | xpc_sh2_IPI_access0 = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 294 | (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS0)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 295 | xpc_sh2_IPI_access1 = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 296 | (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS1)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 297 | xpc_sh2_IPI_access2 = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 298 | (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS2)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 299 | xpc_sh2_IPI_access3 = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 300 | (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS3)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 301 | |
| 302 | for_each_online_node(node) { |
| 303 | nasid = cnodeid_to_nasid(node); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 304 | 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | } else { |
| 315 | xpc_sh1_IPI_access = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 316 | (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH1_IPI_ACCESS)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 317 | |
| 318 | for_each_online_node(node) { |
| 319 | nasid = cnodeid_to_nasid(node); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 320 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS), |
| 321 | -1UL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 322 | |
| 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 Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 329 | xpc_prot_vec[node] = (u64)HUB_L((u64 *) |
| 330 | GLOBAL_MMR_ADDR |
| 331 | (nasid, |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 332 | SH1_MD_DQLP_MMR_DIR_PRIVEC0)); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 333 | HUB_S((u64 *) |
| 334 | GLOBAL_MMR_ADDR(nasid, |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 335 | SH1_MD_DQLP_MMR_DIR_PRIVEC0), |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 336 | -1UL); |
| 337 | HUB_S((u64 *) |
| 338 | GLOBAL_MMR_ADDR(nasid, |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 339 | SH1_MD_DQRP_MMR_DIR_PRIVEC0), |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 340 | -1UL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 341 | } |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 346 | /* |
| 347 | * Restrict protections to disallow IPI operations (and AMO operations on |
| 348 | * Shub 1.1 systems). |
| 349 | */ |
| 350 | void |
| 351 | xpc_restrict_IPI_ops(void) |
| 352 | { |
| 353 | int node; |
| 354 | int nasid; |
| 355 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 356 | /* >>> Change SH_IPI_ACCESS code to use SAL call once it is available */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 357 | |
| 358 | if (is_shub2()) { |
| 359 | |
| 360 | for_each_online_node(node) { |
| 361 | nasid = cnodeid_to_nasid(node); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 362 | 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | } else { |
| 373 | |
| 374 | for_each_online_node(node) { |
| 375 | nasid = cnodeid_to_nasid(node); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 376 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS), |
| 377 | xpc_sh1_IPI_access); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 378 | |
| 379 | if (enable_shub_wars_1_1()) { |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 380 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 381 | SH1_MD_DQLP_MMR_DIR_PRIVEC0), |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 382 | xpc_prot_vec[node]); |
| 383 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 384 | SH1_MD_DQRP_MMR_DIR_PRIVEC0), |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 385 | xpc_prot_vec[node]); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 386 | } |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 391 | /* |
| 392 | * At periodic intervals, scan through all active partitions and ensure |
| 393 | * their heartbeat is still active. If not, the partition is deactivated. |
| 394 | */ |
| 395 | void |
| 396 | xpc_check_remote_hb(void) |
| 397 | { |
| 398 | struct xpc_vars *remote_vars; |
| 399 | struct xpc_partition *part; |
Dean Nelson | 64d032b | 2008-05-12 14:02:03 -0700 | [diff] [blame] | 400 | short partid; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 401 | bte_result_t bres; |
| 402 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 403 | remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 404 | |
Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame^] | 405 | for (partid = 0; partid < xp_max_npartitions; partid++) { |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 406 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 407 | if (xpc_exiting) |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 408 | break; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 409 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 410 | if (partid == sn_partition_id) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 411 | continue; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 412 | |
| 413 | part = &xpc_partitions[partid]; |
| 414 | |
| 415 | if (part->act_state == XPC_P_INACTIVE || |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 416 | part->act_state == XPC_P_DEACTIVATING) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 417 | continue; |
| 418 | } |
| 419 | |
| 420 | /* pull the remote_hb cache line */ |
| 421 | bres = xp_bte_copy(part->remote_vars_pa, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 422 | (u64)remote_vars, |
| 423 | XPC_RP_VARS_SIZE, |
| 424 | (BTE_NOTIFY | BTE_WACQUIRE), NULL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 425 | if (bres != BTE_SUCCESS) { |
| 426 | XPC_DEACTIVATE_PARTITION(part, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 427 | xpc_map_bte_errors(bres)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 428 | continue; |
| 429 | } |
| 430 | |
| 431 | dev_dbg(xpc_part, "partid = %d, heartbeat = %ld, last_heartbeat" |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 432 | " = %ld, heartbeat_offline = %ld, HB_mask = 0x%lx\n", |
| 433 | partid, remote_vars->heartbeat, part->last_heartbeat, |
| 434 | remote_vars->heartbeat_offline, |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 435 | remote_vars->heartbeating_to_mask); |
| 436 | |
| 437 | if (((remote_vars->heartbeat == part->last_heartbeat) && |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 438 | (remote_vars->heartbeat_offline == 0)) || |
| 439 | !xpc_hb_allowed(sn_partition_id, remote_vars)) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 440 | |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 441 | XPC_DEACTIVATE_PARTITION(part, xpNoHeartbeat); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 442 | continue; |
| 443 | } |
| 444 | |
| 445 | part->last_heartbeat = remote_vars->heartbeat; |
| 446 | } |
| 447 | } |
| 448 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 449 | /* |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 450 | * Get a copy of a portion of the remote partition's rsvd page. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 451 | * |
| 452 | * remote_rp points to a buffer that is cacheline aligned for BTE copies and |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 453 | * is large enough to contain a copy of their reserved page header and |
| 454 | * part_nasids mask. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 455 | */ |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 456 | static enum xp_retval |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 457 | xpc_get_remote_rp(int nasid, u64 *discovered_nasids, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 458 | struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 459 | { |
| 460 | int bres, i; |
| 461 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 462 | /* get the reserved page's physical address */ |
| 463 | |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 464 | *remote_rp_pa = xpc_get_rsvd_page_pa(nasid); |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 465 | if (*remote_rp_pa == 0) |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 466 | return xpNoRsvdPageAddr; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 467 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 468 | /* pull over the reserved page header and part_nasids mask */ |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 469 | 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 Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 472 | if (bres != BTE_SUCCESS) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 473 | return xpc_map_bte_errors(bres); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 474 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 475 | if (discovered_nasids != NULL) { |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 476 | u64 *remote_part_nasids = XPC_RP_PART_NASIDS(remote_rp); |
| 477 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 478 | for (i = 0; i < xp_nasid_mask_words; i++) |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 479 | discovered_nasids[i] |= remote_part_nasids[i]; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 480 | } |
| 481 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 482 | /* check that the partid is for another partition */ |
| 483 | |
Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame^] | 484 | if (remote_rp->partid < 0 || remote_rp->partid >= xp_max_npartitions) |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 485 | return xpInvalidPartid; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 486 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 487 | if (remote_rp->partid == sn_partition_id) |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 488 | return xpLocalPartid; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 489 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 490 | if (XPC_VERSION_MAJOR(remote_rp->version) != |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 491 | XPC_VERSION_MAJOR(XPC_RP_VERSION)) { |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 492 | return xpBadVersion; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 493 | } |
| 494 | |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 495 | return xpSuccess; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 496 | } |
| 497 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 498 | /* |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 499 | * Get a copy of the remote partition's XPC variables from the reserved page. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 500 | * |
| 501 | * remote_vars points to a buffer that is cacheline aligned for BTE copies and |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 502 | * assumed to be of size XPC_RP_VARS_SIZE. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 503 | */ |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 504 | static enum xp_retval |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 505 | xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars) |
| 506 | { |
| 507 | int bres; |
| 508 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 509 | if (remote_vars_pa == 0) |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 510 | return xpVarsNotSet; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 511 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 512 | /* pull over the cross partition variables */ |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 513 | bres = xp_bte_copy(remote_vars_pa, (u64)remote_vars, XPC_RP_VARS_SIZE, |
| 514 | (BTE_NOTIFY | BTE_WACQUIRE), NULL); |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 515 | if (bres != BTE_SUCCESS) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 516 | return xpc_map_bte_errors(bres); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 517 | |
| 518 | if (XPC_VERSION_MAJOR(remote_vars->version) != |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 519 | XPC_VERSION_MAJOR(XPC_V_VERSION)) { |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 520 | return xpBadVersion; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 521 | } |
| 522 | |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 523 | return xpSuccess; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 524 | } |
| 525 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 526 | /* |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 527 | * Update the remote partition's info. |
| 528 | */ |
| 529 | static void |
| 530 | xpc_update_partition_info(struct xpc_partition *part, u8 remote_rp_version, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 531 | struct timespec *remote_rp_stamp, u64 remote_rp_pa, |
| 532 | u64 remote_vars_pa, struct xpc_vars *remote_vars) |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 533 | { |
| 534 | part->remote_rp_version = remote_rp_version; |
Tony Luck | b9ae3bd | 2007-05-10 11:47:38 -0700 | [diff] [blame] | 535 | dev_dbg(xpc_part, " remote_rp_version = 0x%016x\n", |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 536 | 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 Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 574 | /* |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 575 | * Prior code has determined the nasid which generated an IPI. Inspect |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 576 | * 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 | */ |
| 588 | static void |
| 589 | xpc_identify_act_IRQ_req(int nasid) |
| 590 | { |
| 591 | struct xpc_rsvd_page *remote_rp; |
| 592 | struct xpc_vars *remote_vars; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 593 | u64 remote_rp_pa; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 594 | u64 remote_vars_pa; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 595 | int remote_rp_version; |
| 596 | int reactivate = 0; |
| 597 | int stamp_diff; |
| 598 | struct timespec remote_rp_stamp = { 0, 0 }; |
Dean Nelson | 64d032b | 2008-05-12 14:02:03 -0700 | [diff] [blame] | 599 | short partid; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 600 | struct xpc_partition *part; |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 601 | enum xp_retval ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 602 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 603 | /* pull over the reserved page structure */ |
| 604 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 605 | remote_rp = (struct xpc_rsvd_page *)xpc_remote_copy_buffer; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 606 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 607 | ret = xpc_get_remote_rp(nasid, NULL, remote_rp, &remote_rp_pa); |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 608 | if (ret != xpSuccess) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 609 | dev_warn(xpc_part, "unable to get reserved page from nasid %d, " |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 610 | "which sent interrupt, reason=%d\n", nasid, ret); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 611 | return; |
| 612 | } |
| 613 | |
| 614 | remote_vars_pa = remote_rp->vars_pa; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 615 | remote_rp_version = remote_rp->version; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 616 | if (XPC_SUPPORTS_RP_STAMP(remote_rp_version)) |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 617 | remote_rp_stamp = remote_rp->stamp; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 618 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 619 | partid = remote_rp->partid; |
| 620 | part = &xpc_partitions[partid]; |
| 621 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 622 | /* pull over the cross partition variables */ |
| 623 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 624 | remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 625 | |
| 626 | ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 627 | if (ret != xpSuccess) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 628 | |
| 629 | dev_warn(xpc_part, "unable to get XPC variables from nasid %d, " |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 630 | "which sent interrupt, reason=%d\n", nasid, ret); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 631 | |
| 632 | XPC_DEACTIVATE_PARTITION(part, ret); |
| 633 | return; |
| 634 | } |
| 635 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 636 | part->act_IRQ_rcvd++; |
| 637 | |
| 638 | dev_dbg(xpc_part, "partid for nasid %d is %d; IRQs = %d; HB = " |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 639 | "%ld:0x%lx\n", (int)nasid, (int)partid, part->act_IRQ_rcvd, |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 640 | remote_vars->heartbeat, remote_vars->heartbeating_to_mask); |
| 641 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 642 | if (xpc_partition_disengaged(part) && |
| 643 | part->act_state == XPC_P_INACTIVE) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 644 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 645 | xpc_update_partition_info(part, remote_rp_version, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 646 | &remote_rp_stamp, remote_rp_pa, |
| 647 | remote_vars_pa, remote_vars); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 648 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 649 | 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 661 | |
| 662 | xpc_activate_partition(part); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 663 | return; |
| 664 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 665 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 666 | DBUG_ON(part->remote_rp_version == 0); |
| 667 | DBUG_ON(part->remote_vars_version == 0); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 668 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 669 | if (!XPC_SUPPORTS_RP_STAMP(part->remote_rp_version)) { |
| 670 | DBUG_ON(XPC_SUPPORTS_DISENGAGE_REQUEST(part-> |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 671 | remote_vars_version)); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 672 | |
| 673 | if (!XPC_SUPPORTS_RP_STAMP(remote_rp_version)) { |
| 674 | DBUG_ON(XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars-> |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 675 | version)); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 676 | /* see if the other side rebooted */ |
| 677 | if (part->remote_amos_page_pa == |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 678 | remote_vars->amos_page_pa && |
| 679 | xpc_hb_allowed(sn_partition_id, remote_vars)) { |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 680 | /* 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 Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 691 | &remote_rp_stamp, remote_rp_pa, |
| 692 | remote_vars_pa, remote_vars); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 693 | part->reactivate_nasid = nasid; |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 694 | XPC_DEACTIVATE_PARTITION(part, xpReactivating); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 695 | 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 Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 712 | &remote_rp_stamp, remote_rp_pa, |
| 713 | remote_vars_pa, remote_vars); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 714 | 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 Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 720 | &remote_rp_stamp); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 721 | 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 Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 731 | partid)); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 732 | |
| 733 | xpc_update_partition_info(part, remote_rp_version, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 734 | &remote_rp_stamp, |
| 735 | remote_rp_pa, remote_vars_pa, |
| 736 | remote_vars); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 737 | reactivate = 1; |
| 738 | } |
| 739 | } |
| 740 | |
Dean Nelson | 246c7e3 | 2005-12-22 14:32:56 -0600 | [diff] [blame] | 741 | if (part->disengage_request_timeout > 0 && |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 742 | !xpc_partition_disengaged(part)) { |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 743 | /* still waiting on other side to disengage from us */ |
| 744 | return; |
| 745 | } |
| 746 | |
| 747 | if (reactivate) { |
| 748 | part->reactivate_nasid = nasid; |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 749 | XPC_DEACTIVATE_PARTITION(part, xpReactivating); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 750 | |
| 751 | } else if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version) && |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 752 | xpc_partition_disengage_requested(1UL << partid)) { |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 753 | XPC_DEACTIVATE_PARTITION(part, xpOtherGoingDown); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 754 | } |
| 755 | } |
| 756 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 757 | /* |
| 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 | */ |
| 764 | int |
| 765 | xpc_identify_act_IRQ_sender(void) |
| 766 | { |
| 767 | int word, bit; |
| 768 | u64 nasid_mask; |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 769 | u64 nasid; /* remote nasid */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 770 | int n_IRQs_detected = 0; |
| 771 | AMO_t *act_amos; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 772 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 773 | act_amos = xpc_vars->amos_page + XPC_ACTIVATE_IRQ_AMOS; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 774 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 775 | /* scan through act AMO variable looking for non-zero entries */ |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 776 | for (word = 0; word < xp_nasid_mask_words; word++) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 777 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 778 | if (xpc_exiting) |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 779 | break; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 780 | |
| 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 790 | /* |
| 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 Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 796 | xpc_mach_nasids[word] |= nasid_mask; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 797 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 798 | /* 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 813 | /* |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 814 | * See if the other side has responded to a partition disengage request |
| 815 | * from us. |
| 816 | */ |
| 817 | int |
| 818 | xpc_partition_disengaged(struct xpc_partition *part) |
| 819 | { |
Dean Nelson | 64d032b | 2008-05-12 14:02:03 -0700 | [diff] [blame] | 820 | short partid = XPC_PARTID(part); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 821 | int disengaged; |
| 822 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 823 | disengaged = (xpc_partition_engaged(1UL << partid) == 0); |
| 824 | if (part->disengage_request_timeout) { |
| 825 | if (!disengaged) { |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 826 | if (time_before(jiffies, |
| 827 | part->disengage_request_timeout)) { |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 828 | /* 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 Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 837 | dev_info(xpc_part, "disengage from remote partition %d " |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 838 | "timed out\n", partid); |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 839 | xpc_disengage_request_timedout = 1; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 840 | 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 Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 848 | disengage_request_timer); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | DBUG_ON(part->act_state != XPC_P_DEACTIVATING && |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 852 | part->act_state != XPC_P_INACTIVE); |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 853 | if (part->act_state != XPC_P_INACTIVE) |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 854 | xpc_wakeup_channel_mgr(part); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 855 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 856 | if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)) |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 857 | xpc_cancel_partition_disengage_request(part); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 858 | } |
| 859 | return disengaged; |
| 860 | } |
| 861 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 862 | /* |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 863 | * Mark specified partition as active. |
| 864 | */ |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 865 | enum xp_retval |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 866 | xpc_mark_partition_active(struct xpc_partition *part) |
| 867 | { |
| 868 | unsigned long irq_flags; |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 869 | enum xp_retval ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 870 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 871 | 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 Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 876 | ret = xpSuccess; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 877 | } else { |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 878 | DBUG_ON(part->reason == xpSuccess); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 879 | ret = part->reason; |
| 880 | } |
| 881 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
| 882 | |
| 883 | return ret; |
| 884 | } |
| 885 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 886 | /* |
| 887 | * Notify XPC that the partition is down. |
| 888 | */ |
| 889 | void |
| 890 | xpc_deactivate_partition(const int line, struct xpc_partition *part, |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 891 | enum xp_retval reason) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 892 | { |
| 893 | unsigned long irq_flags; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 894 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 895 | 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 Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 900 | if (reason == xpReactivating) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 901 | /* 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 Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 907 | if ((part->reason == xpUnloading && reason != xpUnloading) || |
| 908 | reason == xpReactivating) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 909 | 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 Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 920 | if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)) { |
| 921 | xpc_request_partition_disengage(part); |
| 922 | xpc_IPI_send_disengage(part); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 923 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 924 | /* set a timelimit on the disengage request */ |
| 925 | part->disengage_request_timeout = jiffies + |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 926 | (xpc_disengage_request_timelimit * HZ); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 927 | part->disengage_request_timer.expires = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 928 | part->disengage_request_timeout; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 929 | add_timer(&part->disengage_request_timer); |
| 930 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 931 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 932 | dev_dbg(xpc_part, "bringing partition %d down, reason = %d\n", |
| 933 | XPC_PARTID(part), reason); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 934 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 935 | xpc_partition_going_down(part, reason); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 936 | } |
| 937 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 938 | /* |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 939 | * Mark specified partition as inactive. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 940 | */ |
| 941 | void |
| 942 | xpc_mark_partition_inactive(struct xpc_partition *part) |
| 943 | { |
| 944 | unsigned long irq_flags; |
| 945 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 946 | 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 955 | /* |
| 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 | */ |
| 964 | void |
| 965 | xpc_discovery(void) |
| 966 | { |
| 967 | void *remote_rp_base; |
| 968 | struct xpc_rsvd_page *remote_rp; |
| 969 | struct xpc_vars *remote_vars; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 970 | u64 remote_rp_pa; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 971 | u64 remote_vars_pa; |
| 972 | int region; |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 973 | int region_size; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 974 | int max_regions; |
| 975 | int nasid; |
| 976 | struct xpc_rsvd_page *rp; |
Dean Nelson | 64d032b | 2008-05-12 14:02:03 -0700 | [diff] [blame] | 977 | short partid; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 978 | struct xpc_partition *part; |
| 979 | u64 *discovered_nasids; |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 980 | enum xp_retval ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 981 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 982 | remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE + |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 983 | xp_nasid_mask_bytes, |
| 984 | GFP_KERNEL, &remote_rp_base); |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 985 | if (remote_rp == NULL) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 986 | return; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 987 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 988 | remote_vars = (struct xpc_vars *)remote_rp; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 989 | |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 990 | discovered_nasids = kzalloc(sizeof(u64) * xp_nasid_mask_words, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 991 | GFP_KERNEL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 992 | if (discovered_nasids == NULL) { |
| 993 | kfree(remote_rp_base); |
| 994 | return; |
| 995 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 996 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 997 | rp = (struct xpc_rsvd_page *)xpc_rsvd_page; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 998 | |
| 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 Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 1004 | 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1017 | |
| 1018 | for (region = 0; region < max_regions; region++) { |
| 1019 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 1020 | if (xpc_exiting) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1021 | break; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1022 | |
| 1023 | dev_dbg(xpc_part, "searching region %d\n", region); |
| 1024 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 1025 | for (nasid = (region * region_size * 2); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1026 | nasid < ((region + 1) * region_size * 2); nasid += 2) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1027 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 1028 | if (xpc_exiting) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1029 | break; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1030 | |
| 1031 | dev_dbg(xpc_part, "checking nasid %d\n", nasid); |
| 1032 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 1033 | if (XPC_NASID_IN_ARRAY(nasid, xpc_part_nasids)) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1034 | 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 Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 1040 | if (!(XPC_NASID_IN_ARRAY(nasid, xpc_mach_nasids))) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1041 | 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1054 | /* pull over the reserved page structure */ |
| 1055 | |
| 1056 | ret = xpc_get_remote_rp(nasid, discovered_nasids, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1057 | remote_rp, &remote_rp_pa); |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1058 | if (ret != xpSuccess) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1059 | dev_dbg(xpc_part, "unable to get reserved page " |
| 1060 | "from nasid %d, reason=%d\n", nasid, |
| 1061 | ret); |
| 1062 | |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1063 | if (ret == xpLocalPartid) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1064 | break; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 1065 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1066 | continue; |
| 1067 | } |
| 1068 | |
| 1069 | remote_vars_pa = remote_rp->vars_pa; |
| 1070 | |
| 1071 | partid = remote_rp->partid; |
| 1072 | part = &xpc_partitions[partid]; |
| 1073 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1074 | /* pull over the cross partition variables */ |
| 1075 | |
| 1076 | ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1077 | if (ret != xpSuccess) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1078 | 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 Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1104 | 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 Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1108 | "register xp_addr region 0x%016lx\n", |
| 1109 | partid, remote_vars->amos_page_pa); |
| 1110 | |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1111 | XPC_SET_REASON(part, xpPhysAddrRegFailed, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1112 | __LINE__); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1113 | 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 Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1127 | if (XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars-> |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1128 | version)) { |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1129 | part->remote_amos_page_pa = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1130 | remote_vars->amos_page_pa; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1131 | xpc_mark_partition_disengaged(part); |
| 1132 | xpc_cancel_partition_disengage_request(part); |
| 1133 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1134 | xpc_IPI_send_activate(remote_vars); |
| 1135 | } |
| 1136 | } |
| 1137 | |
| 1138 | kfree(discovered_nasids); |
| 1139 | kfree(remote_rp_base); |
| 1140 | } |
| 1141 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1142 | /* |
| 1143 | * Given a partid, get the nasids owned by that partition from the |
Dean Nelson | 3a7d555 | 2005-04-04 13:14:00 -0700 | [diff] [blame] | 1144 | * remote partition's reserved page. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1145 | */ |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1146 | enum xp_retval |
Dean Nelson | 64d032b | 2008-05-12 14:02:03 -0700 | [diff] [blame] | 1147 | xpc_initiate_partid_to_nasids(short partid, void *nasid_mask) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1148 | { |
| 1149 | struct xpc_partition *part; |
| 1150 | u64 part_nasid_pa; |
| 1151 | int bte_res; |
| 1152 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1153 | part = &xpc_partitions[partid]; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 1154 | if (part->remote_rp_pa == 0) |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1155 | return xpPartitionDown; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1156 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 1157 | memset(nasid_mask, 0, XP_NASID_MASK_BYTES); |
| 1158 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1159 | part_nasid_pa = (u64)XPC_RP_PART_NASIDS(part->remote_rp_pa); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1160 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1161 | bte_res = xp_bte_copy(part_nasid_pa, (u64)nasid_mask, |
| 1162 | xp_nasid_mask_bytes, (BTE_NOTIFY | BTE_WACQUIRE), |
| 1163 | NULL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1164 | |
| 1165 | return xpc_map_bte_errors(bte_res); |
| 1166 | } |