diff options
-rw-r--r-- | drivers/misc/sgi-xp/xpc.h | 26 | ||||
-rw-r--r-- | drivers/misc/sgi-xp/xpc_main.c | 16 | ||||
-rw-r--r-- | drivers/misc/sgi-xp/xpc_partition.c | 33 | ||||
-rw-r--r-- | drivers/misc/sgi-xp/xpc_sn2.c | 16 |
4 files changed, 34 insertions, 57 deletions
diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h index a3a67485cf8d..56bf5dcc391d 100644 --- a/drivers/misc/sgi-xp/xpc.h +++ b/drivers/misc/sgi-xp/xpc.h | |||
@@ -115,8 +115,8 @@ struct xpc_rsvd_page { | |||
115 | u64 vars_pa; /* physical address of struct xpc_vars */ | 115 | u64 vars_pa; /* physical address of struct xpc_vars */ |
116 | u64 activate_mq_gpa; /* global phys address of activate_mq */ | 116 | u64 activate_mq_gpa; /* global phys address of activate_mq */ |
117 | } sn; | 117 | } sn; |
118 | struct timespec stamp; /* time when reserved page was setup by XPC */ | 118 | unsigned long stamp; /* time when reserved page was setup by XPC */ |
119 | u64 pad2[9]; /* align to last u64 in 2nd 64-byte cacheline */ | 119 | u64 pad2[10]; /* align to last u64 in 2nd 64-byte cacheline */ |
120 | u64 SAL_nasids_size; /* SAL: size of each nasid mask in bytes */ | 120 | u64 SAL_nasids_size; /* SAL: size of each nasid mask in bytes */ |
121 | }; | 121 | }; |
122 | 122 | ||
@@ -125,26 +125,6 @@ struct xpc_rsvd_page { | |||
125 | #define XPC_SUPPORTS_RP_STAMP(_version) \ | 125 | #define XPC_SUPPORTS_RP_STAMP(_version) \ |
126 | (_version >= _XPC_VERSION(1, 1)) | 126 | (_version >= _XPC_VERSION(1, 1)) |
127 | 127 | ||
128 | #define ZERO_STAMP ((struct timespec){0, 0}) | ||
129 | /* | ||
130 | * compare stamps - the return value is: | ||
131 | * | ||
132 | * < 0, if stamp1 < stamp2 | ||
133 | * = 0, if stamp1 == stamp2 | ||
134 | * > 0, if stamp1 > stamp2 | ||
135 | */ | ||
136 | static inline int | ||
137 | xpc_compare_stamps(struct timespec *stamp1, struct timespec *stamp2) | ||
138 | { | ||
139 | int ret; | ||
140 | |||
141 | ret = stamp1->tv_sec - stamp2->tv_sec; | ||
142 | if (ret == 0) | ||
143 | ret = stamp1->tv_nsec - stamp2->tv_nsec; | ||
144 | |||
145 | return ret; | ||
146 | } | ||
147 | |||
148 | /* | 128 | /* |
149 | * Define the structures by which XPC variables can be exported to other | 129 | * Define the structures by which XPC variables can be exported to other |
150 | * partitions. (There are two: struct xpc_vars and struct xpc_vars_part) | 130 | * partitions. (There are two: struct xpc_vars and struct xpc_vars_part) |
@@ -492,7 +472,7 @@ struct xpc_partition { | |||
492 | /* XPC HB infrastructure */ | 472 | /* XPC HB infrastructure */ |
493 | 473 | ||
494 | u8 remote_rp_version; /* version# of partition's rsvd pg */ | 474 | u8 remote_rp_version; /* version# of partition's rsvd pg */ |
495 | struct timespec remote_rp_stamp; /* time when rsvd pg was initialized */ | 475 | unsigned long remote_rp_stamp; /* time when rsvd pg was initialized */ |
496 | u64 remote_rp_pa; /* phys addr of partition's rsvd pg */ | 476 | u64 remote_rp_pa; /* phys addr of partition's rsvd pg */ |
497 | u64 remote_vars_pa; /* phys addr of partition's vars */ | 477 | u64 remote_vars_pa; /* phys addr of partition's vars */ |
498 | u64 remote_vars_part_pa; /* phys addr of partition's vars part */ | 478 | u64 remote_vars_part_pa; /* phys addr of partition's vars part */ |
diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c index 10dac3652b23..4a6eb3774759 100644 --- a/drivers/misc/sgi-xp/xpc_main.c +++ b/drivers/misc/sgi-xp/xpc_main.c | |||
@@ -233,7 +233,7 @@ xpc_timeout_partition_disengage_request(unsigned long data) | |||
233 | { | 233 | { |
234 | struct xpc_partition *part = (struct xpc_partition *)data; | 234 | struct xpc_partition *part = (struct xpc_partition *)data; |
235 | 235 | ||
236 | DBUG_ON(time_before(jiffies, part->disengage_request_timeout)); | 236 | DBUG_ON(time_is_after_jiffies(part->disengage_request_timeout)); |
237 | 237 | ||
238 | (void)xpc_partition_disengaged(part); | 238 | (void)xpc_partition_disengaged(part); |
239 | 239 | ||
@@ -262,7 +262,7 @@ xpc_hb_beater(unsigned long dummy) | |||
262 | { | 262 | { |
263 | xpc_increment_heartbeat(); | 263 | xpc_increment_heartbeat(); |
264 | 264 | ||
265 | if (time_after_eq(jiffies, xpc_hb_check_timeout)) | 265 | if (time_is_before_eq_jiffies(xpc_hb_check_timeout)) |
266 | wake_up_interruptible(&xpc_act_IRQ_wq); | 266 | wake_up_interruptible(&xpc_act_IRQ_wq); |
267 | 267 | ||
268 | xpc_hb_timer.expires = jiffies + (xpc_hb_interval * HZ); | 268 | xpc_hb_timer.expires = jiffies + (xpc_hb_interval * HZ); |
@@ -312,7 +312,7 @@ xpc_hb_checker(void *ignore) | |||
312 | atomic_read(&xpc_act_IRQ_rcvd) - last_IRQ_count); | 312 | atomic_read(&xpc_act_IRQ_rcvd) - last_IRQ_count); |
313 | 313 | ||
314 | /* checking of remote heartbeats is skewed by IRQ handling */ | 314 | /* checking of remote heartbeats is skewed by IRQ handling */ |
315 | if (time_after_eq(jiffies, xpc_hb_check_timeout)) { | 315 | if (time_is_before_eq_jiffies(xpc_hb_check_timeout)) { |
316 | dev_dbg(xpc_part, "checking remote heartbeats\n"); | 316 | dev_dbg(xpc_part, "checking remote heartbeats\n"); |
317 | xpc_check_remote_hb(); | 317 | xpc_check_remote_hb(); |
318 | 318 | ||
@@ -344,8 +344,8 @@ xpc_hb_checker(void *ignore) | |||
344 | (void)wait_event_interruptible(xpc_act_IRQ_wq, | 344 | (void)wait_event_interruptible(xpc_act_IRQ_wq, |
345 | (last_IRQ_count < | 345 | (last_IRQ_count < |
346 | atomic_read(&xpc_act_IRQ_rcvd) | 346 | atomic_read(&xpc_act_IRQ_rcvd) |
347 | || time_after_eq(jiffies, | 347 | || time_is_before_eq_jiffies( |
348 | xpc_hb_check_timeout) || | 348 | xpc_hb_check_timeout) || |
349 | xpc_exiting)); | 349 | xpc_exiting)); |
350 | } | 350 | } |
351 | 351 | ||
@@ -929,7 +929,7 @@ xpc_do_exit(enum xp_retval reason) | |||
929 | } | 929 | } |
930 | 930 | ||
931 | if (xpc_partition_engaged(-1UL)) { | 931 | if (xpc_partition_engaged(-1UL)) { |
932 | if (time_after(jiffies, printmsg_time)) { | 932 | if (time_is_before_jiffies(printmsg_time)) { |
933 | dev_info(xpc_part, "waiting for remote " | 933 | dev_info(xpc_part, "waiting for remote " |
934 | "partitions to disengage, timeout in " | 934 | "partitions to disengage, timeout in " |
935 | "%ld seconds\n", | 935 | "%ld seconds\n", |
@@ -964,7 +964,7 @@ xpc_do_exit(enum xp_retval reason) | |||
964 | DBUG_ON(xpc_any_hbs_allowed() != 0); | 964 | DBUG_ON(xpc_any_hbs_allowed() != 0); |
965 | 965 | ||
966 | /* indicate to others that our reserved page is uninitialized */ | 966 | /* indicate to others that our reserved page is uninitialized */ |
967 | xpc_rsvd_page->stamp = ZERO_STAMP; | 967 | xpc_rsvd_page->stamp = 0; |
968 | 968 | ||
969 | if (reason == xpUnloading) { | 969 | if (reason == xpUnloading) { |
970 | (void)unregister_die_notifier(&xpc_die_notifier); | 970 | (void)unregister_die_notifier(&xpc_die_notifier); |
@@ -1295,7 +1295,7 @@ xpc_init(void) | |||
1295 | /* initialization was not successful */ | 1295 | /* initialization was not successful */ |
1296 | out_4: | 1296 | out_4: |
1297 | /* indicate to others that our reserved page is uninitialized */ | 1297 | /* indicate to others that our reserved page is uninitialized */ |
1298 | xpc_rsvd_page->stamp = ZERO_STAMP; | 1298 | xpc_rsvd_page->stamp = 0; |
1299 | 1299 | ||
1300 | (void)unregister_die_notifier(&xpc_die_notifier); | 1300 | (void)unregister_die_notifier(&xpc_die_notifier); |
1301 | (void)unregister_reboot_notifier(&xpc_reboot_notifier); | 1301 | (void)unregister_reboot_notifier(&xpc_reboot_notifier); |
diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c index 4e14effdeddb..90ec5ca8c9ab 100644 --- a/drivers/misc/sgi-xp/xpc_partition.c +++ b/drivers/misc/sgi-xp/xpc_partition.c | |||
@@ -152,6 +152,7 @@ xpc_setup_rsvd_page(void) | |||
152 | { | 152 | { |
153 | struct xpc_rsvd_page *rp; | 153 | struct xpc_rsvd_page *rp; |
154 | u64 rp_pa; | 154 | u64 rp_pa; |
155 | unsigned long new_stamp; | ||
155 | 156 | ||
156 | /* get the local reserved page's address */ | 157 | /* get the local reserved page's address */ |
157 | 158 | ||
@@ -201,7 +202,10 @@ xpc_setup_rsvd_page(void) | |||
201 | * This signifies to the remote partition that our reserved | 202 | * This signifies to the remote partition that our reserved |
202 | * page is initialized. | 203 | * page is initialized. |
203 | */ | 204 | */ |
204 | rp->stamp = CURRENT_TIME; | 205 | new_stamp = jiffies; |
206 | if (new_stamp == 0 || new_stamp == rp->stamp) | ||
207 | new_stamp++; | ||
208 | rp->stamp = new_stamp; | ||
205 | 209 | ||
206 | return rp; | 210 | return rp; |
207 | } | 211 | } |
@@ -350,18 +354,8 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids, | |||
350 | discovered_nasids[i] |= remote_part_nasids[i]; | 354 | discovered_nasids[i] |= remote_part_nasids[i]; |
351 | } | 355 | } |
352 | 356 | ||
353 | /* check that the partid is valid and is for another partition */ | 357 | /* see if the reserved page has been set up by XPC */ |
354 | 358 | if (remote_rp->stamp == 0) | |
355 | if (remote_rp->SAL_partid < 0 || | ||
356 | remote_rp->SAL_partid >= xp_max_npartitions) { | ||
357 | return xpInvalidPartid; | ||
358 | } | ||
359 | |||
360 | if (remote_rp->SAL_partid == sn_partition_id) | ||
361 | return xpLocalPartid; | ||
362 | |||
363 | /* see if the rest of the reserved page has been set up by XPC */ | ||
364 | if (timespec_equal(&remote_rp->stamp, &ZERO_STAMP)) | ||
365 | return xpRsvdPageNotSet; | 359 | return xpRsvdPageNotSet; |
366 | 360 | ||
367 | if (XPC_VERSION_MAJOR(remote_rp->version) != | 361 | if (XPC_VERSION_MAJOR(remote_rp->version) != |
@@ -369,8 +363,15 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids, | |||
369 | return xpBadVersion; | 363 | return xpBadVersion; |
370 | } | 364 | } |
371 | 365 | ||
372 | if (remote_rp->max_npartitions <= sn_partition_id) | 366 | /* check that both local and remote partids are valid for each side */ |
367 | if (remote_rp->SAL_partid < 0 || | ||
368 | remote_rp->SAL_partid >= xp_max_npartitions || | ||
369 | remote_rp->max_npartitions <= sn_partition_id) { | ||
373 | return xpInvalidPartid; | 370 | return xpInvalidPartid; |
371 | } | ||
372 | |||
373 | if (remote_rp->SAL_partid == sn_partition_id) | ||
374 | return xpLocalPartid; | ||
374 | 375 | ||
375 | return xpSuccess; | 376 | return xpSuccess; |
376 | } | 377 | } |
@@ -388,8 +389,8 @@ xpc_partition_disengaged(struct xpc_partition *part) | |||
388 | disengaged = (xpc_partition_engaged(1UL << partid) == 0); | 389 | disengaged = (xpc_partition_engaged(1UL << partid) == 0); |
389 | if (part->disengage_request_timeout) { | 390 | if (part->disengage_request_timeout) { |
390 | if (!disengaged) { | 391 | if (!disengaged) { |
391 | if (time_before(jiffies, | 392 | if (time_is_after_jiffies(part-> |
392 | part->disengage_request_timeout)) { | 393 | disengage_request_timeout)) { |
393 | /* timelimit hasn't been reached yet */ | 394 | /* timelimit hasn't been reached yet */ |
394 | return 0; | 395 | return 0; |
395 | } | 396 | } |
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c index 89c0bb9a27f5..7216df36bc73 100644 --- a/drivers/misc/sgi-xp/xpc_sn2.c +++ b/drivers/misc/sgi-xp/xpc_sn2.c | |||
@@ -597,8 +597,8 @@ xpc_initiate_partition_activation_sn2(struct xpc_rsvd_page *remote_rp, | |||
597 | */ | 597 | */ |
598 | static void | 598 | static void |
599 | xpc_update_partition_info_sn2(struct xpc_partition *part, u8 remote_rp_version, | 599 | xpc_update_partition_info_sn2(struct xpc_partition *part, u8 remote_rp_version, |
600 | struct timespec *remote_rp_stamp, | 600 | unsigned long *remote_rp_stamp, u64 remote_rp_pa, |
601 | u64 remote_rp_pa, u64 remote_vars_pa, | 601 | u64 remote_vars_pa, |
602 | struct xpc_vars_sn2 *remote_vars) | 602 | struct xpc_vars_sn2 *remote_vars) |
603 | { | 603 | { |
604 | part->remote_rp_version = remote_rp_version; | 604 | part->remote_rp_version = remote_rp_version; |
@@ -606,8 +606,8 @@ xpc_update_partition_info_sn2(struct xpc_partition *part, u8 remote_rp_version, | |||
606 | part->remote_rp_version); | 606 | part->remote_rp_version); |
607 | 607 | ||
608 | part->remote_rp_stamp = *remote_rp_stamp; | 608 | part->remote_rp_stamp = *remote_rp_stamp; |
609 | dev_dbg(xpc_part, " remote_rp_stamp (tv_sec = 0x%lx tv_nsec = 0x%lx\n", | 609 | dev_dbg(xpc_part, " remote_rp_stamp = 0x%016lx\n", |
610 | part->remote_rp_stamp.tv_sec, part->remote_rp_stamp.tv_nsec); | 610 | part->remote_rp_stamp); |
611 | 611 | ||
612 | part->remote_rp_pa = remote_rp_pa; | 612 | part->remote_rp_pa = remote_rp_pa; |
613 | dev_dbg(xpc_part, " remote_rp_pa = 0x%016lx\n", part->remote_rp_pa); | 613 | dev_dbg(xpc_part, " remote_rp_pa = 0x%016lx\n", part->remote_rp_pa); |
@@ -664,8 +664,7 @@ xpc_identify_act_IRQ_req_sn2(int nasid) | |||
664 | u64 remote_vars_pa; | 664 | u64 remote_vars_pa; |
665 | int remote_rp_version; | 665 | int remote_rp_version; |
666 | int reactivate = 0; | 666 | int reactivate = 0; |
667 | int stamp_diff; | 667 | unsigned long remote_rp_stamp = 0; |
668 | struct timespec remote_rp_stamp = { 0, 0 }; /*>>> ZERO_STAMP */ | ||
669 | short partid; | 668 | short partid; |
670 | struct xpc_partition *part; | 669 | struct xpc_partition *part; |
671 | enum xp_retval ret; | 670 | enum xp_retval ret; |
@@ -788,10 +787,7 @@ xpc_identify_act_IRQ_req_sn2(int nasid) | |||
788 | } else { | 787 | } else { |
789 | DBUG_ON(!XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars->version)); | 788 | DBUG_ON(!XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars->version)); |
790 | 789 | ||
791 | stamp_diff = xpc_compare_stamps(&part->remote_rp_stamp, | 790 | if (remote_rp_stamp != part->remote_rp_stamp) { |
792 | &remote_rp_stamp); | ||
793 | if (stamp_diff != 0) { | ||
794 | DBUG_ON(stamp_diff >= 0); | ||
795 | 791 | ||
796 | /* | 792 | /* |
797 | * Other side rebooted and the previous XPC did support | 793 | * Other side rebooted and the previous XPC did support |