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/intr.h> |
| 25 | #include <asm/sn/sn_sal.h> |
| 26 | #include <asm/sn/nodepda.h> |
| 27 | #include <asm/sn/addrs.h> |
Dean Nelson | 45d9ca4 | 2008-04-22 14:46:56 -0500 | [diff] [blame] | 28 | #include "xpc.h" |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 29 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 30 | /* XPC is exiting flag */ |
| 31 | int xpc_exiting; |
| 32 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 33 | /* SH_IPI_ACCESS shub register value on startup */ |
| 34 | static u64 xpc_sh1_IPI_access; |
| 35 | static u64 xpc_sh2_IPI_access0; |
| 36 | static u64 xpc_sh2_IPI_access1; |
| 37 | static u64 xpc_sh2_IPI_access2; |
| 38 | static u64 xpc_sh2_IPI_access3; |
| 39 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 40 | /* original protection values for each node */ |
Jack Steiner | 24ee0a6 | 2005-09-12 12:15:43 -0500 | [diff] [blame] | 41 | u64 xpc_prot_vec[MAX_NUMNODES]; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 42 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 43 | /* this partition's reserved page pointers */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 44 | struct xpc_rsvd_page *xpc_rsvd_page; |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 45 | static u64 *xpc_part_nasids; |
| 46 | static u64 *xpc_mach_nasids; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 47 | struct xpc_vars *xpc_vars; |
| 48 | struct xpc_vars_part *xpc_vars_part; |
| 49 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 50 | static int xp_nasid_mask_bytes; /* actual size in bytes of nasid mask */ |
| 51 | static int xp_nasid_mask_words; /* actual size in words of nasid mask */ |
| 52 | |
Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame] | 53 | struct xpc_partition *xpc_partitions; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 54 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 55 | /* |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 56 | * Generic buffer used to store a local copy of portions of a remote |
| 57 | * partition's reserved page (either its header and part_nasids mask, |
| 58 | * or its vars). |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 59 | */ |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 60 | char *xpc_remote_copy_buffer; |
| 61 | void *xpc_remote_copy_buffer_base; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 62 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 63 | /* |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 64 | * Guarantee that the kmalloc'd memory is cacheline aligned. |
| 65 | */ |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 66 | void * |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 67 | xpc_kmalloc_cacheline_aligned(size_t size, gfp_t flags, void **base) |
| 68 | { |
| 69 | /* see if kmalloc will give us cachline aligned memory by default */ |
| 70 | *base = kmalloc(size, flags); |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 71 | if (*base == NULL) |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 72 | return NULL; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 73 | |
| 74 | if ((u64)*base == L1_CACHE_ALIGN((u64)*base)) |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 75 | return *base; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 76 | |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 77 | kfree(*base); |
| 78 | |
| 79 | /* nope, we'll have to do it ourselves */ |
| 80 | *base = kmalloc(size + L1_CACHE_BYTES, flags); |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 81 | if (*base == NULL) |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 82 | return NULL; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 83 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 84 | return (void *)L1_CACHE_ALIGN((u64)*base); |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 85 | } |
| 86 | |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 87 | /* |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 88 | * Given a nasid, get the physical address of the partition's reserved page |
| 89 | * for that nasid. This function returns 0 on any error. |
| 90 | */ |
| 91 | static u64 |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 92 | xpc_get_rsvd_page_pa(int nasid) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 93 | { |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame^] | 94 | enum xp_retval ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 95 | s64 status; |
| 96 | u64 cookie = 0; |
| 97 | u64 rp_pa = nasid; /* seed with nasid */ |
| 98 | u64 len = 0; |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 99 | u64 buf = buf; |
| 100 | u64 buf_len = 0; |
| 101 | void *buf_base = NULL; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 102 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 103 | while (1) { |
| 104 | |
| 105 | status = sn_partition_reserved_page_pa(buf, &cookie, &rp_pa, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 106 | &len); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 107 | |
| 108 | dev_dbg(xpc_part, "SAL returned with status=%li, cookie=" |
| 109 | "0x%016lx, address=0x%016lx, len=0x%016lx\n", |
| 110 | status, cookie, rp_pa, len); |
| 111 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 112 | if (status != SALRET_MORE_PASSES) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 113 | break; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 114 | |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame^] | 115 | /* >>> L1_CACHE_ALIGN() is only a sn2-bte_copy requirement */ |
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 | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame^] | 130 | ret = xp_remote_memcpy((void *)buf, (void *)rp_pa, buf_len); |
| 131 | if (ret != xpSuccess) { |
| 132 | dev_dbg(xpc_part, "xp_remote_memcpy failed %d\n", ret); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 133 | status = SALRET_ERROR; |
| 134 | break; |
| 135 | } |
| 136 | } |
| 137 | |
Jesper Juhl | cbf283c | 2006-04-20 10:11:09 -0700 | [diff] [blame] | 138 | kfree(buf_base); |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 139 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 140 | if (status != SALRET_OK) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 141 | rp_pa = 0; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 142 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 143 | dev_dbg(xpc_part, "reserved page at phys address 0x%016lx\n", rp_pa); |
| 144 | return rp_pa; |
| 145 | } |
| 146 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 147 | /* |
| 148 | * Fill the partition reserved page with the information needed by |
| 149 | * other partitions to discover we are alive and establish initial |
| 150 | * communications. |
| 151 | */ |
| 152 | struct xpc_rsvd_page * |
| 153 | xpc_rsvd_page_init(void) |
| 154 | { |
| 155 | struct xpc_rsvd_page *rp; |
| 156 | AMO_t *amos_page; |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 157 | u64 rp_pa, nasid_array = 0; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 158 | int i, ret; |
| 159 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 160 | /* get the local reserved page's address */ |
| 161 | |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 162 | preempt_disable(); |
| 163 | rp_pa = xpc_get_rsvd_page_pa(cpuid_to_nasid(smp_processor_id())); |
| 164 | preempt_enable(); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 165 | if (rp_pa == 0) { |
| 166 | dev_err(xpc_part, "SAL failed to locate the reserved page\n"); |
| 167 | return NULL; |
| 168 | } |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 169 | rp = (struct xpc_rsvd_page *)__va(rp_pa); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 170 | |
| 171 | if (rp->partid != sn_partition_id) { |
| 172 | dev_err(xpc_part, "the reserved page's partid of %d should be " |
| 173 | "%d\n", rp->partid, sn_partition_id); |
| 174 | return NULL; |
| 175 | } |
| 176 | |
| 177 | rp->version = XPC_RP_VERSION; |
| 178 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 179 | /* establish the actual sizes of the nasid masks */ |
| 180 | if (rp->SAL_version == 1) { |
| 181 | /* SAL_version 1 didn't set the nasids_size field */ |
| 182 | rp->nasids_size = 128; |
| 183 | } |
| 184 | xp_nasid_mask_bytes = rp->nasids_size; |
| 185 | xp_nasid_mask_words = xp_nasid_mask_bytes / 8; |
| 186 | |
| 187 | /* setup the pointers to the various items in the reserved page */ |
| 188 | xpc_part_nasids = XPC_RP_PART_NASIDS(rp); |
| 189 | xpc_mach_nasids = XPC_RP_MACH_NASIDS(rp); |
| 190 | xpc_vars = XPC_RP_VARS(rp); |
| 191 | xpc_vars_part = XPC_RP_VARS_PART(rp); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 192 | |
| 193 | /* |
| 194 | * Before clearing xpc_vars, see if a page of AMOs had been previously |
| 195 | * allocated. If not we'll need to allocate one and set permissions |
| 196 | * so that cross-partition AMOs are allowed. |
| 197 | * |
| 198 | * The allocated AMO page needs MCA reporting to remain disabled after |
| 199 | * XPC has unloaded. To make this work, we keep a copy of the pointer |
| 200 | * to this page (i.e., amos_page) in the struct xpc_vars structure, |
| 201 | * which is pointed to by the reserved page, and re-use that saved copy |
| 202 | * on subsequent loads of XPC. This AMO page is never freed, and its |
| 203 | * memory protections are never restricted. |
| 204 | */ |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 205 | amos_page = xpc_vars->amos_page; |
| 206 | if (amos_page == NULL) { |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 207 | amos_page = (AMO_t *)TO_AMO(uncached_alloc_page(0, 1)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 208 | if (amos_page == NULL) { |
| 209 | dev_err(xpc_part, "can't allocate page of AMOs\n"); |
| 210 | return NULL; |
| 211 | } |
| 212 | |
| 213 | /* |
| 214 | * Open up AMO-R/W to cpu. This is done for Shub 1.1 systems |
| 215 | * when xpc_allow_IPI_ops() is called via xpc_hb_init(). |
| 216 | */ |
| 217 | if (!enable_shub_wars_1_1()) { |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 218 | ret = sn_change_memprotect(ia64_tpa((u64)amos_page), |
| 219 | PAGE_SIZE, |
| 220 | SN_MEMPROT_ACCESS_CLASS_1, |
| 221 | &nasid_array); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 222 | if (ret != 0) { |
| 223 | dev_err(xpc_part, "can't change memory " |
| 224 | "protections\n"); |
Jes Sorensen | 65ed0b3 | 2005-06-21 17:15:03 -0700 | [diff] [blame] | 225 | uncached_free_page(__IA64_UNCACHED_OFFSET | |
Dean Nelson | e4a064d | 2008-04-25 15:22:19 -0500 | [diff] [blame] | 226 | TO_PHYS((u64)amos_page), 1); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 227 | return NULL; |
| 228 | } |
| 229 | } |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 230 | } else if (!IS_AMO_ADDRESS((u64)amos_page)) { |
Dean Nelson | 3a7d555 | 2005-04-04 13:14:00 -0700 | [diff] [blame] | 231 | /* |
| 232 | * EFI's XPBOOT can also set amos_page in the reserved page, |
| 233 | * but it happens to leave it as an uncached physical address |
| 234 | * and we need it to be an uncached virtual, so we'll have to |
| 235 | * convert it. |
| 236 | */ |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 237 | if (!IS_AMO_PHYS_ADDRESS((u64)amos_page)) { |
Dean Nelson | 3a7d555 | 2005-04-04 13:14:00 -0700 | [diff] [blame] | 238 | dev_err(xpc_part, "previously used amos_page address " |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 239 | "is bad = 0x%p\n", (void *)amos_page); |
Dean Nelson | 3a7d555 | 2005-04-04 13:14:00 -0700 | [diff] [blame] | 240 | return NULL; |
| 241 | } |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 242 | amos_page = (AMO_t *)TO_AMO((u64)amos_page); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 245 | /* clear xpc_vars */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 246 | memset(xpc_vars, 0, sizeof(struct xpc_vars)); |
| 247 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 248 | xpc_vars->version = XPC_V_VERSION; |
| 249 | xpc_vars->act_nasid = cpuid_to_nasid(0); |
| 250 | xpc_vars->act_phys_cpuid = cpu_physical_id(0); |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 251 | xpc_vars->vars_part_pa = __pa(xpc_vars_part); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 252 | xpc_vars->amos_page_pa = ia64_tpa((u64)amos_page); |
| 253 | xpc_vars->amos_page = amos_page; /* save for next load of XPC */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 254 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 255 | /* clear xpc_vars_part */ |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 256 | memset((u64 *)xpc_vars_part, 0, sizeof(struct xpc_vars_part) * |
Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame] | 257 | xp_max_npartitions); |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 258 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 259 | /* initialize the activate IRQ related AMO variables */ |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 260 | for (i = 0; i < xp_nasid_mask_words; i++) |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 261 | (void)xpc_IPI_init(XPC_ACTIVATE_IRQ_AMOS + i); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 262 | |
| 263 | /* initialize the engaged remote partitions related AMO variables */ |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 264 | (void)xpc_IPI_init(XPC_ENGAGED_PARTITIONS_AMO); |
| 265 | (void)xpc_IPI_init(XPC_DISENGAGE_REQUEST_AMO); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 266 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 267 | /* timestamp of when reserved page was setup by XPC */ |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 268 | rp->stamp = CURRENT_TIME; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 269 | |
| 270 | /* |
| 271 | * This signifies to the remote partition that our reserved |
| 272 | * page is initialized. |
| 273 | */ |
Dave Jones | 821fe94 | 2005-06-25 14:54:29 -0700 | [diff] [blame] | 274 | rp->vars_pa = __pa(xpc_vars); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 275 | |
| 276 | return rp; |
| 277 | } |
| 278 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 279 | /* |
| 280 | * Change protections to allow IPI operations (and AMO operations on |
| 281 | * Shub 1.1 systems). |
| 282 | */ |
| 283 | void |
| 284 | xpc_allow_IPI_ops(void) |
| 285 | { |
| 286 | int node; |
| 287 | int nasid; |
| 288 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 289 | /* >>> 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] | 290 | |
| 291 | if (is_shub2()) { |
| 292 | xpc_sh2_IPI_access0 = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 293 | (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS0)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 294 | xpc_sh2_IPI_access1 = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 295 | (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS1)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 296 | xpc_sh2_IPI_access2 = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 297 | (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS2)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 298 | xpc_sh2_IPI_access3 = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 299 | (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS3)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 300 | |
| 301 | for_each_online_node(node) { |
| 302 | nasid = cnodeid_to_nasid(node); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 303 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS0), |
| 304 | -1UL); |
| 305 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS1), |
| 306 | -1UL); |
| 307 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS2), |
| 308 | -1UL); |
| 309 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS3), |
| 310 | -1UL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | } else { |
| 314 | xpc_sh1_IPI_access = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 315 | (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH1_IPI_ACCESS)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 316 | |
| 317 | for_each_online_node(node) { |
| 318 | nasid = cnodeid_to_nasid(node); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 319 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS), |
| 320 | -1UL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 321 | |
| 322 | /* |
| 323 | * Since the BIST collides with memory operations on |
| 324 | * SHUB 1.1 sn_change_memprotect() cannot be used. |
| 325 | */ |
| 326 | if (enable_shub_wars_1_1()) { |
| 327 | /* open up everything */ |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 328 | xpc_prot_vec[node] = (u64)HUB_L((u64 *) |
| 329 | GLOBAL_MMR_ADDR |
| 330 | (nasid, |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 331 | SH1_MD_DQLP_MMR_DIR_PRIVEC0)); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 332 | HUB_S((u64 *) |
| 333 | GLOBAL_MMR_ADDR(nasid, |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 334 | SH1_MD_DQLP_MMR_DIR_PRIVEC0), |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 335 | -1UL); |
| 336 | HUB_S((u64 *) |
| 337 | GLOBAL_MMR_ADDR(nasid, |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 338 | SH1_MD_DQRP_MMR_DIR_PRIVEC0), |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 339 | -1UL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 340 | } |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 345 | /* |
| 346 | * Restrict protections to disallow IPI operations (and AMO operations on |
| 347 | * Shub 1.1 systems). |
| 348 | */ |
| 349 | void |
| 350 | xpc_restrict_IPI_ops(void) |
| 351 | { |
| 352 | int node; |
| 353 | int nasid; |
| 354 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 355 | /* >>> 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] | 356 | |
| 357 | if (is_shub2()) { |
| 358 | |
| 359 | for_each_online_node(node) { |
| 360 | nasid = cnodeid_to_nasid(node); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 361 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS0), |
| 362 | xpc_sh2_IPI_access0); |
| 363 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS1), |
| 364 | xpc_sh2_IPI_access1); |
| 365 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS2), |
| 366 | xpc_sh2_IPI_access2); |
| 367 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS3), |
| 368 | xpc_sh2_IPI_access3); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | } else { |
| 372 | |
| 373 | for_each_online_node(node) { |
| 374 | nasid = cnodeid_to_nasid(node); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 375 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS), |
| 376 | xpc_sh1_IPI_access); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 377 | |
| 378 | if (enable_shub_wars_1_1()) { |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 379 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 380 | SH1_MD_DQLP_MMR_DIR_PRIVEC0), |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 381 | xpc_prot_vec[node]); |
| 382 | HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 383 | SH1_MD_DQRP_MMR_DIR_PRIVEC0), |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 384 | xpc_prot_vec[node]); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 385 | } |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 390 | /* |
| 391 | * At periodic intervals, scan through all active partitions and ensure |
| 392 | * their heartbeat is still active. If not, the partition is deactivated. |
| 393 | */ |
| 394 | void |
| 395 | xpc_check_remote_hb(void) |
| 396 | { |
| 397 | struct xpc_vars *remote_vars; |
| 398 | struct xpc_partition *part; |
Dean Nelson | 64d032b | 2008-05-12 14:02:03 -0700 | [diff] [blame] | 399 | short partid; |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame^] | 400 | enum xp_retval ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 401 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 402 | remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 403 | |
Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame] | 404 | for (partid = 0; partid < xp_max_npartitions; partid++) { |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 405 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 406 | if (xpc_exiting) |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 407 | break; |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 408 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 409 | if (partid == sn_partition_id) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 410 | continue; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 411 | |
| 412 | part = &xpc_partitions[partid]; |
| 413 | |
| 414 | if (part->act_state == XPC_P_INACTIVE || |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 415 | part->act_state == XPC_P_DEACTIVATING) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 416 | continue; |
| 417 | } |
| 418 | |
| 419 | /* pull the remote_hb cache line */ |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame^] | 420 | ret = xp_remote_memcpy(remote_vars, |
| 421 | (void *)part->remote_vars_pa, |
| 422 | XPC_RP_VARS_SIZE); |
| 423 | if (ret != xpSuccess) { |
| 424 | XPC_DEACTIVATE_PARTITION(part, ret); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 425 | continue; |
| 426 | } |
| 427 | |
| 428 | dev_dbg(xpc_part, "partid = %d, heartbeat = %ld, last_heartbeat" |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 429 | " = %ld, heartbeat_offline = %ld, HB_mask = 0x%lx\n", |
| 430 | partid, remote_vars->heartbeat, part->last_heartbeat, |
| 431 | remote_vars->heartbeat_offline, |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 432 | remote_vars->heartbeating_to_mask); |
| 433 | |
| 434 | if (((remote_vars->heartbeat == part->last_heartbeat) && |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 435 | (remote_vars->heartbeat_offline == 0)) || |
| 436 | !xpc_hb_allowed(sn_partition_id, remote_vars)) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 437 | |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 438 | XPC_DEACTIVATE_PARTITION(part, xpNoHeartbeat); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 439 | continue; |
| 440 | } |
| 441 | |
| 442 | part->last_heartbeat = remote_vars->heartbeat; |
| 443 | } |
| 444 | } |
| 445 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 446 | /* |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 447 | * 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] | 448 | * |
| 449 | * 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] | 450 | * is large enough to contain a copy of their reserved page header and |
| 451 | * part_nasids mask. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 452 | */ |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 453 | static enum xp_retval |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 454 | xpc_get_remote_rp(int nasid, u64 *discovered_nasids, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 455 | struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 456 | { |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame^] | 457 | int i; |
| 458 | enum xp_retval ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 459 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 460 | /* get the reserved page's physical address */ |
| 461 | |
Dean Nelson | 2792902 | 2005-10-25 14:11:53 -0500 | [diff] [blame] | 462 | *remote_rp_pa = xpc_get_rsvd_page_pa(nasid); |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 463 | if (*remote_rp_pa == 0) |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 464 | return xpNoRsvdPageAddr; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 465 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 466 | /* pull over the reserved page header and part_nasids mask */ |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame^] | 467 | ret = xp_remote_memcpy(remote_rp, (void *)*remote_rp_pa, |
| 468 | XPC_RP_HEADER_SIZE + xp_nasid_mask_bytes); |
| 469 | if (ret != xpSuccess) |
| 470 | return ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 471 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 472 | if (discovered_nasids != NULL) { |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 473 | u64 *remote_part_nasids = XPC_RP_PART_NASIDS(remote_rp); |
| 474 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 475 | for (i = 0; i < xp_nasid_mask_words; i++) |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 476 | discovered_nasids[i] |= remote_part_nasids[i]; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 477 | } |
| 478 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 479 | /* check that the partid is for another partition */ |
| 480 | |
Dean Nelson | bc63d38 | 2008-07-29 22:34:04 -0700 | [diff] [blame] | 481 | if (remote_rp->partid < 0 || remote_rp->partid >= xp_max_npartitions) |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 482 | return xpInvalidPartid; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 483 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 484 | if (remote_rp->partid == sn_partition_id) |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 485 | return xpLocalPartid; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 486 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 487 | if (XPC_VERSION_MAJOR(remote_rp->version) != |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 488 | XPC_VERSION_MAJOR(XPC_RP_VERSION)) { |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 489 | return xpBadVersion; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 490 | } |
| 491 | |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 492 | return xpSuccess; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 493 | } |
| 494 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 495 | /* |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 496 | * 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] | 497 | * |
| 498 | * 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] | 499 | * assumed to be of size XPC_RP_VARS_SIZE. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 500 | */ |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 501 | static enum xp_retval |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 502 | xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars) |
| 503 | { |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame^] | 504 | enum xp_retval ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 505 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 506 | if (remote_vars_pa == 0) |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 507 | return xpVarsNotSet; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 508 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 509 | /* pull over the cross partition variables */ |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame^] | 510 | ret = xp_remote_memcpy(remote_vars, (void *)remote_vars_pa, |
| 511 | XPC_RP_VARS_SIZE); |
| 512 | if (ret != xpSuccess) |
| 513 | return ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 514 | |
| 515 | if (XPC_VERSION_MAJOR(remote_vars->version) != |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 516 | XPC_VERSION_MAJOR(XPC_V_VERSION)) { |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 517 | return xpBadVersion; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 518 | } |
| 519 | |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 520 | return xpSuccess; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 521 | } |
| 522 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 523 | /* |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 524 | * Update the remote partition's info. |
| 525 | */ |
| 526 | static void |
| 527 | xpc_update_partition_info(struct xpc_partition *part, u8 remote_rp_version, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 528 | struct timespec *remote_rp_stamp, u64 remote_rp_pa, |
| 529 | u64 remote_vars_pa, struct xpc_vars *remote_vars) |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 530 | { |
| 531 | part->remote_rp_version = remote_rp_version; |
Tony Luck | b9ae3bd | 2007-05-10 11:47:38 -0700 | [diff] [blame] | 532 | dev_dbg(xpc_part, " remote_rp_version = 0x%016x\n", |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 533 | part->remote_rp_version); |
| 534 | |
| 535 | part->remote_rp_stamp = *remote_rp_stamp; |
| 536 | dev_dbg(xpc_part, " remote_rp_stamp (tv_sec = 0x%lx tv_nsec = 0x%lx\n", |
| 537 | part->remote_rp_stamp.tv_sec, part->remote_rp_stamp.tv_nsec); |
| 538 | |
| 539 | part->remote_rp_pa = remote_rp_pa; |
| 540 | dev_dbg(xpc_part, " remote_rp_pa = 0x%016lx\n", part->remote_rp_pa); |
| 541 | |
| 542 | part->remote_vars_pa = remote_vars_pa; |
| 543 | dev_dbg(xpc_part, " remote_vars_pa = 0x%016lx\n", |
| 544 | part->remote_vars_pa); |
| 545 | |
| 546 | part->last_heartbeat = remote_vars->heartbeat; |
| 547 | dev_dbg(xpc_part, " last_heartbeat = 0x%016lx\n", |
| 548 | part->last_heartbeat); |
| 549 | |
| 550 | part->remote_vars_part_pa = remote_vars->vars_part_pa; |
| 551 | dev_dbg(xpc_part, " remote_vars_part_pa = 0x%016lx\n", |
| 552 | part->remote_vars_part_pa); |
| 553 | |
| 554 | part->remote_act_nasid = remote_vars->act_nasid; |
| 555 | dev_dbg(xpc_part, " remote_act_nasid = 0x%x\n", |
| 556 | part->remote_act_nasid); |
| 557 | |
| 558 | part->remote_act_phys_cpuid = remote_vars->act_phys_cpuid; |
| 559 | dev_dbg(xpc_part, " remote_act_phys_cpuid = 0x%x\n", |
| 560 | part->remote_act_phys_cpuid); |
| 561 | |
| 562 | part->remote_amos_page_pa = remote_vars->amos_page_pa; |
| 563 | dev_dbg(xpc_part, " remote_amos_page_pa = 0x%lx\n", |
| 564 | part->remote_amos_page_pa); |
| 565 | |
| 566 | part->remote_vars_version = remote_vars->version; |
| 567 | dev_dbg(xpc_part, " remote_vars_version = 0x%x\n", |
| 568 | part->remote_vars_version); |
| 569 | } |
| 570 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 571 | /* |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 572 | * Prior code has determined the nasid which generated an IPI. Inspect |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 573 | * that nasid to determine if its partition needs to be activated or |
| 574 | * deactivated. |
| 575 | * |
| 576 | * A partition is consider "awaiting activation" if our partition |
| 577 | * flags indicate it is not active and it has a heartbeat. A |
| 578 | * partition is considered "awaiting deactivation" if our partition |
| 579 | * flags indicate it is active but it has no heartbeat or it is not |
| 580 | * sending its heartbeat to us. |
| 581 | * |
| 582 | * To determine the heartbeat, the remote nasid must have a properly |
| 583 | * initialized reserved page. |
| 584 | */ |
| 585 | static void |
| 586 | xpc_identify_act_IRQ_req(int nasid) |
| 587 | { |
| 588 | struct xpc_rsvd_page *remote_rp; |
| 589 | struct xpc_vars *remote_vars; |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 590 | u64 remote_rp_pa; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 591 | u64 remote_vars_pa; |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 592 | int remote_rp_version; |
| 593 | int reactivate = 0; |
| 594 | int stamp_diff; |
| 595 | struct timespec remote_rp_stamp = { 0, 0 }; |
Dean Nelson | 64d032b | 2008-05-12 14:02:03 -0700 | [diff] [blame] | 596 | short partid; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 597 | struct xpc_partition *part; |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 598 | enum xp_retval ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 599 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 600 | /* pull over the reserved page structure */ |
| 601 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 602 | remote_rp = (struct xpc_rsvd_page *)xpc_remote_copy_buffer; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 603 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 604 | ret = xpc_get_remote_rp(nasid, NULL, remote_rp, &remote_rp_pa); |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 605 | if (ret != xpSuccess) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 606 | dev_warn(xpc_part, "unable to get reserved page from nasid %d, " |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 607 | "which sent interrupt, reason=%d\n", nasid, ret); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 608 | return; |
| 609 | } |
| 610 | |
| 611 | remote_vars_pa = remote_rp->vars_pa; |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 612 | remote_rp_version = remote_rp->version; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 613 | if (XPC_SUPPORTS_RP_STAMP(remote_rp_version)) |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 614 | remote_rp_stamp = remote_rp->stamp; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 615 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 616 | partid = remote_rp->partid; |
| 617 | part = &xpc_partitions[partid]; |
| 618 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 619 | /* pull over the cross partition variables */ |
| 620 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 621 | remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 622 | |
| 623 | ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 624 | if (ret != xpSuccess) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 625 | |
| 626 | dev_warn(xpc_part, "unable to get XPC variables from nasid %d, " |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 627 | "which sent interrupt, reason=%d\n", nasid, ret); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 628 | |
| 629 | XPC_DEACTIVATE_PARTITION(part, ret); |
| 630 | return; |
| 631 | } |
| 632 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 633 | part->act_IRQ_rcvd++; |
| 634 | |
| 635 | 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] | 636 | "%ld:0x%lx\n", (int)nasid, (int)partid, part->act_IRQ_rcvd, |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 637 | remote_vars->heartbeat, remote_vars->heartbeating_to_mask); |
| 638 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 639 | if (xpc_partition_disengaged(part) && |
| 640 | part->act_state == XPC_P_INACTIVE) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 641 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 642 | xpc_update_partition_info(part, remote_rp_version, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 643 | &remote_rp_stamp, remote_rp_pa, |
| 644 | remote_vars_pa, remote_vars); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 645 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 646 | if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)) { |
| 647 | if (xpc_partition_disengage_requested(1UL << partid)) { |
| 648 | /* |
| 649 | * Other side is waiting on us to disengage, |
| 650 | * even though we already have. |
| 651 | */ |
| 652 | return; |
| 653 | } |
| 654 | } else { |
| 655 | /* other side doesn't support disengage requests */ |
| 656 | xpc_clear_partition_disengage_request(1UL << partid); |
| 657 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 658 | |
| 659 | xpc_activate_partition(part); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 660 | return; |
| 661 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 662 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 663 | DBUG_ON(part->remote_rp_version == 0); |
| 664 | DBUG_ON(part->remote_vars_version == 0); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 665 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 666 | if (!XPC_SUPPORTS_RP_STAMP(part->remote_rp_version)) { |
| 667 | DBUG_ON(XPC_SUPPORTS_DISENGAGE_REQUEST(part-> |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 668 | remote_vars_version)); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 669 | |
| 670 | if (!XPC_SUPPORTS_RP_STAMP(remote_rp_version)) { |
| 671 | DBUG_ON(XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars-> |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 672 | version)); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 673 | /* see if the other side rebooted */ |
| 674 | if (part->remote_amos_page_pa == |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 675 | remote_vars->amos_page_pa && |
| 676 | xpc_hb_allowed(sn_partition_id, remote_vars)) { |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 677 | /* doesn't look that way, so ignore the IPI */ |
| 678 | return; |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | /* |
| 683 | * Other side rebooted and previous XPC didn't support the |
| 684 | * disengage request, so we don't need to do anything special. |
| 685 | */ |
| 686 | |
| 687 | xpc_update_partition_info(part, remote_rp_version, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 688 | &remote_rp_stamp, remote_rp_pa, |
| 689 | remote_vars_pa, remote_vars); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 690 | part->reactivate_nasid = nasid; |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 691 | XPC_DEACTIVATE_PARTITION(part, xpReactivating); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 692 | return; |
| 693 | } |
| 694 | |
| 695 | DBUG_ON(!XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)); |
| 696 | |
| 697 | if (!XPC_SUPPORTS_RP_STAMP(remote_rp_version)) { |
| 698 | DBUG_ON(!XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars->version)); |
| 699 | |
| 700 | /* |
| 701 | * Other side rebooted and previous XPC did support the |
| 702 | * disengage request, but the new one doesn't. |
| 703 | */ |
| 704 | |
| 705 | xpc_clear_partition_engaged(1UL << partid); |
| 706 | xpc_clear_partition_disengage_request(1UL << partid); |
| 707 | |
| 708 | xpc_update_partition_info(part, remote_rp_version, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 709 | &remote_rp_stamp, remote_rp_pa, |
| 710 | remote_vars_pa, remote_vars); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 711 | reactivate = 1; |
| 712 | |
| 713 | } else { |
| 714 | DBUG_ON(!XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars->version)); |
| 715 | |
| 716 | stamp_diff = xpc_compare_stamps(&part->remote_rp_stamp, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 717 | &remote_rp_stamp); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 718 | if (stamp_diff != 0) { |
| 719 | DBUG_ON(stamp_diff >= 0); |
| 720 | |
| 721 | /* |
| 722 | * Other side rebooted and the previous XPC did support |
| 723 | * the disengage request, as does the new one. |
| 724 | */ |
| 725 | |
| 726 | DBUG_ON(xpc_partition_engaged(1UL << partid)); |
| 727 | DBUG_ON(xpc_partition_disengage_requested(1UL << |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 728 | partid)); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 729 | |
| 730 | xpc_update_partition_info(part, remote_rp_version, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 731 | &remote_rp_stamp, |
| 732 | remote_rp_pa, remote_vars_pa, |
| 733 | remote_vars); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 734 | reactivate = 1; |
| 735 | } |
| 736 | } |
| 737 | |
Dean Nelson | 246c7e3 | 2005-12-22 14:32:56 -0600 | [diff] [blame] | 738 | if (part->disengage_request_timeout > 0 && |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 739 | !xpc_partition_disengaged(part)) { |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 740 | /* still waiting on other side to disengage from us */ |
| 741 | return; |
| 742 | } |
| 743 | |
| 744 | if (reactivate) { |
| 745 | part->reactivate_nasid = nasid; |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 746 | XPC_DEACTIVATE_PARTITION(part, xpReactivating); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 747 | |
| 748 | } else if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version) && |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 749 | xpc_partition_disengage_requested(1UL << partid)) { |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 750 | XPC_DEACTIVATE_PARTITION(part, xpOtherGoingDown); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 751 | } |
| 752 | } |
| 753 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 754 | /* |
| 755 | * Loop through the activation AMO variables and process any bits |
| 756 | * which are set. Each bit indicates a nasid sending a partition |
| 757 | * activation or deactivation request. |
| 758 | * |
| 759 | * Return #of IRQs detected. |
| 760 | */ |
| 761 | int |
| 762 | xpc_identify_act_IRQ_sender(void) |
| 763 | { |
| 764 | int word, bit; |
| 765 | u64 nasid_mask; |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 766 | u64 nasid; /* remote nasid */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 767 | int n_IRQs_detected = 0; |
| 768 | AMO_t *act_amos; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 769 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 770 | act_amos = xpc_vars->amos_page + XPC_ACTIVATE_IRQ_AMOS; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 771 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 772 | /* scan through act AMO variable looking for non-zero entries */ |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 773 | for (word = 0; word < xp_nasid_mask_words; word++) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 774 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 775 | if (xpc_exiting) |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 776 | break; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 777 | |
| 778 | nasid_mask = xpc_IPI_receive(&act_amos[word]); |
| 779 | if (nasid_mask == 0) { |
| 780 | /* no IRQs from nasids in this variable */ |
| 781 | continue; |
| 782 | } |
| 783 | |
| 784 | dev_dbg(xpc_part, "AMO[%d] gave back 0x%lx\n", word, |
| 785 | nasid_mask); |
| 786 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 787 | /* |
| 788 | * If this nasid has been added to the machine since |
| 789 | * our partition was reset, this will retain the |
| 790 | * remote nasid in our reserved pages machine mask. |
| 791 | * This is used in the event of module reload. |
| 792 | */ |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 793 | xpc_mach_nasids[word] |= nasid_mask; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 794 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 795 | /* locate the nasid(s) which sent interrupts */ |
| 796 | |
| 797 | for (bit = 0; bit < (8 * sizeof(u64)); bit++) { |
| 798 | if (nasid_mask & (1UL << bit)) { |
| 799 | n_IRQs_detected++; |
| 800 | nasid = XPC_NASID_FROM_W_B(word, bit); |
| 801 | dev_dbg(xpc_part, "interrupt from nasid %ld\n", |
| 802 | nasid); |
| 803 | xpc_identify_act_IRQ_req(nasid); |
| 804 | } |
| 805 | } |
| 806 | } |
| 807 | return n_IRQs_detected; |
| 808 | } |
| 809 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 810 | /* |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 811 | * See if the other side has responded to a partition disengage request |
| 812 | * from us. |
| 813 | */ |
| 814 | int |
| 815 | xpc_partition_disengaged(struct xpc_partition *part) |
| 816 | { |
Dean Nelson | 64d032b | 2008-05-12 14:02:03 -0700 | [diff] [blame] | 817 | short partid = XPC_PARTID(part); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 818 | int disengaged; |
| 819 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 820 | disengaged = (xpc_partition_engaged(1UL << partid) == 0); |
| 821 | if (part->disengage_request_timeout) { |
| 822 | if (!disengaged) { |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 823 | if (time_before(jiffies, |
| 824 | part->disengage_request_timeout)) { |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 825 | /* timelimit hasn't been reached yet */ |
| 826 | return 0; |
| 827 | } |
| 828 | |
| 829 | /* |
| 830 | * Other side hasn't responded to our disengage |
| 831 | * request in a timely fashion, so assume it's dead. |
| 832 | */ |
| 833 | |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 834 | dev_info(xpc_part, "disengage from remote partition %d " |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 835 | "timed out\n", partid); |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 836 | xpc_disengage_request_timedout = 1; |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 837 | xpc_clear_partition_engaged(1UL << partid); |
| 838 | disengaged = 1; |
| 839 | } |
| 840 | part->disengage_request_timeout = 0; |
| 841 | |
| 842 | /* cancel the timer function, provided it's not us */ |
| 843 | if (!in_interrupt()) { |
| 844 | del_singleshot_timer_sync(&part-> |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 845 | disengage_request_timer); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | DBUG_ON(part->act_state != XPC_P_DEACTIVATING && |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 849 | part->act_state != XPC_P_INACTIVE); |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 850 | if (part->act_state != XPC_P_INACTIVE) |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 851 | xpc_wakeup_channel_mgr(part); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 852 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 853 | if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)) |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 854 | xpc_cancel_partition_disengage_request(part); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 855 | } |
| 856 | return disengaged; |
| 857 | } |
| 858 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 859 | /* |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 860 | * Mark specified partition as active. |
| 861 | */ |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 862 | enum xp_retval |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 863 | xpc_mark_partition_active(struct xpc_partition *part) |
| 864 | { |
| 865 | unsigned long irq_flags; |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 866 | enum xp_retval ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 867 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 868 | dev_dbg(xpc_part, "setting partition %d to ACTIVE\n", XPC_PARTID(part)); |
| 869 | |
| 870 | spin_lock_irqsave(&part->act_lock, irq_flags); |
| 871 | if (part->act_state == XPC_P_ACTIVATING) { |
| 872 | part->act_state = XPC_P_ACTIVE; |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 873 | ret = xpSuccess; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 874 | } else { |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 875 | DBUG_ON(part->reason == xpSuccess); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 876 | ret = part->reason; |
| 877 | } |
| 878 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
| 879 | |
| 880 | return ret; |
| 881 | } |
| 882 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 883 | /* |
| 884 | * Notify XPC that the partition is down. |
| 885 | */ |
| 886 | void |
| 887 | xpc_deactivate_partition(const int line, struct xpc_partition *part, |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 888 | enum xp_retval reason) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 889 | { |
| 890 | unsigned long irq_flags; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 891 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 892 | spin_lock_irqsave(&part->act_lock, irq_flags); |
| 893 | |
| 894 | if (part->act_state == XPC_P_INACTIVE) { |
| 895 | XPC_SET_REASON(part, reason, line); |
| 896 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 897 | if (reason == xpReactivating) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 898 | /* we interrupt ourselves to reactivate partition */ |
| 899 | xpc_IPI_send_reactivate(part); |
| 900 | } |
| 901 | return; |
| 902 | } |
| 903 | if (part->act_state == XPC_P_DEACTIVATING) { |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 904 | if ((part->reason == xpUnloading && reason != xpUnloading) || |
| 905 | reason == xpReactivating) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 906 | XPC_SET_REASON(part, reason, line); |
| 907 | } |
| 908 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
| 909 | return; |
| 910 | } |
| 911 | |
| 912 | part->act_state = XPC_P_DEACTIVATING; |
| 913 | XPC_SET_REASON(part, reason, line); |
| 914 | |
| 915 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
| 916 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 917 | if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)) { |
| 918 | xpc_request_partition_disengage(part); |
| 919 | xpc_IPI_send_disengage(part); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 920 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 921 | /* set a timelimit on the disengage request */ |
| 922 | part->disengage_request_timeout = jiffies + |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 923 | (xpc_disengage_request_timelimit * HZ); |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 924 | part->disengage_request_timer.expires = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 925 | part->disengage_request_timeout; |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 926 | add_timer(&part->disengage_request_timer); |
| 927 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 928 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 929 | dev_dbg(xpc_part, "bringing partition %d down, reason = %d\n", |
| 930 | XPC_PARTID(part), reason); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 931 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 932 | xpc_partition_going_down(part, reason); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 933 | } |
| 934 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 935 | /* |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 936 | * Mark specified partition as inactive. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 937 | */ |
| 938 | void |
| 939 | xpc_mark_partition_inactive(struct xpc_partition *part) |
| 940 | { |
| 941 | unsigned long irq_flags; |
| 942 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 943 | dev_dbg(xpc_part, "setting partition %d to INACTIVE\n", |
| 944 | XPC_PARTID(part)); |
| 945 | |
| 946 | spin_lock_irqsave(&part->act_lock, irq_flags); |
| 947 | part->act_state = XPC_P_INACTIVE; |
| 948 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
| 949 | part->remote_rp_pa = 0; |
| 950 | } |
| 951 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 952 | /* |
| 953 | * SAL has provided a partition and machine mask. The partition mask |
| 954 | * contains a bit for each even nasid in our partition. The machine |
| 955 | * mask contains a bit for each even nasid in the entire machine. |
| 956 | * |
| 957 | * Using those two bit arrays, we can determine which nasids are |
| 958 | * known in the machine. Each should also have a reserved page |
| 959 | * initialized if they are available for partitioning. |
| 960 | */ |
| 961 | void |
| 962 | xpc_discovery(void) |
| 963 | { |
| 964 | void *remote_rp_base; |
| 965 | struct xpc_rsvd_page *remote_rp; |
| 966 | struct xpc_vars *remote_vars; |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 967 | u64 remote_rp_pa; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 968 | u64 remote_vars_pa; |
| 969 | int region; |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 970 | int region_size; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 971 | int max_regions; |
| 972 | int nasid; |
| 973 | struct xpc_rsvd_page *rp; |
Dean Nelson | 64d032b | 2008-05-12 14:02:03 -0700 | [diff] [blame] | 974 | short partid; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 975 | struct xpc_partition *part; |
| 976 | u64 *discovered_nasids; |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 977 | enum xp_retval ret; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 978 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 979 | remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE + |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 980 | xp_nasid_mask_bytes, |
| 981 | GFP_KERNEL, &remote_rp_base); |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 982 | if (remote_rp == NULL) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 983 | return; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 984 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 985 | remote_vars = (struct xpc_vars *)remote_rp; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 986 | |
Jes Sorensen | 7aa6ba4 | 2006-02-17 05:18:43 -0500 | [diff] [blame] | 987 | discovered_nasids = kzalloc(sizeof(u64) * xp_nasid_mask_words, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 988 | GFP_KERNEL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 989 | if (discovered_nasids == NULL) { |
| 990 | kfree(remote_rp_base); |
| 991 | return; |
| 992 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 993 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 994 | rp = (struct xpc_rsvd_page *)xpc_rsvd_page; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 995 | |
| 996 | /* |
| 997 | * The term 'region' in this context refers to the minimum number of |
| 998 | * nodes that can comprise an access protection grouping. The access |
| 999 | * protection is in regards to memory, IOI and IPI. |
| 1000 | */ |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 1001 | max_regions = 64; |
| 1002 | region_size = sn_region_size; |
| 1003 | |
| 1004 | switch (region_size) { |
| 1005 | case 128: |
| 1006 | max_regions *= 2; |
| 1007 | case 64: |
| 1008 | max_regions *= 2; |
| 1009 | case 32: |
| 1010 | max_regions *= 2; |
| 1011 | region_size = 16; |
| 1012 | DBUG_ON(!is_shub2()); |
| 1013 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1014 | |
| 1015 | for (region = 0; region < max_regions; region++) { |
| 1016 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 1017 | if (xpc_exiting) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1018 | break; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1019 | |
| 1020 | dev_dbg(xpc_part, "searching region %d\n", region); |
| 1021 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 1022 | for (nasid = (region * region_size * 2); |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1023 | nasid < ((region + 1) * region_size * 2); nasid += 2) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1024 | |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 1025 | if (xpc_exiting) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1026 | break; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1027 | |
| 1028 | dev_dbg(xpc_part, "checking nasid %d\n", nasid); |
| 1029 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 1030 | if (XPC_NASID_IN_ARRAY(nasid, xpc_part_nasids)) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1031 | dev_dbg(xpc_part, "PROM indicates Nasid %d is " |
| 1032 | "part of the local partition; skipping " |
| 1033 | "region\n", nasid); |
| 1034 | break; |
| 1035 | } |
| 1036 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 1037 | if (!(XPC_NASID_IN_ARRAY(nasid, xpc_mach_nasids))) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1038 | dev_dbg(xpc_part, "PROM indicates Nasid %d was " |
| 1039 | "not on Numa-Link network at reset\n", |
| 1040 | nasid); |
| 1041 | continue; |
| 1042 | } |
| 1043 | |
| 1044 | if (XPC_NASID_IN_ARRAY(nasid, discovered_nasids)) { |
| 1045 | dev_dbg(xpc_part, "Nasid %d is part of a " |
| 1046 | "partition which was previously " |
| 1047 | "discovered\n", nasid); |
| 1048 | continue; |
| 1049 | } |
| 1050 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1051 | /* pull over the reserved page structure */ |
| 1052 | |
| 1053 | ret = xpc_get_remote_rp(nasid, discovered_nasids, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1054 | remote_rp, &remote_rp_pa); |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1055 | if (ret != xpSuccess) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1056 | dev_dbg(xpc_part, "unable to get reserved page " |
| 1057 | "from nasid %d, reason=%d\n", nasid, |
| 1058 | ret); |
| 1059 | |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1060 | if (ret == xpLocalPartid) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1061 | break; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 1062 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1063 | continue; |
| 1064 | } |
| 1065 | |
| 1066 | remote_vars_pa = remote_rp->vars_pa; |
| 1067 | |
| 1068 | partid = remote_rp->partid; |
| 1069 | part = &xpc_partitions[partid]; |
| 1070 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1071 | /* pull over the cross partition variables */ |
| 1072 | |
| 1073 | ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1074 | if (ret != xpSuccess) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1075 | dev_dbg(xpc_part, "unable to get XPC variables " |
| 1076 | "from nasid %d, reason=%d\n", nasid, |
| 1077 | ret); |
| 1078 | |
| 1079 | XPC_DEACTIVATE_PARTITION(part, ret); |
| 1080 | continue; |
| 1081 | } |
| 1082 | |
| 1083 | if (part->act_state != XPC_P_INACTIVE) { |
| 1084 | dev_dbg(xpc_part, "partition %d on nasid %d is " |
| 1085 | "already activating\n", partid, nasid); |
| 1086 | break; |
| 1087 | } |
| 1088 | |
| 1089 | /* |
| 1090 | * Register the remote partition's AMOs with SAL so it |
| 1091 | * can handle and cleanup errors within that address |
| 1092 | * range should the remote partition go down. We don't |
| 1093 | * unregister this range because it is difficult to |
| 1094 | * tell when outstanding writes to the remote partition |
| 1095 | * are finished and thus when it is thus safe to |
| 1096 | * unregister. This should not result in wasted space |
| 1097 | * in the SAL xp_addr_region table because we should |
| 1098 | * get the same page for remote_act_amos_pa after |
| 1099 | * module reloads and system reboots. |
| 1100 | */ |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1101 | if (sn_register_xp_addr_region |
| 1102 | (remote_vars->amos_page_pa, PAGE_SIZE, 1) < 0) { |
| 1103 | dev_dbg(xpc_part, |
| 1104 | "partition %d failed to " |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1105 | "register xp_addr region 0x%016lx\n", |
| 1106 | partid, remote_vars->amos_page_pa); |
| 1107 | |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1108 | XPC_SET_REASON(part, xpPhysAddrRegFailed, |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1109 | __LINE__); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1110 | break; |
| 1111 | } |
| 1112 | |
| 1113 | /* |
| 1114 | * The remote nasid is valid and available. |
| 1115 | * Send an interrupt to that nasid to notify |
| 1116 | * it that we are ready to begin activation. |
| 1117 | */ |
| 1118 | dev_dbg(xpc_part, "sending an interrupt to AMO 0x%lx, " |
| 1119 | "nasid %d, phys_cpuid 0x%x\n", |
| 1120 | remote_vars->amos_page_pa, |
| 1121 | remote_vars->act_nasid, |
| 1122 | remote_vars->act_phys_cpuid); |
| 1123 | |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1124 | if (XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars-> |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1125 | version)) { |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1126 | part->remote_amos_page_pa = |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1127 | remote_vars->amos_page_pa; |
Dean Nelson | a607c389 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1128 | xpc_mark_partition_disengaged(part); |
| 1129 | xpc_cancel_partition_disengage_request(part); |
| 1130 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1131 | xpc_IPI_send_activate(remote_vars); |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | kfree(discovered_nasids); |
| 1136 | kfree(remote_rp_base); |
| 1137 | } |
| 1138 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1139 | /* |
| 1140 | * Given a partid, get the nasids owned by that partition from the |
Dean Nelson | 3a7d555 | 2005-04-04 13:14:00 -0700 | [diff] [blame] | 1141 | * remote partition's reserved page. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1142 | */ |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1143 | enum xp_retval |
Dean Nelson | 64d032b | 2008-05-12 14:02:03 -0700 | [diff] [blame] | 1144 | xpc_initiate_partid_to_nasids(short partid, void *nasid_mask) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1145 | { |
| 1146 | struct xpc_partition *part; |
| 1147 | u64 part_nasid_pa; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1148 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1149 | part = &xpc_partitions[partid]; |
Dean Nelson | 2c2b94f | 2008-04-22 14:50:17 -0500 | [diff] [blame] | 1150 | if (part->remote_rp_pa == 0) |
Dean Nelson | 65c17b8 | 2008-05-12 14:02:02 -0700 | [diff] [blame] | 1151 | return xpPartitionDown; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1152 | |
Dean Nelson | 4b38fcd | 2005-10-25 14:09:51 -0500 | [diff] [blame] | 1153 | memset(nasid_mask, 0, XP_NASID_MASK_BYTES); |
| 1154 | |
Dean Nelson | 4a3ad2d | 2008-04-22 14:48:01 -0500 | [diff] [blame] | 1155 | part_nasid_pa = (u64)XPC_RP_PART_NASIDS(part->remote_rp_pa); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1156 | |
Dean Nelson | 908787d | 2008-07-29 22:34:05 -0700 | [diff] [blame^] | 1157 | return xp_remote_memcpy(nasid_mask, (void *)part_nasid_pa, |
| 1158 | xp_nasid_mask_bytes); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1159 | } |