diff options
| -rw-r--r-- | drivers/misc/sgi-xp/xp.h | 3 | ||||
| -rw-r--r-- | drivers/misc/sgi-xp/xpc.h | 43 | ||||
| -rw-r--r-- | drivers/misc/sgi-xp/xpc_partition.c | 43 | ||||
| -rw-r--r-- | drivers/misc/sgi-xp/xpc_sn2.c | 73 |
4 files changed, 76 insertions, 86 deletions
diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h index 0ca81f16646f..3054fae8b023 100644 --- a/drivers/misc/sgi-xp/xp.h +++ b/drivers/misc/sgi-xp/xp.h | |||
| @@ -21,9 +21,6 @@ | |||
| 21 | #include <asm/sn/arch.h> | 21 | #include <asm/sn/arch.h> |
| 22 | #endif | 22 | #endif |
| 23 | 23 | ||
| 24 | /* ??? Add this #define to some linux header file some day? */ | ||
| 25 | #define BYTES_PER_WORD sizeof(void *) | ||
| 26 | |||
| 27 | #ifdef USE_DBUG_ON | 24 | #ifdef USE_DBUG_ON |
| 28 | #define DBUG_ON(condition) BUG_ON(condition) | 25 | #define DBUG_ON(condition) BUG_ON(condition) |
| 29 | #else | 26 | #else |
diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h index 0f516c3e3e61..0907934cdd8f 100644 --- a/drivers/misc/sgi-xp/xpc.h +++ b/drivers/misc/sgi-xp/xpc.h | |||
| @@ -35,23 +35,7 @@ | |||
| 35 | #define XPC_VERSION_MAJOR(_v) ((_v) >> 4) | 35 | #define XPC_VERSION_MAJOR(_v) ((_v) >> 4) |
| 36 | #define XPC_VERSION_MINOR(_v) ((_v) & 0xf) | 36 | #define XPC_VERSION_MINOR(_v) ((_v) & 0xf) |
| 37 | 37 | ||
| 38 | /* | 38 | /* define frequency of the heartbeat and frequency how often it's checked */ |
| 39 | * The next macros define word or bit representations for given | ||
| 40 | * C-brick nasid in either the SAL provided bit array representing | ||
| 41 | * nasids in the partition/machine or the array of amo structures used | ||
| 42 | * for inter-partition initiation communications. | ||
| 43 | * | ||
| 44 | * For SN2 machines, C-Bricks are alway even numbered NASIDs. As | ||
| 45 | * such, some space will be saved by insisting that nasid information | ||
| 46 | * passed from SAL always be packed for C-Bricks and the | ||
| 47 | * cross-partition interrupts use the same packing scheme. | ||
| 48 | */ | ||
| 49 | #define XPC_NASID_W_INDEX(_n) (((_n) / 64) / 2) | ||
| 50 | #define XPC_NASID_B_INDEX(_n) (((_n) / 2) & (64 - 1)) | ||
| 51 | #define XPC_NASID_IN_ARRAY(_n, _p) ((_p)[XPC_NASID_W_INDEX(_n)] & \ | ||
| 52 | (1UL << XPC_NASID_B_INDEX(_n))) | ||
| 53 | #define XPC_NASID_FROM_W_B(_w, _b) (((_w) * 64 + (_b)) * 2) | ||
| 54 | |||
| 55 | #define XPC_HB_DEFAULT_INTERVAL 5 /* incr HB every x secs */ | 39 | #define XPC_HB_DEFAULT_INTERVAL 5 /* incr HB every x secs */ |
| 56 | #define XPC_HB_CHECK_DEFAULT_INTERVAL 20 /* check HB every x secs */ | 40 | #define XPC_HB_CHECK_DEFAULT_INTERVAL 20 /* check HB every x secs */ |
| 57 | 41 | ||
| @@ -86,11 +70,13 @@ | |||
| 86 | * the actual nasids in the entire machine (mach_nasids). We're only | 70 | * the actual nasids in the entire machine (mach_nasids). We're only |
| 87 | * interested in the even numbered nasids (which contain the processors | 71 | * interested in the even numbered nasids (which contain the processors |
| 88 | * and/or memory), so we only need half as many bits to represent the | 72 | * and/or memory), so we only need half as many bits to represent the |
| 89 | * nasids. The part_nasids mask is located starting at the first cacheline | 73 | * nasids. When mapping nasid to bit in a mask (or bit to nasid) be sure |
| 90 | * following the reserved page header. The mach_nasids mask follows right | 74 | * to either divide or multiply by 2. The part_nasids mask is located |
| 91 | * after the part_nasids mask. The size in bytes of each mask is reflected | 75 | * starting at the first cacheline following the reserved page header. The |
| 92 | * by the reserved page header field 'SAL_nasids_size'. (Local partition's | 76 | * mach_nasids mask follows right after the part_nasids mask. The size in |
| 93 | * mask pointers are xpc_part_nasids and xpc_mach_nasids.) | 77 | * bytes of each mask is reflected by the reserved page header field |
| 78 | * 'SAL_nasids_size'. (Local partition's mask pointers are xpc_part_nasids | ||
| 79 | * and xpc_mach_nasids.) | ||
| 94 | * | 80 | * |
| 95 | * vars (ia64-sn2 only) | 81 | * vars (ia64-sn2 only) |
| 96 | * vars part (ia64-sn2 only) | 82 | * vars part (ia64-sn2 only) |
| @@ -194,10 +180,11 @@ struct xpc_vars_part_sn2 { | |||
| 194 | #define XPC_RP_VARS_SIZE L1_CACHE_ALIGN(sizeof(struct xpc_vars_sn2)) | 180 | #define XPC_RP_VARS_SIZE L1_CACHE_ALIGN(sizeof(struct xpc_vars_sn2)) |
| 195 | 181 | ||
| 196 | #define XPC_RP_PART_NASIDS(_rp) ((u64 *)((u8 *)(_rp) + XPC_RP_HEADER_SIZE)) | 182 | #define XPC_RP_PART_NASIDS(_rp) ((u64 *)((u8 *)(_rp) + XPC_RP_HEADER_SIZE)) |
| 197 | #define XPC_RP_MACH_NASIDS(_rp) (XPC_RP_PART_NASIDS(_rp) + xpc_nasid_mask_words) | 183 | #define XPC_RP_MACH_NASIDS(_rp) (XPC_RP_PART_NASIDS(_rp) + \ |
| 184 | xpc_nasid_mask_nlongs) | ||
| 198 | #define XPC_RP_VARS(_rp) ((struct xpc_vars_sn2 *) \ | 185 | #define XPC_RP_VARS(_rp) ((struct xpc_vars_sn2 *) \ |
| 199 | (XPC_RP_MACH_NASIDS(_rp) + \ | 186 | (XPC_RP_MACH_NASIDS(_rp) + \ |
| 200 | xpc_nasid_mask_words)) | 187 | xpc_nasid_mask_nlongs)) |
| 201 | 188 | ||
| 202 | /* | 189 | /* |
| 203 | * Functions registered by add_timer() or called by kernel_thread() only | 190 | * Functions registered by add_timer() or called by kernel_thread() only |
| @@ -695,9 +682,9 @@ extern void xpc_exit_uv(void); | |||
| 695 | 682 | ||
| 696 | /* found in xpc_partition.c */ | 683 | /* found in xpc_partition.c */ |
| 697 | extern int xpc_exiting; | 684 | extern int xpc_exiting; |
| 698 | extern int xpc_nasid_mask_words; | 685 | extern int xpc_nasid_mask_nlongs; |
| 699 | extern struct xpc_rsvd_page *xpc_rsvd_page; | 686 | extern struct xpc_rsvd_page *xpc_rsvd_page; |
| 700 | extern u64 *xpc_mach_nasids; | 687 | extern unsigned long *xpc_mach_nasids; |
| 701 | extern struct xpc_partition *xpc_partitions; | 688 | extern struct xpc_partition *xpc_partitions; |
| 702 | extern void *xpc_kmalloc_cacheline_aligned(size_t, gfp_t, void **); | 689 | extern void *xpc_kmalloc_cacheline_aligned(size_t, gfp_t, void **); |
| 703 | extern struct xpc_rsvd_page *xpc_setup_rsvd_page(void); | 690 | extern struct xpc_rsvd_page *xpc_setup_rsvd_page(void); |
| @@ -706,8 +693,8 @@ extern int xpc_partition_disengaged(struct xpc_partition *); | |||
| 706 | extern enum xp_retval xpc_mark_partition_active(struct xpc_partition *); | 693 | extern enum xp_retval xpc_mark_partition_active(struct xpc_partition *); |
| 707 | extern void xpc_mark_partition_inactive(struct xpc_partition *); | 694 | extern void xpc_mark_partition_inactive(struct xpc_partition *); |
| 708 | extern void xpc_discovery(void); | 695 | extern void xpc_discovery(void); |
| 709 | extern enum xp_retval xpc_get_remote_rp(int, u64 *, struct xpc_rsvd_page *, | 696 | extern enum xp_retval xpc_get_remote_rp(int, unsigned long *, |
| 710 | u64 *); | 697 | struct xpc_rsvd_page *, u64 *); |
| 711 | extern void xpc_deactivate_partition(const int, struct xpc_partition *, | 698 | extern void xpc_deactivate_partition(const int, struct xpc_partition *, |
| 712 | enum xp_retval); | 699 | enum xp_retval); |
| 713 | extern enum xp_retval xpc_initiate_partid_to_nasids(short, void *); | 700 | extern enum xp_retval xpc_initiate_partid_to_nasids(short, void *); |
diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c index 73a92957b800..ca6784f55970 100644 --- a/drivers/misc/sgi-xp/xpc_partition.c +++ b/drivers/misc/sgi-xp/xpc_partition.c | |||
| @@ -31,11 +31,11 @@ int xpc_exiting; | |||
| 31 | 31 | ||
| 32 | /* this partition's reserved page pointers */ | 32 | /* this partition's reserved page pointers */ |
| 33 | struct xpc_rsvd_page *xpc_rsvd_page; | 33 | struct xpc_rsvd_page *xpc_rsvd_page; |
| 34 | static u64 *xpc_part_nasids; | 34 | static unsigned long *xpc_part_nasids; |
| 35 | u64 *xpc_mach_nasids; | 35 | unsigned long *xpc_mach_nasids; |
| 36 | 36 | ||
| 37 | static int xpc_sizeof_nasid_mask; /* actual size in bytes of nasid mask */ | 37 | static int xpc_nasid_mask_nbytes; /* #of bytes in nasid mask */ |
| 38 | int xpc_nasid_mask_words; /* actual size in words of nasid mask */ | 38 | int xpc_nasid_mask_nlongs; /* #of longs in nasid mask */ |
| 39 | 39 | ||
| 40 | struct xpc_partition *xpc_partitions; | 40 | struct xpc_partition *xpc_partitions; |
| 41 | 41 | ||
| @@ -167,9 +167,9 @@ xpc_setup_rsvd_page(void) | |||
| 167 | /* SAL_version 1 didn't set the nasids_size field */ | 167 | /* SAL_version 1 didn't set the nasids_size field */ |
| 168 | rp->SAL_nasids_size = 128; | 168 | rp->SAL_nasids_size = 128; |
| 169 | } | 169 | } |
| 170 | xpc_sizeof_nasid_mask = rp->SAL_nasids_size; | 170 | xpc_nasid_mask_nbytes = rp->SAL_nasids_size; |
| 171 | xpc_nasid_mask_words = DIV_ROUND_UP(xpc_sizeof_nasid_mask, | 171 | xpc_nasid_mask_nlongs = BITS_TO_LONGS(rp->SAL_nasids_size * |
| 172 | BYTES_PER_WORD); | 172 | BITS_PER_BYTE); |
| 173 | 173 | ||
| 174 | /* setup the pointers to the various items in the reserved page */ | 174 | /* setup the pointers to the various items in the reserved page */ |
| 175 | xpc_part_nasids = XPC_RP_PART_NASIDS(rp); | 175 | xpc_part_nasids = XPC_RP_PART_NASIDS(rp); |
| @@ -199,10 +199,10 @@ xpc_setup_rsvd_page(void) | |||
| 199 | * part_nasids mask. | 199 | * part_nasids mask. |
| 200 | */ | 200 | */ |
| 201 | enum xp_retval | 201 | enum xp_retval |
| 202 | xpc_get_remote_rp(int nasid, u64 *discovered_nasids, | 202 | xpc_get_remote_rp(int nasid, unsigned long *discovered_nasids, |
| 203 | struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa) | 203 | struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa) |
| 204 | { | 204 | { |
| 205 | int i; | 205 | int l; |
| 206 | enum xp_retval ret; | 206 | enum xp_retval ret; |
| 207 | 207 | ||
| 208 | /* get the reserved page's physical address */ | 208 | /* get the reserved page's physical address */ |
| @@ -213,15 +213,16 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids, | |||
| 213 | 213 | ||
| 214 | /* pull over the reserved page header and part_nasids mask */ | 214 | /* pull over the reserved page header and part_nasids mask */ |
| 215 | ret = xp_remote_memcpy(remote_rp, (void *)*remote_rp_pa, | 215 | ret = xp_remote_memcpy(remote_rp, (void *)*remote_rp_pa, |
| 216 | XPC_RP_HEADER_SIZE + xpc_sizeof_nasid_mask); | 216 | XPC_RP_HEADER_SIZE + xpc_nasid_mask_nbytes); |
| 217 | if (ret != xpSuccess) | 217 | if (ret != xpSuccess) |
| 218 | return ret; | 218 | return ret; |
| 219 | 219 | ||
| 220 | if (discovered_nasids != NULL) { | 220 | if (discovered_nasids != NULL) { |
| 221 | u64 *remote_part_nasids = XPC_RP_PART_NASIDS(remote_rp); | 221 | unsigned long *remote_part_nasids = |
| 222 | XPC_RP_PART_NASIDS(remote_rp); | ||
| 222 | 223 | ||
| 223 | for (i = 0; i < xpc_nasid_mask_words; i++) | 224 | for (l = 0; l < xpc_nasid_mask_nlongs; l++) |
| 224 | discovered_nasids[i] |= remote_part_nasids[i]; | 225 | discovered_nasids[l] |= remote_part_nasids[l]; |
| 225 | } | 226 | } |
| 226 | 227 | ||
| 227 | /* see if the reserved page has been set up by XPC */ | 228 | /* see if the reserved page has been set up by XPC */ |
| @@ -401,16 +402,16 @@ xpc_discovery(void) | |||
| 401 | int max_regions; | 402 | int max_regions; |
| 402 | int nasid; | 403 | int nasid; |
| 403 | struct xpc_rsvd_page *rp; | 404 | struct xpc_rsvd_page *rp; |
| 404 | u64 *discovered_nasids; | 405 | unsigned long *discovered_nasids; |
| 405 | enum xp_retval ret; | 406 | enum xp_retval ret; |
| 406 | 407 | ||
| 407 | remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE + | 408 | remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE + |
| 408 | xpc_sizeof_nasid_mask, | 409 | xpc_nasid_mask_nbytes, |
| 409 | GFP_KERNEL, &remote_rp_base); | 410 | GFP_KERNEL, &remote_rp_base); |
| 410 | if (remote_rp == NULL) | 411 | if (remote_rp == NULL) |
| 411 | return; | 412 | return; |
| 412 | 413 | ||
| 413 | discovered_nasids = kzalloc(sizeof(u64) * xpc_nasid_mask_words, | 414 | discovered_nasids = kzalloc(sizeof(long) * xpc_nasid_mask_nlongs, |
| 414 | GFP_KERNEL); | 415 | GFP_KERNEL); |
| 415 | if (discovered_nasids == NULL) { | 416 | if (discovered_nasids == NULL) { |
| 416 | kfree(remote_rp_base); | 417 | kfree(remote_rp_base); |
| @@ -453,21 +454,21 @@ xpc_discovery(void) | |||
| 453 | 454 | ||
| 454 | dev_dbg(xpc_part, "checking nasid %d\n", nasid); | 455 | dev_dbg(xpc_part, "checking nasid %d\n", nasid); |
| 455 | 456 | ||
| 456 | if (XPC_NASID_IN_ARRAY(nasid, xpc_part_nasids)) { | 457 | if (test_bit(nasid / 2, xpc_part_nasids)) { |
| 457 | dev_dbg(xpc_part, "PROM indicates Nasid %d is " | 458 | dev_dbg(xpc_part, "PROM indicates Nasid %d is " |
| 458 | "part of the local partition; skipping " | 459 | "part of the local partition; skipping " |
| 459 | "region\n", nasid); | 460 | "region\n", nasid); |
| 460 | break; | 461 | break; |
| 461 | } | 462 | } |
| 462 | 463 | ||
| 463 | if (!(XPC_NASID_IN_ARRAY(nasid, xpc_mach_nasids))) { | 464 | if (!(test_bit(nasid / 2, xpc_mach_nasids))) { |
| 464 | dev_dbg(xpc_part, "PROM indicates Nasid %d was " | 465 | dev_dbg(xpc_part, "PROM indicates Nasid %d was " |
| 465 | "not on Numa-Link network at reset\n", | 466 | "not on Numa-Link network at reset\n", |
| 466 | nasid); | 467 | nasid); |
| 467 | continue; | 468 | continue; |
| 468 | } | 469 | } |
| 469 | 470 | ||
| 470 | if (XPC_NASID_IN_ARRAY(nasid, discovered_nasids)) { | 471 | if (test_bit(nasid / 2, discovered_nasids)) { |
| 471 | dev_dbg(xpc_part, "Nasid %d is part of a " | 472 | dev_dbg(xpc_part, "Nasid %d is part of a " |
| 472 | "partition which was previously " | 473 | "partition which was previously " |
| 473 | "discovered\n", nasid); | 474 | "discovered\n", nasid); |
| @@ -512,10 +513,10 @@ xpc_initiate_partid_to_nasids(short partid, void *nasid_mask) | |||
| 512 | if (part->remote_rp_pa == 0) | 513 | if (part->remote_rp_pa == 0) |
| 513 | return xpPartitionDown; | 514 | return xpPartitionDown; |
| 514 | 515 | ||
| 515 | memset(nasid_mask, 0, xpc_sizeof_nasid_mask); | 516 | memset(nasid_mask, 0, xpc_nasid_mask_nbytes); |
| 516 | 517 | ||
| 517 | part_nasid_pa = (u64)XPC_RP_PART_NASIDS(part->remote_rp_pa); | 518 | part_nasid_pa = (u64)XPC_RP_PART_NASIDS(part->remote_rp_pa); |
| 518 | 519 | ||
| 519 | return xp_remote_memcpy(nasid_mask, (void *)part_nasid_pa, | 520 | return xp_remote_memcpy(nasid_mask, (void *)part_nasid_pa, |
| 520 | xpc_sizeof_nasid_mask); | 521 | xpc_nasid_mask_nbytes); |
| 521 | } | 522 | } |
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c index e42c3038203c..f82889f60151 100644 --- a/drivers/misc/sgi-xp/xpc_sn2.c +++ b/drivers/misc/sgi-xp/xpc_sn2.c | |||
| @@ -210,28 +210,26 @@ static void | |||
| 210 | xpc_send_activate_IRQ_sn2(u64 amos_page_pa, int from_nasid, int to_nasid, | 210 | xpc_send_activate_IRQ_sn2(u64 amos_page_pa, int from_nasid, int to_nasid, |
| 211 | int to_phys_cpuid) | 211 | int to_phys_cpuid) |
| 212 | { | 212 | { |
| 213 | int w_index = XPC_NASID_W_INDEX(from_nasid); | ||
| 214 | int b_index = XPC_NASID_B_INDEX(from_nasid); | ||
| 215 | struct amo *amos = (struct amo *)__va(amos_page_pa + | 213 | struct amo *amos = (struct amo *)__va(amos_page_pa + |
| 216 | (XPC_ACTIVATE_IRQ_AMOS_SN2 * | 214 | (XPC_ACTIVATE_IRQ_AMOS_SN2 * |
| 217 | sizeof(struct amo))); | 215 | sizeof(struct amo))); |
| 218 | 216 | ||
| 219 | (void)xpc_send_IRQ_sn2(&amos[w_index], (1UL << b_index), to_nasid, | 217 | (void)xpc_send_IRQ_sn2(&amos[BIT_WORD(from_nasid / 2)], |
| 218 | BIT_MASK(from_nasid / 2), to_nasid, | ||
| 220 | to_phys_cpuid, SGI_XPC_ACTIVATE); | 219 | to_phys_cpuid, SGI_XPC_ACTIVATE); |
| 221 | } | 220 | } |
| 222 | 221 | ||
| 223 | static void | 222 | static void |
| 224 | xpc_send_local_activate_IRQ_sn2(int from_nasid) | 223 | xpc_send_local_activate_IRQ_sn2(int from_nasid) |
| 225 | { | 224 | { |
| 226 | int w_index = XPC_NASID_W_INDEX(from_nasid); | ||
| 227 | int b_index = XPC_NASID_B_INDEX(from_nasid); | ||
| 228 | struct amo *amos = (struct amo *)__va(xpc_vars_sn2->amos_page_pa + | 225 | struct amo *amos = (struct amo *)__va(xpc_vars_sn2->amos_page_pa + |
| 229 | (XPC_ACTIVATE_IRQ_AMOS_SN2 * | 226 | (XPC_ACTIVATE_IRQ_AMOS_SN2 * |
| 230 | sizeof(struct amo))); | 227 | sizeof(struct amo))); |
| 231 | 228 | ||
| 232 | /* fake the sending and receipt of an activate IRQ from remote nasid */ | 229 | /* fake the sending and receipt of an activate IRQ from remote nasid */ |
| 233 | FETCHOP_STORE_OP(TO_AMO((u64)&amos[w_index].variable), FETCHOP_OR, | 230 | FETCHOP_STORE_OP(TO_AMO((u64)&amos[BIT_WORD(from_nasid / 2)].variable), |
| 234 | (1UL << b_index)); | 231 | FETCHOP_OR, BIT_MASK(from_nasid / 2)); |
| 232 | |||
| 235 | atomic_inc(&xpc_activate_IRQ_rcvd); | 233 | atomic_inc(&xpc_activate_IRQ_rcvd); |
| 236 | wake_up_interruptible(&xpc_activate_IRQ_wq); | 234 | wake_up_interruptible(&xpc_activate_IRQ_wq); |
| 237 | } | 235 | } |
| @@ -439,7 +437,8 @@ xpc_indicate_partition_engaged_sn2(struct xpc_partition *part) | |||
| 439 | 437 | ||
| 440 | /* set bit corresponding to our partid in remote partition's amo */ | 438 | /* set bit corresponding to our partid in remote partition's amo */ |
| 441 | FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_OR, | 439 | FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_OR, |
| 442 | (1UL << sn_partition_id)); | 440 | BIT(sn_partition_id)); |
| 441 | |||
| 443 | /* | 442 | /* |
| 444 | * We must always use the nofault function regardless of whether we | 443 | * We must always use the nofault function regardless of whether we |
| 445 | * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we | 444 | * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we |
| @@ -466,7 +465,8 @@ xpc_indicate_partition_disengaged_sn2(struct xpc_partition *part) | |||
| 466 | 465 | ||
| 467 | /* clear bit corresponding to our partid in remote partition's amo */ | 466 | /* clear bit corresponding to our partid in remote partition's amo */ |
| 468 | FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND, | 467 | FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND, |
| 469 | ~(1UL << sn_partition_id)); | 468 | ~BIT(sn_partition_id)); |
| 469 | |||
| 470 | /* | 470 | /* |
| 471 | * We must always use the nofault function regardless of whether we | 471 | * We must always use the nofault function regardless of whether we |
| 472 | * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we | 472 | * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we |
| @@ -497,7 +497,7 @@ xpc_partition_engaged_sn2(short partid) | |||
| 497 | 497 | ||
| 498 | /* our partition's amo variable ANDed with partid mask */ | 498 | /* our partition's amo variable ANDed with partid mask */ |
| 499 | return (FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_LOAD) & | 499 | return (FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_LOAD) & |
| 500 | (1UL << partid)) != 0; | 500 | BIT(partid)) != 0; |
| 501 | } | 501 | } |
| 502 | 502 | ||
| 503 | static int | 503 | static int |
| @@ -518,7 +518,7 @@ xpc_assume_partition_disengaged_sn2(short partid) | |||
| 518 | 518 | ||
| 519 | /* clear bit(s) based on partid mask in our partition's amo */ | 519 | /* clear bit(s) based on partid mask in our partition's amo */ |
| 520 | FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND, | 520 | FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND, |
| 521 | ~(1UL << partid)); | 521 | ~BIT(partid)); |
| 522 | } | 522 | } |
| 523 | 523 | ||
| 524 | /* original protection values for each node */ | 524 | /* original protection values for each node */ |
| @@ -639,7 +639,7 @@ xpc_rsvd_page_init_sn2(struct xpc_rsvd_page *rp) | |||
| 639 | xp_max_npartitions); | 639 | xp_max_npartitions); |
| 640 | 640 | ||
| 641 | /* initialize the activate IRQ related amo variables */ | 641 | /* initialize the activate IRQ related amo variables */ |
| 642 | for (i = 0; i < xpc_nasid_mask_words; i++) | 642 | for (i = 0; i < xpc_nasid_mask_nlongs; i++) |
| 643 | (void)xpc_init_IRQ_amo_sn2(XPC_ACTIVATE_IRQ_AMOS_SN2 + i); | 643 | (void)xpc_init_IRQ_amo_sn2(XPC_ACTIVATE_IRQ_AMOS_SN2 + i); |
| 644 | 644 | ||
| 645 | /* initialize the engaged remote partitions related amo variables */ | 645 | /* initialize the engaged remote partitions related amo variables */ |
| @@ -796,7 +796,8 @@ xpc_request_partition_deactivation_sn2(struct xpc_partition *part) | |||
| 796 | 796 | ||
| 797 | /* set bit corresponding to our partid in remote partition's amo */ | 797 | /* set bit corresponding to our partid in remote partition's amo */ |
| 798 | FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_OR, | 798 | FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_OR, |
| 799 | (1UL << sn_partition_id)); | 799 | BIT(sn_partition_id)); |
| 800 | |||
| 800 | /* | 801 | /* |
| 801 | * We must always use the nofault function regardless of whether we | 802 | * We must always use the nofault function regardless of whether we |
| 802 | * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we | 803 | * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we |
| @@ -831,7 +832,8 @@ xpc_cancel_partition_deactivation_request_sn2(struct xpc_partition *part) | |||
| 831 | 832 | ||
| 832 | /* clear bit corresponding to our partid in remote partition's amo */ | 833 | /* clear bit corresponding to our partid in remote partition's amo */ |
| 833 | FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND, | 834 | FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND, |
| 834 | ~(1UL << sn_partition_id)); | 835 | ~BIT(sn_partition_id)); |
| 836 | |||
| 835 | /* | 837 | /* |
| 836 | * We must always use the nofault function regardless of whether we | 838 | * We must always use the nofault function regardless of whether we |
| 837 | * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we | 839 | * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we |
| @@ -853,7 +855,7 @@ xpc_partition_deactivation_requested_sn2(short partid) | |||
| 853 | 855 | ||
| 854 | /* our partition's amo variable ANDed with partid mask */ | 856 | /* our partition's amo variable ANDed with partid mask */ |
| 855 | return (FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_LOAD) & | 857 | return (FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_LOAD) & |
| 856 | (1UL << partid)) != 0; | 858 | BIT(partid)) != 0; |
| 857 | } | 859 | } |
| 858 | 860 | ||
| 859 | /* | 861 | /* |
| @@ -1031,28 +1033,31 @@ xpc_identify_activate_IRQ_req_sn2(int nasid) | |||
| 1031 | int | 1033 | int |
| 1032 | xpc_identify_activate_IRQ_sender_sn2(void) | 1034 | xpc_identify_activate_IRQ_sender_sn2(void) |
| 1033 | { | 1035 | { |
| 1034 | int word, bit; | 1036 | int l; |
| 1035 | u64 nasid_mask; | 1037 | int b; |
| 1038 | unsigned long nasid_mask_long; | ||
| 1036 | u64 nasid; /* remote nasid */ | 1039 | u64 nasid; /* remote nasid */ |
| 1037 | int n_IRQs_detected = 0; | 1040 | int n_IRQs_detected = 0; |
| 1038 | struct amo *act_amos; | 1041 | struct amo *act_amos; |
| 1039 | 1042 | ||
| 1040 | act_amos = xpc_vars_sn2->amos_page + XPC_ACTIVATE_IRQ_AMOS_SN2; | 1043 | act_amos = xpc_vars_sn2->amos_page + XPC_ACTIVATE_IRQ_AMOS_SN2; |
| 1041 | 1044 | ||
| 1042 | /* scan through act amo variable looking for non-zero entries */ | 1045 | /* scan through activate amo variables looking for non-zero entries */ |
| 1043 | for (word = 0; word < xpc_nasid_mask_words; word++) { | 1046 | for (l = 0; l < xpc_nasid_mask_nlongs; l++) { |
| 1044 | 1047 | ||
| 1045 | if (xpc_exiting) | 1048 | if (xpc_exiting) |
| 1046 | break; | 1049 | break; |
| 1047 | 1050 | ||
| 1048 | nasid_mask = xpc_receive_IRQ_amo_sn2(&act_amos[word]); | 1051 | nasid_mask_long = xpc_receive_IRQ_amo_sn2(&act_amos[l]); |
| 1049 | if (nasid_mask == 0) { | 1052 | |
| 1050 | /* no IRQs from nasids in this variable */ | 1053 | b = find_first_bit(&nasid_mask_long, BITS_PER_LONG); |
| 1054 | if (b >= BITS_PER_LONG) { | ||
| 1055 | /* no IRQs from nasids in this amo variable */ | ||
| 1051 | continue; | 1056 | continue; |
| 1052 | } | 1057 | } |
| 1053 | 1058 | ||
| 1054 | dev_dbg(xpc_part, "amo[%d] gave back 0x%lx\n", word, | 1059 | dev_dbg(xpc_part, "amo[%d] gave back 0x%lx\n", l, |
| 1055 | nasid_mask); | 1060 | nasid_mask_long); |
| 1056 | 1061 | ||
| 1057 | /* | 1062 | /* |
| 1058 | * If this nasid has been added to the machine since | 1063 | * If this nasid has been added to the machine since |
| @@ -1060,19 +1065,19 @@ xpc_identify_activate_IRQ_sender_sn2(void) | |||
| 1060 | * remote nasid in our reserved pages machine mask. | 1065 | * remote nasid in our reserved pages machine mask. |
| 1061 | * This is used in the event of module reload. | 1066 | * This is used in the event of module reload. |
| 1062 | */ | 1067 | */ |
| 1063 | xpc_mach_nasids[word] |= nasid_mask; | 1068 | xpc_mach_nasids[l] |= nasid_mask_long; |
| 1064 | 1069 | ||
| 1065 | /* locate the nasid(s) which sent interrupts */ | 1070 | /* locate the nasid(s) which sent interrupts */ |
| 1066 | 1071 | ||
| 1067 | for (bit = 0; bit < (8 * sizeof(u64)); bit++) { | 1072 | do { |
| 1068 | if (nasid_mask & (1UL << bit)) { | 1073 | n_IRQs_detected++; |
| 1069 | n_IRQs_detected++; | 1074 | nasid = (l * BITS_PER_LONG + b) * 2; |
| 1070 | nasid = XPC_NASID_FROM_W_B(word, bit); | 1075 | dev_dbg(xpc_part, "interrupt from nasid %ld\n", nasid); |
| 1071 | dev_dbg(xpc_part, "interrupt from nasid %ld\n", | 1076 | xpc_identify_activate_IRQ_req_sn2(nasid); |
| 1072 | nasid); | 1077 | |
| 1073 | xpc_identify_activate_IRQ_req_sn2(nasid); | 1078 | b = find_next_bit(&nasid_mask_long, BITS_PER_LONG, |
| 1074 | } | 1079 | b + 1); |
| 1075 | } | 1080 | } while (b < BITS_PER_LONG); |
| 1076 | } | 1081 | } |
| 1077 | return n_IRQs_detected; | 1082 | return n_IRQs_detected; |
| 1078 | } | 1083 | } |
