diff options
author | Dean Nelson <dcn@sgi.com> | 2008-07-30 01:34:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-30 12:41:50 -0400 |
commit | 04de741885bc7565a28150e82c56a56e544440e6 (patch) | |
tree | 7c955e1d9dbe4c7d319818f48e22ef85113b2c2f /drivers/misc/sgi-xp/xpc_sn2.c | |
parent | ea57f80c8c0e59cfc5095f7e856ce7c8e6ac2984 (diff) |
sgi-xp: use standard bitops macros and functions
Change sgi-xp to use the standard bitops macros and functions instead of
trying to invent its own mechanism.
Signed-off-by: Dean Nelson <dcn@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/misc/sgi-xp/xpc_sn2.c')
-rw-r--r-- | drivers/misc/sgi-xp/xpc_sn2.c | 73 |
1 files changed, 39 insertions, 34 deletions
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 | } |