aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDean Nelson <dcn@sgi.com>2008-07-30 01:34:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-30 12:41:50 -0400
commit5b8669dfd110a62a74eea525a009342f73987ea0 (patch)
tree04572d8508f450131298b6ec072e97aa9fdba539 /drivers
parent83469b5525b4a35be40b17cb41d64118d84d9f80 (diff)
sgi-xp: setup the activate GRU message queue
Setup the activate GRU message queue that is used for partition activation and channel connection on UV systems. Signed-off-by: Dean Nelson <dcn@sgi.com> Cc: Jack Steiner <steiner@sgi.com> Cc: "Luck, Tony" <tony.luck@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/sgi-xp/xp.h3
-rw-r--r--drivers/misc/sgi-xp/xp_uv.c10
-rw-r--r--drivers/misc/sgi-xp/xpc.h158
-rw-r--r--drivers/misc/sgi-xp/xpc_channel.c22
-rw-r--r--drivers/misc/sgi-xp/xpc_main.c329
-rw-r--r--drivers/misc/sgi-xp/xpc_partition.c28
-rw-r--r--drivers/misc/sgi-xp/xpc_sn2.c387
-rw-r--r--drivers/misc/sgi-xp/xpc_uv.c781
8 files changed, 1328 insertions, 390 deletions
diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
index 45d0a08c2ddd..9ac5758f4d08 100644
--- a/drivers/misc/sgi-xp/xp.h
+++ b/drivers/misc/sgi-xp/xp.h
@@ -208,8 +208,9 @@ enum xp_retval {
208 xpNeedMoreInfo, /* 57: more info is needed by SAL */ 208 xpNeedMoreInfo, /* 57: more info is needed by SAL */
209 209
210 xpGruCopyError, /* 58: gru_copy_gru() returned error */ 210 xpGruCopyError, /* 58: gru_copy_gru() returned error */
211 xpGruSendMqError, /* 59: gru send message queue related error */
211 212
212 xpUnknownReason /* 59: unknown reason - must be last in enum */ 213 xpUnknownReason /* 60: unknown reason - must be last in enum */
213}; 214};
214 215
215/* 216/*
diff --git a/drivers/misc/sgi-xp/xp_uv.c b/drivers/misc/sgi-xp/xp_uv.c
index 44f2c2b58c2f..d9f7ce2510bc 100644
--- a/drivers/misc/sgi-xp/xp_uv.c
+++ b/drivers/misc/sgi-xp/xp_uv.c
@@ -42,15 +42,25 @@ xp_remote_memcpy_uv(unsigned long dst_gpa, const unsigned long src_gpa,
42 return xpGruCopyError; 42 return xpGruCopyError;
43} 43}
44 44
45static int
46xp_cpu_to_nasid_uv(int cpuid)
47{
48 /* ??? Is this same as sn2 nasid in mach/part bitmaps set up by SAL? */
49 return UV_PNODE_TO_NASID(uv_cpu_to_pnode(cpuid));
50}
51
45enum xp_retval 52enum xp_retval
46xp_init_uv(void) 53xp_init_uv(void)
47{ 54{
48 BUG_ON(!is_uv()); 55 BUG_ON(!is_uv());
49 56
50 xp_max_npartitions = XP_MAX_NPARTITIONS_UV; 57 xp_max_npartitions = XP_MAX_NPARTITIONS_UV;
58 xp_partition_id = 0; /* !!! not correct value */
59 xp_region_size = 0; /* !!! not correct value */
51 60
52 xp_pa = xp_pa_uv; 61 xp_pa = xp_pa_uv;
53 xp_remote_memcpy = xp_remote_memcpy_uv; 62 xp_remote_memcpy = xp_remote_memcpy_uv;
63 xp_cpu_to_nasid = xp_cpu_to_nasid_uv;
54 64
55 return xpSuccess; 65 return xpSuccess;
56} 66}
diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
index 1e48f7765050..4c26181defff 100644
--- a/drivers/misc/sgi-xp/xpc.h
+++ b/drivers/misc/sgi-xp/xpc.h
@@ -164,8 +164,8 @@ struct xpc_vars_part_sn2 {
164 * MAGIC2 indicates that this partition has pulled the remote partititions 164 * MAGIC2 indicates that this partition has pulled the remote partititions
165 * per partition variables that pertain to this partition. 165 * per partition variables that pertain to this partition.
166 */ 166 */
167#define XPC_VP_MAGIC1 0x0053524156435058L /* 'XPCVARS\0'L (little endian) */ 167#define XPC_VP_MAGIC1_SN2 0x0053524156435058L /* 'XPCVARS\0'L (little endian) */
168#define XPC_VP_MAGIC2 0x0073726176435058L /* 'XPCvars\0'L (little endian) */ 168#define XPC_VP_MAGIC2_SN2 0x0073726176435058L /* 'XPCvars\0'L (little endian) */
169 169
170/* the reserved page sizes and offsets */ 170/* the reserved page sizes and offsets */
171 171
@@ -181,6 +181,80 @@ struct xpc_vars_part_sn2 {
181 xpc_nasid_mask_nlongs)) 181 xpc_nasid_mask_nlongs))
182 182
183/* 183/*
184 * The activate_mq is used to send/receive messages that affect XPC's heartbeat,
185 * partition active state, and channel state. This is UV only.
186 */
187struct xpc_activate_mq_msghdr_uv {
188 short partid; /* sender's partid */
189 u8 act_state; /* sender's act_state at time msg sent */
190 u8 type; /* message's type */
191 unsigned long rp_ts_jiffies; /* timestamp of sender's rp setup by XPC */
192};
193
194/* activate_mq defined message types */
195#define XPC_ACTIVATE_MQ_MSG_SYNC_ACT_STATE_UV 0
196#define XPC_ACTIVATE_MQ_MSG_INC_HEARTBEAT_UV 1
197#define XPC_ACTIVATE_MQ_MSG_OFFLINE_HEARTBEAT_UV 2
198#define XPC_ACTIVATE_MQ_MSG_ONLINE_HEARTBEAT_UV 3
199
200#define XPC_ACTIVATE_MQ_MSG_ACTIVATE_REQ_UV 4
201#define XPC_ACTIVATE_MQ_MSG_DEACTIVATE_REQ_UV 5
202
203#define XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREQUEST_UV 6
204#define XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREPLY_UV 7
205#define XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREQUEST_UV 8
206#define XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREPLY_UV 9
207
208#define XPC_ACTIVATE_MQ_MSG_MARK_ENGAGED_UV 10
209#define XPC_ACTIVATE_MQ_MSG_MARK_DISENGAGED_UV 11
210
211struct xpc_activate_mq_msg_uv {
212 struct xpc_activate_mq_msghdr_uv header;
213};
214
215struct xpc_activate_mq_msg_heartbeat_req_uv {
216 struct xpc_activate_mq_msghdr_uv header;
217 u64 heartbeat;
218};
219
220struct xpc_activate_mq_msg_activate_req_uv {
221 struct xpc_activate_mq_msghdr_uv header;
222 unsigned long rp_gpa;
223 unsigned long activate_mq_gpa;
224};
225
226struct xpc_activate_mq_msg_deactivate_req_uv {
227 struct xpc_activate_mq_msghdr_uv header;
228 enum xp_retval reason;
229};
230
231struct xpc_activate_mq_msg_chctl_closerequest_uv {
232 struct xpc_activate_mq_msghdr_uv header;
233 short ch_number;
234 enum xp_retval reason;
235};
236
237struct xpc_activate_mq_msg_chctl_closereply_uv {
238 struct xpc_activate_mq_msghdr_uv header;
239 short ch_number;
240};
241
242struct xpc_activate_mq_msg_chctl_openrequest_uv {
243 struct xpc_activate_mq_msghdr_uv header;
244 short ch_number;
245 short msg_size; /* size of notify_mq's messages */
246 short local_nentries; /* ??? Is this needed? What is? */
247};
248
249struct xpc_activate_mq_msg_chctl_openreply_uv {
250 struct xpc_activate_mq_msghdr_uv header;
251 short ch_number;
252 short remote_nentries; /* ??? Is this needed? What is? */
253 short local_nentries; /* ??? Is this needed? What is? */
254 unsigned long local_notify_mq_gpa;
255};
256
257/*
184 * Functions registered by add_timer() or called by kernel_thread() only 258 * Functions registered by add_timer() or called by kernel_thread() only
185 * allow for a single 64-bit argument. The following macros can be used to 259 * allow for a single 64-bit argument. The following macros can be used to
186 * pack and unpack two (32-bit, 16-bit or 8-bit) arguments into or out from 260 * pack and unpack two (32-bit, 16-bit or 8-bit) arguments into or out from
@@ -331,6 +405,18 @@ struct xpc_notify {
331 */ 405 */
332 406
333struct xpc_channel_sn2 { 407struct xpc_channel_sn2 {
408 struct xpc_openclose_args *local_openclose_args; /* args passed on */
409 /* opening or closing of channel */
410
411 void *local_msgqueue_base; /* base address of kmalloc'd space */
412 struct xpc_msg *local_msgqueue; /* local message queue */
413 void *remote_msgqueue_base; /* base address of kmalloc'd space */
414 struct xpc_msg *remote_msgqueue; /* cached copy of remote partition's */
415 /* local message queue */
416 unsigned long remote_msgqueue_pa; /* phys addr of remote partition's */
417 /* local message queue */
418
419 struct xpc_notify *notify_queue; /* notify queue for messages sent */
334 420
335 /* various flavors of local and remote Get/Put values */ 421 /* various flavors of local and remote Get/Put values */
336 422
@@ -344,13 +430,14 @@ struct xpc_channel_sn2 {
344}; 430};
345 431
346struct xpc_channel_uv { 432struct xpc_channel_uv {
347 /* !!! code is coming */ 433 unsigned long remote_notify_mq_gpa; /* gru phys address of remote */
434 /* partition's notify mq */
348}; 435};
349 436
350struct xpc_channel { 437struct xpc_channel {
351 short partid; /* ID of remote partition connected */ 438 short partid; /* ID of remote partition connected */
352 spinlock_t lock; /* lock for updating this structure */ 439 spinlock_t lock; /* lock for updating this structure */
353 u32 flags; /* general flags */ 440 unsigned int flags; /* general flags */
354 441
355 enum xp_retval reason; /* reason why channel is disconnect'g */ 442 enum xp_retval reason; /* reason why channel is disconnect'g */
356 int reason_line; /* line# disconnect initiated from */ 443 int reason_line; /* line# disconnect initiated from */
@@ -361,14 +448,6 @@ struct xpc_channel {
361 u16 local_nentries; /* #of msg entries in local msg queue */ 448 u16 local_nentries; /* #of msg entries in local msg queue */
362 u16 remote_nentries; /* #of msg entries in remote msg queue */ 449 u16 remote_nentries; /* #of msg entries in remote msg queue */
363 450
364 void *local_msgqueue_base; /* base address of kmalloc'd space */
365 struct xpc_msg *local_msgqueue; /* local message queue */
366 void *remote_msgqueue_base; /* base address of kmalloc'd space */
367 struct xpc_msg *remote_msgqueue; /* cached copy of remote partition's */
368 /* local message queue */
369 unsigned long remote_msgqueue_pa; /* phys addr of remote partition's */
370 /* local message queue */
371
372 atomic_t references; /* #of external references to queues */ 451 atomic_t references; /* #of external references to queues */
373 452
374 atomic_t n_on_msg_allocate_wq; /* #on msg allocation wait queue */ 453 atomic_t n_on_msg_allocate_wq; /* #on msg allocation wait queue */
@@ -377,19 +456,13 @@ struct xpc_channel {
377 u8 delayed_chctl_flags; /* chctl flags received, but delayed */ 456 u8 delayed_chctl_flags; /* chctl flags received, but delayed */
378 /* action until channel disconnected */ 457 /* action until channel disconnected */
379 458
380 /* queue of msg senders who want to be notified when msg received */
381
382 atomic_t n_to_notify; /* #of msg senders to notify */ 459 atomic_t n_to_notify; /* #of msg senders to notify */
383 struct xpc_notify *notify_queue; /* notify queue for messages sent */
384 460
385 xpc_channel_func func; /* user's channel function */ 461 xpc_channel_func func; /* user's channel function */
386 void *key; /* pointer to user's key */ 462 void *key; /* pointer to user's key */
387 463
388 struct completion wdisconnect_wait; /* wait for channel disconnect */ 464 struct completion wdisconnect_wait; /* wait for channel disconnect */
389 465
390 struct xpc_openclose_args *local_openclose_args; /* args passed on */
391 /* opening or closing of channel */
392
393 /* kthread management related fields */ 466 /* kthread management related fields */
394 467
395 atomic_t kthreads_assigned; /* #of kthreads assigned to channel */ 468 atomic_t kthreads_assigned; /* #of kthreads assigned to channel */
@@ -507,6 +580,8 @@ struct xpc_partition_sn2 {
507 unsigned long remote_GPs_pa; /* phys addr of remote partition's local */ 580 unsigned long remote_GPs_pa; /* phys addr of remote partition's local */
508 /* Get/Put values */ 581 /* Get/Put values */
509 582
583 void *local_openclose_args_base; /* base address of kmalloc'd space */
584 struct xpc_openclose_args *local_openclose_args; /* local's args */
510 unsigned long remote_openclose_args_pa; /* phys addr of remote's args */ 585 unsigned long remote_openclose_args_pa; /* phys addr of remote's args */
511 586
512 int notify_IRQ_nasid; /* nasid of where to send notify IRQs */ 587 int notify_IRQ_nasid; /* nasid of where to send notify IRQs */
@@ -520,9 +595,27 @@ struct xpc_partition_sn2 {
520}; 595};
521 596
522struct xpc_partition_uv { 597struct xpc_partition_uv {
523 /* !!! code is coming */ 598 unsigned long remote_activate_mq_gpa; /* gru phys address of remote */
599 /* partition's activate mq */
600 spinlock_t flags_lock; /* protect updating of flags */
601 unsigned int flags; /* general flags */
602 u8 remote_act_state; /* remote partition's act_state */
603 u8 act_state_req; /* act_state request from remote partition */
604 enum xp_retval reason; /* reason for deactivate act_state request */
605 u64 heartbeat; /* incremented by remote partition */
524}; 606};
525 607
608/* struct xpc_partition_uv flags */
609
610#define XPC_P_HEARTBEAT_OFFLINE_UV 0x00000001
611#define XPC_P_ENGAGED_UV 0x00000002
612
613/* struct xpc_partition_uv act_state change requests */
614
615#define XPC_P_ASR_ACTIVATE_UV 0x01
616#define XPC_P_ASR_REACTIVATE_UV 0x02
617#define XPC_P_ASR_DEACTIVATE_UV 0x03
618
526struct xpc_partition { 619struct xpc_partition {
527 620
528 /* XPC HB infrastructure */ 621 /* XPC HB infrastructure */
@@ -556,8 +649,6 @@ struct xpc_partition {
556 union xpc_channel_ctl_flags chctl; /* chctl flags yet to be processed */ 649 union xpc_channel_ctl_flags chctl; /* chctl flags yet to be processed */
557 spinlock_t chctl_lock; /* chctl flags lock */ 650 spinlock_t chctl_lock; /* chctl flags lock */
558 651
559 void *local_openclose_args_base; /* base address of kmalloc'd space */
560 struct xpc_openclose_args *local_openclose_args; /* local's args */
561 void *remote_openclose_args_base; /* base address of kmalloc'd space */ 652 void *remote_openclose_args_base; /* base address of kmalloc'd space */
562 struct xpc_openclose_args *remote_openclose_args; /* copy of remote's */ 653 struct xpc_openclose_args *remote_openclose_args; /* copy of remote's */
563 /* args */ 654 /* args */
@@ -616,17 +707,20 @@ extern struct device *xpc_part;
616extern struct device *xpc_chan; 707extern struct device *xpc_chan;
617extern int xpc_disengage_timelimit; 708extern int xpc_disengage_timelimit;
618extern int xpc_disengage_timedout; 709extern int xpc_disengage_timedout;
619extern atomic_t xpc_activate_IRQ_rcvd; 710extern int xpc_activate_IRQ_rcvd;
711extern spinlock_t xpc_activate_IRQ_rcvd_lock;
620extern wait_queue_head_t xpc_activate_IRQ_wq; 712extern wait_queue_head_t xpc_activate_IRQ_wq;
621extern void *xpc_heartbeating_to_mask; 713extern void *xpc_heartbeating_to_mask;
714extern void *xpc_kzalloc_cacheline_aligned(size_t, gfp_t, void **);
622extern void xpc_activate_partition(struct xpc_partition *); 715extern void xpc_activate_partition(struct xpc_partition *);
623extern void xpc_activate_kthreads(struct xpc_channel *, int); 716extern void xpc_activate_kthreads(struct xpc_channel *, int);
624extern void xpc_create_kthreads(struct xpc_channel *, int, int); 717extern void xpc_create_kthreads(struct xpc_channel *, int, int);
625extern void xpc_disconnect_wait(int); 718extern void xpc_disconnect_wait(int);
719extern int (*xpc_setup_partitions_sn) (void);
626extern enum xp_retval (*xpc_get_partition_rsvd_page_pa) (void *, u64 *, 720extern enum xp_retval (*xpc_get_partition_rsvd_page_pa) (void *, u64 *,
627 unsigned long *, 721 unsigned long *,
628 size_t *); 722 size_t *);
629extern enum xp_retval (*xpc_rsvd_page_init) (struct xpc_rsvd_page *); 723extern int (*xpc_setup_rsvd_page_sn) (struct xpc_rsvd_page *);
630extern void (*xpc_heartbeat_init) (void); 724extern void (*xpc_heartbeat_init) (void);
631extern void (*xpc_heartbeat_exit) (void); 725extern void (*xpc_heartbeat_exit) (void);
632extern void (*xpc_increment_heartbeat) (void); 726extern void (*xpc_increment_heartbeat) (void);
@@ -635,8 +729,8 @@ extern void (*xpc_online_heartbeat) (void);
635extern enum xp_retval (*xpc_get_remote_heartbeat) (struct xpc_partition *); 729extern enum xp_retval (*xpc_get_remote_heartbeat) (struct xpc_partition *);
636extern enum xp_retval (*xpc_make_first_contact) (struct xpc_partition *); 730extern enum xp_retval (*xpc_make_first_contact) (struct xpc_partition *);
637extern u64 (*xpc_get_chctl_all_flags) (struct xpc_partition *); 731extern u64 (*xpc_get_chctl_all_flags) (struct xpc_partition *);
638extern enum xp_retval (*xpc_allocate_msgqueues) (struct xpc_channel *); 732extern enum xp_retval (*xpc_setup_msg_structures) (struct xpc_channel *);
639extern void (*xpc_free_msgqueues) (struct xpc_channel *); 733extern void (*xpc_teardown_msg_structures) (struct xpc_channel *);
640extern void (*xpc_notify_senders_of_disconnect) (struct xpc_channel *); 734extern void (*xpc_notify_senders_of_disconnect) (struct xpc_channel *);
641extern void (*xpc_process_msg_chctl_flags) (struct xpc_partition *, int); 735extern void (*xpc_process_msg_chctl_flags) (struct xpc_partition *, int);
642extern int (*xpc_n_of_deliverable_msgs) (struct xpc_channel *); 736extern int (*xpc_n_of_deliverable_msgs) (struct xpc_channel *);
@@ -647,9 +741,9 @@ extern void (*xpc_request_partition_reactivation) (struct xpc_partition *);
647extern void (*xpc_request_partition_deactivation) (struct xpc_partition *); 741extern void (*xpc_request_partition_deactivation) (struct xpc_partition *);
648extern void (*xpc_cancel_partition_deactivation_request) ( 742extern void (*xpc_cancel_partition_deactivation_request) (
649 struct xpc_partition *); 743 struct xpc_partition *);
650extern void (*xpc_process_activate_IRQ_rcvd) (int); 744extern void (*xpc_process_activate_IRQ_rcvd) (void);
651extern enum xp_retval (*xpc_setup_infrastructure) (struct xpc_partition *); 745extern enum xp_retval (*xpc_setup_ch_structures_sn) (struct xpc_partition *);
652extern void (*xpc_teardown_infrastructure) (struct xpc_partition *); 746extern void (*xpc_teardown_ch_structures_sn) (struct xpc_partition *);
653 747
654extern void (*xpc_indicate_partition_engaged) (struct xpc_partition *); 748extern void (*xpc_indicate_partition_engaged) (struct xpc_partition *);
655extern int (*xpc_partition_engaged) (short); 749extern int (*xpc_partition_engaged) (short);
@@ -665,6 +759,9 @@ extern void (*xpc_send_chctl_openrequest) (struct xpc_channel *,
665 unsigned long *); 759 unsigned long *);
666extern void (*xpc_send_chctl_openreply) (struct xpc_channel *, unsigned long *); 760extern void (*xpc_send_chctl_openreply) (struct xpc_channel *, unsigned long *);
667 761
762extern void (*xpc_save_remote_msgqueue_pa) (struct xpc_channel *,
763 unsigned long);
764
668extern enum xp_retval (*xpc_send_msg) (struct xpc_channel *, u32, void *, u16, 765extern enum xp_retval (*xpc_send_msg) (struct xpc_channel *, u32, void *, u16,
669 u8, xpc_notify_func, void *); 766 u8, xpc_notify_func, void *);
670extern void (*xpc_received_msg) (struct xpc_channel *, struct xpc_msg *); 767extern void (*xpc_received_msg) (struct xpc_channel *, struct xpc_msg *);
@@ -674,7 +771,7 @@ extern int xpc_init_sn2(void);
674extern void xpc_exit_sn2(void); 771extern void xpc_exit_sn2(void);
675 772
676/* found in xpc_uv.c */ 773/* found in xpc_uv.c */
677extern void xpc_init_uv(void); 774extern int xpc_init_uv(void);
678extern void xpc_exit_uv(void); 775extern void xpc_exit_uv(void);
679 776
680/* found in xpc_partition.c */ 777/* found in xpc_partition.c */
@@ -684,7 +781,8 @@ extern struct xpc_rsvd_page *xpc_rsvd_page;
684extern unsigned long *xpc_mach_nasids; 781extern unsigned long *xpc_mach_nasids;
685extern struct xpc_partition *xpc_partitions; 782extern struct xpc_partition *xpc_partitions;
686extern void *xpc_kmalloc_cacheline_aligned(size_t, gfp_t, void **); 783extern void *xpc_kmalloc_cacheline_aligned(size_t, gfp_t, void **);
687extern struct xpc_rsvd_page *xpc_setup_rsvd_page(void); 784extern int xpc_setup_rsvd_page(void);
785extern void xpc_teardown_rsvd_page(void);
688extern int xpc_identify_activate_IRQ_sender(void); 786extern int xpc_identify_activate_IRQ_sender(void);
689extern int xpc_partition_disengaged(struct xpc_partition *); 787extern int xpc_partition_disengaged(struct xpc_partition *);
690extern enum xp_retval xpc_mark_partition_active(struct xpc_partition *); 788extern enum xp_retval xpc_mark_partition_active(struct xpc_partition *);
diff --git a/drivers/misc/sgi-xp/xpc_channel.c b/drivers/misc/sgi-xp/xpc_channel.c
index 17ab75d69e83..73df9fb5ee66 100644
--- a/drivers/misc/sgi-xp/xpc_channel.c
+++ b/drivers/misc/sgi-xp/xpc_channel.c
@@ -39,7 +39,7 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
39 39
40 if (!(ch->flags & XPC_C_SETUP)) { 40 if (!(ch->flags & XPC_C_SETUP)) {
41 spin_unlock_irqrestore(&ch->lock, *irq_flags); 41 spin_unlock_irqrestore(&ch->lock, *irq_flags);
42 ret = xpc_allocate_msgqueues(ch); 42 ret = xpc_setup_msg_structures(ch);
43 spin_lock_irqsave(&ch->lock, *irq_flags); 43 spin_lock_irqsave(&ch->lock, *irq_flags);
44 44
45 if (ret != xpSuccess) 45 if (ret != xpSuccess)
@@ -62,8 +62,6 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
62 if (!(ch->flags & XPC_C_ROPENREPLY)) 62 if (!(ch->flags & XPC_C_ROPENREPLY))
63 return; 63 return;
64 64
65 DBUG_ON(ch->remote_msgqueue_pa == 0);
66
67 ch->flags = (XPC_C_CONNECTED | XPC_C_SETUP); /* clear all else */ 65 ch->flags = (XPC_C_CONNECTED | XPC_C_SETUP); /* clear all else */
68 66
69 dev_info(xpc_chan, "channel %d to partition %d connected\n", 67 dev_info(xpc_chan, "channel %d to partition %d connected\n",
@@ -134,13 +132,23 @@ xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags)
134 spin_lock_irqsave(&ch->lock, *irq_flags); 132 spin_lock_irqsave(&ch->lock, *irq_flags);
135 } 133 }
136 134
135 DBUG_ON(atomic_read(&ch->n_to_notify) != 0);
136
137 /* it's now safe to free the channel's message queues */ 137 /* it's now safe to free the channel's message queues */
138 xpc_free_msgqueues(ch); 138 xpc_teardown_msg_structures(ch);
139
140 ch->func = NULL;
141 ch->key = NULL;
142 ch->msg_size = 0;
143 ch->local_nentries = 0;
144 ch->remote_nentries = 0;
145 ch->kthreads_assigned_limit = 0;
146 ch->kthreads_idle_limit = 0;
139 147
140 /* 148 /*
141 * Mark the channel disconnected and clear all other flags, including 149 * Mark the channel disconnected and clear all other flags, including
142 * XPC_C_SETUP (because of call to xpc_free_msgqueues()) but not 150 * XPC_C_SETUP (because of call to xpc_teardown_msg_structures()) but
143 * including XPC_C_WDISCONNECT (if it was set). 151 * not including XPC_C_WDISCONNECT (if it was set).
144 */ 152 */
145 ch->flags = (XPC_C_DISCONNECTED | (ch->flags & XPC_C_WDISCONNECT)); 153 ch->flags = (XPC_C_DISCONNECTED | (ch->flags & XPC_C_WDISCONNECT));
146 154
@@ -395,7 +403,7 @@ again:
395 DBUG_ON(args->remote_nentries == 0); 403 DBUG_ON(args->remote_nentries == 0);
396 404
397 ch->flags |= XPC_C_ROPENREPLY; 405 ch->flags |= XPC_C_ROPENREPLY;
398 ch->remote_msgqueue_pa = args->local_msgqueue_pa; 406 xpc_save_remote_msgqueue_pa(ch, args->local_msgqueue_pa);
399 407
400 if (args->local_nentries < ch->remote_nentries) { 408 if (args->local_nentries < ch->remote_nentries) {
401 dev_dbg(xpc_chan, "XPC_CHCTL_OPENREPLY: new " 409 dev_dbg(xpc_chan, "XPC_CHCTL_OPENREPLY: new "
diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index b303c130bba8..13ec47928994 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -141,8 +141,9 @@ static struct ctl_table_header *xpc_sysctl;
141/* non-zero if any remote partition disengage was timed out */ 141/* non-zero if any remote partition disengage was timed out */
142int xpc_disengage_timedout; 142int xpc_disengage_timedout;
143 143
144/* #of activate IRQs received */ 144/* #of activate IRQs received and not yet processed */
145atomic_t xpc_activate_IRQ_rcvd = ATOMIC_INIT(0); 145int xpc_activate_IRQ_rcvd;
146DEFINE_SPINLOCK(xpc_activate_IRQ_rcvd_lock);
146 147
147/* IRQ handler notifies this wait queue on receipt of an IRQ */ 148/* IRQ handler notifies this wait queue on receipt of an IRQ */
148DECLARE_WAIT_QUEUE_HEAD(xpc_activate_IRQ_wq); 149DECLARE_WAIT_QUEUE_HEAD(xpc_activate_IRQ_wq);
@@ -169,10 +170,11 @@ static struct notifier_block xpc_die_notifier = {
169 .notifier_call = xpc_system_die, 170 .notifier_call = xpc_system_die,
170}; 171};
171 172
173int (*xpc_setup_partitions_sn) (void);
172enum xp_retval (*xpc_get_partition_rsvd_page_pa) (void *buf, u64 *cookie, 174enum xp_retval (*xpc_get_partition_rsvd_page_pa) (void *buf, u64 *cookie,
173 unsigned long *rp_pa, 175 unsigned long *rp_pa,
174 size_t *len); 176 size_t *len);
175enum xp_retval (*xpc_rsvd_page_init) (struct xpc_rsvd_page *rp); 177int (*xpc_setup_rsvd_page_sn) (struct xpc_rsvd_page *rp);
176void (*xpc_heartbeat_init) (void); 178void (*xpc_heartbeat_init) (void);
177void (*xpc_heartbeat_exit) (void); 179void (*xpc_heartbeat_exit) (void);
178void (*xpc_increment_heartbeat) (void); 180void (*xpc_increment_heartbeat) (void);
@@ -183,8 +185,8 @@ enum xp_retval (*xpc_get_remote_heartbeat) (struct xpc_partition *part);
183enum xp_retval (*xpc_make_first_contact) (struct xpc_partition *part); 185enum xp_retval (*xpc_make_first_contact) (struct xpc_partition *part);
184void (*xpc_notify_senders_of_disconnect) (struct xpc_channel *ch); 186void (*xpc_notify_senders_of_disconnect) (struct xpc_channel *ch);
185u64 (*xpc_get_chctl_all_flags) (struct xpc_partition *part); 187u64 (*xpc_get_chctl_all_flags) (struct xpc_partition *part);
186enum xp_retval (*xpc_allocate_msgqueues) (struct xpc_channel *ch); 188enum xp_retval (*xpc_setup_msg_structures) (struct xpc_channel *ch);
187void (*xpc_free_msgqueues) (struct xpc_channel *ch); 189void (*xpc_teardown_msg_structures) (struct xpc_channel *ch);
188void (*xpc_process_msg_chctl_flags) (struct xpc_partition *part, int ch_number); 190void (*xpc_process_msg_chctl_flags) (struct xpc_partition *part, int ch_number);
189int (*xpc_n_of_deliverable_msgs) (struct xpc_channel *ch); 191int (*xpc_n_of_deliverable_msgs) (struct xpc_channel *ch);
190struct xpc_msg *(*xpc_get_deliverable_msg) (struct xpc_channel *ch); 192struct xpc_msg *(*xpc_get_deliverable_msg) (struct xpc_channel *ch);
@@ -196,9 +198,9 @@ void (*xpc_request_partition_reactivation) (struct xpc_partition *part);
196void (*xpc_request_partition_deactivation) (struct xpc_partition *part); 198void (*xpc_request_partition_deactivation) (struct xpc_partition *part);
197void (*xpc_cancel_partition_deactivation_request) (struct xpc_partition *part); 199void (*xpc_cancel_partition_deactivation_request) (struct xpc_partition *part);
198 200
199void (*xpc_process_activate_IRQ_rcvd) (int n_IRQs_expected); 201void (*xpc_process_activate_IRQ_rcvd) (void);
200enum xp_retval (*xpc_setup_infrastructure) (struct xpc_partition *part); 202enum xp_retval (*xpc_setup_ch_structures_sn) (struct xpc_partition *part);
201void (*xpc_teardown_infrastructure) (struct xpc_partition *part); 203void (*xpc_teardown_ch_structures_sn) (struct xpc_partition *part);
202 204
203void (*xpc_indicate_partition_engaged) (struct xpc_partition *part); 205void (*xpc_indicate_partition_engaged) (struct xpc_partition *part);
204int (*xpc_partition_engaged) (short partid); 206int (*xpc_partition_engaged) (short partid);
@@ -215,6 +217,9 @@ void (*xpc_send_chctl_openrequest) (struct xpc_channel *ch,
215void (*xpc_send_chctl_openreply) (struct xpc_channel *ch, 217void (*xpc_send_chctl_openreply) (struct xpc_channel *ch,
216 unsigned long *irq_flags); 218 unsigned long *irq_flags);
217 219
220void (*xpc_save_remote_msgqueue_pa) (struct xpc_channel *ch,
221 unsigned long msgqueue_pa);
222
218enum xp_retval (*xpc_send_msg) (struct xpc_channel *ch, u32 flags, 223enum xp_retval (*xpc_send_msg) (struct xpc_channel *ch, u32 flags,
219 void *payload, u16 payload_size, u8 notify_type, 224 void *payload, u16 payload_size, u8 notify_type,
220 xpc_notify_func func, void *key); 225 xpc_notify_func func, void *key);
@@ -308,8 +313,6 @@ xpc_check_remote_hb(void)
308static int 313static int
309xpc_hb_checker(void *ignore) 314xpc_hb_checker(void *ignore)
310{ 315{
311 int last_IRQ_count = 0;
312 int new_IRQ_count;
313 int force_IRQ = 0; 316 int force_IRQ = 0;
314 317
315 /* this thread was marked active by xpc_hb_init() */ 318 /* this thread was marked active by xpc_hb_init() */
@@ -325,43 +328,37 @@ xpc_hb_checker(void *ignore)
325 dev_dbg(xpc_part, "woke up with %d ticks rem; %d IRQs have " 328 dev_dbg(xpc_part, "woke up with %d ticks rem; %d IRQs have "
326 "been received\n", 329 "been received\n",
327 (int)(xpc_hb_check_timeout - jiffies), 330 (int)(xpc_hb_check_timeout - jiffies),
328 atomic_read(&xpc_activate_IRQ_rcvd) - last_IRQ_count); 331 xpc_activate_IRQ_rcvd);
329 332
330 /* checking of remote heartbeats is skewed by IRQ handling */ 333 /* checking of remote heartbeats is skewed by IRQ handling */
331 if (time_is_before_eq_jiffies(xpc_hb_check_timeout)) { 334 if (time_is_before_eq_jiffies(xpc_hb_check_timeout)) {
335 xpc_hb_check_timeout = jiffies +
336 (xpc_hb_check_interval * HZ);
337
332 dev_dbg(xpc_part, "checking remote heartbeats\n"); 338 dev_dbg(xpc_part, "checking remote heartbeats\n");
333 xpc_check_remote_hb(); 339 xpc_check_remote_hb();
334 340
335 /* 341 /*
336 * We need to periodically recheck to ensure no 342 * On sn2 we need to periodically recheck to ensure no
337 * IRQ/amo pairs have been missed. That check 343 * IRQ/amo pairs have been missed.
338 * must always reset xpc_hb_check_timeout.
339 */ 344 */
340 force_IRQ = 1; 345 if (is_shub())
346 force_IRQ = 1;
341 } 347 }
342 348
343 /* check for outstanding IRQs */ 349 /* check for outstanding IRQs */
344 new_IRQ_count = atomic_read(&xpc_activate_IRQ_rcvd); 350 if (xpc_activate_IRQ_rcvd > 0 || force_IRQ != 0) {
345 if (last_IRQ_count < new_IRQ_count || force_IRQ != 0) {
346 force_IRQ = 0; 351 force_IRQ = 0;
347 352 dev_dbg(xpc_part, "processing activate IRQs "
348 dev_dbg(xpc_part, "found an IRQ to process; will be " 353 "received\n");
349 "resetting xpc_hb_check_timeout\n"); 354 xpc_process_activate_IRQ_rcvd();
350
351 xpc_process_activate_IRQ_rcvd(new_IRQ_count -
352 last_IRQ_count);
353 last_IRQ_count = new_IRQ_count;
354
355 xpc_hb_check_timeout = jiffies +
356 (xpc_hb_check_interval * HZ);
357 } 355 }
358 356
359 /* wait for IRQ or timeout */ 357 /* wait for IRQ or timeout */
360 (void)wait_event_interruptible(xpc_activate_IRQ_wq, 358 (void)wait_event_interruptible(xpc_activate_IRQ_wq,
361 (last_IRQ_count < atomic_read( 359 (time_is_before_eq_jiffies(
362 &xpc_activate_IRQ_rcvd)
363 || time_is_before_eq_jiffies(
364 xpc_hb_check_timeout) || 360 xpc_hb_check_timeout) ||
361 xpc_activate_IRQ_rcvd > 0 ||
365 xpc_exiting)); 362 xpc_exiting));
366 } 363 }
367 364
@@ -437,6 +434,153 @@ xpc_channel_mgr(struct xpc_partition *part)
437} 434}
438 435
439/* 436/*
437 * Guarantee that the kzalloc'd memory is cacheline aligned.
438 */
439void *
440xpc_kzalloc_cacheline_aligned(size_t size, gfp_t flags, void **base)
441{
442 /* see if kzalloc will give us cachline aligned memory by default */
443 *base = kzalloc(size, flags);
444 if (*base == NULL)
445 return NULL;
446
447 if ((u64)*base == L1_CACHE_ALIGN((u64)*base))
448 return *base;
449
450 kfree(*base);
451
452 /* nope, we'll have to do it ourselves */
453 *base = kzalloc(size + L1_CACHE_BYTES, flags);
454 if (*base == NULL)
455 return NULL;
456
457 return (void *)L1_CACHE_ALIGN((u64)*base);
458}
459
460/*
461 * Setup the channel structures necessary to support XPartition Communication
462 * between the specified remote partition and the local one.
463 */
464static enum xp_retval
465xpc_setup_ch_structures(struct xpc_partition *part)
466{
467 enum xp_retval ret;
468 int ch_number;
469 struct xpc_channel *ch;
470 short partid = XPC_PARTID(part);
471
472 /*
473 * Allocate all of the channel structures as a contiguous chunk of
474 * memory.
475 */
476 DBUG_ON(part->channels != NULL);
477 part->channels = kzalloc(sizeof(struct xpc_channel) * XPC_MAX_NCHANNELS,
478 GFP_KERNEL);
479 if (part->channels == NULL) {
480 dev_err(xpc_chan, "can't get memory for channels\n");
481 return xpNoMemory;
482 }
483
484 /* allocate the remote open and close args */
485
486 part->remote_openclose_args =
487 xpc_kzalloc_cacheline_aligned(XPC_OPENCLOSE_ARGS_SIZE,
488 GFP_KERNEL, &part->
489 remote_openclose_args_base);
490 if (part->remote_openclose_args == NULL) {
491 dev_err(xpc_chan, "can't get memory for remote connect args\n");
492 ret = xpNoMemory;
493 goto out_1;
494 }
495
496 part->chctl.all_flags = 0;
497 spin_lock_init(&part->chctl_lock);
498
499 atomic_set(&part->channel_mgr_requests, 1);
500 init_waitqueue_head(&part->channel_mgr_wq);
501
502 part->nchannels = XPC_MAX_NCHANNELS;
503
504 atomic_set(&part->nchannels_active, 0);
505 atomic_set(&part->nchannels_engaged, 0);
506
507 for (ch_number = 0; ch_number < part->nchannels; ch_number++) {
508 ch = &part->channels[ch_number];
509
510 ch->partid = partid;
511 ch->number = ch_number;
512 ch->flags = XPC_C_DISCONNECTED;
513
514 atomic_set(&ch->kthreads_assigned, 0);
515 atomic_set(&ch->kthreads_idle, 0);
516 atomic_set(&ch->kthreads_active, 0);
517
518 atomic_set(&ch->references, 0);
519 atomic_set(&ch->n_to_notify, 0);
520
521 spin_lock_init(&ch->lock);
522 init_completion(&ch->wdisconnect_wait);
523
524 atomic_set(&ch->n_on_msg_allocate_wq, 0);
525 init_waitqueue_head(&ch->msg_allocate_wq);
526 init_waitqueue_head(&ch->idle_wq);
527 }
528
529 ret = xpc_setup_ch_structures_sn(part);
530 if (ret != xpSuccess)
531 goto out_2;
532
533 /*
534 * With the setting of the partition setup_state to XPC_P_SS_SETUP,
535 * we're declaring that this partition is ready to go.
536 */
537 part->setup_state = XPC_P_SS_SETUP;
538
539 return xpSuccess;
540
541 /* setup of ch structures failed */
542out_2:
543 kfree(part->remote_openclose_args_base);
544 part->remote_openclose_args = NULL;
545out_1:
546 kfree(part->channels);
547 part->channels = NULL;
548 return ret;
549}
550
551/*
552 * Teardown the channel structures necessary to support XPartition Communication
553 * between the specified remote partition and the local one.
554 */
555static void
556xpc_teardown_ch_structures(struct xpc_partition *part)
557{
558 DBUG_ON(atomic_read(&part->nchannels_engaged) != 0);
559 DBUG_ON(atomic_read(&part->nchannels_active) != 0);
560
561 /*
562 * Make this partition inaccessible to local processes by marking it
563 * as no longer setup. Then wait before proceeding with the teardown
564 * until all existing references cease.
565 */
566 DBUG_ON(part->setup_state != XPC_P_SS_SETUP);
567 part->setup_state = XPC_P_SS_WTEARDOWN;
568
569 wait_event(part->teardown_wq, (atomic_read(&part->references) == 0));
570
571 /* now we can begin tearing down the infrastructure */
572
573 xpc_teardown_ch_structures_sn(part);
574
575 kfree(part->remote_openclose_args_base);
576 part->remote_openclose_args = NULL;
577 kfree(part->channels);
578 part->channels = NULL;
579
580 part->setup_state = XPC_P_SS_TORNDOWN;
581}
582
583/*
440 * When XPC HB determines that a partition has come up, it will create a new 584 * When XPC HB determines that a partition has come up, it will create a new
441 * kthread and that kthread will call this function to attempt to set up the 585 * kthread and that kthread will call this function to attempt to set up the
442 * basic infrastructure used for Cross Partition Communication with the newly 586 * basic infrastructure used for Cross Partition Communication with the newly
@@ -476,7 +620,7 @@ xpc_activating(void *__partid)
476 620
477 xpc_allow_hb(partid); 621 xpc_allow_hb(partid);
478 622
479 if (xpc_setup_infrastructure(part) == xpSuccess) { 623 if (xpc_setup_ch_structures(part) == xpSuccess) {
480 (void)xpc_part_ref(part); /* this will always succeed */ 624 (void)xpc_part_ref(part); /* this will always succeed */
481 625
482 if (xpc_make_first_contact(part) == xpSuccess) { 626 if (xpc_make_first_contact(part) == xpSuccess) {
@@ -486,7 +630,7 @@ xpc_activating(void *__partid)
486 } 630 }
487 631
488 xpc_part_deref(part); 632 xpc_part_deref(part);
489 xpc_teardown_infrastructure(part); 633 xpc_teardown_ch_structures(part);
490 } 634 }
491 635
492 xpc_disallow_hb(partid); 636 xpc_disallow_hb(partid);
@@ -806,6 +950,56 @@ xpc_disconnect_wait(int ch_number)
806 } 950 }
807} 951}
808 952
953static int
954xpc_setup_partitions(void)
955{
956 short partid;
957 struct xpc_partition *part;
958
959 xpc_partitions = kzalloc(sizeof(struct xpc_partition) *
960 xp_max_npartitions, GFP_KERNEL);
961 if (xpc_partitions == NULL) {
962 dev_err(xpc_part, "can't get memory for partition structure\n");
963 return -ENOMEM;
964 }
965
966 /*
967 * The first few fields of each entry of xpc_partitions[] need to
968 * be initialized now so that calls to xpc_connect() and
969 * xpc_disconnect() can be made prior to the activation of any remote
970 * partition. NOTE THAT NONE OF THE OTHER FIELDS BELONGING TO THESE
971 * ENTRIES ARE MEANINGFUL UNTIL AFTER AN ENTRY'S CORRESPONDING
972 * PARTITION HAS BEEN ACTIVATED.
973 */
974 for (partid = 0; partid < xp_max_npartitions; partid++) {
975 part = &xpc_partitions[partid];
976
977 DBUG_ON((u64)part != L1_CACHE_ALIGN((u64)part));
978
979 part->activate_IRQ_rcvd = 0;
980 spin_lock_init(&part->act_lock);
981 part->act_state = XPC_P_AS_INACTIVE;
982 XPC_SET_REASON(part, 0, 0);
983
984 init_timer(&part->disengage_timer);
985 part->disengage_timer.function =
986 xpc_timeout_partition_disengage;
987 part->disengage_timer.data = (unsigned long)part;
988
989 part->setup_state = XPC_P_SS_UNSET;
990 init_waitqueue_head(&part->teardown_wq);
991 atomic_set(&part->references, 0);
992 }
993
994 return xpc_setup_partitions_sn();
995}
996
997static void
998xpc_teardown_partitions(void)
999{
1000 kfree(xpc_partitions);
1001}
1002
809static void 1003static void
810xpc_do_exit(enum xp_retval reason) 1004xpc_do_exit(enum xp_retval reason)
811{ 1005{
@@ -892,8 +1086,7 @@ xpc_do_exit(enum xp_retval reason)
892 DBUG_ON(xpc_any_partition_engaged()); 1086 DBUG_ON(xpc_any_partition_engaged());
893 DBUG_ON(xpc_any_hbs_allowed() != 0); 1087 DBUG_ON(xpc_any_hbs_allowed() != 0);
894 1088
895 /* a zero timestamp indicates our rsvd page is not initialized */ 1089 xpc_teardown_rsvd_page();
896 xpc_rsvd_page->ts_jiffies = 0;
897 1090
898 if (reason == xpUnloading) { 1091 if (reason == xpUnloading) {
899 (void)unregister_die_notifier(&xpc_die_notifier); 1092 (void)unregister_die_notifier(&xpc_die_notifier);
@@ -906,7 +1099,7 @@ xpc_do_exit(enum xp_retval reason)
906 if (xpc_sysctl) 1099 if (xpc_sysctl)
907 unregister_sysctl_table(xpc_sysctl); 1100 unregister_sysctl_table(xpc_sysctl);
908 1101
909 kfree(xpc_partitions); 1102 xpc_teardown_partitions();
910 1103
911 if (is_shub()) 1104 if (is_shub())
912 xpc_exit_sn2(); 1105 xpc_exit_sn2();
@@ -1062,8 +1255,6 @@ int __init
1062xpc_init(void) 1255xpc_init(void)
1063{ 1256{
1064 int ret; 1257 int ret;
1065 short partid;
1066 struct xpc_partition *part;
1067 struct task_struct *kthread; 1258 struct task_struct *kthread;
1068 1259
1069 snprintf(xpc_part->bus_id, BUS_ID_SIZE, "part"); 1260 snprintf(xpc_part->bus_id, BUS_ID_SIZE, "part");
@@ -1076,56 +1267,29 @@ xpc_init(void)
1076 * further to only support exactly 64 partitions on this 1267 * further to only support exactly 64 partitions on this
1077 * architecture, no less. 1268 * architecture, no less.
1078 */ 1269 */
1079 if (xp_max_npartitions != 64) 1270 if (xp_max_npartitions != 64) {
1080 return -EINVAL; 1271 dev_err(xpc_part, "max #of partitions not set to 64\n");
1081 1272 ret = -EINVAL;
1082 ret = xpc_init_sn2(); 1273 } else {
1083 if (ret != 0) 1274 ret = xpc_init_sn2();
1084 return ret; 1275 }
1085 1276
1086 } else if (is_uv()) { 1277 } else if (is_uv()) {
1087 xpc_init_uv(); 1278 ret = xpc_init_uv();
1088 1279
1089 } else { 1280 } else {
1090 return -ENODEV; 1281 ret = -ENODEV;
1091 } 1282 }
1092 1283
1093 xpc_partitions = kzalloc(sizeof(struct xpc_partition) * 1284 if (ret != 0)
1094 xp_max_npartitions, GFP_KERNEL); 1285 return ret;
1095 if (xpc_partitions == NULL) { 1286
1287 ret = xpc_setup_partitions();
1288 if (ret != 0) {
1096 dev_err(xpc_part, "can't get memory for partition structure\n"); 1289 dev_err(xpc_part, "can't get memory for partition structure\n");
1097 ret = -ENOMEM;
1098 goto out_1; 1290 goto out_1;
1099 } 1291 }
1100 1292
1101 /*
1102 * The first few fields of each entry of xpc_partitions[] need to
1103 * be initialized now so that calls to xpc_connect() and
1104 * xpc_disconnect() can be made prior to the activation of any remote
1105 * partition. NOTE THAT NONE OF THE OTHER FIELDS BELONGING TO THESE
1106 * ENTRIES ARE MEANINGFUL UNTIL AFTER AN ENTRY'S CORRESPONDING
1107 * PARTITION HAS BEEN ACTIVATED.
1108 */
1109 for (partid = 0; partid < xp_max_npartitions; partid++) {
1110 part = &xpc_partitions[partid];
1111
1112 DBUG_ON((u64)part != L1_CACHE_ALIGN((u64)part));
1113
1114 part->activate_IRQ_rcvd = 0;
1115 spin_lock_init(&part->act_lock);
1116 part->act_state = XPC_P_AS_INACTIVE;
1117 XPC_SET_REASON(part, 0, 0);
1118
1119 init_timer(&part->disengage_timer);
1120 part->disengage_timer.function =
1121 xpc_timeout_partition_disengage;
1122 part->disengage_timer.data = (unsigned long)part;
1123
1124 part->setup_state = XPC_P_SS_UNSET;
1125 init_waitqueue_head(&part->teardown_wq);
1126 atomic_set(&part->references, 0);
1127 }
1128
1129 xpc_sysctl = register_sysctl_table(xpc_sys_dir); 1293 xpc_sysctl = register_sysctl_table(xpc_sys_dir);
1130 1294
1131 /* 1295 /*
@@ -1133,10 +1297,9 @@ xpc_init(void)
1133 * other partitions to discover we are alive and establish initial 1297 * other partitions to discover we are alive and establish initial
1134 * communications. 1298 * communications.
1135 */ 1299 */
1136 xpc_rsvd_page = xpc_setup_rsvd_page(); 1300 ret = xpc_setup_rsvd_page();
1137 if (xpc_rsvd_page == NULL) { 1301 if (ret != 0) {
1138 dev_err(xpc_part, "can't setup our reserved page\n"); 1302 dev_err(xpc_part, "can't setup our reserved page\n");
1139 ret = -EBUSY;
1140 goto out_2; 1303 goto out_2;
1141 } 1304 }
1142 1305
@@ -1187,15 +1350,15 @@ xpc_init(void)
1187 1350
1188 /* initialization was not successful */ 1351 /* initialization was not successful */
1189out_3: 1352out_3:
1190 /* a zero timestamp indicates our rsvd page is not initialized */ 1353 xpc_teardown_rsvd_page();
1191 xpc_rsvd_page->ts_jiffies = 0;
1192 1354
1193 (void)unregister_die_notifier(&xpc_die_notifier); 1355 (void)unregister_die_notifier(&xpc_die_notifier);
1194 (void)unregister_reboot_notifier(&xpc_reboot_notifier); 1356 (void)unregister_reboot_notifier(&xpc_reboot_notifier);
1195out_2: 1357out_2:
1196 if (xpc_sysctl) 1358 if (xpc_sysctl)
1197 unregister_sysctl_table(xpc_sysctl); 1359 unregister_sysctl_table(xpc_sysctl);
1198 kfree(xpc_partitions); 1360
1361 xpc_teardown_partitions();
1199out_1: 1362out_1:
1200 if (is_shub()) 1363 if (is_shub())
1201 xpc_exit_sn2(); 1364 xpc_exit_sn2();
diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c
index b5fb21641130..6722f6fe4dc7 100644
--- a/drivers/misc/sgi-xp/xpc_partition.c
+++ b/drivers/misc/sgi-xp/xpc_partition.c
@@ -73,6 +73,12 @@ xpc_get_rsvd_page_pa(int nasid)
73 73
74 while (1) { 74 while (1) {
75 75
76 /* !!! rp_pa will need to be _gpa on UV.
77 * ??? So do we save it into the architecture specific parts
78 * ??? of the xpc_partition structure? Do we rename this
79 * ??? function or have two versions? Rename rp_pa for UV to
80 * ??? rp_gpa?
81 */
76 ret = xpc_get_partition_rsvd_page_pa(buf, &cookie, &rp_pa, 82 ret = xpc_get_partition_rsvd_page_pa(buf, &cookie, &rp_pa,
77 &len); 83 &len);
78 84
@@ -118,9 +124,10 @@ xpc_get_rsvd_page_pa(int nasid)
118 * other partitions to discover we are alive and establish initial 124 * other partitions to discover we are alive and establish initial
119 * communications. 125 * communications.
120 */ 126 */
121struct xpc_rsvd_page * 127int
122xpc_setup_rsvd_page(void) 128xpc_setup_rsvd_page(void)
123{ 129{
130 int ret;
124 struct xpc_rsvd_page *rp; 131 struct xpc_rsvd_page *rp;
125 unsigned long rp_pa; 132 unsigned long rp_pa;
126 unsigned long new_ts_jiffies; 133 unsigned long new_ts_jiffies;
@@ -132,7 +139,7 @@ xpc_setup_rsvd_page(void)
132 preempt_enable(); 139 preempt_enable();
133 if (rp_pa == 0) { 140 if (rp_pa == 0) {
134 dev_err(xpc_part, "SAL failed to locate the reserved page\n"); 141 dev_err(xpc_part, "SAL failed to locate the reserved page\n");
135 return NULL; 142 return -ESRCH;
136 } 143 }
137 rp = (struct xpc_rsvd_page *)__va(rp_pa); 144 rp = (struct xpc_rsvd_page *)__va(rp_pa);
138 145
@@ -146,7 +153,7 @@ xpc_setup_rsvd_page(void)
146 dev_err(xpc_part, "the reserved page's partid of %d is outside " 153 dev_err(xpc_part, "the reserved page's partid of %d is outside "
147 "supported range (< 0 || >= %d)\n", rp->SAL_partid, 154 "supported range (< 0 || >= %d)\n", rp->SAL_partid,
148 xp_max_npartitions); 155 xp_max_npartitions);
149 return NULL; 156 return -EINVAL;
150 } 157 }
151 158
152 rp->version = XPC_RP_VERSION; 159 rp->version = XPC_RP_VERSION;
@@ -165,8 +172,9 @@ xpc_setup_rsvd_page(void)
165 xpc_part_nasids = XPC_RP_PART_NASIDS(rp); 172 xpc_part_nasids = XPC_RP_PART_NASIDS(rp);
166 xpc_mach_nasids = XPC_RP_MACH_NASIDS(rp); 173 xpc_mach_nasids = XPC_RP_MACH_NASIDS(rp);
167 174
168 if (xpc_rsvd_page_init(rp) != xpSuccess) 175 ret = xpc_setup_rsvd_page_sn(rp);
169 return NULL; 176 if (ret != 0)
177 return ret;
170 178
171 /* 179 /*
172 * Set timestamp of when reserved page was setup by XPC. 180 * Set timestamp of when reserved page was setup by XPC.
@@ -178,7 +186,15 @@ xpc_setup_rsvd_page(void)
178 new_ts_jiffies++; 186 new_ts_jiffies++;
179 rp->ts_jiffies = new_ts_jiffies; 187 rp->ts_jiffies = new_ts_jiffies;
180 188
181 return rp; 189 xpc_rsvd_page = rp;
190 return 0;
191}
192
193void
194xpc_teardown_rsvd_page(void)
195{
196 /* a zero timestamp indicates our rsvd page is not initialized */
197 xpc_rsvd_page->ts_jiffies = 0;
182} 198}
183 199
184/* 200/*
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c
index d1ccadc0857d..8b4b0653d9e9 100644
--- a/drivers/misc/sgi-xp/xpc_sn2.c
+++ b/drivers/misc/sgi-xp/xpc_sn2.c
@@ -53,12 +53,19 @@
53 * Buffer used to store a local copy of portions of a remote partition's 53 * Buffer used to store a local copy of portions of a remote partition's
54 * reserved page (either its header and part_nasids mask, or its vars). 54 * reserved page (either its header and part_nasids mask, or its vars).
55 */ 55 */
56static char *xpc_remote_copy_buffer_sn2;
57static void *xpc_remote_copy_buffer_base_sn2; 56static void *xpc_remote_copy_buffer_base_sn2;
57static char *xpc_remote_copy_buffer_sn2;
58 58
59static struct xpc_vars_sn2 *xpc_vars_sn2; 59static struct xpc_vars_sn2 *xpc_vars_sn2;
60static struct xpc_vars_part_sn2 *xpc_vars_part_sn2; 60static struct xpc_vars_part_sn2 *xpc_vars_part_sn2;
61 61
62static int
63xpc_setup_partitions_sn_sn2(void)
64{
65 /* nothing needs to be done */
66 return 0;
67}
68
62/* SH_IPI_ACCESS shub register value on startup */ 69/* SH_IPI_ACCESS shub register value on startup */
63static u64 xpc_sh1_IPI_access_sn2; 70static u64 xpc_sh1_IPI_access_sn2;
64static u64 xpc_sh2_IPI_access0_sn2; 71static u64 xpc_sh2_IPI_access0_sn2;
@@ -198,7 +205,12 @@ xpc_init_IRQ_amo_sn2(int index)
198static irqreturn_t 205static irqreturn_t
199xpc_handle_activate_IRQ_sn2(int irq, void *dev_id) 206xpc_handle_activate_IRQ_sn2(int irq, void *dev_id)
200{ 207{
201 atomic_inc(&xpc_activate_IRQ_rcvd); 208 unsigned long irq_flags;
209
210 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags);
211 xpc_activate_IRQ_rcvd++;
212 spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock, irq_flags);
213
202 wake_up_interruptible(&xpc_activate_IRQ_wq); 214 wake_up_interruptible(&xpc_activate_IRQ_wq);
203 return IRQ_HANDLED; 215 return IRQ_HANDLED;
204} 216}
@@ -222,6 +234,7 @@ xpc_send_activate_IRQ_sn2(unsigned long amos_page_pa, int from_nasid,
222static void 234static void
223xpc_send_local_activate_IRQ_sn2(int from_nasid) 235xpc_send_local_activate_IRQ_sn2(int from_nasid)
224{ 236{
237 unsigned long irq_flags;
225 struct amo *amos = (struct amo *)__va(xpc_vars_sn2->amos_page_pa + 238 struct amo *amos = (struct amo *)__va(xpc_vars_sn2->amos_page_pa +
226 (XPC_ACTIVATE_IRQ_AMOS_SN2 * 239 (XPC_ACTIVATE_IRQ_AMOS_SN2 *
227 sizeof(struct amo))); 240 sizeof(struct amo)));
@@ -230,7 +243,10 @@ xpc_send_local_activate_IRQ_sn2(int from_nasid)
230 FETCHOP_STORE_OP(TO_AMO((u64)&amos[BIT_WORD(from_nasid / 2)].variable), 243 FETCHOP_STORE_OP(TO_AMO((u64)&amos[BIT_WORD(from_nasid / 2)].variable),
231 FETCHOP_OR, BIT_MASK(from_nasid / 2)); 244 FETCHOP_OR, BIT_MASK(from_nasid / 2));
232 245
233 atomic_inc(&xpc_activate_IRQ_rcvd); 246 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags);
247 xpc_activate_IRQ_rcvd++;
248 spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock, irq_flags);
249
234 wake_up_interruptible(&xpc_activate_IRQ_wq); 250 wake_up_interruptible(&xpc_activate_IRQ_wq);
235} 251}
236 252
@@ -375,7 +391,7 @@ static void
375xpc_send_chctl_closerequest_sn2(struct xpc_channel *ch, 391xpc_send_chctl_closerequest_sn2(struct xpc_channel *ch,
376 unsigned long *irq_flags) 392 unsigned long *irq_flags)
377{ 393{
378 struct xpc_openclose_args *args = ch->local_openclose_args; 394 struct xpc_openclose_args *args = ch->sn.sn2.local_openclose_args;
379 395
380 args->reason = ch->reason; 396 args->reason = ch->reason;
381 XPC_SEND_NOTIFY_IRQ_SN2(ch, XPC_CHCTL_CLOSEREQUEST, irq_flags); 397 XPC_SEND_NOTIFY_IRQ_SN2(ch, XPC_CHCTL_CLOSEREQUEST, irq_flags);
@@ -390,7 +406,7 @@ xpc_send_chctl_closereply_sn2(struct xpc_channel *ch, unsigned long *irq_flags)
390static void 406static void
391xpc_send_chctl_openrequest_sn2(struct xpc_channel *ch, unsigned long *irq_flags) 407xpc_send_chctl_openrequest_sn2(struct xpc_channel *ch, unsigned long *irq_flags)
392{ 408{
393 struct xpc_openclose_args *args = ch->local_openclose_args; 409 struct xpc_openclose_args *args = ch->sn.sn2.local_openclose_args;
394 410
395 args->msg_size = ch->msg_size; 411 args->msg_size = ch->msg_size;
396 args->local_nentries = ch->local_nentries; 412 args->local_nentries = ch->local_nentries;
@@ -400,11 +416,11 @@ xpc_send_chctl_openrequest_sn2(struct xpc_channel *ch, unsigned long *irq_flags)
400static void 416static void
401xpc_send_chctl_openreply_sn2(struct xpc_channel *ch, unsigned long *irq_flags) 417xpc_send_chctl_openreply_sn2(struct xpc_channel *ch, unsigned long *irq_flags)
402{ 418{
403 struct xpc_openclose_args *args = ch->local_openclose_args; 419 struct xpc_openclose_args *args = ch->sn.sn2.local_openclose_args;
404 420
405 args->remote_nentries = ch->remote_nentries; 421 args->remote_nentries = ch->remote_nentries;
406 args->local_nentries = ch->local_nentries; 422 args->local_nentries = ch->local_nentries;
407 args->local_msgqueue_pa = xp_pa(ch->local_msgqueue); 423 args->local_msgqueue_pa = xp_pa(ch->sn.sn2.local_msgqueue);
408 XPC_SEND_NOTIFY_IRQ_SN2(ch, XPC_CHCTL_OPENREPLY, irq_flags); 424 XPC_SEND_NOTIFY_IRQ_SN2(ch, XPC_CHCTL_OPENREPLY, irq_flags);
409} 425}
410 426
@@ -420,6 +436,13 @@ xpc_send_chctl_local_msgrequest_sn2(struct xpc_channel *ch)
420 XPC_SEND_LOCAL_NOTIFY_IRQ_SN2(ch, XPC_CHCTL_MSGREQUEST); 436 XPC_SEND_LOCAL_NOTIFY_IRQ_SN2(ch, XPC_CHCTL_MSGREQUEST);
421} 437}
422 438
439static void
440xpc_save_remote_msgqueue_pa_sn2(struct xpc_channel *ch,
441 unsigned long msgqueue_pa)
442{
443 ch->sn.sn2.remote_msgqueue_pa = msgqueue_pa;
444}
445
423/* 446/*
424 * This next set of functions are used to keep track of when a partition is 447 * This next set of functions are used to keep track of when a partition is
425 * potentially engaged in accessing memory belonging to another partition. 448 * potentially engaged in accessing memory belonging to another partition.
@@ -489,6 +512,17 @@ xpc_indicate_partition_disengaged_sn2(struct xpc_partition *part)
489 part_sn2->activate_IRQ_phys_cpuid); 512 part_sn2->activate_IRQ_phys_cpuid);
490} 513}
491 514
515static void
516xpc_assume_partition_disengaged_sn2(short partid)
517{
518 struct amo *amo = xpc_vars_sn2->amos_page +
519 XPC_ENGAGED_PARTITIONS_AMO_SN2;
520
521 /* clear bit(s) based on partid mask in our partition's amo */
522 FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND,
523 ~BIT(partid));
524}
525
492static int 526static int
493xpc_partition_engaged_sn2(short partid) 527xpc_partition_engaged_sn2(short partid)
494{ 528{
@@ -510,17 +544,6 @@ xpc_any_partition_engaged_sn2(void)
510 return FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_LOAD) != 0; 544 return FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_LOAD) != 0;
511} 545}
512 546
513static void
514xpc_assume_partition_disengaged_sn2(short partid)
515{
516 struct amo *amo = xpc_vars_sn2->amos_page +
517 XPC_ENGAGED_PARTITIONS_AMO_SN2;
518
519 /* clear bit(s) based on partid mask in our partition's amo */
520 FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND,
521 ~BIT(partid));
522}
523
524/* original protection values for each node */ 547/* original protection values for each node */
525static u64 xpc_prot_vec_sn2[MAX_NUMNODES]; 548static u64 xpc_prot_vec_sn2[MAX_NUMNODES];
526 549
@@ -595,8 +618,8 @@ xpc_get_partition_rsvd_page_pa_sn2(void *buf, u64 *cookie, unsigned long *rp_pa,
595} 618}
596 619
597 620
598static enum xp_retval 621static int
599xpc_rsvd_page_init_sn2(struct xpc_rsvd_page *rp) 622xpc_setup_rsvd_page_sn_sn2(struct xpc_rsvd_page *rp)
600{ 623{
601 struct amo *amos_page; 624 struct amo *amos_page;
602 int i; 625 int i;
@@ -627,7 +650,7 @@ xpc_rsvd_page_init_sn2(struct xpc_rsvd_page *rp)
627 amos_page = (struct amo *)TO_AMO(uncached_alloc_page(0, 1)); 650 amos_page = (struct amo *)TO_AMO(uncached_alloc_page(0, 1));
628 if (amos_page == NULL) { 651 if (amos_page == NULL) {
629 dev_err(xpc_part, "can't allocate page of amos\n"); 652 dev_err(xpc_part, "can't allocate page of amos\n");
630 return xpNoMemory; 653 return -ENOMEM;
631 } 654 }
632 655
633 /* 656 /*
@@ -639,7 +662,7 @@ xpc_rsvd_page_init_sn2(struct xpc_rsvd_page *rp)
639 dev_err(xpc_part, "can't allow amo operations\n"); 662 dev_err(xpc_part, "can't allow amo operations\n");
640 uncached_free_page(__IA64_UNCACHED_OFFSET | 663 uncached_free_page(__IA64_UNCACHED_OFFSET |
641 TO_PHYS((u64)amos_page), 1); 664 TO_PHYS((u64)amos_page), 1);
642 return ret; 665 return -EPERM;
643 } 666 }
644 } 667 }
645 668
@@ -665,7 +688,7 @@ xpc_rsvd_page_init_sn2(struct xpc_rsvd_page *rp)
665 (void)xpc_init_IRQ_amo_sn2(XPC_ENGAGED_PARTITIONS_AMO_SN2); 688 (void)xpc_init_IRQ_amo_sn2(XPC_ENGAGED_PARTITIONS_AMO_SN2);
666 (void)xpc_init_IRQ_amo_sn2(XPC_DEACTIVATE_REQUEST_AMO_SN2); 689 (void)xpc_init_IRQ_amo_sn2(XPC_DEACTIVATE_REQUEST_AMO_SN2);
667 690
668 return xpSuccess; 691 return 0;
669} 692}
670 693
671static void 694static void
@@ -1082,10 +1105,19 @@ xpc_identify_activate_IRQ_sender_sn2(void)
1082} 1105}
1083 1106
1084static void 1107static void
1085xpc_process_activate_IRQ_rcvd_sn2(int n_IRQs_expected) 1108xpc_process_activate_IRQ_rcvd_sn2(void)
1086{ 1109{
1110 unsigned long irq_flags;
1111 int n_IRQs_expected;
1087 int n_IRQs_detected; 1112 int n_IRQs_detected;
1088 1113
1114 DBUG_ON(xpc_activate_IRQ_rcvd == 0);
1115
1116 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags);
1117 n_IRQs_expected = xpc_activate_IRQ_rcvd;
1118 xpc_activate_IRQ_rcvd = 0;
1119 spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock, irq_flags);
1120
1089 n_IRQs_detected = xpc_identify_activate_IRQ_sender_sn2(); 1121 n_IRQs_detected = xpc_identify_activate_IRQ_sender_sn2();
1090 if (n_IRQs_detected < n_IRQs_expected) { 1122 if (n_IRQs_detected < n_IRQs_expected) {
1091 /* retry once to help avoid missing amo */ 1123 /* retry once to help avoid missing amo */
@@ -1094,116 +1126,63 @@ xpc_process_activate_IRQ_rcvd_sn2(int n_IRQs_expected)
1094} 1126}
1095 1127
1096/* 1128/*
1097 * Guarantee that the kzalloc'd memory is cacheline aligned. 1129 * Setup the channel structures that are sn2 specific.
1098 */
1099static void *
1100xpc_kzalloc_cacheline_aligned_sn2(size_t size, gfp_t flags, void **base)
1101{
1102 /* see if kzalloc will give us cachline aligned memory by default */
1103 *base = kzalloc(size, flags);
1104 if (*base == NULL)
1105 return NULL;
1106
1107 if ((u64)*base == L1_CACHE_ALIGN((u64)*base))
1108 return *base;
1109
1110 kfree(*base);
1111
1112 /* nope, we'll have to do it ourselves */
1113 *base = kzalloc(size + L1_CACHE_BYTES, flags);
1114 if (*base == NULL)
1115 return NULL;
1116
1117 return (void *)L1_CACHE_ALIGN((u64)*base);
1118}
1119
1120/*
1121 * Setup the infrastructure necessary to support XPartition Communication
1122 * between the specified remote partition and the local one.
1123 */ 1130 */
1124static enum xp_retval 1131static enum xp_retval
1125xpc_setup_infrastructure_sn2(struct xpc_partition *part) 1132xpc_setup_ch_structures_sn_sn2(struct xpc_partition *part)
1126{ 1133{
1127 struct xpc_partition_sn2 *part_sn2 = &part->sn.sn2; 1134 struct xpc_partition_sn2 *part_sn2 = &part->sn.sn2;
1135 struct xpc_channel_sn2 *ch_sn2;
1128 enum xp_retval retval; 1136 enum xp_retval retval;
1129 int ret; 1137 int ret;
1130 int cpuid; 1138 int cpuid;
1131 int ch_number; 1139 int ch_number;
1132 struct xpc_channel *ch;
1133 struct timer_list *timer; 1140 struct timer_list *timer;
1134 short partid = XPC_PARTID(part); 1141 short partid = XPC_PARTID(part);
1135 1142
1136 /*
1137 * Allocate all of the channel structures as a contiguous chunk of
1138 * memory.
1139 */
1140 DBUG_ON(part->channels != NULL);
1141 part->channels = kzalloc(sizeof(struct xpc_channel) * XPC_MAX_NCHANNELS,
1142 GFP_KERNEL);
1143 if (part->channels == NULL) {
1144 dev_err(xpc_chan, "can't get memory for channels\n");
1145 return xpNoMemory;
1146 }
1147
1148 /* allocate all the required GET/PUT values */ 1143 /* allocate all the required GET/PUT values */
1149 1144
1150 part_sn2->local_GPs = 1145 part_sn2->local_GPs =
1151 xpc_kzalloc_cacheline_aligned_sn2(XPC_GP_SIZE, GFP_KERNEL, 1146 xpc_kzalloc_cacheline_aligned(XPC_GP_SIZE, GFP_KERNEL,
1152 &part_sn2->local_GPs_base); 1147 &part_sn2->local_GPs_base);
1153 if (part_sn2->local_GPs == NULL) { 1148 if (part_sn2->local_GPs == NULL) {
1154 dev_err(xpc_chan, "can't get memory for local get/put " 1149 dev_err(xpc_chan, "can't get memory for local get/put "
1155 "values\n"); 1150 "values\n");
1156 retval = xpNoMemory; 1151 return xpNoMemory;
1157 goto out_1;
1158 } 1152 }
1159 1153
1160 part_sn2->remote_GPs = 1154 part_sn2->remote_GPs =
1161 xpc_kzalloc_cacheline_aligned_sn2(XPC_GP_SIZE, GFP_KERNEL, 1155 xpc_kzalloc_cacheline_aligned(XPC_GP_SIZE, GFP_KERNEL,
1162 &part_sn2->remote_GPs_base); 1156 &part_sn2->remote_GPs_base);
1163 if (part_sn2->remote_GPs == NULL) { 1157 if (part_sn2->remote_GPs == NULL) {
1164 dev_err(xpc_chan, "can't get memory for remote get/put " 1158 dev_err(xpc_chan, "can't get memory for remote get/put "
1165 "values\n"); 1159 "values\n");
1166 retval = xpNoMemory; 1160 retval = xpNoMemory;
1167 goto out_2; 1161 goto out_1;
1168 } 1162 }
1169 1163
1170 part_sn2->remote_GPs_pa = 0; 1164 part_sn2->remote_GPs_pa = 0;
1171 1165
1172 /* allocate all the required open and close args */ 1166 /* allocate all the required open and close args */
1173 1167
1174 part->local_openclose_args = 1168 part_sn2->local_openclose_args =
1175 xpc_kzalloc_cacheline_aligned_sn2(XPC_OPENCLOSE_ARGS_SIZE, 1169 xpc_kzalloc_cacheline_aligned(XPC_OPENCLOSE_ARGS_SIZE,
1176 GFP_KERNEL, 1170 GFP_KERNEL, &part_sn2->
1177 &part->local_openclose_args_base); 1171 local_openclose_args_base);
1178 if (part->local_openclose_args == NULL) { 1172 if (part_sn2->local_openclose_args == NULL) {
1179 dev_err(xpc_chan, "can't get memory for local connect args\n"); 1173 dev_err(xpc_chan, "can't get memory for local connect args\n");
1180 retval = xpNoMemory; 1174 retval = xpNoMemory;
1181 goto out_3; 1175 goto out_2;
1182 }
1183
1184 part->remote_openclose_args =
1185 xpc_kzalloc_cacheline_aligned_sn2(XPC_OPENCLOSE_ARGS_SIZE,
1186 GFP_KERNEL,
1187 &part->remote_openclose_args_base);
1188 if (part->remote_openclose_args == NULL) {
1189 dev_err(xpc_chan, "can't get memory for remote connect args\n");
1190 retval = xpNoMemory;
1191 goto out_4;
1192 } 1176 }
1193 1177
1194 part_sn2->remote_openclose_args_pa = 0; 1178 part_sn2->remote_openclose_args_pa = 0;
1195 1179
1196 part_sn2->local_chctl_amo_va = xpc_init_IRQ_amo_sn2(partid); 1180 part_sn2->local_chctl_amo_va = xpc_init_IRQ_amo_sn2(partid);
1197 part->chctl.all_flags = 0;
1198 spin_lock_init(&part->chctl_lock);
1199 1181
1200 part_sn2->notify_IRQ_nasid = 0; 1182 part_sn2->notify_IRQ_nasid = 0;
1201 part_sn2->notify_IRQ_phys_cpuid = 0; 1183 part_sn2->notify_IRQ_phys_cpuid = 0;
1202 part_sn2->remote_chctl_amo_va = NULL; 1184 part_sn2->remote_chctl_amo_va = NULL;
1203 1185
1204 atomic_set(&part->channel_mgr_requests, 1);
1205 init_waitqueue_head(&part->channel_mgr_wq);
1206
1207 sprintf(part_sn2->notify_IRQ_owner, "xpc%02d", partid); 1186 sprintf(part_sn2->notify_IRQ_owner, "xpc%02d", partid);
1208 ret = request_irq(SGI_XPC_NOTIFY, xpc_handle_notify_IRQ_sn2, 1187 ret = request_irq(SGI_XPC_NOTIFY, xpc_handle_notify_IRQ_sn2,
1209 IRQF_SHARED, part_sn2->notify_IRQ_owner, 1188 IRQF_SHARED, part_sn2->notify_IRQ_owner,
@@ -1212,7 +1191,7 @@ xpc_setup_infrastructure_sn2(struct xpc_partition *part)
1212 dev_err(xpc_chan, "can't register NOTIFY IRQ handler, " 1191 dev_err(xpc_chan, "can't register NOTIFY IRQ handler, "
1213 "errno=%d\n", -ret); 1192 "errno=%d\n", -ret);
1214 retval = xpLackOfResources; 1193 retval = xpLackOfResources;
1215 goto out_5; 1194 goto out_3;
1216 } 1195 }
1217 1196
1218 /* Setup a timer to check for dropped notify IRQs */ 1197 /* Setup a timer to check for dropped notify IRQs */
@@ -1224,45 +1203,17 @@ xpc_setup_infrastructure_sn2(struct xpc_partition *part)
1224 timer->expires = jiffies + XPC_DROPPED_NOTIFY_IRQ_WAIT_INTERVAL; 1203 timer->expires = jiffies + XPC_DROPPED_NOTIFY_IRQ_WAIT_INTERVAL;
1225 add_timer(timer); 1204 add_timer(timer);
1226 1205
1227 part->nchannels = XPC_MAX_NCHANNELS;
1228
1229 atomic_set(&part->nchannels_active, 0);
1230 atomic_set(&part->nchannels_engaged, 0);
1231
1232 for (ch_number = 0; ch_number < part->nchannels; ch_number++) { 1206 for (ch_number = 0; ch_number < part->nchannels; ch_number++) {
1233 ch = &part->channels[ch_number]; 1207 ch_sn2 = &part->channels[ch_number].sn.sn2;
1234
1235 ch->partid = partid;
1236 ch->number = ch_number;
1237 ch->flags = XPC_C_DISCONNECTED;
1238
1239 ch->sn.sn2.local_GP = &part_sn2->local_GPs[ch_number];
1240 ch->local_openclose_args =
1241 &part->local_openclose_args[ch_number];
1242
1243 atomic_set(&ch->kthreads_assigned, 0);
1244 atomic_set(&ch->kthreads_idle, 0);
1245 atomic_set(&ch->kthreads_active, 0);
1246 1208
1247 atomic_set(&ch->references, 0); 1209 ch_sn2->local_GP = &part_sn2->local_GPs[ch_number];
1248 atomic_set(&ch->n_to_notify, 0); 1210 ch_sn2->local_openclose_args =
1211 &part_sn2->local_openclose_args[ch_number];
1249 1212
1250 spin_lock_init(&ch->lock); 1213 mutex_init(&ch_sn2->msg_to_pull_mutex);
1251 mutex_init(&ch->sn.sn2.msg_to_pull_mutex);
1252 init_completion(&ch->wdisconnect_wait);
1253
1254 atomic_set(&ch->n_on_msg_allocate_wq, 0);
1255 init_waitqueue_head(&ch->msg_allocate_wq);
1256 init_waitqueue_head(&ch->idle_wq);
1257 } 1214 }
1258 1215
1259 /* 1216 /*
1260 * With the setting of the partition setup_state to XPC_P_SS_SETUP,
1261 * we're declaring that this partition is ready to go.
1262 */
1263 part->setup_state = XPC_P_SS_SETUP;
1264
1265 /*
1266 * Setup the per partition specific variables required by the 1217 * Setup the per partition specific variables required by the
1267 * remote partition to establish channel connections with us. 1218 * remote partition to establish channel connections with us.
1268 * 1219 *
@@ -1271,7 +1222,7 @@ xpc_setup_infrastructure_sn2(struct xpc_partition *part)
1271 */ 1222 */
1272 xpc_vars_part_sn2[partid].GPs_pa = xp_pa(part_sn2->local_GPs); 1223 xpc_vars_part_sn2[partid].GPs_pa = xp_pa(part_sn2->local_GPs);
1273 xpc_vars_part_sn2[partid].openclose_args_pa = 1224 xpc_vars_part_sn2[partid].openclose_args_pa =
1274 xp_pa(part->local_openclose_args); 1225 xp_pa(part_sn2->local_openclose_args);
1275 xpc_vars_part_sn2[partid].chctl_amo_pa = 1226 xpc_vars_part_sn2[partid].chctl_amo_pa =
1276 xp_pa(part_sn2->local_chctl_amo_va); 1227 xp_pa(part_sn2->local_chctl_amo_va);
1277 cpuid = raw_smp_processor_id(); /* any CPU in this partition will do */ 1228 cpuid = raw_smp_processor_id(); /* any CPU in this partition will do */
@@ -1279,80 +1230,48 @@ xpc_setup_infrastructure_sn2(struct xpc_partition *part)
1279 xpc_vars_part_sn2[partid].notify_IRQ_phys_cpuid = 1230 xpc_vars_part_sn2[partid].notify_IRQ_phys_cpuid =
1280 cpu_physical_id(cpuid); 1231 cpu_physical_id(cpuid);
1281 xpc_vars_part_sn2[partid].nchannels = part->nchannels; 1232 xpc_vars_part_sn2[partid].nchannels = part->nchannels;
1282 xpc_vars_part_sn2[partid].magic = XPC_VP_MAGIC1; 1233 xpc_vars_part_sn2[partid].magic = XPC_VP_MAGIC1_SN2;
1283 1234
1284 return xpSuccess; 1235 return xpSuccess;
1285 1236
1286 /* setup of infrastructure failed */ 1237 /* setup of ch structures failed */
1287out_5:
1288 kfree(part->remote_openclose_args_base);
1289 part->remote_openclose_args = NULL;
1290out_4:
1291 kfree(part->local_openclose_args_base);
1292 part->local_openclose_args = NULL;
1293out_3: 1238out_3:
1239 kfree(part_sn2->local_openclose_args_base);
1240 part_sn2->local_openclose_args = NULL;
1241out_2:
1294 kfree(part_sn2->remote_GPs_base); 1242 kfree(part_sn2->remote_GPs_base);
1295 part_sn2->remote_GPs = NULL; 1243 part_sn2->remote_GPs = NULL;
1296out_2: 1244out_1:
1297 kfree(part_sn2->local_GPs_base); 1245 kfree(part_sn2->local_GPs_base);
1298 part_sn2->local_GPs = NULL; 1246 part_sn2->local_GPs = NULL;
1299out_1:
1300 kfree(part->channels);
1301 part->channels = NULL;
1302 return retval; 1247 return retval;
1303} 1248}
1304 1249
1305/* 1250/*
1306 * Teardown the infrastructure necessary to support XPartition Communication 1251 * Teardown the channel structures that are sn2 specific.
1307 * between the specified remote partition and the local one.
1308 */ 1252 */
1309static void 1253static void
1310xpc_teardown_infrastructure_sn2(struct xpc_partition *part) 1254xpc_teardown_ch_structures_sn_sn2(struct xpc_partition *part)
1311{ 1255{
1312 struct xpc_partition_sn2 *part_sn2 = &part->sn.sn2; 1256 struct xpc_partition_sn2 *part_sn2 = &part->sn.sn2;
1313 short partid = XPC_PARTID(part); 1257 short partid = XPC_PARTID(part);
1314 1258
1315 /* 1259 /*
1316 * We start off by making this partition inaccessible to local 1260 * Indicate that the variables specific to the remote partition are no
1317 * processes by marking it as no longer setup. Then we make it 1261 * longer available for its use.
1318 * inaccessible to remote processes by clearing the XPC per partition
1319 * specific variable's magic # (which indicates that these variables
1320 * are no longer valid) and by ignoring all XPC notify IRQs sent to
1321 * this partition.
1322 */ 1262 */
1323
1324 DBUG_ON(atomic_read(&part->nchannels_engaged) != 0);
1325 DBUG_ON(atomic_read(&part->nchannels_active) != 0);
1326 DBUG_ON(part->setup_state != XPC_P_SS_SETUP);
1327 part->setup_state = XPC_P_SS_WTEARDOWN;
1328
1329 xpc_vars_part_sn2[partid].magic = 0; 1263 xpc_vars_part_sn2[partid].magic = 0;
1330 1264
1331 free_irq(SGI_XPC_NOTIFY, (void *)(u64)partid);
1332
1333 /*
1334 * Before proceeding with the teardown we have to wait until all
1335 * existing references cease.
1336 */
1337 wait_event(part->teardown_wq, (atomic_read(&part->references) == 0));
1338
1339 /* now we can begin tearing down the infrastructure */
1340
1341 part->setup_state = XPC_P_SS_TORNDOWN;
1342
1343 /* in case we've still got outstanding timers registered... */ 1265 /* in case we've still got outstanding timers registered... */
1344 del_timer_sync(&part_sn2->dropped_notify_IRQ_timer); 1266 del_timer_sync(&part_sn2->dropped_notify_IRQ_timer);
1267 free_irq(SGI_XPC_NOTIFY, (void *)(u64)partid);
1345 1268
1346 kfree(part->remote_openclose_args_base); 1269 kfree(part_sn2->local_openclose_args_base);
1347 part->remote_openclose_args = NULL; 1270 part_sn2->local_openclose_args = NULL;
1348 kfree(part->local_openclose_args_base);
1349 part->local_openclose_args = NULL;
1350 kfree(part_sn2->remote_GPs_base); 1271 kfree(part_sn2->remote_GPs_base);
1351 part_sn2->remote_GPs = NULL; 1272 part_sn2->remote_GPs = NULL;
1352 kfree(part_sn2->local_GPs_base); 1273 kfree(part_sn2->local_GPs_base);
1353 part_sn2->local_GPs = NULL; 1274 part_sn2->local_GPs = NULL;
1354 kfree(part->channels);
1355 part->channels = NULL;
1356 part_sn2->local_chctl_amo_va = NULL; 1275 part_sn2->local_chctl_amo_va = NULL;
1357} 1276}
1358 1277
@@ -1429,8 +1348,8 @@ xpc_pull_remote_vars_part_sn2(struct xpc_partition *part)
1429 1348
1430 /* see if they've been set up yet */ 1349 /* see if they've been set up yet */
1431 1350
1432 if (pulled_entry->magic != XPC_VP_MAGIC1 && 1351 if (pulled_entry->magic != XPC_VP_MAGIC1_SN2 &&
1433 pulled_entry->magic != XPC_VP_MAGIC2) { 1352 pulled_entry->magic != XPC_VP_MAGIC2_SN2) {
1434 1353
1435 if (pulled_entry->magic != 0) { 1354 if (pulled_entry->magic != 0) {
1436 dev_dbg(xpc_chan, "partition %d's XPC vars_part for " 1355 dev_dbg(xpc_chan, "partition %d's XPC vars_part for "
@@ -1443,7 +1362,7 @@ xpc_pull_remote_vars_part_sn2(struct xpc_partition *part)
1443 return xpRetry; 1362 return xpRetry;
1444 } 1363 }
1445 1364
1446 if (xpc_vars_part_sn2[partid].magic == XPC_VP_MAGIC1) { 1365 if (xpc_vars_part_sn2[partid].magic == XPC_VP_MAGIC1_SN2) {
1447 1366
1448 /* validate the variables */ 1367 /* validate the variables */
1449 1368
@@ -1473,10 +1392,10 @@ xpc_pull_remote_vars_part_sn2(struct xpc_partition *part)
1473 1392
1474 /* let the other side know that we've pulled their variables */ 1393 /* let the other side know that we've pulled their variables */
1475 1394
1476 xpc_vars_part_sn2[partid].magic = XPC_VP_MAGIC2; 1395 xpc_vars_part_sn2[partid].magic = XPC_VP_MAGIC2_SN2;
1477 } 1396 }
1478 1397
1479 if (pulled_entry->magic == XPC_VP_MAGIC1) 1398 if (pulled_entry->magic == XPC_VP_MAGIC1_SN2)
1480 return xpRetry; 1399 return xpRetry;
1481 1400
1482 return xpSuccess; 1401 return xpSuccess;
@@ -1605,6 +1524,7 @@ xpc_get_chctl_all_flags_sn2(struct xpc_partition *part)
1605static enum xp_retval 1524static enum xp_retval
1606xpc_allocate_local_msgqueue_sn2(struct xpc_channel *ch) 1525xpc_allocate_local_msgqueue_sn2(struct xpc_channel *ch)
1607{ 1526{
1527 struct xpc_channel_sn2 *ch_sn2 = &ch->sn.sn2;
1608 unsigned long irq_flags; 1528 unsigned long irq_flags;
1609 int nentries; 1529 int nentries;
1610 size_t nbytes; 1530 size_t nbytes;
@@ -1612,17 +1532,17 @@ xpc_allocate_local_msgqueue_sn2(struct xpc_channel *ch)
1612 for (nentries = ch->local_nentries; nentries > 0; nentries--) { 1532 for (nentries = ch->local_nentries; nentries > 0; nentries--) {
1613 1533
1614 nbytes = nentries * ch->msg_size; 1534 nbytes = nentries * ch->msg_size;
1615 ch->local_msgqueue = 1535 ch_sn2->local_msgqueue =
1616 xpc_kzalloc_cacheline_aligned_sn2(nbytes, GFP_KERNEL, 1536 xpc_kzalloc_cacheline_aligned(nbytes, GFP_KERNEL,
1617 &ch->local_msgqueue_base); 1537 &ch_sn2->local_msgqueue_base);
1618 if (ch->local_msgqueue == NULL) 1538 if (ch_sn2->local_msgqueue == NULL)
1619 continue; 1539 continue;
1620 1540
1621 nbytes = nentries * sizeof(struct xpc_notify); 1541 nbytes = nentries * sizeof(struct xpc_notify);
1622 ch->notify_queue = kzalloc(nbytes, GFP_KERNEL); 1542 ch_sn2->notify_queue = kzalloc(nbytes, GFP_KERNEL);
1623 if (ch->notify_queue == NULL) { 1543 if (ch_sn2->notify_queue == NULL) {
1624 kfree(ch->local_msgqueue_base); 1544 kfree(ch_sn2->local_msgqueue_base);
1625 ch->local_msgqueue = NULL; 1545 ch_sn2->local_msgqueue = NULL;
1626 continue; 1546 continue;
1627 } 1547 }
1628 1548
@@ -1649,6 +1569,7 @@ xpc_allocate_local_msgqueue_sn2(struct xpc_channel *ch)
1649static enum xp_retval 1569static enum xp_retval
1650xpc_allocate_remote_msgqueue_sn2(struct xpc_channel *ch) 1570xpc_allocate_remote_msgqueue_sn2(struct xpc_channel *ch)
1651{ 1571{
1572 struct xpc_channel_sn2 *ch_sn2 = &ch->sn.sn2;
1652 unsigned long irq_flags; 1573 unsigned long irq_flags;
1653 int nentries; 1574 int nentries;
1654 size_t nbytes; 1575 size_t nbytes;
@@ -1658,10 +1579,10 @@ xpc_allocate_remote_msgqueue_sn2(struct xpc_channel *ch)
1658 for (nentries = ch->remote_nentries; nentries > 0; nentries--) { 1579 for (nentries = ch->remote_nentries; nentries > 0; nentries--) {
1659 1580
1660 nbytes = nentries * ch->msg_size; 1581 nbytes = nentries * ch->msg_size;
1661 ch->remote_msgqueue = 1582 ch_sn2->remote_msgqueue =
1662 xpc_kzalloc_cacheline_aligned_sn2(nbytes, GFP_KERNEL, 1583 xpc_kzalloc_cacheline_aligned(nbytes, GFP_KERNEL, &ch_sn2->
1663 &ch->remote_msgqueue_base); 1584 remote_msgqueue_base);
1664 if (ch->remote_msgqueue == NULL) 1585 if (ch_sn2->remote_msgqueue == NULL)
1665 continue; 1586 continue;
1666 1587
1667 spin_lock_irqsave(&ch->lock, irq_flags); 1588 spin_lock_irqsave(&ch->lock, irq_flags);
@@ -1687,8 +1608,9 @@ xpc_allocate_remote_msgqueue_sn2(struct xpc_channel *ch)
1687 * Note: Assumes all of the channel sizes are filled in. 1608 * Note: Assumes all of the channel sizes are filled in.
1688 */ 1609 */
1689static enum xp_retval 1610static enum xp_retval
1690xpc_allocate_msgqueues_sn2(struct xpc_channel *ch) 1611xpc_setup_msg_structures_sn2(struct xpc_channel *ch)
1691{ 1612{
1613 struct xpc_channel_sn2 *ch_sn2 = &ch->sn.sn2;
1692 enum xp_retval ret; 1614 enum xp_retval ret;
1693 1615
1694 DBUG_ON(ch->flags & XPC_C_SETUP); 1616 DBUG_ON(ch->flags & XPC_C_SETUP);
@@ -1698,10 +1620,10 @@ xpc_allocate_msgqueues_sn2(struct xpc_channel *ch)
1698 1620
1699 ret = xpc_allocate_remote_msgqueue_sn2(ch); 1621 ret = xpc_allocate_remote_msgqueue_sn2(ch);
1700 if (ret != xpSuccess) { 1622 if (ret != xpSuccess) {
1701 kfree(ch->local_msgqueue_base); 1623 kfree(ch_sn2->local_msgqueue_base);
1702 ch->local_msgqueue = NULL; 1624 ch_sn2->local_msgqueue = NULL;
1703 kfree(ch->notify_queue); 1625 kfree(ch_sn2->notify_queue);
1704 ch->notify_queue = NULL; 1626 ch_sn2->notify_queue = NULL;
1705 } 1627 }
1706 } 1628 }
1707 return ret; 1629 return ret;
@@ -1715,21 +1637,13 @@ xpc_allocate_msgqueues_sn2(struct xpc_channel *ch)
1715 * they're cleared when XPC_C_DISCONNECTED is cleared. 1637 * they're cleared when XPC_C_DISCONNECTED is cleared.
1716 */ 1638 */
1717static void 1639static void
1718xpc_free_msgqueues_sn2(struct xpc_channel *ch) 1640xpc_teardown_msg_structures_sn2(struct xpc_channel *ch)
1719{ 1641{
1720 struct xpc_channel_sn2 *ch_sn2 = &ch->sn.sn2; 1642 struct xpc_channel_sn2 *ch_sn2 = &ch->sn.sn2;
1721 1643
1722 DBUG_ON(!spin_is_locked(&ch->lock)); 1644 DBUG_ON(!spin_is_locked(&ch->lock));
1723 DBUG_ON(atomic_read(&ch->n_to_notify) != 0);
1724 1645
1725 ch->remote_msgqueue_pa = 0; 1646 ch_sn2->remote_msgqueue_pa = 0;
1726 ch->func = NULL;
1727 ch->key = NULL;
1728 ch->msg_size = 0;
1729 ch->local_nentries = 0;
1730 ch->remote_nentries = 0;
1731 ch->kthreads_assigned_limit = 0;
1732 ch->kthreads_idle_limit = 0;
1733 1647
1734 ch_sn2->local_GP->get = 0; 1648 ch_sn2->local_GP->get = 0;
1735 ch_sn2->local_GP->put = 0; 1649 ch_sn2->local_GP->put = 0;
@@ -1745,12 +1659,12 @@ xpc_free_msgqueues_sn2(struct xpc_channel *ch)
1745 dev_dbg(xpc_chan, "ch->flags=0x%x, partid=%d, channel=%d\n", 1659 dev_dbg(xpc_chan, "ch->flags=0x%x, partid=%d, channel=%d\n",
1746 ch->flags, ch->partid, ch->number); 1660 ch->flags, ch->partid, ch->number);
1747 1661
1748 kfree(ch->local_msgqueue_base); 1662 kfree(ch_sn2->local_msgqueue_base);
1749 ch->local_msgqueue = NULL; 1663 ch_sn2->local_msgqueue = NULL;
1750 kfree(ch->remote_msgqueue_base); 1664 kfree(ch_sn2->remote_msgqueue_base);
1751 ch->remote_msgqueue = NULL; 1665 ch_sn2->remote_msgqueue = NULL;
1752 kfree(ch->notify_queue); 1666 kfree(ch_sn2->notify_queue);
1753 ch->notify_queue = NULL; 1667 ch_sn2->notify_queue = NULL;
1754 } 1668 }
1755} 1669}
1756 1670
@@ -1766,7 +1680,7 @@ xpc_notify_senders_sn2(struct xpc_channel *ch, enum xp_retval reason, s64 put)
1766 1680
1767 while (++get < put && atomic_read(&ch->n_to_notify) > 0) { 1681 while (++get < put && atomic_read(&ch->n_to_notify) > 0) {
1768 1682
1769 notify = &ch->notify_queue[get % ch->local_nentries]; 1683 notify = &ch->sn.sn2.notify_queue[get % ch->local_nentries];
1770 1684
1771 /* 1685 /*
1772 * See if the notify entry indicates it was associated with 1686 * See if the notify entry indicates it was associated with
@@ -1818,7 +1732,7 @@ xpc_clear_local_msgqueue_flags_sn2(struct xpc_channel *ch)
1818 1732
1819 get = ch_sn2->w_remote_GP.get; 1733 get = ch_sn2->w_remote_GP.get;
1820 do { 1734 do {
1821 msg = (struct xpc_msg *)((u64)ch->local_msgqueue + 1735 msg = (struct xpc_msg *)((u64)ch_sn2->local_msgqueue +
1822 (get % ch->local_nentries) * 1736 (get % ch->local_nentries) *
1823 ch->msg_size); 1737 ch->msg_size);
1824 msg->flags = 0; 1738 msg->flags = 0;
@@ -1837,7 +1751,7 @@ xpc_clear_remote_msgqueue_flags_sn2(struct xpc_channel *ch)
1837 1751
1838 put = ch_sn2->w_remote_GP.put; 1752 put = ch_sn2->w_remote_GP.put;
1839 do { 1753 do {
1840 msg = (struct xpc_msg *)((u64)ch->remote_msgqueue + 1754 msg = (struct xpc_msg *)((u64)ch_sn2->remote_msgqueue +
1841 (put % ch->remote_nentries) * 1755 (put % ch->remote_nentries) *
1842 ch->msg_size); 1756 ch->msg_size);
1843 msg->flags = 0; 1757 msg->flags = 0;
@@ -1976,8 +1890,9 @@ xpc_pull_remote_msg_sn2(struct xpc_channel *ch, s64 get)
1976 } 1890 }
1977 1891
1978 msg_offset = msg_index * ch->msg_size; 1892 msg_offset = msg_index * ch->msg_size;
1979 msg = (struct xpc_msg *)((u64)ch->remote_msgqueue + msg_offset); 1893 msg = (struct xpc_msg *)((u64)ch_sn2->remote_msgqueue +
1980 remote_msg_pa = ch->remote_msgqueue_pa + msg_offset; 1894 msg_offset);
1895 remote_msg_pa = ch_sn2->remote_msgqueue_pa + msg_offset;
1981 1896
1982 ret = xpc_pull_remote_cachelines_sn2(part, msg, remote_msg_pa, 1897 ret = xpc_pull_remote_cachelines_sn2(part, msg, remote_msg_pa,
1983 nmsgs * ch->msg_size); 1898 nmsgs * ch->msg_size);
@@ -2001,7 +1916,7 @@ xpc_pull_remote_msg_sn2(struct xpc_channel *ch, s64 get)
2001 1916
2002 /* return the message we were looking for */ 1917 /* return the message we were looking for */
2003 msg_offset = (get % ch->remote_nentries) * ch->msg_size; 1918 msg_offset = (get % ch->remote_nentries) * ch->msg_size;
2004 msg = (struct xpc_msg *)((u64)ch->remote_msgqueue + msg_offset); 1919 msg = (struct xpc_msg *)((u64)ch_sn2->remote_msgqueue + msg_offset);
2005 1920
2006 return msg; 1921 return msg;
2007} 1922}
@@ -2080,7 +1995,7 @@ xpc_send_msgs_sn2(struct xpc_channel *ch, s64 initial_put)
2080 if (put == ch_sn2->w_local_GP.put) 1995 if (put == ch_sn2->w_local_GP.put)
2081 break; 1996 break;
2082 1997
2083 msg = (struct xpc_msg *)((u64)ch->local_msgqueue + 1998 msg = (struct xpc_msg *)((u64)ch_sn2->local_msgqueue +
2084 (put % ch->local_nentries) * 1999 (put % ch->local_nentries) *
2085 ch->msg_size); 2000 ch->msg_size);
2086 2001
@@ -2182,7 +2097,7 @@ xpc_allocate_msg_sn2(struct xpc_channel *ch, u32 flags,
2182 } 2097 }
2183 2098
2184 /* get the message's address and initialize it */ 2099 /* get the message's address and initialize it */
2185 msg = (struct xpc_msg *)((u64)ch->local_msgqueue + 2100 msg = (struct xpc_msg *)((u64)ch_sn2->local_msgqueue +
2186 (put % ch->local_nentries) * ch->msg_size); 2101 (put % ch->local_nentries) * ch->msg_size);
2187 2102
2188 DBUG_ON(msg->flags != 0); 2103 DBUG_ON(msg->flags != 0);
@@ -2207,6 +2122,7 @@ xpc_send_msg_sn2(struct xpc_channel *ch, u32 flags, void *payload,
2207 void *key) 2122 void *key)
2208{ 2123{
2209 enum xp_retval ret = xpSuccess; 2124 enum xp_retval ret = xpSuccess;
2125 struct xpc_channel_sn2 *ch_sn2 = &ch->sn.sn2;
2210 struct xpc_msg *msg = msg; 2126 struct xpc_msg *msg = msg;
2211 struct xpc_notify *notify = notify; 2127 struct xpc_notify *notify = notify;
2212 s64 msg_number; 2128 s64 msg_number;
@@ -2243,7 +2159,7 @@ xpc_send_msg_sn2(struct xpc_channel *ch, u32 flags, void *payload,
2243 2159
2244 atomic_inc(&ch->n_to_notify); 2160 atomic_inc(&ch->n_to_notify);
2245 2161
2246 notify = &ch->notify_queue[msg_number % ch->local_nentries]; 2162 notify = &ch_sn2->notify_queue[msg_number % ch->local_nentries];
2247 notify->func = func; 2163 notify->func = func;
2248 notify->key = key; 2164 notify->key = key;
2249 notify->type = notify_type; 2165 notify->type = notify_type;
@@ -2279,7 +2195,7 @@ xpc_send_msg_sn2(struct xpc_channel *ch, u32 flags, void *payload,
2279 2195
2280 /* see if the message is next in line to be sent, if so send it */ 2196 /* see if the message is next in line to be sent, if so send it */
2281 2197
2282 put = ch->sn.sn2.local_GP->put; 2198 put = ch_sn2->local_GP->put;
2283 if (put == msg_number) 2199 if (put == msg_number)
2284 xpc_send_msgs_sn2(ch, put); 2200 xpc_send_msgs_sn2(ch, put);
2285 2201
@@ -2307,7 +2223,7 @@ xpc_acknowledge_msgs_sn2(struct xpc_channel *ch, s64 initial_get, u8 msg_flags)
2307 if (get == ch_sn2->w_local_GP.get) 2223 if (get == ch_sn2->w_local_GP.get)
2308 break; 2224 break;
2309 2225
2310 msg = (struct xpc_msg *)((u64)ch->remote_msgqueue + 2226 msg = (struct xpc_msg *)((u64)ch_sn2->remote_msgqueue +
2311 (get % ch->remote_nentries) * 2227 (get % ch->remote_nentries) *
2312 ch->msg_size); 2228 ch->msg_size);
2313 2229
@@ -2385,8 +2301,9 @@ xpc_init_sn2(void)
2385 int ret; 2301 int ret;
2386 size_t buf_size; 2302 size_t buf_size;
2387 2303
2304 xpc_setup_partitions_sn = xpc_setup_partitions_sn_sn2;
2388 xpc_get_partition_rsvd_page_pa = xpc_get_partition_rsvd_page_pa_sn2; 2305 xpc_get_partition_rsvd_page_pa = xpc_get_partition_rsvd_page_pa_sn2;
2389 xpc_rsvd_page_init = xpc_rsvd_page_init_sn2; 2306 xpc_setup_rsvd_page_sn = xpc_setup_rsvd_page_sn_sn2;
2390 xpc_increment_heartbeat = xpc_increment_heartbeat_sn2; 2307 xpc_increment_heartbeat = xpc_increment_heartbeat_sn2;
2391 xpc_offline_heartbeat = xpc_offline_heartbeat_sn2; 2308 xpc_offline_heartbeat = xpc_offline_heartbeat_sn2;
2392 xpc_online_heartbeat = xpc_online_heartbeat_sn2; 2309 xpc_online_heartbeat = xpc_online_heartbeat_sn2;
@@ -2403,29 +2320,33 @@ xpc_init_sn2(void)
2403 xpc_cancel_partition_deactivation_request_sn2; 2320 xpc_cancel_partition_deactivation_request_sn2;
2404 2321
2405 xpc_process_activate_IRQ_rcvd = xpc_process_activate_IRQ_rcvd_sn2; 2322 xpc_process_activate_IRQ_rcvd = xpc_process_activate_IRQ_rcvd_sn2;
2406 xpc_setup_infrastructure = xpc_setup_infrastructure_sn2; 2323 xpc_setup_ch_structures_sn = xpc_setup_ch_structures_sn_sn2;
2407 xpc_teardown_infrastructure = xpc_teardown_infrastructure_sn2; 2324 xpc_teardown_ch_structures_sn = xpc_teardown_ch_structures_sn_sn2;
2408 xpc_make_first_contact = xpc_make_first_contact_sn2; 2325 xpc_make_first_contact = xpc_make_first_contact_sn2;
2326
2409 xpc_get_chctl_all_flags = xpc_get_chctl_all_flags_sn2; 2327 xpc_get_chctl_all_flags = xpc_get_chctl_all_flags_sn2;
2410 xpc_allocate_msgqueues = xpc_allocate_msgqueues_sn2; 2328 xpc_send_chctl_closerequest = xpc_send_chctl_closerequest_sn2;
2411 xpc_free_msgqueues = xpc_free_msgqueues_sn2; 2329 xpc_send_chctl_closereply = xpc_send_chctl_closereply_sn2;
2330 xpc_send_chctl_openrequest = xpc_send_chctl_openrequest_sn2;
2331 xpc_send_chctl_openreply = xpc_send_chctl_openreply_sn2;
2332
2333 xpc_save_remote_msgqueue_pa = xpc_save_remote_msgqueue_pa_sn2;
2334
2335 xpc_setup_msg_structures = xpc_setup_msg_structures_sn2;
2336 xpc_teardown_msg_structures = xpc_teardown_msg_structures_sn2;
2337
2412 xpc_notify_senders_of_disconnect = xpc_notify_senders_of_disconnect_sn2; 2338 xpc_notify_senders_of_disconnect = xpc_notify_senders_of_disconnect_sn2;
2413 xpc_process_msg_chctl_flags = xpc_process_msg_chctl_flags_sn2; 2339 xpc_process_msg_chctl_flags = xpc_process_msg_chctl_flags_sn2;
2414 xpc_n_of_deliverable_msgs = xpc_n_of_deliverable_msgs_sn2; 2340 xpc_n_of_deliverable_msgs = xpc_n_of_deliverable_msgs_sn2;
2415 xpc_get_deliverable_msg = xpc_get_deliverable_msg_sn2; 2341 xpc_get_deliverable_msg = xpc_get_deliverable_msg_sn2;
2416 2342
2417 xpc_indicate_partition_engaged = xpc_indicate_partition_engaged_sn2; 2343 xpc_indicate_partition_engaged = xpc_indicate_partition_engaged_sn2;
2418 xpc_partition_engaged = xpc_partition_engaged_sn2;
2419 xpc_any_partition_engaged = xpc_any_partition_engaged_sn2;
2420 xpc_indicate_partition_disengaged = 2344 xpc_indicate_partition_disengaged =
2421 xpc_indicate_partition_disengaged_sn2; 2345 xpc_indicate_partition_disengaged_sn2;
2346 xpc_partition_engaged = xpc_partition_engaged_sn2;
2347 xpc_any_partition_engaged = xpc_any_partition_engaged_sn2;
2422 xpc_assume_partition_disengaged = xpc_assume_partition_disengaged_sn2; 2348 xpc_assume_partition_disengaged = xpc_assume_partition_disengaged_sn2;
2423 2349
2424 xpc_send_chctl_closerequest = xpc_send_chctl_closerequest_sn2;
2425 xpc_send_chctl_closereply = xpc_send_chctl_closereply_sn2;
2426 xpc_send_chctl_openrequest = xpc_send_chctl_openrequest_sn2;
2427 xpc_send_chctl_openreply = xpc_send_chctl_openreply_sn2;
2428
2429 xpc_send_msg = xpc_send_msg_sn2; 2350 xpc_send_msg = xpc_send_msg_sn2;
2430 xpc_received_msg = xpc_received_msg_sn2; 2351 xpc_received_msg = xpc_received_msg_sn2;
2431 2352
diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index c2d4ddd6e955..689cb5c68ccf 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -14,41 +14,528 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/mm.h>
18#include <linux/interrupt.h>
19#include <linux/delay.h>
20#include <linux/device.h>
17#include <asm/uv/uv_hub.h> 21#include <asm/uv/uv_hub.h>
22#include "../sgi-gru/gru.h"
18#include "../sgi-gru/grukservices.h" 23#include "../sgi-gru/grukservices.h"
19#include "xpc.h" 24#include "xpc.h"
20 25
26static atomic64_t xpc_heartbeat_uv;
21static DECLARE_BITMAP(xpc_heartbeating_to_mask_uv, XP_MAX_NPARTITIONS_UV); 27static DECLARE_BITMAP(xpc_heartbeating_to_mask_uv, XP_MAX_NPARTITIONS_UV);
22 28
23static void *xpc_activate_mq; 29#define XPC_ACTIVATE_MSG_SIZE_UV (1 * GRU_CACHE_LINE_BYTES)
30#define XPC_NOTIFY_MSG_SIZE_UV (2 * GRU_CACHE_LINE_BYTES)
31
32#define XPC_ACTIVATE_MQ_SIZE_UV (4 * XP_MAX_NPARTITIONS_UV * \
33 XPC_ACTIVATE_MSG_SIZE_UV)
34#define XPC_NOTIFY_MQ_SIZE_UV (4 * XP_MAX_NPARTITIONS_UV * \
35 XPC_NOTIFY_MSG_SIZE_UV)
36
37static void *xpc_activate_mq_uv;
38static void *xpc_notify_mq_uv;
39
40static int
41xpc_setup_partitions_sn_uv(void)
42{
43 short partid;
44 struct xpc_partition_uv *part_uv;
45
46 for (partid = 0; partid < XP_MAX_NPARTITIONS_UV; partid++) {
47 part_uv = &xpc_partitions[partid].sn.uv;
48
49 spin_lock_init(&part_uv->flags_lock);
50 part_uv->remote_act_state = XPC_P_AS_INACTIVE;
51 }
52 return 0;
53}
54
55static void *
56xpc_create_gru_mq_uv(unsigned int mq_size, int cpuid, unsigned int irq,
57 irq_handler_t irq_handler)
58{
59 int ret;
60 int nid;
61 int mq_order;
62 struct page *page;
63 void *mq;
64
65 nid = cpu_to_node(cpuid);
66 mq_order = get_order(mq_size);
67 page = alloc_pages_node(nid, GFP_KERNEL | __GFP_ZERO | GFP_THISNODE,
68 mq_order);
69 if (page == NULL)
70 return NULL;
71
72 mq = page_address(page);
73 ret = gru_create_message_queue(mq, mq_size);
74 if (ret != 0) {
75 dev_err(xpc_part, "gru_create_message_queue() returned "
76 "error=%d\n", ret);
77 free_pages((unsigned long)mq, mq_order);
78 return NULL;
79 }
80
81 /* !!! Need to do some other things to set up IRQ */
82
83 ret = request_irq(irq, irq_handler, 0, "xpc", NULL);
84 if (ret != 0) {
85 dev_err(xpc_part, "request_irq(irq=%d) returned error=%d\n",
86 irq, ret);
87 free_pages((unsigned long)mq, mq_order);
88 return NULL;
89 }
90
91 /* !!! enable generation of irq when GRU mq op occurs to this mq */
92
93 /* ??? allow other partitions to access GRU mq? */
94
95 return mq;
96}
24 97
25static void 98static void
26xpc_send_local_activate_IRQ_uv(struct xpc_partition *part) 99xpc_destroy_gru_mq_uv(void *mq, unsigned int mq_size, unsigned int irq)
100{
101 /* ??? disallow other partitions to access GRU mq? */
102
103 /* !!! disable generation of irq when GRU mq op occurs to this mq */
104
105 free_irq(irq, NULL);
106
107 free_pages((unsigned long)mq, get_order(mq_size));
108}
109
110static enum xp_retval
111xpc_send_gru_msg(unsigned long mq_gpa, void *msg, size_t msg_size)
27{ 112{
113 enum xp_retval xp_ret;
114 int ret;
115
116 while (1) {
117 ret = gru_send_message_gpa(mq_gpa, msg, msg_size);
118 if (ret == MQE_OK) {
119 xp_ret = xpSuccess;
120 break;
121 }
122
123 if (ret == MQE_QUEUE_FULL) {
124 dev_dbg(xpc_chan, "gru_send_message_gpa() returned "
125 "error=MQE_QUEUE_FULL\n");
126 /* !!! handle QLimit reached; delay & try again */
127 /* ??? Do we add a limit to the number of retries? */
128 (void)msleep_interruptible(10);
129 } else if (ret == MQE_CONGESTION) {
130 dev_dbg(xpc_chan, "gru_send_message_gpa() returned "
131 "error=MQE_CONGESTION\n");
132 /* !!! handle LB Overflow; simply try again */
133 /* ??? Do we add a limit to the number of retries? */
134 } else {
135 /* !!! Currently this is MQE_UNEXPECTED_CB_ERR */
136 dev_err(xpc_chan, "gru_send_message_gpa() returned "
137 "error=%d\n", ret);
138 xp_ret = xpGruSendMqError;
139 break;
140 }
141 }
142 return xp_ret;
143}
144
145static void
146xpc_process_activate_IRQ_rcvd_uv(void)
147{
148 unsigned long irq_flags;
149 short partid;
150 struct xpc_partition *part;
151 u8 act_state_req;
152
153 DBUG_ON(xpc_activate_IRQ_rcvd == 0);
154
155 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags);
156 for (partid = 0; partid < XP_MAX_NPARTITIONS_UV; partid++) {
157 part = &xpc_partitions[partid];
158
159 if (part->sn.uv.act_state_req == 0)
160 continue;
161
162 xpc_activate_IRQ_rcvd--;
163 BUG_ON(xpc_activate_IRQ_rcvd < 0);
164
165 act_state_req = part->sn.uv.act_state_req;
166 part->sn.uv.act_state_req = 0;
167 spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock, irq_flags);
168
169 if (act_state_req == XPC_P_ASR_ACTIVATE_UV) {
170 if (part->act_state == XPC_P_AS_INACTIVE)
171 xpc_activate_partition(part);
172 else if (part->act_state == XPC_P_AS_DEACTIVATING)
173 XPC_DEACTIVATE_PARTITION(part, xpReactivating);
174
175 } else if (act_state_req == XPC_P_ASR_REACTIVATE_UV) {
176 if (part->act_state == XPC_P_AS_INACTIVE)
177 xpc_activate_partition(part);
178 else
179 XPC_DEACTIVATE_PARTITION(part, xpReactivating);
180
181 } else if (act_state_req == XPC_P_ASR_DEACTIVATE_UV) {
182 XPC_DEACTIVATE_PARTITION(part, part->sn.uv.reason);
183
184 } else {
185 BUG();
186 }
187
188 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags);
189 if (xpc_activate_IRQ_rcvd == 0)
190 break;
191 }
192 spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock, irq_flags);
193
194}
195
196static irqreturn_t
197xpc_handle_activate_IRQ_uv(int irq, void *dev_id)
198{
199 unsigned long irq_flags;
200 struct xpc_activate_mq_msghdr_uv *msg_hdr;
201 short partid;
202 struct xpc_partition *part;
203 struct xpc_partition_uv *part_uv;
204 struct xpc_openclose_args *args;
205 int wakeup_hb_checker = 0;
206
207 while ((msg_hdr = gru_get_next_message(xpc_activate_mq_uv)) != NULL) {
208
209 partid = msg_hdr->partid;
210 if (partid < 0 || partid >= XP_MAX_NPARTITIONS_UV) {
211 dev_err(xpc_part, "xpc_handle_activate_IRQ_uv() invalid"
212 "partid=0x%x passed in message\n", partid);
213 gru_free_message(xpc_activate_mq_uv, msg_hdr);
214 continue;
215 }
216 part = &xpc_partitions[partid];
217 part_uv = &part->sn.uv;
218
219 part_uv->remote_act_state = msg_hdr->act_state;
220
221 switch (msg_hdr->type) {
222 case XPC_ACTIVATE_MQ_MSG_SYNC_ACT_STATE_UV:
223 /* syncing of remote_act_state was just done above */
224 break;
225
226 case XPC_ACTIVATE_MQ_MSG_INC_HEARTBEAT_UV: {
227 struct xpc_activate_mq_msg_heartbeat_req_uv *msg;
228
229 msg = (struct xpc_activate_mq_msg_heartbeat_req_uv *)
230 msg_hdr;
231 part_uv->heartbeat = msg->heartbeat;
232 break;
233 }
234 case XPC_ACTIVATE_MQ_MSG_OFFLINE_HEARTBEAT_UV: {
235 struct xpc_activate_mq_msg_heartbeat_req_uv *msg;
236
237 msg = (struct xpc_activate_mq_msg_heartbeat_req_uv *)
238 msg_hdr;
239 part_uv->heartbeat = msg->heartbeat;
240 spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
241 part_uv->flags |= XPC_P_HEARTBEAT_OFFLINE_UV;
242 spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags);
243 break;
244 }
245 case XPC_ACTIVATE_MQ_MSG_ONLINE_HEARTBEAT_UV: {
246 struct xpc_activate_mq_msg_heartbeat_req_uv *msg;
247
248 msg = (struct xpc_activate_mq_msg_heartbeat_req_uv *)
249 msg_hdr;
250 part_uv->heartbeat = msg->heartbeat;
251 spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
252 part_uv->flags &= ~XPC_P_HEARTBEAT_OFFLINE_UV;
253 spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags);
254 break;
255 }
256 case XPC_ACTIVATE_MQ_MSG_ACTIVATE_REQ_UV: {
257 struct xpc_activate_mq_msg_activate_req_uv *msg;
258
259 /*
260 * ??? Do we deal here with ts_jiffies being different
261 * ??? if act_state != XPC_P_AS_INACTIVE instead of
262 * ??? below?
263 */
264 msg = (struct xpc_activate_mq_msg_activate_req_uv *)
265 msg_hdr;
266 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock,
267 irq_flags);
268 if (part_uv->act_state_req == 0)
269 xpc_activate_IRQ_rcvd++;
270 part_uv->act_state_req = XPC_P_ASR_ACTIVATE_UV;
271 part->remote_rp_pa = msg->rp_gpa; /* !!! _pa is _gpa */
272 part->remote_rp_ts_jiffies = msg_hdr->rp_ts_jiffies;
273 part_uv->remote_activate_mq_gpa = msg->activate_mq_gpa;
274 spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock,
275 irq_flags);
276 wakeup_hb_checker++;
277 break;
278 }
279 case XPC_ACTIVATE_MQ_MSG_DEACTIVATE_REQ_UV: {
280 struct xpc_activate_mq_msg_deactivate_req_uv *msg;
281
282 msg = (struct xpc_activate_mq_msg_deactivate_req_uv *)
283 msg_hdr;
284 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock,
285 irq_flags);
286 if (part_uv->act_state_req == 0)
287 xpc_activate_IRQ_rcvd++;
288 part_uv->act_state_req = XPC_P_ASR_DEACTIVATE_UV;
289 part_uv->reason = msg->reason;
290 spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock,
291 irq_flags);
292 wakeup_hb_checker++;
293 break;
294 }
295 case XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREQUEST_UV: {
296 struct xpc_activate_mq_msg_chctl_closerequest_uv *msg;
297
298 msg = (struct xpc_activate_mq_msg_chctl_closerequest_uv
299 *)msg_hdr;
300 args = &part->remote_openclose_args[msg->ch_number];
301 args->reason = msg->reason;
302
303 spin_lock_irqsave(&part->chctl_lock, irq_flags);
304 part->chctl.flags[msg->ch_number] |=
305 XPC_CHCTL_CLOSEREQUEST;
306 spin_unlock_irqrestore(&part->chctl_lock, irq_flags);
307
308 xpc_wakeup_channel_mgr(part);
309 break;
310 }
311 case XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREPLY_UV: {
312 struct xpc_activate_mq_msg_chctl_closereply_uv *msg;
313
314 msg = (struct xpc_activate_mq_msg_chctl_closereply_uv *)
315 msg_hdr;
316
317 spin_lock_irqsave(&part->chctl_lock, irq_flags);
318 part->chctl.flags[msg->ch_number] |=
319 XPC_CHCTL_CLOSEREPLY;
320 spin_unlock_irqrestore(&part->chctl_lock, irq_flags);
321
322 xpc_wakeup_channel_mgr(part);
323 break;
324 }
325 case XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREQUEST_UV: {
326 struct xpc_activate_mq_msg_chctl_openrequest_uv *msg;
327
328 msg = (struct xpc_activate_mq_msg_chctl_openrequest_uv
329 *)msg_hdr;
330 args = &part->remote_openclose_args[msg->ch_number];
331 args->msg_size = msg->msg_size;
332 args->local_nentries = msg->local_nentries;
333
334 spin_lock_irqsave(&part->chctl_lock, irq_flags);
335 part->chctl.flags[msg->ch_number] |=
336 XPC_CHCTL_OPENREQUEST;
337 spin_unlock_irqrestore(&part->chctl_lock, irq_flags);
338
339 xpc_wakeup_channel_mgr(part);
340 break;
341 }
342 case XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREPLY_UV: {
343 struct xpc_activate_mq_msg_chctl_openreply_uv *msg;
344
345 msg = (struct xpc_activate_mq_msg_chctl_openreply_uv *)
346 msg_hdr;
347 args = &part->remote_openclose_args[msg->ch_number];
348 args->remote_nentries = msg->remote_nentries;
349 args->local_nentries = msg->local_nentries;
350 args->local_msgqueue_pa = msg->local_notify_mq_gpa;
351
352 spin_lock_irqsave(&part->chctl_lock, irq_flags);
353 part->chctl.flags[msg->ch_number] |=
354 XPC_CHCTL_OPENREPLY;
355 spin_unlock_irqrestore(&part->chctl_lock, irq_flags);
356
357 xpc_wakeup_channel_mgr(part);
358 break;
359 }
360 case XPC_ACTIVATE_MQ_MSG_MARK_ENGAGED_UV:
361 spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
362 part_uv->flags |= XPC_P_ENGAGED_UV;
363 spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags);
364 break;
365
366 case XPC_ACTIVATE_MQ_MSG_MARK_DISENGAGED_UV:
367 spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
368 part_uv->flags &= ~XPC_P_ENGAGED_UV;
369 spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags);
370 break;
371
372 default:
373 dev_err(xpc_part, "received unknown activate_mq msg "
374 "type=%d from partition=%d\n", msg_hdr->type,
375 partid);
376 }
377
378 if (msg_hdr->rp_ts_jiffies != part->remote_rp_ts_jiffies &&
379 part->remote_rp_ts_jiffies != 0) {
380 /*
381 * ??? Does what we do here need to be sensitive to
382 * ??? act_state or remote_act_state?
383 */
384 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock,
385 irq_flags);
386 if (part_uv->act_state_req == 0)
387 xpc_activate_IRQ_rcvd++;
388 part_uv->act_state_req = XPC_P_ASR_REACTIVATE_UV;
389 spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock,
390 irq_flags);
391 wakeup_hb_checker++;
392 }
393
394 gru_free_message(xpc_activate_mq_uv, msg_hdr);
395 }
396
397 if (wakeup_hb_checker)
398 wake_up_interruptible(&xpc_activate_IRQ_wq);
399
400 return IRQ_HANDLED;
401}
402
403static enum xp_retval
404xpc_send_activate_IRQ_uv(struct xpc_partition *part, void *msg, size_t msg_size,
405 int msg_type)
406{
407 struct xpc_activate_mq_msghdr_uv *msg_hdr = msg;
408
409 DBUG_ON(msg_size > XPC_ACTIVATE_MSG_SIZE_UV);
410
411 msg_hdr->type = msg_type;
412 msg_hdr->partid = XPC_PARTID(part);
413 msg_hdr->act_state = part->act_state;
414 msg_hdr->rp_ts_jiffies = xpc_rsvd_page->ts_jiffies;
415
416 /* ??? Is holding a spin_lock (ch->lock) during this call a bad idea? */
417 return xpc_send_gru_msg(part->sn.uv.remote_activate_mq_gpa, msg,
418 msg_size);
419}
420
421static void
422xpc_send_activate_IRQ_part_uv(struct xpc_partition *part, void *msg,
423 size_t msg_size, int msg_type)
424{
425 enum xp_retval ret;
426
427 ret = xpc_send_activate_IRQ_uv(part, msg, msg_size, msg_type);
428 if (unlikely(ret != xpSuccess))
429 XPC_DEACTIVATE_PARTITION(part, ret);
430}
431
432static void
433xpc_send_activate_IRQ_ch_uv(struct xpc_channel *ch, unsigned long *irq_flags,
434 void *msg, size_t msg_size, int msg_type)
435{
436 struct xpc_partition *part = &xpc_partitions[ch->number];
437 enum xp_retval ret;
438
439 ret = xpc_send_activate_IRQ_uv(part, msg, msg_size, msg_type);
440 if (unlikely(ret != xpSuccess)) {
441 if (irq_flags != NULL)
442 spin_unlock_irqrestore(&ch->lock, *irq_flags);
443
444 XPC_DEACTIVATE_PARTITION(part, ret);
445
446 if (irq_flags != NULL)
447 spin_lock_irqsave(&ch->lock, *irq_flags);
448 }
449}
450
451static void
452xpc_send_local_activate_IRQ_uv(struct xpc_partition *part, int act_state_req)
453{
454 unsigned long irq_flags;
455 struct xpc_partition_uv *part_uv = &part->sn.uv;
456
28 /* 457 /*
29 * !!! Make our side think that the remote parition sent an activate 458 * !!! Make our side think that the remote parition sent an activate
30 * !!! message our way. Also do what the activate IRQ handler would 459 * !!! message our way by doing what the activate IRQ handler would
31 * !!! do had one really been sent. 460 * !!! do had one really been sent.
32 */ 461 */
462
463 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags);
464 if (part_uv->act_state_req == 0)
465 xpc_activate_IRQ_rcvd++;
466 part_uv->act_state_req = act_state_req;
467 spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock, irq_flags);
468
469 wake_up_interruptible(&xpc_activate_IRQ_wq);
33} 470}
34 471
35static enum xp_retval 472static enum xp_retval
36xpc_rsvd_page_init_uv(struct xpc_rsvd_page *rp) 473xpc_get_partition_rsvd_page_pa_uv(void *buf, u64 *cookie, unsigned long *rp_pa,
474 size_t *len)
37{ 475{
38 /* !!! need to have established xpc_activate_mq earlier */ 476 /* !!! call the UV version of sn_partition_reserved_page_pa() */
39 rp->sn.activate_mq_gpa = uv_gpa(xpc_activate_mq); 477 return xpUnsupported;
40 return xpSuccess; 478}
479
480static int
481xpc_setup_rsvd_page_sn_uv(struct xpc_rsvd_page *rp)
482{
483 rp->sn.activate_mq_gpa = uv_gpa(xpc_activate_mq_uv);
484 return 0;
485}
486
487static void
488xpc_send_heartbeat_uv(int msg_type)
489{
490 short partid;
491 struct xpc_partition *part;
492 struct xpc_activate_mq_msg_heartbeat_req_uv msg;
493
494 /*
495 * !!! On uv we're broadcasting a heartbeat message every 5 seconds.
496 * !!! Whereas on sn2 we're bte_copy'ng the heartbeat info every 20
497 * !!! seconds. This is an increase in numalink traffic.
498 * ??? Is this good?
499 */
500
501 msg.heartbeat = atomic64_inc_return(&xpc_heartbeat_uv);
502
503 partid = find_first_bit(xpc_heartbeating_to_mask_uv,
504 XP_MAX_NPARTITIONS_UV);
505
506 while (partid < XP_MAX_NPARTITIONS_UV) {
507 part = &xpc_partitions[partid];
508
509 xpc_send_activate_IRQ_part_uv(part, &msg, sizeof(msg),
510 msg_type);
511
512 partid = find_next_bit(xpc_heartbeating_to_mask_uv,
513 XP_MAX_NPARTITIONS_UV, partid + 1);
514 }
41} 515}
42 516
43static void 517static void
44xpc_increment_heartbeat_uv(void) 518xpc_increment_heartbeat_uv(void)
45{ 519{
46 /* !!! send heartbeat msg to xpc_heartbeating_to_mask partids */ 520 xpc_send_heartbeat_uv(XPC_ACTIVATE_MQ_MSG_INC_HEARTBEAT_UV);
521}
522
523static void
524xpc_offline_heartbeat_uv(void)
525{
526 xpc_send_heartbeat_uv(XPC_ACTIVATE_MQ_MSG_OFFLINE_HEARTBEAT_UV);
527}
528
529static void
530xpc_online_heartbeat_uv(void)
531{
532 xpc_send_heartbeat_uv(XPC_ACTIVATE_MQ_MSG_ONLINE_HEARTBEAT_UV);
47} 533}
48 534
49static void 535static void
50xpc_heartbeat_init_uv(void) 536xpc_heartbeat_init_uv(void)
51{ 537{
538 atomic64_set(&xpc_heartbeat_uv, 0);
52 bitmap_zero(xpc_heartbeating_to_mask_uv, XP_MAX_NPARTITIONS_UV); 539 bitmap_zero(xpc_heartbeating_to_mask_uv, XP_MAX_NPARTITIONS_UV);
53 xpc_heartbeating_to_mask = &xpc_heartbeating_to_mask_uv[0]; 540 xpc_heartbeating_to_mask = &xpc_heartbeating_to_mask_uv[0];
54} 541}
@@ -56,48 +543,94 @@ xpc_heartbeat_init_uv(void)
56static void 543static void
57xpc_heartbeat_exit_uv(void) 544xpc_heartbeat_exit_uv(void)
58{ 545{
59 /* !!! send heartbeat_offline msg to xpc_heartbeating_to_mask partids */ 546 xpc_send_heartbeat_uv(XPC_ACTIVATE_MQ_MSG_OFFLINE_HEARTBEAT_UV);
547}
548
549static enum xp_retval
550xpc_get_remote_heartbeat_uv(struct xpc_partition *part)
551{
552 struct xpc_partition_uv *part_uv = &part->sn.uv;
553 enum xp_retval ret = xpNoHeartbeat;
554
555 if (part_uv->remote_act_state != XPC_P_AS_INACTIVE &&
556 part_uv->remote_act_state != XPC_P_AS_DEACTIVATING) {
557
558 if (part_uv->heartbeat != part->last_heartbeat ||
559 (part_uv->flags & XPC_P_HEARTBEAT_OFFLINE_UV)) {
560
561 part->last_heartbeat = part_uv->heartbeat;
562 ret = xpSuccess;
563 }
564 }
565 return ret;
60} 566}
61 567
62static void 568static void
63xpc_request_partition_activation_uv(struct xpc_rsvd_page *remote_rp, 569xpc_request_partition_activation_uv(struct xpc_rsvd_page *remote_rp,
64 unsigned long remote_rp_pa, int nasid) 570 unsigned long remote_rp_gpa, int nasid)
65{ 571{
66 short partid = remote_rp->SAL_partid; 572 short partid = remote_rp->SAL_partid;
67 struct xpc_partition *part = &xpc_partitions[partid]; 573 struct xpc_partition *part = &xpc_partitions[partid];
574 struct xpc_activate_mq_msg_activate_req_uv msg;
68 575
69/* 576 part->remote_rp_pa = remote_rp_gpa; /* !!! _pa here is really _gpa */
70 * !!! Setup part structure with the bits of info we can glean from the rp: 577 part->remote_rp_ts_jiffies = remote_rp->ts_jiffies;
71 * !!! part->remote_rp_pa = remote_rp_pa; 578 part->sn.uv.remote_activate_mq_gpa = remote_rp->sn.activate_mq_gpa;
72 * !!! part->sn.uv.activate_mq_gpa = remote_rp->sn.activate_mq_gpa; 579
73 */ 580 /*
581 * ??? Is it a good idea to make this conditional on what is
582 * ??? potentially stale state information?
583 */
584 if (part->sn.uv.remote_act_state == XPC_P_AS_INACTIVE) {
585 msg.rp_gpa = uv_gpa(xpc_rsvd_page);
586 msg.activate_mq_gpa = xpc_rsvd_page->sn.activate_mq_gpa;
587 xpc_send_activate_IRQ_part_uv(part, &msg, sizeof(msg),
588 XPC_ACTIVATE_MQ_MSG_ACTIVATE_REQ_UV);
589 }
74 590
75 xpc_send_local_activate_IRQ_uv(part); 591 if (part->act_state == XPC_P_AS_INACTIVE)
592 xpc_send_local_activate_IRQ_uv(part, XPC_P_ASR_ACTIVATE_UV);
76} 593}
77 594
78static void 595static void
79xpc_request_partition_reactivation_uv(struct xpc_partition *part) 596xpc_request_partition_reactivation_uv(struct xpc_partition *part)
80{ 597{
81 xpc_send_local_activate_IRQ_uv(part); 598 xpc_send_local_activate_IRQ_uv(part, XPC_P_ASR_ACTIVATE_UV);
599}
600
601static void
602xpc_request_partition_deactivation_uv(struct xpc_partition *part)
603{
604 struct xpc_activate_mq_msg_deactivate_req_uv msg;
605
606 /*
607 * ??? Is it a good idea to make this conditional on what is
608 * ??? potentially stale state information?
609 */
610 if (part->sn.uv.remote_act_state != XPC_P_AS_DEACTIVATING &&
611 part->sn.uv.remote_act_state != XPC_P_AS_INACTIVE) {
612
613 msg.reason = part->reason;
614 xpc_send_activate_IRQ_part_uv(part, &msg, sizeof(msg),
615 XPC_ACTIVATE_MQ_MSG_DEACTIVATE_REQ_UV);
616 }
82} 617}
83 618
84/* 619/*
85 * Setup the infrastructure necessary to support XPartition Communication 620 * Setup the channel structures that are uv specific.
86 * between the specified remote partition and the local one.
87 */ 621 */
88static enum xp_retval 622static enum xp_retval
89xpc_setup_infrastructure_uv(struct xpc_partition *part) 623xpc_setup_ch_structures_sn_uv(struct xpc_partition *part)
90{ 624{
91 /* !!! this function needs fleshing out */ 625 /* !!! this function needs fleshing out */
92 return xpUnsupported; 626 return xpUnsupported;
93} 627}
94 628
95/* 629/*
96 * Teardown the infrastructure necessary to support XPartition Communication 630 * Teardown the channel structures that are uv specific.
97 * between the specified remote partition and the local one.
98 */ 631 */
99static void 632static void
100xpc_teardown_infrastructure_uv(struct xpc_partition *part) 633xpc_teardown_ch_structures_sn_uv(struct xpc_partition *part)
101{ 634{
102 /* !!! this function needs fleshing out */ 635 /* !!! this function needs fleshing out */
103 return; 636 return;
@@ -106,15 +639,163 @@ xpc_teardown_infrastructure_uv(struct xpc_partition *part)
106static enum xp_retval 639static enum xp_retval
107xpc_make_first_contact_uv(struct xpc_partition *part) 640xpc_make_first_contact_uv(struct xpc_partition *part)
108{ 641{
109 /* !!! this function needs fleshing out */ 642 struct xpc_activate_mq_msg_uv msg;
110 return xpUnsupported; 643
644 /*
645 * We send a sync msg to get the remote partition's remote_act_state
646 * updated to our current act_state which at this point should
647 * be XPC_P_AS_ACTIVATING.
648 */
649 xpc_send_activate_IRQ_part_uv(part, &msg, sizeof(msg),
650 XPC_ACTIVATE_MQ_MSG_SYNC_ACT_STATE_UV);
651
652 while (part->sn.uv.remote_act_state != XPC_P_AS_ACTIVATING) {
653
654 dev_dbg(xpc_part, "waiting to make first contact with "
655 "partition %d\n", XPC_PARTID(part));
656
657 /* wait a 1/4 of a second or so */
658 (void)msleep_interruptible(250);
659
660 if (part->act_state == XPC_P_AS_DEACTIVATING)
661 return part->reason;
662 }
663
664 return xpSuccess;
111} 665}
112 666
113static u64 667static u64
114xpc_get_chctl_all_flags_uv(struct xpc_partition *part) 668xpc_get_chctl_all_flags_uv(struct xpc_partition *part)
115{ 669{
670 unsigned long irq_flags;
671 union xpc_channel_ctl_flags chctl;
672
673 spin_lock_irqsave(&part->chctl_lock, irq_flags);
674 chctl = part->chctl;
675 if (chctl.all_flags != 0)
676 part->chctl.all_flags = 0;
677
678 spin_unlock_irqrestore(&part->chctl_lock, irq_flags);
679 return chctl.all_flags;
680}
681
682static enum xp_retval
683xpc_setup_msg_structures_uv(struct xpc_channel *ch)
684{
685 /* !!! this function needs fleshing out */
686 return xpUnsupported;
687}
688
689static void
690xpc_teardown_msg_structures_uv(struct xpc_channel *ch)
691{
692 struct xpc_channel_uv *ch_uv = &ch->sn.uv;
693
694 ch_uv->remote_notify_mq_gpa = 0;
695
116 /* !!! this function needs fleshing out */ 696 /* !!! this function needs fleshing out */
117 return 0UL; 697}
698
699static void
700xpc_send_chctl_closerequest_uv(struct xpc_channel *ch, unsigned long *irq_flags)
701{
702 struct xpc_activate_mq_msg_chctl_closerequest_uv msg;
703
704 msg.ch_number = ch->number;
705 msg.reason = ch->reason;
706 xpc_send_activate_IRQ_ch_uv(ch, irq_flags, &msg, sizeof(msg),
707 XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREQUEST_UV);
708}
709
710static void
711xpc_send_chctl_closereply_uv(struct xpc_channel *ch, unsigned long *irq_flags)
712{
713 struct xpc_activate_mq_msg_chctl_closereply_uv msg;
714
715 msg.ch_number = ch->number;
716 xpc_send_activate_IRQ_ch_uv(ch, irq_flags, &msg, sizeof(msg),
717 XPC_ACTIVATE_MQ_MSG_CHCTL_CLOSEREPLY_UV);
718}
719
720static void
721xpc_send_chctl_openrequest_uv(struct xpc_channel *ch, unsigned long *irq_flags)
722{
723 struct xpc_activate_mq_msg_chctl_openrequest_uv msg;
724
725 msg.ch_number = ch->number;
726 msg.msg_size = ch->msg_size;
727 msg.local_nentries = ch->local_nentries;
728 xpc_send_activate_IRQ_ch_uv(ch, irq_flags, &msg, sizeof(msg),
729 XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREQUEST_UV);
730}
731
732static void
733xpc_send_chctl_openreply_uv(struct xpc_channel *ch, unsigned long *irq_flags)
734{
735 struct xpc_activate_mq_msg_chctl_openreply_uv msg;
736
737 msg.ch_number = ch->number;
738 msg.local_nentries = ch->local_nentries;
739 msg.remote_nentries = ch->remote_nentries;
740 msg.local_notify_mq_gpa = uv_gpa(xpc_notify_mq_uv);
741 xpc_send_activate_IRQ_ch_uv(ch, irq_flags, &msg, sizeof(msg),
742 XPC_ACTIVATE_MQ_MSG_CHCTL_OPENREPLY_UV);
743}
744
745static void
746xpc_save_remote_msgqueue_pa_uv(struct xpc_channel *ch,
747 unsigned long msgqueue_pa)
748{
749 ch->sn.uv.remote_notify_mq_gpa = msgqueue_pa;
750}
751
752static void
753xpc_indicate_partition_engaged_uv(struct xpc_partition *part)
754{
755 struct xpc_activate_mq_msg_uv msg;
756
757 xpc_send_activate_IRQ_part_uv(part, &msg, sizeof(msg),
758 XPC_ACTIVATE_MQ_MSG_MARK_ENGAGED_UV);
759}
760
761static void
762xpc_indicate_partition_disengaged_uv(struct xpc_partition *part)
763{
764 struct xpc_activate_mq_msg_uv msg;
765
766 xpc_send_activate_IRQ_part_uv(part, &msg, sizeof(msg),
767 XPC_ACTIVATE_MQ_MSG_MARK_DISENGAGED_UV);
768}
769
770static void
771xpc_assume_partition_disengaged_uv(short partid)
772{
773 struct xpc_partition_uv *part_uv = &xpc_partitions[partid].sn.uv;
774 unsigned long irq_flags;
775
776 spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
777 part_uv->flags &= ~XPC_P_ENGAGED_UV;
778 spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags);
779}
780
781static int
782xpc_partition_engaged_uv(short partid)
783{
784 return (xpc_partitions[partid].sn.uv.flags & XPC_P_ENGAGED_UV) != 0;
785}
786
787static int
788xpc_any_partition_engaged_uv(void)
789{
790 struct xpc_partition_uv *part_uv;
791 short partid;
792
793 for (partid = 0; partid < XP_MAX_NPARTITIONS_UV; partid++) {
794 part_uv = &xpc_partitions[partid].sn.uv;
795 if ((part_uv->flags & XPC_P_ENGAGED_UV) != 0)
796 return 1;
797 }
798 return 0;
118} 799}
119 800
120static struct xpc_msg * 801static struct xpc_msg *
@@ -124,24 +805,64 @@ xpc_get_deliverable_msg_uv(struct xpc_channel *ch)
124 return NULL; 805 return NULL;
125} 806}
126 807
127void 808int
128xpc_init_uv(void) 809xpc_init_uv(void)
129{ 810{
130 xpc_rsvd_page_init = xpc_rsvd_page_init_uv; 811 xpc_setup_partitions_sn = xpc_setup_partitions_sn_uv;
812 xpc_process_activate_IRQ_rcvd = xpc_process_activate_IRQ_rcvd_uv;
813 xpc_get_partition_rsvd_page_pa = xpc_get_partition_rsvd_page_pa_uv;
814 xpc_setup_rsvd_page_sn = xpc_setup_rsvd_page_sn_uv;
131 xpc_increment_heartbeat = xpc_increment_heartbeat_uv; 815 xpc_increment_heartbeat = xpc_increment_heartbeat_uv;
816 xpc_offline_heartbeat = xpc_offline_heartbeat_uv;
817 xpc_online_heartbeat = xpc_online_heartbeat_uv;
132 xpc_heartbeat_init = xpc_heartbeat_init_uv; 818 xpc_heartbeat_init = xpc_heartbeat_init_uv;
133 xpc_heartbeat_exit = xpc_heartbeat_exit_uv; 819 xpc_heartbeat_exit = xpc_heartbeat_exit_uv;
820 xpc_get_remote_heartbeat = xpc_get_remote_heartbeat_uv;
821
134 xpc_request_partition_activation = xpc_request_partition_activation_uv; 822 xpc_request_partition_activation = xpc_request_partition_activation_uv;
135 xpc_request_partition_reactivation = 823 xpc_request_partition_reactivation =
136 xpc_request_partition_reactivation_uv; 824 xpc_request_partition_reactivation_uv;
137 xpc_setup_infrastructure = xpc_setup_infrastructure_uv; 825 xpc_request_partition_deactivation =
138 xpc_teardown_infrastructure = xpc_teardown_infrastructure_uv; 826 xpc_request_partition_deactivation_uv;
827
828 xpc_setup_ch_structures_sn = xpc_setup_ch_structures_sn_uv;
829 xpc_teardown_ch_structures_sn = xpc_teardown_ch_structures_sn_uv;
830
139 xpc_make_first_contact = xpc_make_first_contact_uv; 831 xpc_make_first_contact = xpc_make_first_contact_uv;
832
140 xpc_get_chctl_all_flags = xpc_get_chctl_all_flags_uv; 833 xpc_get_chctl_all_flags = xpc_get_chctl_all_flags_uv;
834 xpc_send_chctl_closerequest = xpc_send_chctl_closerequest_uv;
835 xpc_send_chctl_closereply = xpc_send_chctl_closereply_uv;
836 xpc_send_chctl_openrequest = xpc_send_chctl_openrequest_uv;
837 xpc_send_chctl_openreply = xpc_send_chctl_openreply_uv;
838
839 xpc_save_remote_msgqueue_pa = xpc_save_remote_msgqueue_pa_uv;
840
841 xpc_setup_msg_structures = xpc_setup_msg_structures_uv;
842 xpc_teardown_msg_structures = xpc_teardown_msg_structures_uv;
843
844 xpc_indicate_partition_engaged = xpc_indicate_partition_engaged_uv;
845 xpc_indicate_partition_disengaged =
846 xpc_indicate_partition_disengaged_uv;
847 xpc_assume_partition_disengaged = xpc_assume_partition_disengaged_uv;
848 xpc_partition_engaged = xpc_partition_engaged_uv;
849 xpc_any_partition_engaged = xpc_any_partition_engaged_uv;
850
141 xpc_get_deliverable_msg = xpc_get_deliverable_msg_uv; 851 xpc_get_deliverable_msg = xpc_get_deliverable_msg_uv;
852
853 /* ??? The cpuid argument's value is 0, is that what we want? */
854 /* !!! The irq argument's value isn't correct. */
855 xpc_activate_mq_uv = xpc_create_gru_mq_uv(XPC_ACTIVATE_MQ_SIZE_UV, 0, 0,
856 xpc_handle_activate_IRQ_uv);
857 if (xpc_activate_mq_uv == NULL)
858 return -ENOMEM;
859
860 return 0;
142} 861}
143 862
144void 863void
145xpc_exit_uv(void) 864xpc_exit_uv(void)
146{ 865{
866 /* !!! The irq argument's value isn't correct. */
867 xpc_destroy_gru_mq_uv(xpc_activate_mq_uv, XPC_ACTIVATE_MQ_SIZE_UV, 0);
147} 868}