aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/sgi-xp/xpc.h
diff options
context:
space:
mode:
authorDean Nelson <dcn@sgi.com>2008-04-22 15:48:01 -0400
committerTony Luck <tony.luck@intel.com>2008-04-22 18:08:29 -0400
commit4a3ad2ddc0b920cd3ead84b0c67599be02d689ca (patch)
tree244e6cc7fefcf5c8c5d8245c5ac9923835a7e366 /drivers/misc/sgi-xp/xpc.h
parent45d9ca492e4bd1522d1b5bd125c2908f1cee3d4a (diff)
[IA64] run some drivers/misc/sgi-xp through scripts/Lindent
Ran patches through scripts/Lindent (part 1). Signed-off-by: Dean Nelson <dcn@sgi.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'drivers/misc/sgi-xp/xpc.h')
-rw-r--r--drivers/misc/sgi-xp/xpc.h442
1 files changed, 185 insertions, 257 deletions
diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
index 14e70ee53ebe..64368bb88890 100644
--- a/drivers/misc/sgi-xp/xpc.h
+++ b/drivers/misc/sgi-xp/xpc.h
@@ -6,7 +6,6 @@
6 * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9
10/* 9/*
11 * Cross Partition Communication (XPC) structures and macros. 10 * Cross Partition Communication (XPC) structures and macros.
12 */ 11 */
@@ -14,7 +13,6 @@
14#ifndef _DRIVERS_MISC_SGIXP_XPC_H 13#ifndef _DRIVERS_MISC_SGIXP_XPC_H
15#define _DRIVERS_MISC_SGIXP_XPC_H 14#define _DRIVERS_MISC_SGIXP_XPC_H
16 15
17
18#include <linux/interrupt.h> 16#include <linux/interrupt.h>
19#include <linux/sysctl.h> 17#include <linux/sysctl.h>
20#include <linux/device.h> 18#include <linux/device.h>
@@ -29,7 +27,6 @@
29#include <asm/sn/shub_mmr.h> 27#include <asm/sn/shub_mmr.h>
30#include "xp.h" 28#include "xp.h"
31 29
32
33/* 30/*
34 * XPC Version numbers consist of a major and minor number. XPC can always 31 * XPC Version numbers consist of a major and minor number. XPC can always
35 * talk to versions with same major #, and never talk to versions with a 32 * talk to versions with same major #, and never talk to versions with a
@@ -39,7 +36,6 @@
39#define XPC_VERSION_MAJOR(_v) ((_v) >> 4) 36#define XPC_VERSION_MAJOR(_v) ((_v) >> 4)
40#define XPC_VERSION_MINOR(_v) ((_v) & 0xf) 37#define XPC_VERSION_MINOR(_v) ((_v) & 0xf)
41 38
42
43/* 39/*
44 * The next macros define word or bit representations for given 40 * The next macros define word or bit representations for given
45 * C-brick nasid in either the SAL provided bit array representing 41 * C-brick nasid in either the SAL provided bit array representing
@@ -67,7 +63,6 @@
67/* define the process name of the discovery thread */ 63/* define the process name of the discovery thread */
68#define XPC_DISCOVERY_THREAD_NAME "xpc_discovery" 64#define XPC_DISCOVERY_THREAD_NAME "xpc_discovery"
69 65
70
71/* 66/*
72 * the reserved page 67 * the reserved page
73 * 68 *
@@ -121,7 +116,7 @@ struct xpc_rsvd_page {
121 u64 nasids_size; /* SAL: size of each nasid mask in bytes */ 116 u64 nasids_size; /* SAL: size of each nasid mask in bytes */
122}; 117};
123 118
124#define XPC_RP_VERSION _XPC_VERSION(1,1) /* version 1.1 of the reserved page */ 119#define XPC_RP_VERSION _XPC_VERSION(1,1) /* version 1.1 of the reserved page */
125 120
126#define XPC_SUPPORTS_RP_STAMP(_version) \ 121#define XPC_SUPPORTS_RP_STAMP(_version) \
127 (_version >= _XPC_VERSION(1,1)) 122 (_version >= _XPC_VERSION(1,1))
@@ -138,14 +133,12 @@ xpc_compare_stamps(struct timespec *stamp1, struct timespec *stamp2)
138{ 133{
139 int ret; 134 int ret;
140 135
141
142 if ((ret = stamp1->tv_sec - stamp2->tv_sec) == 0) { 136 if ((ret = stamp1->tv_sec - stamp2->tv_sec) == 0) {
143 ret = stamp1->tv_nsec - stamp2->tv_nsec; 137 ret = stamp1->tv_nsec - stamp2->tv_nsec;
144 } 138 }
145 return ret; 139 return ret;
146} 140}
147 141
148
149/* 142/*
150 * Define the structures by which XPC variables can be exported to other 143 * Define the structures by which XPC variables can be exported to other
151 * partitions. (There are two: struct xpc_vars and struct xpc_vars_part) 144 * partitions. (There are two: struct xpc_vars and struct xpc_vars_part)
@@ -172,12 +165,11 @@ struct xpc_vars {
172 AMO_t *amos_page; /* vaddr of page of AMOs from MSPEC driver */ 165 AMO_t *amos_page; /* vaddr of page of AMOs from MSPEC driver */
173}; 166};
174 167
175#define XPC_V_VERSION _XPC_VERSION(3,1) /* version 3.1 of the cross vars */ 168#define XPC_V_VERSION _XPC_VERSION(3,1) /* version 3.1 of the cross vars */
176 169
177#define XPC_SUPPORTS_DISENGAGE_REQUEST(_version) \ 170#define XPC_SUPPORTS_DISENGAGE_REQUEST(_version) \
178 (_version >= _XPC_VERSION(3,1)) 171 (_version >= _XPC_VERSION(3,1))
179 172
180
181static inline int 173static inline int
182xpc_hb_allowed(partid_t partid, struct xpc_vars *vars) 174xpc_hb_allowed(partid_t partid, struct xpc_vars *vars)
183{ 175{
@@ -193,7 +185,7 @@ xpc_allow_hb(partid_t partid, struct xpc_vars *vars)
193 old_mask = vars->heartbeating_to_mask; 185 old_mask = vars->heartbeating_to_mask;
194 new_mask = (old_mask | (1UL << partid)); 186 new_mask = (old_mask | (1UL << partid));
195 } while (cmpxchg(&vars->heartbeating_to_mask, old_mask, new_mask) != 187 } while (cmpxchg(&vars->heartbeating_to_mask, old_mask, new_mask) !=
196 old_mask); 188 old_mask);
197} 189}
198 190
199static inline void 191static inline void
@@ -205,10 +197,9 @@ xpc_disallow_hb(partid_t partid, struct xpc_vars *vars)
205 old_mask = vars->heartbeating_to_mask; 197 old_mask = vars->heartbeating_to_mask;
206 new_mask = (old_mask & ~(1UL << partid)); 198 new_mask = (old_mask & ~(1UL << partid));
207 } while (cmpxchg(&vars->heartbeating_to_mask, old_mask, new_mask) != 199 } while (cmpxchg(&vars->heartbeating_to_mask, old_mask, new_mask) !=
208 old_mask); 200 old_mask);
209} 201}
210 202
211
212/* 203/*
213 * The AMOs page consists of a number of AMO variables which are divided into 204 * The AMOs page consists of a number of AMO variables which are divided into
214 * four groups, The first two groups are used to identify an IRQ's sender. 205 * four groups, The first two groups are used to identify an IRQ's sender.
@@ -222,7 +213,6 @@ xpc_disallow_hb(partid_t partid, struct xpc_vars *vars)
222#define XPC_ENGAGED_PARTITIONS_AMO (XPC_ACTIVATE_IRQ_AMOS + XP_NASID_MASK_WORDS) 213#define XPC_ENGAGED_PARTITIONS_AMO (XPC_ACTIVATE_IRQ_AMOS + XP_NASID_MASK_WORDS)
223#define XPC_DISENGAGE_REQUEST_AMO (XPC_ENGAGED_PARTITIONS_AMO + 1) 214#define XPC_DISENGAGE_REQUEST_AMO (XPC_ENGAGED_PARTITIONS_AMO + 1)
224 215
225
226/* 216/*
227 * The following structure describes the per partition specific variables. 217 * The following structure describes the per partition specific variables.
228 * 218 *
@@ -257,9 +247,8 @@ struct xpc_vars_part {
257 * MAGIC2 indicates that this partition has pulled the remote partititions 247 * MAGIC2 indicates that this partition has pulled the remote partititions
258 * per partition variables that pertain to this partition. 248 * per partition variables that pertain to this partition.
259 */ 249 */
260#define XPC_VP_MAGIC1 0x0053524156435058L /* 'XPCVARS\0'L (little endian) */ 250#define XPC_VP_MAGIC1 0x0053524156435058L /* 'XPCVARS\0'L (little endian) */
261#define XPC_VP_MAGIC2 0x0073726176435058L /* 'XPCvars\0'L (little endian) */ 251#define XPC_VP_MAGIC2 0x0073726176435058L /* 'XPCvars\0'L (little endian) */
262
263 252
264/* the reserved page sizes and offsets */ 253/* the reserved page sizes and offsets */
265 254
@@ -271,7 +260,6 @@ struct xpc_vars_part {
271#define XPC_RP_VARS(_rp) ((struct xpc_vars *) XPC_RP_MACH_NASIDS(_rp) + xp_nasid_mask_words) 260#define XPC_RP_VARS(_rp) ((struct xpc_vars *) XPC_RP_MACH_NASIDS(_rp) + xp_nasid_mask_words)
272#define XPC_RP_VARS_PART(_rp) (struct xpc_vars_part *) ((u8 *) XPC_RP_VARS(rp) + XPC_RP_VARS_SIZE) 261#define XPC_RP_VARS_PART(_rp) (struct xpc_vars_part *) ((u8 *) XPC_RP_VARS(rp) + XPC_RP_VARS_SIZE)
273 262
274
275/* 263/*
276 * Functions registered by add_timer() or called by kernel_thread() only 264 * Functions registered by add_timer() or called by kernel_thread() only
277 * allow for a single 64-bit argument. The following macros can be used to 265 * allow for a single 64-bit argument. The following macros can be used to
@@ -285,8 +273,6 @@ struct xpc_vars_part {
285#define XPC_UNPACK_ARG1(_args) (((u64) _args) & 0xffffffff) 273#define XPC_UNPACK_ARG1(_args) (((u64) _args) & 0xffffffff)
286#define XPC_UNPACK_ARG2(_args) ((((u64) _args) >> 32) & 0xffffffff) 274#define XPC_UNPACK_ARG2(_args) ((((u64) _args) >> 32) & 0xffffffff)
287 275
288
289
290/* 276/*
291 * Define a Get/Put value pair (pointers) used with a message queue. 277 * Define a Get/Put value pair (pointers) used with a message queue.
292 */ 278 */
@@ -298,8 +284,6 @@ struct xpc_gp {
298#define XPC_GP_SIZE \ 284#define XPC_GP_SIZE \
299 L1_CACHE_ALIGN(sizeof(struct xpc_gp) * XPC_NCHANNELS) 285 L1_CACHE_ALIGN(sizeof(struct xpc_gp) * XPC_NCHANNELS)
300 286
301
302
303/* 287/*
304 * Define a structure that contains arguments associated with opening and 288 * Define a structure that contains arguments associated with opening and
305 * closing a channel. 289 * closing a channel.
@@ -315,20 +299,15 @@ struct xpc_openclose_args {
315#define XPC_OPENCLOSE_ARGS_SIZE \ 299#define XPC_OPENCLOSE_ARGS_SIZE \
316 L1_CACHE_ALIGN(sizeof(struct xpc_openclose_args) * XPC_NCHANNELS) 300 L1_CACHE_ALIGN(sizeof(struct xpc_openclose_args) * XPC_NCHANNELS)
317 301
318
319
320/* struct xpc_msg flags */ 302/* struct xpc_msg flags */
321 303
322#define XPC_M_DONE 0x01 /* msg has been received/consumed */ 304#define XPC_M_DONE 0x01 /* msg has been received/consumed */
323#define XPC_M_READY 0x02 /* msg is ready to be sent */ 305#define XPC_M_READY 0x02 /* msg is ready to be sent */
324#define XPC_M_INTERRUPT 0x04 /* send interrupt when msg consumed */ 306#define XPC_M_INTERRUPT 0x04 /* send interrupt when msg consumed */
325 307
326
327#define XPC_MSG_ADDRESS(_payload) \ 308#define XPC_MSG_ADDRESS(_payload) \
328 ((struct xpc_msg *)((u8 *)(_payload) - XPC_MSG_PAYLOAD_OFFSET)) 309 ((struct xpc_msg *)((u8 *)(_payload) - XPC_MSG_PAYLOAD_OFFSET))
329 310
330
331
332/* 311/*
333 * Defines notify entry. 312 * Defines notify entry.
334 * 313 *
@@ -336,19 +315,17 @@ struct xpc_openclose_args {
336 * and consumed by the intended recipient. 315 * and consumed by the intended recipient.
337 */ 316 */
338struct xpc_notify { 317struct xpc_notify {
339 volatile u8 type; /* type of notification */ 318 volatile u8 type; /* type of notification */
340 319
341 /* the following two fields are only used if type == XPC_N_CALL */ 320 /* the following two fields are only used if type == XPC_N_CALL */
342 xpc_notify_func func; /* user's notify function */ 321 xpc_notify_func func; /* user's notify function */
343 void *key; /* pointer to user's key */ 322 void *key; /* pointer to user's key */
344}; 323};
345 324
346/* struct xpc_notify type of notification */ 325/* struct xpc_notify type of notification */
347 326
348#define XPC_N_CALL 0x01 /* notify function provided by user */ 327#define XPC_N_CALL 0x01 /* notify function provided by user */
349 328
350
351
352/* 329/*
353 * Define the structure that manages all the stuff required by a channel. In 330 * Define the structure that manages all the stuff required by a channel. In
354 * particular, they are used to manage the messages sent across the channel. 331 * particular, they are used to manage the messages sent across the channel.
@@ -428,48 +405,48 @@ struct xpc_notify {
428 * messages. 405 * messages.
429 */ 406 */
430struct xpc_channel { 407struct xpc_channel {
431 partid_t partid; /* ID of remote partition connected */ 408 partid_t partid; /* ID of remote partition connected */
432 spinlock_t lock; /* lock for updating this structure */ 409 spinlock_t lock; /* lock for updating this structure */
433 u32 flags; /* general flags */ 410 u32 flags; /* general flags */
434 411
435 enum xpc_retval reason; /* reason why channel is disconnect'g */ 412 enum xpc_retval reason; /* reason why channel is disconnect'g */
436 int reason_line; /* line# disconnect initiated from */ 413 int reason_line; /* line# disconnect initiated from */
437 414
438 u16 number; /* channel # */ 415 u16 number; /* channel # */
439 416
440 u16 msg_size; /* sizeof each msg entry */ 417 u16 msg_size; /* sizeof each msg entry */
441 u16 local_nentries; /* #of msg entries in local msg queue */ 418 u16 local_nentries; /* #of msg entries in local msg queue */
442 u16 remote_nentries; /* #of msg entries in remote msg queue*/ 419 u16 remote_nentries; /* #of msg entries in remote msg queue */
443 420
444 void *local_msgqueue_base; /* base address of kmalloc'd space */ 421 void *local_msgqueue_base; /* base address of kmalloc'd space */
445 struct xpc_msg *local_msgqueue; /* local message queue */ 422 struct xpc_msg *local_msgqueue; /* local message queue */
446 void *remote_msgqueue_base; /* base address of kmalloc'd space */ 423 void *remote_msgqueue_base; /* base address of kmalloc'd space */
447 struct xpc_msg *remote_msgqueue;/* cached copy of remote partition's */ 424 struct xpc_msg *remote_msgqueue; /* cached copy of remote partition's */
448 /* local message queue */ 425 /* local message queue */
449 u64 remote_msgqueue_pa; /* phys addr of remote partition's */ 426 u64 remote_msgqueue_pa; /* phys addr of remote partition's */
450 /* local message queue */ 427 /* local message queue */
451 428
452 atomic_t references; /* #of external references to queues */ 429 atomic_t references; /* #of external references to queues */
453 430
454 atomic_t n_on_msg_allocate_wq; /* #on msg allocation wait queue */ 431 atomic_t n_on_msg_allocate_wq; /* #on msg allocation wait queue */
455 wait_queue_head_t msg_allocate_wq; /* msg allocation wait queue */ 432 wait_queue_head_t msg_allocate_wq; /* msg allocation wait queue */
456 433
457 u8 delayed_IPI_flags; /* IPI flags received, but delayed */ 434 u8 delayed_IPI_flags; /* IPI flags received, but delayed */
458 /* action until channel disconnected */ 435 /* action until channel disconnected */
459 436
460 /* queue of msg senders who want to be notified when msg received */ 437 /* queue of msg senders who want to be notified when msg received */
461 438
462 atomic_t n_to_notify; /* #of msg senders to notify */ 439 atomic_t n_to_notify; /* #of msg senders to notify */
463 struct xpc_notify *notify_queue;/* notify queue for messages sent */ 440 struct xpc_notify *notify_queue; /* notify queue for messages sent */
464 441
465 xpc_channel_func func; /* user's channel function */ 442 xpc_channel_func func; /* user's channel function */
466 void *key; /* pointer to user's key */ 443 void *key; /* pointer to user's key */
467 444
468 struct mutex msg_to_pull_mutex; /* next msg to pull serialization */ 445 struct mutex msg_to_pull_mutex; /* next msg to pull serialization */
469 struct completion wdisconnect_wait; /* wait for channel disconnect */ 446 struct completion wdisconnect_wait; /* wait for channel disconnect */
470 447
471 struct xpc_openclose_args *local_openclose_args; /* args passed on */ 448 struct xpc_openclose_args *local_openclose_args; /* args passed on */
472 /* opening or closing of channel */ 449 /* opening or closing of channel */
473 450
474 /* various flavors of local and remote Get/Put values */ 451 /* various flavors of local and remote Get/Put values */
475 452
@@ -477,7 +454,7 @@ struct xpc_channel {
477 struct xpc_gp remote_GP; /* remote Get/Put values */ 454 struct xpc_gp remote_GP; /* remote Get/Put values */
478 struct xpc_gp w_local_GP; /* working local Get/Put values */ 455 struct xpc_gp w_local_GP; /* working local Get/Put values */
479 struct xpc_gp w_remote_GP; /* working remote Get/Put values */ 456 struct xpc_gp w_remote_GP; /* working remote Get/Put values */
480 s64 next_msg_to_pull; /* Put value of next msg to pull */ 457 s64 next_msg_to_pull; /* Put value of next msg to pull */
481 458
482 /* kthread management related fields */ 459 /* kthread management related fields */
483 460
@@ -485,48 +462,45 @@ struct xpc_channel {
485// >>> allow the assigned limit be unbounded and let the idle limit be dynamic 462// >>> allow the assigned limit be unbounded and let the idle limit be dynamic
486// >>> dependent on activity over the last interval of time 463// >>> dependent on activity over the last interval of time
487 atomic_t kthreads_assigned; /* #of kthreads assigned to channel */ 464 atomic_t kthreads_assigned; /* #of kthreads assigned to channel */
488 u32 kthreads_assigned_limit; /* limit on #of kthreads assigned */ 465 u32 kthreads_assigned_limit; /* limit on #of kthreads assigned */
489 atomic_t kthreads_idle; /* #of kthreads idle waiting for work */ 466 atomic_t kthreads_idle; /* #of kthreads idle waiting for work */
490 u32 kthreads_idle_limit; /* limit on #of kthreads idle */ 467 u32 kthreads_idle_limit; /* limit on #of kthreads idle */
491 atomic_t kthreads_active; /* #of kthreads actively working */ 468 atomic_t kthreads_active; /* #of kthreads actively working */
492 // >>> following field is temporary 469 // >>> following field is temporary
493 u32 kthreads_created; /* total #of kthreads created */ 470 u32 kthreads_created; /* total #of kthreads created */
494 471
495 wait_queue_head_t idle_wq; /* idle kthread wait queue */ 472 wait_queue_head_t idle_wq; /* idle kthread wait queue */
496 473
497} ____cacheline_aligned; 474} ____cacheline_aligned;
498 475
499
500/* struct xpc_channel flags */ 476/* struct xpc_channel flags */
501 477
502#define XPC_C_WASCONNECTED 0x00000001 /* channel was connected */ 478#define XPC_C_WASCONNECTED 0x00000001 /* channel was connected */
503 479
504#define XPC_C_ROPENREPLY 0x00000002 /* remote open channel reply */ 480#define XPC_C_ROPENREPLY 0x00000002 /* remote open channel reply */
505#define XPC_C_OPENREPLY 0x00000004 /* local open channel reply */ 481#define XPC_C_OPENREPLY 0x00000004 /* local open channel reply */
506#define XPC_C_ROPENREQUEST 0x00000008 /* remote open channel request */ 482#define XPC_C_ROPENREQUEST 0x00000008 /* remote open channel request */
507#define XPC_C_OPENREQUEST 0x00000010 /* local open channel request */ 483#define XPC_C_OPENREQUEST 0x00000010 /* local open channel request */
508 484
509#define XPC_C_SETUP 0x00000020 /* channel's msgqueues are alloc'd */ 485#define XPC_C_SETUP 0x00000020 /* channel's msgqueues are alloc'd */
510#define XPC_C_CONNECTEDCALLOUT 0x00000040 /* connected callout initiated */ 486#define XPC_C_CONNECTEDCALLOUT 0x00000040 /* connected callout initiated */
511#define XPC_C_CONNECTEDCALLOUT_MADE \ 487#define XPC_C_CONNECTEDCALLOUT_MADE \
512 0x00000080 /* connected callout completed */ 488 0x00000080 /* connected callout completed */
513#define XPC_C_CONNECTED 0x00000100 /* local channel is connected */ 489#define XPC_C_CONNECTED 0x00000100 /* local channel is connected */
514#define XPC_C_CONNECTING 0x00000200 /* channel is being connected */ 490#define XPC_C_CONNECTING 0x00000200 /* channel is being connected */
515 491
516#define XPC_C_RCLOSEREPLY 0x00000400 /* remote close channel reply */ 492#define XPC_C_RCLOSEREPLY 0x00000400 /* remote close channel reply */
517#define XPC_C_CLOSEREPLY 0x00000800 /* local close channel reply */ 493#define XPC_C_CLOSEREPLY 0x00000800 /* local close channel reply */
518#define XPC_C_RCLOSEREQUEST 0x00001000 /* remote close channel request */ 494#define XPC_C_RCLOSEREQUEST 0x00001000 /* remote close channel request */
519#define XPC_C_CLOSEREQUEST 0x00002000 /* local close channel request */ 495#define XPC_C_CLOSEREQUEST 0x00002000 /* local close channel request */
520 496
521#define XPC_C_DISCONNECTED 0x00004000 /* channel is disconnected */ 497#define XPC_C_DISCONNECTED 0x00004000 /* channel is disconnected */
522#define XPC_C_DISCONNECTING 0x00008000 /* channel is being disconnected */ 498#define XPC_C_DISCONNECTING 0x00008000 /* channel is being disconnected */
523#define XPC_C_DISCONNECTINGCALLOUT \ 499#define XPC_C_DISCONNECTINGCALLOUT \
524 0x00010000 /* disconnecting callout initiated */ 500 0x00010000 /* disconnecting callout initiated */
525#define XPC_C_DISCONNECTINGCALLOUT_MADE \ 501#define XPC_C_DISCONNECTINGCALLOUT_MADE \
526 0x00020000 /* disconnecting callout completed */ 502 0x00020000 /* disconnecting callout completed */
527#define XPC_C_WDISCONNECT 0x00040000 /* waiting for channel disconnect */ 503#define XPC_C_WDISCONNECT 0x00040000 /* waiting for channel disconnect */
528
529
530 504
531/* 505/*
532 * Manages channels on a partition basis. There is one of these structures 506 * Manages channels on a partition basis. There is one of these structures
@@ -537,33 +511,31 @@ struct xpc_partition {
537 511
538 /* XPC HB infrastructure */ 512 /* XPC HB infrastructure */
539 513
540 u8 remote_rp_version; /* version# of partition's rsvd pg */ 514 u8 remote_rp_version; /* version# of partition's rsvd pg */
541 struct timespec remote_rp_stamp;/* time when rsvd pg was initialized */ 515 struct timespec remote_rp_stamp; /* time when rsvd pg was initialized */
542 u64 remote_rp_pa; /* phys addr of partition's rsvd pg */ 516 u64 remote_rp_pa; /* phys addr of partition's rsvd pg */
543 u64 remote_vars_pa; /* phys addr of partition's vars */ 517 u64 remote_vars_pa; /* phys addr of partition's vars */
544 u64 remote_vars_part_pa; /* phys addr of partition's vars part */ 518 u64 remote_vars_part_pa; /* phys addr of partition's vars part */
545 u64 last_heartbeat; /* HB at last read */ 519 u64 last_heartbeat; /* HB at last read */
546 u64 remote_amos_page_pa; /* phys addr of partition's amos page */ 520 u64 remote_amos_page_pa; /* phys addr of partition's amos page */
547 int remote_act_nasid; /* active part's act/deact nasid */ 521 int remote_act_nasid; /* active part's act/deact nasid */
548 int remote_act_phys_cpuid; /* active part's act/deact phys cpuid */ 522 int remote_act_phys_cpuid; /* active part's act/deact phys cpuid */
549 u32 act_IRQ_rcvd; /* IRQs since activation */ 523 u32 act_IRQ_rcvd; /* IRQs since activation */
550 spinlock_t act_lock; /* protect updating of act_state */ 524 spinlock_t act_lock; /* protect updating of act_state */
551 u8 act_state; /* from XPC HB viewpoint */ 525 u8 act_state; /* from XPC HB viewpoint */
552 u8 remote_vars_version; /* version# of partition's vars */ 526 u8 remote_vars_version; /* version# of partition's vars */
553 enum xpc_retval reason; /* reason partition is deactivating */ 527 enum xpc_retval reason; /* reason partition is deactivating */
554 int reason_line; /* line# deactivation initiated from */ 528 int reason_line; /* line# deactivation initiated from */
555 int reactivate_nasid; /* nasid in partition to reactivate */ 529 int reactivate_nasid; /* nasid in partition to reactivate */
556 530
557 unsigned long disengage_request_timeout; /* timeout in jiffies */ 531 unsigned long disengage_request_timeout; /* timeout in jiffies */
558 struct timer_list disengage_request_timer; 532 struct timer_list disengage_request_timer;
559 533
560
561 /* XPC infrastructure referencing and teardown control */ 534 /* XPC infrastructure referencing and teardown control */
562 535
563 volatile u8 setup_state; /* infrastructure setup state */ 536 volatile u8 setup_state; /* infrastructure setup state */
564 wait_queue_head_t teardown_wq; /* kthread waiting to teardown infra */ 537 wait_queue_head_t teardown_wq; /* kthread waiting to teardown infra */
565 atomic_t references; /* #of references to infrastructure */ 538 atomic_t references; /* #of references to infrastructure */
566
567 539
568 /* 540 /*
569 * NONE OF THE PRECEDING FIELDS OF THIS STRUCTURE WILL BE CLEARED WHEN 541 * NONE OF THE PRECEDING FIELDS OF THIS STRUCTURE WILL BE CLEARED WHEN
@@ -572,53 +544,48 @@ struct xpc_partition {
572 * 'nchannels' FIELD MUST BE THE FIRST OF THE FIELDS TO BE CLEARED.) 544 * 'nchannels' FIELD MUST BE THE FIRST OF THE FIELDS TO BE CLEARED.)
573 */ 545 */
574 546
575 547 u8 nchannels; /* #of defined channels supported */
576 u8 nchannels; /* #of defined channels supported */ 548 atomic_t nchannels_active; /* #of channels that are not DISCONNECTED */
577 atomic_t nchannels_active; /* #of channels that are not DISCONNECTED */ 549 atomic_t nchannels_engaged; /* #of channels engaged with remote part */
578 atomic_t nchannels_engaged;/* #of channels engaged with remote part */ 550 struct xpc_channel *channels; /* array of channel structures */
579 struct xpc_channel *channels;/* array of channel structures */ 551
580 552 void *local_GPs_base; /* base address of kmalloc'd space */
581 void *local_GPs_base; /* base address of kmalloc'd space */ 553 struct xpc_gp *local_GPs; /* local Get/Put values */
582 struct xpc_gp *local_GPs; /* local Get/Put values */ 554 void *remote_GPs_base; /* base address of kmalloc'd space */
583 void *remote_GPs_base; /* base address of kmalloc'd space */ 555 struct xpc_gp *remote_GPs; /* copy of remote partition's local Get/Put */
584 struct xpc_gp *remote_GPs;/* copy of remote partition's local Get/Put */ 556 /* values */
585 /* values */ 557 u64 remote_GPs_pa; /* phys address of remote partition's local */
586 u64 remote_GPs_pa; /* phys address of remote partition's local */ 558 /* Get/Put values */
587 /* Get/Put values */
588
589 559
590 /* fields used to pass args when opening or closing a channel */ 560 /* fields used to pass args when opening or closing a channel */
591 561
592 void *local_openclose_args_base; /* base address of kmalloc'd space */ 562 void *local_openclose_args_base; /* base address of kmalloc'd space */
593 struct xpc_openclose_args *local_openclose_args; /* local's args */ 563 struct xpc_openclose_args *local_openclose_args; /* local's args */
594 void *remote_openclose_args_base; /* base address of kmalloc'd space */ 564 void *remote_openclose_args_base; /* base address of kmalloc'd space */
595 struct xpc_openclose_args *remote_openclose_args; /* copy of remote's */ 565 struct xpc_openclose_args *remote_openclose_args; /* copy of remote's */
596 /* args */ 566 /* args */
597 u64 remote_openclose_args_pa; /* phys addr of remote's args */ 567 u64 remote_openclose_args_pa; /* phys addr of remote's args */
598
599 568
600 /* IPI sending, receiving and handling related fields */ 569 /* IPI sending, receiving and handling related fields */
601 570
602 int remote_IPI_nasid; /* nasid of where to send IPIs */ 571 int remote_IPI_nasid; /* nasid of where to send IPIs */
603 int remote_IPI_phys_cpuid; /* phys CPU ID of where to send IPIs */ 572 int remote_IPI_phys_cpuid; /* phys CPU ID of where to send IPIs */
604 AMO_t *remote_IPI_amo_va; /* address of remote IPI AMO_t structure */ 573 AMO_t *remote_IPI_amo_va; /* address of remote IPI AMO_t structure */
605 574
606 AMO_t *local_IPI_amo_va; /* address of IPI AMO_t structure */ 575 AMO_t *local_IPI_amo_va; /* address of IPI AMO_t structure */
607 u64 local_IPI_amo; /* IPI amo flags yet to be handled */ 576 u64 local_IPI_amo; /* IPI amo flags yet to be handled */
608 char IPI_owner[8]; /* IPI owner's name */ 577 char IPI_owner[8]; /* IPI owner's name */
609 struct timer_list dropped_IPI_timer; /* dropped IPI timer */ 578 struct timer_list dropped_IPI_timer; /* dropped IPI timer */
610
611 spinlock_t IPI_lock; /* IPI handler lock */
612 579
580 spinlock_t IPI_lock; /* IPI handler lock */
613 581
614 /* channel manager related fields */ 582 /* channel manager related fields */
615 583
616 atomic_t channel_mgr_requests; /* #of requests to activate chan mgr */ 584 atomic_t channel_mgr_requests; /* #of requests to activate chan mgr */
617 wait_queue_head_t channel_mgr_wq; /* channel mgr's wait queue */ 585 wait_queue_head_t channel_mgr_wq; /* channel mgr's wait queue */
618 586
619} ____cacheline_aligned; 587} ____cacheline_aligned;
620 588
621
622/* struct xpc_partition act_state values (for XPC HB) */ 589/* struct xpc_partition act_state values (for XPC HB) */
623 590
624#define XPC_P_INACTIVE 0x00 /* partition is not active */ 591#define XPC_P_INACTIVE 0x00 /* partition is not active */
@@ -627,11 +594,9 @@ struct xpc_partition {
627#define XPC_P_ACTIVE 0x03 /* xpc_partition_up() was called */ 594#define XPC_P_ACTIVE 0x03 /* xpc_partition_up() was called */
628#define XPC_P_DEACTIVATING 0x04 /* partition deactivation initiated */ 595#define XPC_P_DEACTIVATING 0x04 /* partition deactivation initiated */
629 596
630
631#define XPC_DEACTIVATE_PARTITION(_p, _reason) \ 597#define XPC_DEACTIVATE_PARTITION(_p, _reason) \
632 xpc_deactivate_partition(__LINE__, (_p), (_reason)) 598 xpc_deactivate_partition(__LINE__, (_p), (_reason))
633 599
634
635/* struct xpc_partition setup_state values */ 600/* struct xpc_partition setup_state values */
636 601
637#define XPC_P_UNSET 0x00 /* infrastructure was never setup */ 602#define XPC_P_UNSET 0x00 /* infrastructure was never setup */
@@ -639,8 +604,6 @@ struct xpc_partition {
639#define XPC_P_WTEARDOWN 0x02 /* waiting to teardown infrastructure */ 604#define XPC_P_WTEARDOWN 0x02 /* waiting to teardown infrastructure */
640#define XPC_P_TORNDOWN 0x03 /* infrastructure is torndown */ 605#define XPC_P_TORNDOWN 0x03 /* infrastructure is torndown */
641 606
642
643
644/* 607/*
645 * struct xpc_partition IPI_timer #of seconds to wait before checking for 608 * struct xpc_partition IPI_timer #of seconds to wait before checking for
646 * dropped IPIs. These occur whenever an IPI amo write doesn't complete until 609 * dropped IPIs. These occur whenever an IPI amo write doesn't complete until
@@ -648,22 +611,17 @@ struct xpc_partition {
648 */ 611 */
649#define XPC_P_DROPPED_IPI_WAIT (0.25 * HZ) 612#define XPC_P_DROPPED_IPI_WAIT (0.25 * HZ)
650 613
651
652/* number of seconds to wait for other partitions to disengage */ 614/* number of seconds to wait for other partitions to disengage */
653#define XPC_DISENGAGE_REQUEST_DEFAULT_TIMELIMIT 90 615#define XPC_DISENGAGE_REQUEST_DEFAULT_TIMELIMIT 90
654 616
655/* interval in seconds to print 'waiting disengagement' messages */ 617/* interval in seconds to print 'waiting disengagement' messages */
656#define XPC_DISENGAGE_PRINTMSG_INTERVAL 10 618#define XPC_DISENGAGE_PRINTMSG_INTERVAL 10
657 619
658
659#define XPC_PARTID(_p) ((partid_t) ((_p) - &xpc_partitions[0])) 620#define XPC_PARTID(_p) ((partid_t) ((_p) - &xpc_partitions[0]))
660 621
661
662
663/* found in xp_main.c */ 622/* found in xp_main.c */
664extern struct xpc_registration xpc_registrations[]; 623extern struct xpc_registration xpc_registrations[];
665 624
666
667/* found in xpc_main.c */ 625/* found in xpc_main.c */
668extern struct device *xpc_part; 626extern struct device *xpc_part;
669extern struct device *xpc_chan; 627extern struct device *xpc_chan;
@@ -676,7 +634,6 @@ extern void xpc_activate_kthreads(struct xpc_channel *, int);
676extern void xpc_create_kthreads(struct xpc_channel *, int, int); 634extern void xpc_create_kthreads(struct xpc_channel *, int, int);
677extern void xpc_disconnect_wait(int); 635extern void xpc_disconnect_wait(int);
678 636
679
680/* found in xpc_partition.c */ 637/* found in xpc_partition.c */
681extern int xpc_exiting; 638extern int xpc_exiting;
682extern struct xpc_vars *xpc_vars; 639extern struct xpc_vars *xpc_vars;
@@ -696,10 +653,9 @@ extern void xpc_mark_partition_inactive(struct xpc_partition *);
696extern void xpc_discovery(void); 653extern void xpc_discovery(void);
697extern void xpc_check_remote_hb(void); 654extern void xpc_check_remote_hb(void);
698extern void xpc_deactivate_partition(const int, struct xpc_partition *, 655extern void xpc_deactivate_partition(const int, struct xpc_partition *,
699 enum xpc_retval); 656 enum xpc_retval);
700extern enum xpc_retval xpc_initiate_partid_to_nasids(partid_t, void *); 657extern enum xpc_retval xpc_initiate_partid_to_nasids(partid_t, void *);
701 658
702
703/* found in xpc_channel.c */ 659/* found in xpc_channel.c */
704extern void xpc_initiate_connect(int); 660extern void xpc_initiate_connect(int);
705extern void xpc_initiate_disconnect(int); 661extern void xpc_initiate_disconnect(int);
@@ -714,13 +670,11 @@ extern void xpc_process_channel_activity(struct xpc_partition *);
714extern void xpc_connected_callout(struct xpc_channel *); 670extern void xpc_connected_callout(struct xpc_channel *);
715extern void xpc_deliver_msg(struct xpc_channel *); 671extern void xpc_deliver_msg(struct xpc_channel *);
716extern void xpc_disconnect_channel(const int, struct xpc_channel *, 672extern void xpc_disconnect_channel(const int, struct xpc_channel *,
717 enum xpc_retval, unsigned long *); 673 enum xpc_retval, unsigned long *);
718extern void xpc_disconnect_callout(struct xpc_channel *, enum xpc_retval); 674extern void xpc_disconnect_callout(struct xpc_channel *, enum xpc_retval);
719extern void xpc_partition_going_down(struct xpc_partition *, enum xpc_retval); 675extern void xpc_partition_going_down(struct xpc_partition *, enum xpc_retval);
720extern void xpc_teardown_infrastructure(struct xpc_partition *); 676extern void xpc_teardown_infrastructure(struct xpc_partition *);
721 677
722
723
724static inline void 678static inline void
725xpc_wakeup_channel_mgr(struct xpc_partition *part) 679xpc_wakeup_channel_mgr(struct xpc_partition *part)
726{ 680{
@@ -729,8 +683,6 @@ xpc_wakeup_channel_mgr(struct xpc_partition *part)
729 } 683 }
730} 684}
731 685
732
733
734/* 686/*
735 * These next two inlines are used to keep us from tearing down a channel's 687 * These next two inlines are used to keep us from tearing down a channel's
736 * msg queues while a thread may be referencing them. 688 * msg queues while a thread may be referencing them.
@@ -752,12 +704,9 @@ xpc_msgqueue_deref(struct xpc_channel *ch)
752 } 704 }
753} 705}
754 706
755
756
757#define XPC_DISCONNECT_CHANNEL(_ch, _reason, _irqflgs) \ 707#define XPC_DISCONNECT_CHANNEL(_ch, _reason, _irqflgs) \
758 xpc_disconnect_channel(__LINE__, _ch, _reason, _irqflgs) 708 xpc_disconnect_channel(__LINE__, _ch, _reason, _irqflgs)
759 709
760
761/* 710/*
762 * These two inlines are used to keep us from tearing down a partition's 711 * These two inlines are used to keep us from tearing down a partition's
763 * setup infrastructure while a thread may be referencing it. 712 * setup infrastructure while a thread may be referencing it.
@@ -767,7 +716,6 @@ xpc_part_deref(struct xpc_partition *part)
767{ 716{
768 s32 refs = atomic_dec_return(&part->references); 717 s32 refs = atomic_dec_return(&part->references);
769 718
770
771 DBUG_ON(refs < 0); 719 DBUG_ON(refs < 0);
772 if (refs == 0 && part->setup_state == XPC_P_WTEARDOWN) { 720 if (refs == 0 && part->setup_state == XPC_P_WTEARDOWN) {
773 wake_up(&part->teardown_wq); 721 wake_up(&part->teardown_wq);
@@ -779,7 +727,6 @@ xpc_part_ref(struct xpc_partition *part)
779{ 727{
780 int setup; 728 int setup;
781 729
782
783 atomic_inc(&part->references); 730 atomic_inc(&part->references);
784 setup = (part->setup_state == XPC_P_SETUP); 731 setup = (part->setup_state == XPC_P_SETUP);
785 if (!setup) { 732 if (!setup) {
@@ -788,8 +735,6 @@ xpc_part_ref(struct xpc_partition *part)
788 return setup; 735 return setup;
789} 736}
790 737
791
792
793/* 738/*
794 * The following macro is to be used for the setting of the reason and 739 * The following macro is to be used for the setting of the reason and
795 * reason_line fields in both the struct xpc_channel and struct xpc_partition 740 * reason_line fields in both the struct xpc_channel and struct xpc_partition
@@ -801,8 +746,6 @@ xpc_part_ref(struct xpc_partition *part)
801 (_p)->reason_line = _line; \ 746 (_p)->reason_line = _line; \
802 } 747 }
803 748
804
805
806/* 749/*
807 * This next set of inlines are used to keep track of when a partition is 750 * This next set of inlines are used to keep track of when a partition is
808 * potentially engaged in accessing memory belonging to another partition. 751 * potentially engaged in accessing memory belonging to another partition.
@@ -812,23 +755,24 @@ static inline void
812xpc_mark_partition_engaged(struct xpc_partition *part) 755xpc_mark_partition_engaged(struct xpc_partition *part)
813{ 756{
814 unsigned long irq_flags; 757 unsigned long irq_flags;
815 AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa + 758 AMO_t *amo = (AMO_t *)__va(part->remote_amos_page_pa +
816 (XPC_ENGAGED_PARTITIONS_AMO * sizeof(AMO_t))); 759 (XPC_ENGAGED_PARTITIONS_AMO *
817 760 sizeof(AMO_t)));
818 761
819 local_irq_save(irq_flags); 762 local_irq_save(irq_flags);
820 763
821 /* set bit corresponding to our partid in remote partition's AMO */ 764 /* set bit corresponding to our partid in remote partition's AMO */
822 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_OR, 765 FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_OR,
823 (1UL << sn_partition_id)); 766 (1UL << sn_partition_id));
824 /* 767 /*
825 * We must always use the nofault function regardless of whether we 768 * We must always use the nofault function regardless of whether we
826 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we 769 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we
827 * didn't, we'd never know that the other partition is down and would 770 * didn't, we'd never know that the other partition is down and would
828 * keep sending IPIs and AMOs to it until the heartbeat times out. 771 * keep sending IPIs and AMOs to it until the heartbeat times out.
829 */ 772 */
830 (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo-> 773 (void)xp_nofault_PIOR((u64 *)GLOBAL_MMR_ADDR(NASID_GET(&amo->
831 variable), xp_nofault_PIOR_target)); 774 variable),
775 xp_nofault_PIOR_target));
832 776
833 local_irq_restore(irq_flags); 777 local_irq_restore(irq_flags);
834} 778}
@@ -837,23 +781,24 @@ static inline void
837xpc_mark_partition_disengaged(struct xpc_partition *part) 781xpc_mark_partition_disengaged(struct xpc_partition *part)
838{ 782{
839 unsigned long irq_flags; 783 unsigned long irq_flags;
840 AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa + 784 AMO_t *amo = (AMO_t *)__va(part->remote_amos_page_pa +
841 (XPC_ENGAGED_PARTITIONS_AMO * sizeof(AMO_t))); 785 (XPC_ENGAGED_PARTITIONS_AMO *
842 786 sizeof(AMO_t)));
843 787
844 local_irq_save(irq_flags); 788 local_irq_save(irq_flags);
845 789
846 /* clear bit corresponding to our partid in remote partition's AMO */ 790 /* clear bit corresponding to our partid in remote partition's AMO */
847 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND, 791 FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND,
848 ~(1UL << sn_partition_id)); 792 ~(1UL << sn_partition_id));
849 /* 793 /*
850 * We must always use the nofault function regardless of whether we 794 * We must always use the nofault function regardless of whether we
851 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we 795 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we
852 * didn't, we'd never know that the other partition is down and would 796 * didn't, we'd never know that the other partition is down and would
853 * keep sending IPIs and AMOs to it until the heartbeat times out. 797 * keep sending IPIs and AMOs to it until the heartbeat times out.
854 */ 798 */
855 (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo-> 799 (void)xp_nofault_PIOR((u64 *)GLOBAL_MMR_ADDR(NASID_GET(&amo->
856 variable), xp_nofault_PIOR_target)); 800 variable),
801 xp_nofault_PIOR_target));
857 802
858 local_irq_restore(irq_flags); 803 local_irq_restore(irq_flags);
859} 804}
@@ -862,23 +807,23 @@ static inline void
862xpc_request_partition_disengage(struct xpc_partition *part) 807xpc_request_partition_disengage(struct xpc_partition *part)
863{ 808{
864 unsigned long irq_flags; 809 unsigned long irq_flags;
865 AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa + 810 AMO_t *amo = (AMO_t *)__va(part->remote_amos_page_pa +
866 (XPC_DISENGAGE_REQUEST_AMO * sizeof(AMO_t))); 811 (XPC_DISENGAGE_REQUEST_AMO * sizeof(AMO_t)));
867
868 812
869 local_irq_save(irq_flags); 813 local_irq_save(irq_flags);
870 814
871 /* set bit corresponding to our partid in remote partition's AMO */ 815 /* set bit corresponding to our partid in remote partition's AMO */
872 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_OR, 816 FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_OR,
873 (1UL << sn_partition_id)); 817 (1UL << sn_partition_id));
874 /* 818 /*
875 * We must always use the nofault function regardless of whether we 819 * We must always use the nofault function regardless of whether we
876 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we 820 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we
877 * didn't, we'd never know that the other partition is down and would 821 * didn't, we'd never know that the other partition is down and would
878 * keep sending IPIs and AMOs to it until the heartbeat times out. 822 * keep sending IPIs and AMOs to it until the heartbeat times out.
879 */ 823 */
880 (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo-> 824 (void)xp_nofault_PIOR((u64 *)GLOBAL_MMR_ADDR(NASID_GET(&amo->
881 variable), xp_nofault_PIOR_target)); 825 variable),
826 xp_nofault_PIOR_target));
882 827
883 local_irq_restore(irq_flags); 828 local_irq_restore(irq_flags);
884} 829}
@@ -887,23 +832,23 @@ static inline void
887xpc_cancel_partition_disengage_request(struct xpc_partition *part) 832xpc_cancel_partition_disengage_request(struct xpc_partition *part)
888{ 833{
889 unsigned long irq_flags; 834 unsigned long irq_flags;
890 AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa + 835 AMO_t *amo = (AMO_t *)__va(part->remote_amos_page_pa +
891 (XPC_DISENGAGE_REQUEST_AMO * sizeof(AMO_t))); 836 (XPC_DISENGAGE_REQUEST_AMO * sizeof(AMO_t)));
892
893 837
894 local_irq_save(irq_flags); 838 local_irq_save(irq_flags);
895 839
896 /* clear bit corresponding to our partid in remote partition's AMO */ 840 /* clear bit corresponding to our partid in remote partition's AMO */
897 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND, 841 FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND,
898 ~(1UL << sn_partition_id)); 842 ~(1UL << sn_partition_id));
899 /* 843 /*
900 * We must always use the nofault function regardless of whether we 844 * We must always use the nofault function regardless of whether we
901 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we 845 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we
902 * didn't, we'd never know that the other partition is down and would 846 * didn't, we'd never know that the other partition is down and would
903 * keep sending IPIs and AMOs to it until the heartbeat times out. 847 * keep sending IPIs and AMOs to it until the heartbeat times out.
904 */ 848 */
905 (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo-> 849 (void)xp_nofault_PIOR((u64 *)GLOBAL_MMR_ADDR(NASID_GET(&amo->
906 variable), xp_nofault_PIOR_target)); 850 variable),
851 xp_nofault_PIOR_target));
907 852
908 local_irq_restore(irq_flags); 853 local_irq_restore(irq_flags);
909} 854}
@@ -913,10 +858,9 @@ xpc_partition_engaged(u64 partid_mask)
913{ 858{
914 AMO_t *amo = xpc_vars->amos_page + XPC_ENGAGED_PARTITIONS_AMO; 859 AMO_t *amo = xpc_vars->amos_page + XPC_ENGAGED_PARTITIONS_AMO;
915 860
916
917 /* return our partition's AMO variable ANDed with partid_mask */ 861 /* return our partition's AMO variable ANDed with partid_mask */
918 return (FETCHOP_LOAD_OP(TO_AMO((u64) &amo->variable), FETCHOP_LOAD) & 862 return (FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_LOAD) &
919 partid_mask); 863 partid_mask);
920} 864}
921 865
922static inline u64 866static inline u64
@@ -924,10 +868,9 @@ xpc_partition_disengage_requested(u64 partid_mask)
924{ 868{
925 AMO_t *amo = xpc_vars->amos_page + XPC_DISENGAGE_REQUEST_AMO; 869 AMO_t *amo = xpc_vars->amos_page + XPC_DISENGAGE_REQUEST_AMO;
926 870
927
928 /* return our partition's AMO variable ANDed with partid_mask */ 871 /* return our partition's AMO variable ANDed with partid_mask */
929 return (FETCHOP_LOAD_OP(TO_AMO((u64) &amo->variable), FETCHOP_LOAD) & 872 return (FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_LOAD) &
930 partid_mask); 873 partid_mask);
931} 874}
932 875
933static inline void 876static inline void
@@ -935,10 +878,9 @@ xpc_clear_partition_engaged(u64 partid_mask)
935{ 878{
936 AMO_t *amo = xpc_vars->amos_page + XPC_ENGAGED_PARTITIONS_AMO; 879 AMO_t *amo = xpc_vars->amos_page + XPC_ENGAGED_PARTITIONS_AMO;
937 880
938
939 /* clear bit(s) based on partid_mask in our partition's AMO */ 881 /* clear bit(s) based on partid_mask in our partition's AMO */
940 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND, 882 FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND,
941 ~partid_mask); 883 ~partid_mask);
942} 884}
943 885
944static inline void 886static inline void
@@ -946,14 +888,11 @@ xpc_clear_partition_disengage_request(u64 partid_mask)
946{ 888{
947 AMO_t *amo = xpc_vars->amos_page + XPC_DISENGAGE_REQUEST_AMO; 889 AMO_t *amo = xpc_vars->amos_page + XPC_DISENGAGE_REQUEST_AMO;
948 890
949
950 /* clear bit(s) based on partid_mask in our partition's AMO */ 891 /* clear bit(s) based on partid_mask in our partition's AMO */
951 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND, 892 FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND,
952 ~partid_mask); 893 ~partid_mask);
953} 894}
954 895
955
956
957/* 896/*
958 * The following set of macros and inlines are used for the sending and 897 * The following set of macros and inlines are used for the sending and
959 * receiving of IPIs (also known as IRQs). There are two flavors of IPIs, 898 * receiving of IPIs (also known as IRQs). There are two flavors of IPIs,
@@ -964,20 +903,18 @@ xpc_clear_partition_disengage_request(u64 partid_mask)
964static inline u64 903static inline u64
965xpc_IPI_receive(AMO_t *amo) 904xpc_IPI_receive(AMO_t *amo)
966{ 905{
967 return FETCHOP_LOAD_OP(TO_AMO((u64) &amo->variable), FETCHOP_CLEAR); 906 return FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_CLEAR);
968} 907}
969 908
970
971static inline enum xpc_retval 909static inline enum xpc_retval
972xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector) 910xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector)
973{ 911{
974 int ret = 0; 912 int ret = 0;
975 unsigned long irq_flags; 913 unsigned long irq_flags;
976 914
977
978 local_irq_save(irq_flags); 915 local_irq_save(irq_flags);
979 916
980 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_OR, flag); 917 FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_OR, flag);
981 sn_send_IPI_phys(nasid, phys_cpuid, vector, 0); 918 sn_send_IPI_phys(nasid, phys_cpuid, vector, 0);
982 919
983 /* 920 /*
@@ -986,15 +923,14 @@ xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector)
986 * didn't, we'd never know that the other partition is down and would 923 * didn't, we'd never know that the other partition is down and would
987 * keep sending IPIs and AMOs to it until the heartbeat times out. 924 * keep sending IPIs and AMOs to it until the heartbeat times out.
988 */ 925 */
989 ret = xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->variable), 926 ret = xp_nofault_PIOR((u64 *)GLOBAL_MMR_ADDR(NASID_GET(&amo->variable),
990 xp_nofault_PIOR_target)); 927 xp_nofault_PIOR_target));
991 928
992 local_irq_restore(irq_flags); 929 local_irq_restore(irq_flags);
993 930
994 return ((ret == 0) ? xpcSuccess : xpcPioReadError); 931 return ((ret == 0) ? xpcSuccess : xpcPioReadError);
995} 932}
996 933
997
998/* 934/*
999 * IPIs associated with SGI_XPC_ACTIVATE IRQ. 935 * IPIs associated with SGI_XPC_ACTIVATE IRQ.
1000 */ 936 */
@@ -1004,47 +940,47 @@ xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector)
1004 */ 940 */
1005static inline void 941static inline void
1006xpc_activate_IRQ_send(u64 amos_page_pa, int from_nasid, int to_nasid, 942xpc_activate_IRQ_send(u64 amos_page_pa, int from_nasid, int to_nasid,
1007 int to_phys_cpuid) 943 int to_phys_cpuid)
1008{ 944{
1009 int w_index = XPC_NASID_W_INDEX(from_nasid); 945 int w_index = XPC_NASID_W_INDEX(from_nasid);
1010 int b_index = XPC_NASID_B_INDEX(from_nasid); 946 int b_index = XPC_NASID_B_INDEX(from_nasid);
1011 AMO_t *amos = (AMO_t *) __va(amos_page_pa + 947 AMO_t *amos = (AMO_t *)__va(amos_page_pa +
1012 (XPC_ACTIVATE_IRQ_AMOS * sizeof(AMO_t))); 948 (XPC_ACTIVATE_IRQ_AMOS * sizeof(AMO_t)));
1013
1014 949
1015 (void) xpc_IPI_send(&amos[w_index], (1UL << b_index), to_nasid, 950 (void)xpc_IPI_send(&amos[w_index], (1UL << b_index), to_nasid,
1016 to_phys_cpuid, SGI_XPC_ACTIVATE); 951 to_phys_cpuid, SGI_XPC_ACTIVATE);
1017} 952}
1018 953
1019static inline void 954static inline void
1020xpc_IPI_send_activate(struct xpc_vars *vars) 955xpc_IPI_send_activate(struct xpc_vars *vars)
1021{ 956{
1022 xpc_activate_IRQ_send(vars->amos_page_pa, cnodeid_to_nasid(0), 957 xpc_activate_IRQ_send(vars->amos_page_pa, cnodeid_to_nasid(0),
1023 vars->act_nasid, vars->act_phys_cpuid); 958 vars->act_nasid, vars->act_phys_cpuid);
1024} 959}
1025 960
1026static inline void 961static inline void
1027xpc_IPI_send_activated(struct xpc_partition *part) 962xpc_IPI_send_activated(struct xpc_partition *part)
1028{ 963{
1029 xpc_activate_IRQ_send(part->remote_amos_page_pa, cnodeid_to_nasid(0), 964 xpc_activate_IRQ_send(part->remote_amos_page_pa, cnodeid_to_nasid(0),
1030 part->remote_act_nasid, part->remote_act_phys_cpuid); 965 part->remote_act_nasid,
966 part->remote_act_phys_cpuid);
1031} 967}
1032 968
1033static inline void 969static inline void
1034xpc_IPI_send_reactivate(struct xpc_partition *part) 970xpc_IPI_send_reactivate(struct xpc_partition *part)
1035{ 971{
1036 xpc_activate_IRQ_send(xpc_vars->amos_page_pa, part->reactivate_nasid, 972 xpc_activate_IRQ_send(xpc_vars->amos_page_pa, part->reactivate_nasid,
1037 xpc_vars->act_nasid, xpc_vars->act_phys_cpuid); 973 xpc_vars->act_nasid, xpc_vars->act_phys_cpuid);
1038} 974}
1039 975
1040static inline void 976static inline void
1041xpc_IPI_send_disengage(struct xpc_partition *part) 977xpc_IPI_send_disengage(struct xpc_partition *part)
1042{ 978{
1043 xpc_activate_IRQ_send(part->remote_amos_page_pa, cnodeid_to_nasid(0), 979 xpc_activate_IRQ_send(part->remote_amos_page_pa, cnodeid_to_nasid(0),
1044 part->remote_act_nasid, part->remote_act_phys_cpuid); 980 part->remote_act_nasid,
981 part->remote_act_phys_cpuid);
1045} 982}
1046 983
1047
1048/* 984/*
1049 * IPIs associated with SGI_XPC_NOTIFY IRQ. 985 * IPIs associated with SGI_XPC_NOTIFY IRQ.
1050 */ 986 */
@@ -1058,18 +994,16 @@ xpc_IPI_send_disengage(struct xpc_partition *part)
1058 994
1059static inline void 995static inline void
1060xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string, 996xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string,
1061 unsigned long *irq_flags) 997 unsigned long *irq_flags)
1062{ 998{
1063 struct xpc_partition *part = &xpc_partitions[ch->partid]; 999 struct xpc_partition *part = &xpc_partitions[ch->partid];
1064 enum xpc_retval ret; 1000 enum xpc_retval ret;
1065 1001
1066
1067 if (likely(part->act_state != XPC_P_DEACTIVATING)) { 1002 if (likely(part->act_state != XPC_P_DEACTIVATING)) {
1068 ret = xpc_IPI_send(part->remote_IPI_amo_va, 1003 ret = xpc_IPI_send(part->remote_IPI_amo_va,
1069 (u64) ipi_flag << (ch->number * 8), 1004 (u64)ipi_flag << (ch->number * 8),
1070 part->remote_IPI_nasid, 1005 part->remote_IPI_nasid,
1071 part->remote_IPI_phys_cpuid, 1006 part->remote_IPI_phys_cpuid, SGI_XPC_NOTIFY);
1072 SGI_XPC_NOTIFY);
1073 dev_dbg(xpc_chan, "%s sent to partid=%d, channel=%d, ret=%d\n", 1007 dev_dbg(xpc_chan, "%s sent to partid=%d, channel=%d, ret=%d\n",
1074 ipi_flag_string, ch->partid, ch->number, ret); 1008 ipi_flag_string, ch->partid, ch->number, ret);
1075 if (unlikely(ret != xpcSuccess)) { 1009 if (unlikely(ret != xpcSuccess)) {
@@ -1084,7 +1018,6 @@ xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string,
1084 } 1018 }
1085} 1019}
1086 1020
1087
1088/* 1021/*
1089 * Make it look like the remote partition, which is associated with the 1022 * Make it look like the remote partition, which is associated with the
1090 * specified channel, sent us an IPI. This faked IPI will be handled 1023 * specified channel, sent us an IPI. This faked IPI will be handled
@@ -1095,18 +1028,16 @@ xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string,
1095 1028
1096static inline void 1029static inline void
1097xpc_notify_IRQ_send_local(struct xpc_channel *ch, u8 ipi_flag, 1030xpc_notify_IRQ_send_local(struct xpc_channel *ch, u8 ipi_flag,
1098 char *ipi_flag_string) 1031 char *ipi_flag_string)
1099{ 1032{
1100 struct xpc_partition *part = &xpc_partitions[ch->partid]; 1033 struct xpc_partition *part = &xpc_partitions[ch->partid];
1101 1034
1102 1035 FETCHOP_STORE_OP(TO_AMO((u64)&part->local_IPI_amo_va->variable),
1103 FETCHOP_STORE_OP(TO_AMO((u64) &part->local_IPI_amo_va->variable), 1036 FETCHOP_OR, ((u64)ipi_flag << (ch->number * 8)));
1104 FETCHOP_OR, ((u64) ipi_flag << (ch->number * 8)));
1105 dev_dbg(xpc_chan, "%s sent local from partid=%d, channel=%d\n", 1037 dev_dbg(xpc_chan, "%s sent local from partid=%d, channel=%d\n",
1106 ipi_flag_string, ch->partid, ch->number); 1038 ipi_flag_string, ch->partid, ch->number);
1107} 1039}
1108 1040
1109
1110/* 1041/*
1111 * The sending and receiving of IPIs includes the setting of an AMO variable 1042 * The sending and receiving of IPIs includes the setting of an AMO variable
1112 * to indicate the reason the IPI was sent. The 64-bit variable is divided 1043 * to indicate the reason the IPI was sent. The 64-bit variable is divided
@@ -1121,7 +1052,6 @@ xpc_notify_IRQ_send_local(struct xpc_channel *ch, u8 ipi_flag,
1121#define XPC_IPI_OPENREPLY 0x08 1052#define XPC_IPI_OPENREPLY 0x08
1122#define XPC_IPI_MSGREQUEST 0x10 1053#define XPC_IPI_MSGREQUEST 0x10
1123 1054
1124
1125/* given an AMO variable and a channel#, get its associated IPI flags */ 1055/* given an AMO variable and a channel#, get its associated IPI flags */
1126#define XPC_GET_IPI_FLAGS(_amo, _c) ((u8) (((_amo) >> ((_c) * 8)) & 0xff)) 1056#define XPC_GET_IPI_FLAGS(_amo, _c) ((u8) (((_amo) >> ((_c) * 8)) & 0xff))
1127#define XPC_SET_IPI_FLAGS(_amo, _c, _f) (_amo) |= ((u64) (_f) << ((_c) * 8)) 1057#define XPC_SET_IPI_FLAGS(_amo, _c, _f) (_amo) |= ((u64) (_f) << ((_c) * 8))
@@ -1129,13 +1059,11 @@ xpc_notify_IRQ_send_local(struct xpc_channel *ch, u8 ipi_flag,
1129#define XPC_ANY_OPENCLOSE_IPI_FLAGS_SET(_amo) ((_amo) & __IA64_UL_CONST(0x0f0f0f0f0f0f0f0f)) 1059#define XPC_ANY_OPENCLOSE_IPI_FLAGS_SET(_amo) ((_amo) & __IA64_UL_CONST(0x0f0f0f0f0f0f0f0f))
1130#define XPC_ANY_MSG_IPI_FLAGS_SET(_amo) ((_amo) & __IA64_UL_CONST(0x1010101010101010)) 1060#define XPC_ANY_MSG_IPI_FLAGS_SET(_amo) ((_amo) & __IA64_UL_CONST(0x1010101010101010))
1131 1061
1132
1133static inline void 1062static inline void
1134xpc_IPI_send_closerequest(struct xpc_channel *ch, unsigned long *irq_flags) 1063xpc_IPI_send_closerequest(struct xpc_channel *ch, unsigned long *irq_flags)
1135{ 1064{
1136 struct xpc_openclose_args *args = ch->local_openclose_args; 1065 struct xpc_openclose_args *args = ch->local_openclose_args;
1137 1066
1138
1139 args->reason = ch->reason; 1067 args->reason = ch->reason;
1140 1068
1141 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_CLOSEREQUEST, irq_flags); 1069 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_CLOSEREQUEST, irq_flags);
@@ -1152,7 +1080,6 @@ xpc_IPI_send_openrequest(struct xpc_channel *ch, unsigned long *irq_flags)
1152{ 1080{
1153 struct xpc_openclose_args *args = ch->local_openclose_args; 1081 struct xpc_openclose_args *args = ch->local_openclose_args;
1154 1082
1155
1156 args->msg_size = ch->msg_size; 1083 args->msg_size = ch->msg_size;
1157 args->local_nentries = ch->local_nentries; 1084 args->local_nentries = ch->local_nentries;
1158 1085
@@ -1164,7 +1091,6 @@ xpc_IPI_send_openreply(struct xpc_channel *ch, unsigned long *irq_flags)
1164{ 1091{
1165 struct xpc_openclose_args *args = ch->local_openclose_args; 1092 struct xpc_openclose_args *args = ch->local_openclose_args;
1166 1093
1167
1168 args->remote_nentries = ch->remote_nentries; 1094 args->remote_nentries = ch->remote_nentries;
1169 args->local_nentries = ch->local_nentries; 1095 args->local_nentries = ch->local_nentries;
1170 args->local_msgqueue_pa = __pa(ch->local_msgqueue); 1096 args->local_msgqueue_pa = __pa(ch->local_msgqueue);
@@ -1184,7 +1110,6 @@ xpc_IPI_send_local_msgrequest(struct xpc_channel *ch)
1184 XPC_NOTIFY_IRQ_SEND_LOCAL(ch, XPC_IPI_MSGREQUEST); 1110 XPC_NOTIFY_IRQ_SEND_LOCAL(ch, XPC_IPI_MSGREQUEST);
1185} 1111}
1186 1112
1187
1188/* 1113/*
1189 * Memory for XPC's AMO variables is allocated by the MSPEC driver. These 1114 * Memory for XPC's AMO variables is allocated by the MSPEC driver. These
1190 * pages are located in the lowest granule. The lowest granule uses 4k pages 1115 * pages are located in the lowest granule. The lowest granule uses 4k pages
@@ -1201,13 +1126,10 @@ xpc_IPI_init(int index)
1201{ 1126{
1202 AMO_t *amo = xpc_vars->amos_page + index; 1127 AMO_t *amo = xpc_vars->amos_page + index;
1203 1128
1204 1129 (void)xpc_IPI_receive(amo); /* clear AMO variable */
1205 (void) xpc_IPI_receive(amo); /* clear AMO variable */
1206 return amo; 1130 return amo;
1207} 1131}
1208 1132
1209
1210
1211static inline enum xpc_retval 1133static inline enum xpc_retval
1212xpc_map_bte_errors(bte_result_t error) 1134xpc_map_bte_errors(bte_result_t error)
1213{ 1135{
@@ -1220,22 +1142,31 @@ xpc_map_bte_errors(bte_result_t error)
1220 return xpcBteUnmappedError; 1142 return xpcBteUnmappedError;
1221 } 1143 }
1222 switch (error) { 1144 switch (error) {
1223 case BTE_SUCCESS: return xpcSuccess; 1145 case BTE_SUCCESS:
1224 case BTEFAIL_DIR: return xpcBteDirectoryError; 1146 return xpcSuccess;
1225 case BTEFAIL_POISON: return xpcBtePoisonError; 1147 case BTEFAIL_DIR:
1226 case BTEFAIL_WERR: return xpcBteWriteError; 1148 return xpcBteDirectoryError;
1227 case BTEFAIL_ACCESS: return xpcBteAccessError; 1149 case BTEFAIL_POISON:
1228 case BTEFAIL_PWERR: return xpcBtePWriteError; 1150 return xpcBtePoisonError;
1229 case BTEFAIL_PRERR: return xpcBtePReadError; 1151 case BTEFAIL_WERR:
1230 case BTEFAIL_TOUT: return xpcBteTimeOutError; 1152 return xpcBteWriteError;
1231 case BTEFAIL_XTERR: return xpcBteXtalkError; 1153 case BTEFAIL_ACCESS:
1232 case BTEFAIL_NOTAVAIL: return xpcBteNotAvailable; 1154 return xpcBteAccessError;
1233 default: return xpcBteUnmappedError; 1155 case BTEFAIL_PWERR:
1156 return xpcBtePWriteError;
1157 case BTEFAIL_PRERR:
1158 return xpcBtePReadError;
1159 case BTEFAIL_TOUT:
1160 return xpcBteTimeOutError;
1161 case BTEFAIL_XTERR:
1162 return xpcBteXtalkError;
1163 case BTEFAIL_NOTAVAIL:
1164 return xpcBteNotAvailable;
1165 default:
1166 return xpcBteUnmappedError;
1234 } 1167 }
1235} 1168}
1236 1169
1237
1238
1239/* 1170/*
1240 * Check to see if there is any channel activity to/from the specified 1171 * Check to see if there is any channel activity to/from the specified
1241 * partition. 1172 * partition.
@@ -1246,7 +1177,6 @@ xpc_check_for_channel_activity(struct xpc_partition *part)
1246 u64 IPI_amo; 1177 u64 IPI_amo;
1247 unsigned long irq_flags; 1178 unsigned long irq_flags;
1248 1179
1249
1250 IPI_amo = xpc_IPI_receive(part->local_IPI_amo_va); 1180 IPI_amo = xpc_IPI_receive(part->local_IPI_amo_va);
1251 if (IPI_amo == 0) { 1181 if (IPI_amo == 0) {
1252 return; 1182 return;
@@ -1262,6 +1192,4 @@ xpc_check_for_channel_activity(struct xpc_partition *part)
1262 xpc_wakeup_channel_mgr(part); 1192 xpc_wakeup_channel_mgr(part);
1263} 1193}
1264 1194
1265
1266#endif /* _DRIVERS_MISC_SGIXP_XPC_H */ 1195#endif /* _DRIVERS_MISC_SGIXP_XPC_H */
1267