···66 * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved.77 */8899-109/*1110 * The xp_nofault_PIOR function takes a pointer to a remote PIO register1211 * and attempts to load and consume a value from it. This function
+183-255
drivers/misc/sgi-xp/xpc.h
···66 * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved.77 */8899-109/*1110 * Cross Partition Communication (XPC) structures and macros.1211 */13121413#ifndef _DRIVERS_MISC_SGIXP_XPC_H1514#define _DRIVERS_MISC_SGIXP_XPC_H1616-17151816#include <linux/interrupt.h>1917#include <linux/sysctl.h>···2729#include <asm/sn/shub_mmr.h>2830#include "xp.h"29313030-3132/*3233 * XPC Version numbers consist of a major and minor number. XPC can always3334 * talk to versions with same major #, and never talk to versions with a···3538#define _XPC_VERSION(_maj, _min) (((_maj) << 4) | ((_min) & 0xf))3639#define XPC_VERSION_MAJOR(_v) ((_v) >> 4)3740#define XPC_VERSION_MINOR(_v) ((_v) & 0xf)3838-39414042/*4143 * The next macros define word or bit representations for given···62666367/* define the process name of the discovery thread */6468#define XPC_DISCOVERY_THREAD_NAME "xpc_discovery"6565-66696770/*6871 * the reserved page···116121 u64 nasids_size; /* SAL: size of each nasid mask in bytes */117122};118123119119-#define XPC_RP_VERSION _XPC_VERSION(1,1) /* version 1.1 of the reserved page */124124+#define XPC_RP_VERSION _XPC_VERSION(1,1) /* version 1.1 of the reserved page */120125121126#define XPC_SUPPORTS_RP_STAMP(_version) \122127 (_version >= _XPC_VERSION(1,1))···133138{134139 int ret;135140136136-137141 if ((ret = stamp1->tv_sec - stamp2->tv_sec) == 0) {138142 ret = stamp1->tv_nsec - stamp2->tv_nsec;139143 }140144 return ret;141145}142142-143146144147/*145148 * Define the structures by which XPC variables can be exported to other···165172 AMO_t *amos_page; /* vaddr of page of AMOs from MSPEC driver */166173};167174168168-#define XPC_V_VERSION _XPC_VERSION(3,1) /* version 3.1 of the cross vars */175175+#define XPC_V_VERSION _XPC_VERSION(3,1) /* version 3.1 of the cross vars */169176170177#define XPC_SUPPORTS_DISENGAGE_REQUEST(_version) \171178 (_version >= _XPC_VERSION(3,1))172172-173179174180static inline int175181xpc_hb_allowed(partid_t partid, struct xpc_vars *vars)···185193 old_mask = vars->heartbeating_to_mask;186194 new_mask = (old_mask | (1UL << partid));187195 } while (cmpxchg(&vars->heartbeating_to_mask, old_mask, new_mask) !=188188- old_mask);196196+ old_mask);189197}190198191199static inline void···197205 old_mask = vars->heartbeating_to_mask;198206 new_mask = (old_mask & ~(1UL << partid));199207 } while (cmpxchg(&vars->heartbeating_to_mask, old_mask, new_mask) !=200200- old_mask);208208+ old_mask);201209}202202-203210204211/*205212 * The AMOs page consists of a number of AMO variables which are divided into···212221#define XPC_ACTIVATE_IRQ_AMOS (XPC_NOTIFY_IRQ_AMOS + XP_MAX_PARTITIONS)213222#define XPC_ENGAGED_PARTITIONS_AMO (XPC_ACTIVATE_IRQ_AMOS + XP_NASID_MASK_WORDS)214223#define XPC_DISENGAGE_REQUEST_AMO (XPC_ENGAGED_PARTITIONS_AMO + 1)215215-216224217225/*218226 * The following structure describes the per partition specific variables.···247257 * MAGIC2 indicates that this partition has pulled the remote partititions248258 * per partition variables that pertain to this partition.249259 */250250-#define XPC_VP_MAGIC1 0x0053524156435058L /* 'XPCVARS\0'L (little endian) */251251-#define XPC_VP_MAGIC2 0x0073726176435058L /* 'XPCvars\0'L (little endian) */252252-260260+#define XPC_VP_MAGIC1 0x0053524156435058L /* 'XPCVARS\0'L (little endian) */261261+#define XPC_VP_MAGIC2 0x0073726176435058L /* 'XPCvars\0'L (little endian) */253262254263/* the reserved page sizes and offsets */255264···259270#define XPC_RP_MACH_NASIDS(_rp) (XPC_RP_PART_NASIDS(_rp) + xp_nasid_mask_words)260271#define XPC_RP_VARS(_rp) ((struct xpc_vars *) XPC_RP_MACH_NASIDS(_rp) + xp_nasid_mask_words)261272#define XPC_RP_VARS_PART(_rp) (struct xpc_vars_part *) ((u8 *) XPC_RP_VARS(rp) + XPC_RP_VARS_SIZE)262262-263273264274/*265275 * Functions registered by add_timer() or called by kernel_thread() only···273285#define XPC_UNPACK_ARG1(_args) (((u64) _args) & 0xffffffff)274286#define XPC_UNPACK_ARG2(_args) ((((u64) _args) >> 32) & 0xffffffff)275287276276-277277-278288/*279289 * Define a Get/Put value pair (pointers) used with a message queue.280290 */···283297284298#define XPC_GP_SIZE \285299 L1_CACHE_ALIGN(sizeof(struct xpc_gp) * XPC_NCHANNELS)286286-287287-288300289301/*290302 * Define a structure that contains arguments associated with opening and···299315#define XPC_OPENCLOSE_ARGS_SIZE \300316 L1_CACHE_ALIGN(sizeof(struct xpc_openclose_args) * XPC_NCHANNELS)301317302302-303303-304318/* struct xpc_msg flags */305319306320#define XPC_M_DONE 0x01 /* msg has been received/consumed */307321#define XPC_M_READY 0x02 /* msg is ready to be sent */308322#define XPC_M_INTERRUPT 0x04 /* send interrupt when msg consumed */309323310310-311324#define XPC_MSG_ADDRESS(_payload) \312325 ((struct xpc_msg *)((u8 *)(_payload) - XPC_MSG_PAYLOAD_OFFSET))313313-314314-315326316327/*317328 * Defines notify entry.···315336 * and consumed by the intended recipient.316337 */317338struct xpc_notify {318318- volatile u8 type; /* type of notification */339339+ volatile u8 type; /* type of notification */319340320341 /* the following two fields are only used if type == XPC_N_CALL */321321- xpc_notify_func func; /* user's notify function */322322- void *key; /* pointer to user's key */342342+ xpc_notify_func func; /* user's notify function */343343+ void *key; /* pointer to user's key */323344};324345325346/* struct xpc_notify type of notification */326347327348#define XPC_N_CALL 0x01 /* notify function provided by user */328328-329329-330349331350/*332351 * Define the structure that manages all the stuff required by a channel. In···405428 * messages.406429 */407430struct xpc_channel {408408- partid_t partid; /* ID of remote partition connected */409409- spinlock_t lock; /* lock for updating this structure */410410- u32 flags; /* general flags */431431+ partid_t partid; /* ID of remote partition connected */432432+ spinlock_t lock; /* lock for updating this structure */433433+ u32 flags; /* general flags */411434412412- enum xpc_retval reason; /* reason why channel is disconnect'g */413413- int reason_line; /* line# disconnect initiated from */435435+ enum xpc_retval reason; /* reason why channel is disconnect'g */436436+ int reason_line; /* line# disconnect initiated from */414437415415- u16 number; /* channel # */438438+ u16 number; /* channel # */416439417417- u16 msg_size; /* sizeof each msg entry */418418- u16 local_nentries; /* #of msg entries in local msg queue */419419- u16 remote_nentries; /* #of msg entries in remote msg queue*/440440+ u16 msg_size; /* sizeof each msg entry */441441+ u16 local_nentries; /* #of msg entries in local msg queue */442442+ u16 remote_nentries; /* #of msg entries in remote msg queue */420443421444 void *local_msgqueue_base; /* base address of kmalloc'd space */422445 struct xpc_msg *local_msgqueue; /* local message queue */423446 void *remote_msgqueue_base; /* base address of kmalloc'd space */424424- struct xpc_msg *remote_msgqueue;/* cached copy of remote partition's */425425- /* local message queue */426426- u64 remote_msgqueue_pa; /* phys addr of remote partition's */427427- /* local message queue */447447+ struct xpc_msg *remote_msgqueue; /* cached copy of remote partition's */448448+ /* local message queue */449449+ u64 remote_msgqueue_pa; /* phys addr of remote partition's */450450+ /* local message queue */428451429429- atomic_t references; /* #of external references to queues */452452+ atomic_t references; /* #of external references to queues */430453431431- atomic_t n_on_msg_allocate_wq; /* #on msg allocation wait queue */432432- wait_queue_head_t msg_allocate_wq; /* msg allocation wait queue */454454+ atomic_t n_on_msg_allocate_wq; /* #on msg allocation wait queue */455455+ wait_queue_head_t msg_allocate_wq; /* msg allocation wait queue */433456434434- u8 delayed_IPI_flags; /* IPI flags received, but delayed */435435- /* action until channel disconnected */457457+ u8 delayed_IPI_flags; /* IPI flags received, but delayed */458458+ /* action until channel disconnected */436459437460 /* queue of msg senders who want to be notified when msg received */438461439439- atomic_t n_to_notify; /* #of msg senders to notify */440440- struct xpc_notify *notify_queue;/* notify queue for messages sent */462462+ atomic_t n_to_notify; /* #of msg senders to notify */463463+ struct xpc_notify *notify_queue; /* notify queue for messages sent */441464442442- xpc_channel_func func; /* user's channel function */443443- void *key; /* pointer to user's key */465465+ xpc_channel_func func; /* user's channel function */466466+ void *key; /* pointer to user's key */444467445468 struct mutex msg_to_pull_mutex; /* next msg to pull serialization */446446- struct completion wdisconnect_wait; /* wait for channel disconnect */469469+ struct completion wdisconnect_wait; /* wait for channel disconnect */447470448448- struct xpc_openclose_args *local_openclose_args; /* args passed on */449449- /* opening or closing of channel */471471+ struct xpc_openclose_args *local_openclose_args; /* args passed on */472472+ /* opening or closing of channel */450473451474 /* various flavors of local and remote Get/Put values */452475···454477 struct xpc_gp remote_GP; /* remote Get/Put values */455478 struct xpc_gp w_local_GP; /* working local Get/Put values */456479 struct xpc_gp w_remote_GP; /* working remote Get/Put values */457457- s64 next_msg_to_pull; /* Put value of next msg to pull */480480+ s64 next_msg_to_pull; /* Put value of next msg to pull */458481459482 /* kthread management related fields */460483···462485// >>> allow the assigned limit be unbounded and let the idle limit be dynamic463486// >>> dependent on activity over the last interval of time464487 atomic_t kthreads_assigned; /* #of kthreads assigned to channel */465465- u32 kthreads_assigned_limit; /* limit on #of kthreads assigned */466466- atomic_t kthreads_idle; /* #of kthreads idle waiting for work */488488+ u32 kthreads_assigned_limit; /* limit on #of kthreads assigned */489489+ atomic_t kthreads_idle; /* #of kthreads idle waiting for work */467490 u32 kthreads_idle_limit; /* limit on #of kthreads idle */468491 atomic_t kthreads_active; /* #of kthreads actively working */469492 // >>> following field is temporary470470- u32 kthreads_created; /* total #of kthreads created */493493+ u32 kthreads_created; /* total #of kthreads created */471494472495 wait_queue_head_t idle_wq; /* idle kthread wait queue */473496474497} ____cacheline_aligned;475498476476-477499/* struct xpc_channel flags */478500479479-#define XPC_C_WASCONNECTED 0x00000001 /* channel was connected */501501+#define XPC_C_WASCONNECTED 0x00000001 /* channel was connected */480502481481-#define XPC_C_ROPENREPLY 0x00000002 /* remote open channel reply */482482-#define XPC_C_OPENREPLY 0x00000004 /* local open channel reply */483483-#define XPC_C_ROPENREQUEST 0x00000008 /* remote open channel request */484484-#define XPC_C_OPENREQUEST 0x00000010 /* local open channel request */503503+#define XPC_C_ROPENREPLY 0x00000002 /* remote open channel reply */504504+#define XPC_C_OPENREPLY 0x00000004 /* local open channel reply */505505+#define XPC_C_ROPENREQUEST 0x00000008 /* remote open channel request */506506+#define XPC_C_OPENREQUEST 0x00000010 /* local open channel request */485507486486-#define XPC_C_SETUP 0x00000020 /* channel's msgqueues are alloc'd */487487-#define XPC_C_CONNECTEDCALLOUT 0x00000040 /* connected callout initiated */508508+#define XPC_C_SETUP 0x00000020 /* channel's msgqueues are alloc'd */509509+#define XPC_C_CONNECTEDCALLOUT 0x00000040 /* connected callout initiated */488510#define XPC_C_CONNECTEDCALLOUT_MADE \489489- 0x00000080 /* connected callout completed */490490-#define XPC_C_CONNECTED 0x00000100 /* local channel is connected */491491-#define XPC_C_CONNECTING 0x00000200 /* channel is being connected */511511+ 0x00000080 /* connected callout completed */512512+#define XPC_C_CONNECTED 0x00000100 /* local channel is connected */513513+#define XPC_C_CONNECTING 0x00000200 /* channel is being connected */492514493493-#define XPC_C_RCLOSEREPLY 0x00000400 /* remote close channel reply */494494-#define XPC_C_CLOSEREPLY 0x00000800 /* local close channel reply */495495-#define XPC_C_RCLOSEREQUEST 0x00001000 /* remote close channel request */496496-#define XPC_C_CLOSEREQUEST 0x00002000 /* local close channel request */515515+#define XPC_C_RCLOSEREPLY 0x00000400 /* remote close channel reply */516516+#define XPC_C_CLOSEREPLY 0x00000800 /* local close channel reply */517517+#define XPC_C_RCLOSEREQUEST 0x00001000 /* remote close channel request */518518+#define XPC_C_CLOSEREQUEST 0x00002000 /* local close channel request */497519498498-#define XPC_C_DISCONNECTED 0x00004000 /* channel is disconnected */499499-#define XPC_C_DISCONNECTING 0x00008000 /* channel is being disconnected */520520+#define XPC_C_DISCONNECTED 0x00004000 /* channel is disconnected */521521+#define XPC_C_DISCONNECTING 0x00008000 /* channel is being disconnected */500522#define XPC_C_DISCONNECTINGCALLOUT \501501- 0x00010000 /* disconnecting callout initiated */523523+ 0x00010000 /* disconnecting callout initiated */502524#define XPC_C_DISCONNECTINGCALLOUT_MADE \503503- 0x00020000 /* disconnecting callout completed */504504-#define XPC_C_WDISCONNECT 0x00040000 /* waiting for channel disconnect */505505-506506-525525+ 0x00020000 /* disconnecting callout completed */526526+#define XPC_C_WDISCONNECT 0x00040000 /* waiting for channel disconnect */507527508528/*509529 * Manages channels on a partition basis. There is one of these structures···511537512538 /* XPC HB infrastructure */513539514514- u8 remote_rp_version; /* version# of partition's rsvd pg */515515- struct timespec remote_rp_stamp;/* time when rsvd pg was initialized */516516- u64 remote_rp_pa; /* phys addr of partition's rsvd pg */517517- u64 remote_vars_pa; /* phys addr of partition's vars */540540+ u8 remote_rp_version; /* version# of partition's rsvd pg */541541+ struct timespec remote_rp_stamp; /* time when rsvd pg was initialized */542542+ u64 remote_rp_pa; /* phys addr of partition's rsvd pg */543543+ u64 remote_vars_pa; /* phys addr of partition's vars */518544 u64 remote_vars_part_pa; /* phys addr of partition's vars part */519519- u64 last_heartbeat; /* HB at last read */545545+ u64 last_heartbeat; /* HB at last read */520546 u64 remote_amos_page_pa; /* phys addr of partition's amos page */521521- int remote_act_nasid; /* active part's act/deact nasid */547547+ int remote_act_nasid; /* active part's act/deact nasid */522548 int remote_act_phys_cpuid; /* active part's act/deact phys cpuid */523523- u32 act_IRQ_rcvd; /* IRQs since activation */524524- spinlock_t act_lock; /* protect updating of act_state */525525- u8 act_state; /* from XPC HB viewpoint */526526- u8 remote_vars_version; /* version# of partition's vars */527527- enum xpc_retval reason; /* reason partition is deactivating */528528- int reason_line; /* line# deactivation initiated from */529529- int reactivate_nasid; /* nasid in partition to reactivate */549549+ u32 act_IRQ_rcvd; /* IRQs since activation */550550+ spinlock_t act_lock; /* protect updating of act_state */551551+ u8 act_state; /* from XPC HB viewpoint */552552+ u8 remote_vars_version; /* version# of partition's vars */553553+ enum xpc_retval reason; /* reason partition is deactivating */554554+ int reason_line; /* line# deactivation initiated from */555555+ int reactivate_nasid; /* nasid in partition to reactivate */530556531531- unsigned long disengage_request_timeout; /* timeout in jiffies */557557+ unsigned long disengage_request_timeout; /* timeout in jiffies */532558 struct timer_list disengage_request_timer;533533-534559535560 /* XPC infrastructure referencing and teardown control */536561537562 volatile u8 setup_state; /* infrastructure setup state */538563 wait_queue_head_t teardown_wq; /* kthread waiting to teardown infra */539539- atomic_t references; /* #of references to infrastructure */540540-564564+ atomic_t references; /* #of references to infrastructure */541565542566 /*543567 * NONE OF THE PRECEDING FIELDS OF THIS STRUCTURE WILL BE CLEARED WHEN···544572 * 'nchannels' FIELD MUST BE THE FIRST OF THE FIELDS TO BE CLEARED.)545573 */546574575575+ u8 nchannels; /* #of defined channels supported */576576+ atomic_t nchannels_active; /* #of channels that are not DISCONNECTED */577577+ atomic_t nchannels_engaged; /* #of channels engaged with remote part */578578+ struct xpc_channel *channels; /* array of channel structures */547579548548- u8 nchannels; /* #of defined channels supported */549549- atomic_t nchannels_active; /* #of channels that are not DISCONNECTED */550550- atomic_t nchannels_engaged;/* #of channels engaged with remote part */551551- struct xpc_channel *channels;/* array of channel structures */552552-553553- void *local_GPs_base; /* base address of kmalloc'd space */554554- struct xpc_gp *local_GPs; /* local Get/Put values */555555- void *remote_GPs_base; /* base address of kmalloc'd space */556556- struct xpc_gp *remote_GPs;/* copy of remote partition's local Get/Put */557557- /* values */558558- u64 remote_GPs_pa; /* phys address of remote partition's local */559559- /* Get/Put values */560560-580580+ void *local_GPs_base; /* base address of kmalloc'd space */581581+ struct xpc_gp *local_GPs; /* local Get/Put values */582582+ void *remote_GPs_base; /* base address of kmalloc'd space */583583+ struct xpc_gp *remote_GPs; /* copy of remote partition's local Get/Put */584584+ /* values */585585+ u64 remote_GPs_pa; /* phys address of remote partition's local */586586+ /* Get/Put values */561587562588 /* fields used to pass args when opening or closing a channel */563589564564- void *local_openclose_args_base; /* base address of kmalloc'd space */565565- struct xpc_openclose_args *local_openclose_args; /* local's args */566566- void *remote_openclose_args_base; /* base address of kmalloc'd space */567567- struct xpc_openclose_args *remote_openclose_args; /* copy of remote's */568568- /* args */569569- u64 remote_openclose_args_pa; /* phys addr of remote's args */570570-590590+ void *local_openclose_args_base; /* base address of kmalloc'd space */591591+ struct xpc_openclose_args *local_openclose_args; /* local's args */592592+ void *remote_openclose_args_base; /* base address of kmalloc'd space */593593+ struct xpc_openclose_args *remote_openclose_args; /* copy of remote's */594594+ /* args */595595+ u64 remote_openclose_args_pa; /* phys addr of remote's args */571596572597 /* IPI sending, receiving and handling related fields */573598574574- int remote_IPI_nasid; /* nasid of where to send IPIs */575575- int remote_IPI_phys_cpuid; /* phys CPU ID of where to send IPIs */576576- AMO_t *remote_IPI_amo_va; /* address of remote IPI AMO_t structure */599599+ int remote_IPI_nasid; /* nasid of where to send IPIs */600600+ int remote_IPI_phys_cpuid; /* phys CPU ID of where to send IPIs */601601+ AMO_t *remote_IPI_amo_va; /* address of remote IPI AMO_t structure */577602578578- AMO_t *local_IPI_amo_va; /* address of IPI AMO_t structure */579579- u64 local_IPI_amo; /* IPI amo flags yet to be handled */580580- char IPI_owner[8]; /* IPI owner's name */581581- struct timer_list dropped_IPI_timer; /* dropped IPI timer */603603+ AMO_t *local_IPI_amo_va; /* address of IPI AMO_t structure */604604+ u64 local_IPI_amo; /* IPI amo flags yet to be handled */605605+ char IPI_owner[8]; /* IPI owner's name */606606+ struct timer_list dropped_IPI_timer; /* dropped IPI timer */582607583583- spinlock_t IPI_lock; /* IPI handler lock */584584-608608+ spinlock_t IPI_lock; /* IPI handler lock */585609586610 /* channel manager related fields */587611588612 atomic_t channel_mgr_requests; /* #of requests to activate chan mgr */589589- wait_queue_head_t channel_mgr_wq; /* channel mgr's wait queue */613613+ wait_queue_head_t channel_mgr_wq; /* channel mgr's wait queue */590614591615} ____cacheline_aligned;592592-593616594617/* struct xpc_partition act_state values (for XPC HB) */595618···594627#define XPC_P_ACTIVE 0x03 /* xpc_partition_up() was called */595628#define XPC_P_DEACTIVATING 0x04 /* partition deactivation initiated */596629597597-598630#define XPC_DEACTIVATE_PARTITION(_p, _reason) \599631 xpc_deactivate_partition(__LINE__, (_p), (_reason))600600-601632602633/* struct xpc_partition setup_state values */603634···604639#define XPC_P_WTEARDOWN 0x02 /* waiting to teardown infrastructure */605640#define XPC_P_TORNDOWN 0x03 /* infrastructure is torndown */606641607607-608608-609642/*610643 * struct xpc_partition IPI_timer #of seconds to wait before checking for611644 * dropped IPIs. These occur whenever an IPI amo write doesn't complete until···611648 */612649#define XPC_P_DROPPED_IPI_WAIT (0.25 * HZ)613650614614-615651/* number of seconds to wait for other partitions to disengage */616652#define XPC_DISENGAGE_REQUEST_DEFAULT_TIMELIMIT 90617653618654/* interval in seconds to print 'waiting disengagement' messages */619655#define XPC_DISENGAGE_PRINTMSG_INTERVAL 10620656621621-622657#define XPC_PARTID(_p) ((partid_t) ((_p) - &xpc_partitions[0]))623623-624624-625658626659/* found in xp_main.c */627660extern struct xpc_registration xpc_registrations[];628628-629661630662/* found in xpc_main.c */631663extern struct device *xpc_part;···633675extern void xpc_activate_kthreads(struct xpc_channel *, int);634676extern void xpc_create_kthreads(struct xpc_channel *, int, int);635677extern void xpc_disconnect_wait(int);636636-637678638679/* found in xpc_partition.c */639680extern int xpc_exiting;···653696extern void xpc_discovery(void);654697extern void xpc_check_remote_hb(void);655698extern void xpc_deactivate_partition(const int, struct xpc_partition *,656656- enum xpc_retval);699699+ enum xpc_retval);657700extern enum xpc_retval xpc_initiate_partid_to_nasids(partid_t, void *);658658-659701660702/* found in xpc_channel.c */661703extern void xpc_initiate_connect(int);···670714extern void xpc_connected_callout(struct xpc_channel *);671715extern void xpc_deliver_msg(struct xpc_channel *);672716extern void xpc_disconnect_channel(const int, struct xpc_channel *,673673- enum xpc_retval, unsigned long *);717717+ enum xpc_retval, unsigned long *);674718extern void xpc_disconnect_callout(struct xpc_channel *, enum xpc_retval);675719extern void xpc_partition_going_down(struct xpc_partition *, enum xpc_retval);676720extern void xpc_teardown_infrastructure(struct xpc_partition *);677677-678678-679721680722static inline void681723xpc_wakeup_channel_mgr(struct xpc_partition *part)···682728 wake_up(&part->channel_mgr_wq);683729 }684730}685685-686686-687731688732/*689733 * These next two inlines are used to keep us from tearing down a channel's···704752 }705753}706754707707-708708-709755#define XPC_DISCONNECT_CHANNEL(_ch, _reason, _irqflgs) \710756 xpc_disconnect_channel(__LINE__, _ch, _reason, _irqflgs)711711-712757713758/*714759 * These two inlines are used to keep us from tearing down a partition's···715766xpc_part_deref(struct xpc_partition *part)716767{717768 s32 refs = atomic_dec_return(&part->references);718718-719769720770 DBUG_ON(refs < 0);721771 if (refs == 0 && part->setup_state == XPC_P_WTEARDOWN) {···727779{728780 int setup;729781730730-731782 atomic_inc(&part->references);732783 setup = (part->setup_state == XPC_P_SETUP);733784 if (!setup) {···734787 }735788 return setup;736789}737737-738738-739790740791/*741792 * The following macro is to be used for the setting of the reason and···746801 (_p)->reason_line = _line; \747802 }748803749749-750750-751804/*752805 * This next set of inlines are used to keep track of when a partition is753806 * potentially engaged in accessing memory belonging to another partition.···755812xpc_mark_partition_engaged(struct xpc_partition *part)756813{757814 unsigned long irq_flags;758758- AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa +759759- (XPC_ENGAGED_PARTITIONS_AMO * sizeof(AMO_t)));760760-815815+ AMO_t *amo = (AMO_t *)__va(part->remote_amos_page_pa +816816+ (XPC_ENGAGED_PARTITIONS_AMO *817817+ sizeof(AMO_t)));761818762819 local_irq_save(irq_flags);763820764821 /* set bit corresponding to our partid in remote partition's AMO */765765- FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_OR,766766- (1UL << sn_partition_id));822822+ FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_OR,823823+ (1UL << sn_partition_id));767824 /*768825 * We must always use the nofault function regardless of whether we769826 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we770827 * didn't, we'd never know that the other partition is down and would771828 * keep sending IPIs and AMOs to it until the heartbeat times out.772829 */773773- (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->774774- variable), xp_nofault_PIOR_target));830830+ (void)xp_nofault_PIOR((u64 *)GLOBAL_MMR_ADDR(NASID_GET(&amo->831831+ variable),832832+ xp_nofault_PIOR_target));775833776834 local_irq_restore(irq_flags);777835}···781837xpc_mark_partition_disengaged(struct xpc_partition *part)782838{783839 unsigned long irq_flags;784784- AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa +785785- (XPC_ENGAGED_PARTITIONS_AMO * sizeof(AMO_t)));786786-840840+ AMO_t *amo = (AMO_t *)__va(part->remote_amos_page_pa +841841+ (XPC_ENGAGED_PARTITIONS_AMO *842842+ sizeof(AMO_t)));787843788844 local_irq_save(irq_flags);789845790846 /* clear bit corresponding to our partid in remote partition's AMO */791791- FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND,792792- ~(1UL << sn_partition_id));847847+ FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND,848848+ ~(1UL << sn_partition_id));793849 /*794850 * We must always use the nofault function regardless of whether we795851 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we796852 * didn't, we'd never know that the other partition is down and would797853 * keep sending IPIs and AMOs to it until the heartbeat times out.798854 */799799- (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->800800- variable), xp_nofault_PIOR_target));855855+ (void)xp_nofault_PIOR((u64 *)GLOBAL_MMR_ADDR(NASID_GET(&amo->856856+ variable),857857+ xp_nofault_PIOR_target));801858802859 local_irq_restore(irq_flags);803860}···807862xpc_request_partition_disengage(struct xpc_partition *part)808863{809864 unsigned long irq_flags;810810- AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa +811811- (XPC_DISENGAGE_REQUEST_AMO * sizeof(AMO_t)));812812-865865+ AMO_t *amo = (AMO_t *)__va(part->remote_amos_page_pa +866866+ (XPC_DISENGAGE_REQUEST_AMO * sizeof(AMO_t)));813867814868 local_irq_save(irq_flags);815869816870 /* set bit corresponding to our partid in remote partition's AMO */817817- FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_OR,818818- (1UL << sn_partition_id));871871+ FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_OR,872872+ (1UL << sn_partition_id));819873 /*820874 * We must always use the nofault function regardless of whether we821875 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we822876 * didn't, we'd never know that the other partition is down and would823877 * keep sending IPIs and AMOs to it until the heartbeat times out.824878 */825825- (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->826826- variable), xp_nofault_PIOR_target));879879+ (void)xp_nofault_PIOR((u64 *)GLOBAL_MMR_ADDR(NASID_GET(&amo->880880+ variable),881881+ xp_nofault_PIOR_target));827882828883 local_irq_restore(irq_flags);829884}···832887xpc_cancel_partition_disengage_request(struct xpc_partition *part)833888{834889 unsigned long irq_flags;835835- AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa +836836- (XPC_DISENGAGE_REQUEST_AMO * sizeof(AMO_t)));837837-890890+ AMO_t *amo = (AMO_t *)__va(part->remote_amos_page_pa +891891+ (XPC_DISENGAGE_REQUEST_AMO * sizeof(AMO_t)));838892839893 local_irq_save(irq_flags);840894841895 /* clear bit corresponding to our partid in remote partition's AMO */842842- FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND,843843- ~(1UL << sn_partition_id));896896+ FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND,897897+ ~(1UL << sn_partition_id));844898 /*845899 * We must always use the nofault function regardless of whether we846900 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we847901 * didn't, we'd never know that the other partition is down and would848902 * keep sending IPIs and AMOs to it until the heartbeat times out.849903 */850850- (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->851851- variable), xp_nofault_PIOR_target));904904+ (void)xp_nofault_PIOR((u64 *)GLOBAL_MMR_ADDR(NASID_GET(&amo->905905+ variable),906906+ xp_nofault_PIOR_target));852907853908 local_irq_restore(irq_flags);854909}···858913{859914 AMO_t *amo = xpc_vars->amos_page + XPC_ENGAGED_PARTITIONS_AMO;860915861861-862916 /* return our partition's AMO variable ANDed with partid_mask */863863- return (FETCHOP_LOAD_OP(TO_AMO((u64) &amo->variable), FETCHOP_LOAD) &864864- partid_mask);917917+ return (FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_LOAD) &918918+ partid_mask);865919}866920867921static inline u64···868924{869925 AMO_t *amo = xpc_vars->amos_page + XPC_DISENGAGE_REQUEST_AMO;870926871871-872927 /* return our partition's AMO variable ANDed with partid_mask */873873- return (FETCHOP_LOAD_OP(TO_AMO((u64) &amo->variable), FETCHOP_LOAD) &874874- partid_mask);928928+ return (FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_LOAD) &929929+ partid_mask);875930}876931877932static inline void···878935{879936 AMO_t *amo = xpc_vars->amos_page + XPC_ENGAGED_PARTITIONS_AMO;880937881881-882938 /* clear bit(s) based on partid_mask in our partition's AMO */883883- FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND,884884- ~partid_mask);939939+ FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND,940940+ ~partid_mask);885941}886942887943static inline void···888946{889947 AMO_t *amo = xpc_vars->amos_page + XPC_DISENGAGE_REQUEST_AMO;890948891891-892949 /* clear bit(s) based on partid_mask in our partition's AMO */893893- FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND,894894- ~partid_mask);950950+ FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_AND,951951+ ~partid_mask);895952}896896-897897-898953899954/*900955 * The following set of macros and inlines are used for the sending and···903964static inline u64904965xpc_IPI_receive(AMO_t *amo)905966{906906- return FETCHOP_LOAD_OP(TO_AMO((u64) &amo->variable), FETCHOP_CLEAR);967967+ return FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_CLEAR);907968}908908-909969910970static inline enum xpc_retval911971xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector)···912974 int ret = 0;913975 unsigned long irq_flags;914976915915-916977 local_irq_save(irq_flags);917978918918- FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_OR, flag);979979+ FETCHOP_STORE_OP(TO_AMO((u64)&amo->variable), FETCHOP_OR, flag);919980 sn_send_IPI_phys(nasid, phys_cpuid, vector, 0);920981921982 /*···923986 * didn't, we'd never know that the other partition is down and would924987 * keep sending IPIs and AMOs to it until the heartbeat times out.925988 */926926- ret = xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->variable),927927- xp_nofault_PIOR_target));989989+ ret = xp_nofault_PIOR((u64 *)GLOBAL_MMR_ADDR(NASID_GET(&amo->variable),990990+ xp_nofault_PIOR_target));928991929992 local_irq_restore(irq_flags);930993931994 return ((ret == 0) ? xpcSuccess : xpcPioReadError);932995}933933-934996935997/*936998 * IPIs associated with SGI_XPC_ACTIVATE IRQ.···9401004 */9411005static inline void9421006xpc_activate_IRQ_send(u64 amos_page_pa, int from_nasid, int to_nasid,943943- int to_phys_cpuid)10071007+ int to_phys_cpuid)9441008{9451009 int w_index = XPC_NASID_W_INDEX(from_nasid);9461010 int b_index = XPC_NASID_B_INDEX(from_nasid);947947- AMO_t *amos = (AMO_t *) __va(amos_page_pa +948948- (XPC_ACTIVATE_IRQ_AMOS * sizeof(AMO_t)));10111011+ AMO_t *amos = (AMO_t *)__va(amos_page_pa +10121012+ (XPC_ACTIVATE_IRQ_AMOS * sizeof(AMO_t)));9491013950950-951951- (void) xpc_IPI_send(&amos[w_index], (1UL << b_index), to_nasid,952952- to_phys_cpuid, SGI_XPC_ACTIVATE);10141014+ (void)xpc_IPI_send(&amos[w_index], (1UL << b_index), to_nasid,10151015+ to_phys_cpuid, SGI_XPC_ACTIVATE);9531016}95410179551018static inline void9561019xpc_IPI_send_activate(struct xpc_vars *vars)9571020{9581021 xpc_activate_IRQ_send(vars->amos_page_pa, cnodeid_to_nasid(0),959959- vars->act_nasid, vars->act_phys_cpuid);10221022+ vars->act_nasid, vars->act_phys_cpuid);9601023}96110249621025static inline void9631026xpc_IPI_send_activated(struct xpc_partition *part)9641027{9651028 xpc_activate_IRQ_send(part->remote_amos_page_pa, cnodeid_to_nasid(0),966966- part->remote_act_nasid, part->remote_act_phys_cpuid);10291029+ part->remote_act_nasid,10301030+ part->remote_act_phys_cpuid);9671031}96810329691033static inline void9701034xpc_IPI_send_reactivate(struct xpc_partition *part)9711035{9721036 xpc_activate_IRQ_send(xpc_vars->amos_page_pa, part->reactivate_nasid,973973- xpc_vars->act_nasid, xpc_vars->act_phys_cpuid);10371037+ xpc_vars->act_nasid, xpc_vars->act_phys_cpuid);9741038}97510399761040static inline void9771041xpc_IPI_send_disengage(struct xpc_partition *part)9781042{9791043 xpc_activate_IRQ_send(part->remote_amos_page_pa, cnodeid_to_nasid(0),980980- part->remote_act_nasid, part->remote_act_phys_cpuid);10441044+ part->remote_act_nasid,10451045+ part->remote_act_phys_cpuid);9811046}982982-98310479841048/*9851049 * IPIs associated with SGI_XPC_NOTIFY IRQ.···99410589951059static inline void9961060xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string,997997- unsigned long *irq_flags)10611061+ unsigned long *irq_flags)9981062{9991063 struct xpc_partition *part = &xpc_partitions[ch->partid];10001064 enum xpc_retval ret;1001106510021002-10031066 if (likely(part->act_state != XPC_P_DEACTIVATING)) {10041067 ret = xpc_IPI_send(part->remote_IPI_amo_va,10051005- (u64) ipi_flag << (ch->number * 8),10061006- part->remote_IPI_nasid,10071007- part->remote_IPI_phys_cpuid,10081008- SGI_XPC_NOTIFY);10681068+ (u64)ipi_flag << (ch->number * 8),10691069+ part->remote_IPI_nasid,10701070+ part->remote_IPI_phys_cpuid, SGI_XPC_NOTIFY);10091071 dev_dbg(xpc_chan, "%s sent to partid=%d, channel=%d, ret=%d\n",10101072 ipi_flag_string, ch->partid, ch->number, ret);10111073 if (unlikely(ret != xpcSuccess)) {···10181084 }10191085}1020108610211021-10221087/*10231088 * Make it look like the remote partition, which is associated with the10241089 * specified channel, sent us an IPI. This faked IPI will be handled···1028109510291096static inline void10301097xpc_notify_IRQ_send_local(struct xpc_channel *ch, u8 ipi_flag,10311031- char *ipi_flag_string)10981098+ char *ipi_flag_string)10321099{10331100 struct xpc_partition *part = &xpc_partitions[ch->partid];1034110110351035-10361036- FETCHOP_STORE_OP(TO_AMO((u64) &part->local_IPI_amo_va->variable),10371037- FETCHOP_OR, ((u64) ipi_flag << (ch->number * 8)));11021102+ FETCHOP_STORE_OP(TO_AMO((u64)&part->local_IPI_amo_va->variable),11031103+ FETCHOP_OR, ((u64)ipi_flag << (ch->number * 8)));10381104 dev_dbg(xpc_chan, "%s sent local from partid=%d, channel=%d\n",10391105 ipi_flag_string, ch->partid, ch->number);10401106}10411041-1042110710431108/*10441109 * The sending and receiving of IPIs includes the setting of an AMO variable···10521121#define XPC_IPI_OPENREPLY 0x0810531122#define XPC_IPI_MSGREQUEST 0x101054112310551055-10561124/* given an AMO variable and a channel#, get its associated IPI flags */10571125#define XPC_GET_IPI_FLAGS(_amo, _c) ((u8) (((_amo) >> ((_c) * 8)) & 0xff))10581126#define XPC_SET_IPI_FLAGS(_amo, _c, _f) (_amo) |= ((u64) (_f) << ((_c) * 8))···10591129#define XPC_ANY_OPENCLOSE_IPI_FLAGS_SET(_amo) ((_amo) & __IA64_UL_CONST(0x0f0f0f0f0f0f0f0f))10601130#define XPC_ANY_MSG_IPI_FLAGS_SET(_amo) ((_amo) & __IA64_UL_CONST(0x1010101010101010))1061113110621062-10631132static inline void10641133xpc_IPI_send_closerequest(struct xpc_channel *ch, unsigned long *irq_flags)10651134{10661135 struct xpc_openclose_args *args = ch->local_openclose_args;10671067-1068113610691137 args->reason = ch->reason;10701138···10801152{10811153 struct xpc_openclose_args *args = ch->local_openclose_args;1082115410831083-10841155 args->msg_size = ch->msg_size;10851156 args->local_nentries = ch->local_nentries;10861157···10901163xpc_IPI_send_openreply(struct xpc_channel *ch, unsigned long *irq_flags)10911164{10921165 struct xpc_openclose_args *args = ch->local_openclose_args;10931093-1094116610951167 args->remote_nentries = ch->remote_nentries;10961168 args->local_nentries = ch->local_nentries;···11101184 XPC_NOTIFY_IRQ_SEND_LOCAL(ch, XPC_IPI_MSGREQUEST);11111185}1112118611131113-11141187/*11151188 * Memory for XPC's AMO variables is allocated by the MSPEC driver. These11161189 * pages are located in the lowest granule. The lowest granule uses 4k pages···11261201{11271202 AMO_t *amo = xpc_vars->amos_page + index;1128120311291129-11301130- (void) xpc_IPI_receive(amo); /* clear AMO variable */12041204+ (void)xpc_IPI_receive(amo); /* clear AMO variable */11311205 return amo;11321206}11331133-11341134-1135120711361208static inline enum xpc_retval11371209xpc_map_bte_errors(bte_result_t error)···11421220 return xpcBteUnmappedError;11431221 }11441222 switch (error) {11451145- case BTE_SUCCESS: return xpcSuccess;11461146- case BTEFAIL_DIR: return xpcBteDirectoryError;11471147- case BTEFAIL_POISON: return xpcBtePoisonError;11481148- case BTEFAIL_WERR: return xpcBteWriteError;11491149- case BTEFAIL_ACCESS: return xpcBteAccessError;11501150- case BTEFAIL_PWERR: return xpcBtePWriteError;11511151- case BTEFAIL_PRERR: return xpcBtePReadError;11521152- case BTEFAIL_TOUT: return xpcBteTimeOutError;11531153- case BTEFAIL_XTERR: return xpcBteXtalkError;11541154- case BTEFAIL_NOTAVAIL: return xpcBteNotAvailable;11551155- default: return xpcBteUnmappedError;12231223+ case BTE_SUCCESS:12241224+ return xpcSuccess;12251225+ case BTEFAIL_DIR:12261226+ return xpcBteDirectoryError;12271227+ case BTEFAIL_POISON:12281228+ return xpcBtePoisonError;12291229+ case BTEFAIL_WERR:12301230+ return xpcBteWriteError;12311231+ case BTEFAIL_ACCESS:12321232+ return xpcBteAccessError;12331233+ case BTEFAIL_PWERR:12341234+ return xpcBtePWriteError;12351235+ case BTEFAIL_PRERR:12361236+ return xpcBtePReadError;12371237+ case BTEFAIL_TOUT:12381238+ return xpcBteTimeOutError;12391239+ case BTEFAIL_XTERR:12401240+ return xpcBteXtalkError;12411241+ case BTEFAIL_NOTAVAIL:12421242+ return xpcBteNotAvailable;12431243+ default:12441244+ return xpcBteUnmappedError;11561245 }11571246}11581158-11591159-1160124711611248/*11621249 * Check to see if there is any channel activity to/from the specified···11761245{11771246 u64 IPI_amo;11781247 unsigned long irq_flags;11791179-1180124811811249 IPI_amo = xpc_IPI_receive(part->local_IPI_amo_va);11821250 if (IPI_amo == 0) {···11921262 xpc_wakeup_channel_mgr(part);11931263}1194126411951195-11961265#endif /* _DRIVERS_MISC_SGIXP_XPC_H */11971197-
+138-190
drivers/misc/sgi-xp/xpc_partition.c
···66 * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved.77 */8899-109/*1110 * Cross Partition Communication (XPC) partition support.1211 *···1415 * heartbeats of other partitions.1516 *1617 */1717-18181919#include <linux/kernel.h>2020#include <linux/sysctl.h>···2830#include <asm/sn/addrs.h>2931#include "xpc.h"30323131-3233/* XPC is exiting flag */3334int xpc_exiting;3434-35353636/* SH_IPI_ACCESS shub register value on startup */3737static u64 xpc_sh1_IPI_access;···3842static u64 xpc_sh2_IPI_access2;3943static u64 xpc_sh2_IPI_access3;40444141-4245/* original protection values for each node */4346u64 xpc_prot_vec[MAX_NUMNODES];4444-45474648/* this partition's reserved page pointers */4749struct xpc_rsvd_page *xpc_rsvd_page;···5157static int xp_nasid_mask_bytes; /* actual size in bytes of nasid mask */5258static int xp_nasid_mask_words; /* actual size in words of nasid mask */53595454-5560/*5661 * For performance reasons, each entry of xpc_partitions[] is cacheline5762 * aligned. And xpc_partitions[] is padded with an additional entry at the···5966 */6067struct xpc_partition xpc_partitions[XP_MAX_PARTITIONS + 1];61686262-6369/*6470 * Generic buffer used to store a local copy of portions of a remote6571 * partition's reserved page (either its header and part_nasids mask,···6674 */6775char *xpc_remote_copy_buffer;6876void *xpc_remote_copy_buffer_base;6969-70777178/*7279 * Guarantee that the kmalloc'd memory is cacheline aligned.···7887 if (*base == NULL) {7988 return NULL;8089 }8181- if ((u64) *base == L1_CACHE_ALIGN((u64) *base)) {9090+ if ((u64)*base == L1_CACHE_ALIGN((u64)*base)) {8291 return *base;8392 }8493 kfree(*base);···8897 if (*base == NULL) {8998 return NULL;9099 }9191- return (void *) L1_CACHE_ALIGN((u64) *base);100100+ return (void *)L1_CACHE_ALIGN((u64)*base);92101}9393-9410295103/*96104 * Given a nasid, get the physical address of the partition's reserved page···107117 u64 buf_len = 0;108118 void *buf_base = NULL;109119110110-111120 while (1) {112121113122 status = sn_partition_reserved_page_pa(buf, &cookie, &rp_pa,114114- &len);123123+ &len);115124116125 dev_dbg(xpc_part, "SAL returned with status=%li, cookie="117126 "0x%016lx, address=0x%016lx, len=0x%016lx\n",···123134 if (L1_CACHE_ALIGN(len) > buf_len) {124135 kfree(buf_base);125136 buf_len = L1_CACHE_ALIGN(len);126126- buf = (u64) xpc_kmalloc_cacheline_aligned(buf_len,127127- GFP_KERNEL, &buf_base);137137+ buf = (u64)xpc_kmalloc_cacheline_aligned(buf_len,138138+ GFP_KERNEL,139139+ &buf_base);128140 if (buf_base == NULL) {129141 dev_err(xpc_part, "unable to kmalloc "130142 "len=0x%016lx\n", buf_len);···135145 }136146137147 bte_res = xp_bte_copy(rp_pa, buf, buf_len,138138- (BTE_NOTIFY | BTE_WACQUIRE), NULL);148148+ (BTE_NOTIFY | BTE_WACQUIRE), NULL);139149 if (bte_res != BTE_SUCCESS) {140150 dev_dbg(xpc_part, "xp_bte_copy failed %i\n", bte_res);141151 status = SALRET_ERROR;···152162 return rp_pa;153163}154164155155-156165/*157166 * Fill the partition reserved page with the information needed by158167 * other partitions to discover we are alive and establish initial···165176 u64 rp_pa, nasid_array = 0;166177 int i, ret;167178168168-169179 /* get the local reserved page's address */170180171181 preempt_disable();···174186 dev_err(xpc_part, "SAL failed to locate the reserved page\n");175187 return NULL;176188 }177177- rp = (struct xpc_rsvd_page *) __va(rp_pa);189189+ rp = (struct xpc_rsvd_page *)__va(rp_pa);178190179191 if (rp->partid != sn_partition_id) {180192 dev_err(xpc_part, "the reserved page's partid of %d should be "···211223 * memory protections are never restricted.212224 */213225 if ((amos_page = xpc_vars->amos_page) == NULL) {214214- amos_page = (AMO_t *) TO_AMO(uncached_alloc_page(0));226226+ amos_page = (AMO_t *)TO_AMO(uncached_alloc_page(0));215227 if (amos_page == NULL) {216228 dev_err(xpc_part, "can't allocate page of AMOs\n");217229 return NULL;···222234 * when xpc_allow_IPI_ops() is called via xpc_hb_init().223235 */224236 if (!enable_shub_wars_1_1()) {225225- ret = sn_change_memprotect(ia64_tpa((u64) amos_page),226226- PAGE_SIZE, SN_MEMPROT_ACCESS_CLASS_1,227227- &nasid_array);237237+ ret = sn_change_memprotect(ia64_tpa((u64)amos_page),238238+ PAGE_SIZE,239239+ SN_MEMPROT_ACCESS_CLASS_1,240240+ &nasid_array);228241 if (ret != 0) {229242 dev_err(xpc_part, "can't change memory "230243 "protections\n");231244 uncached_free_page(__IA64_UNCACHED_OFFSET |232232- TO_PHYS((u64) amos_page));245245+ TO_PHYS((u64)amos_page));233246 return NULL;234247 }235248 }236236- } else if (!IS_AMO_ADDRESS((u64) amos_page)) {249249+ } else if (!IS_AMO_ADDRESS((u64)amos_page)) {237250 /*238251 * EFI's XPBOOT can also set amos_page in the reserved page,239252 * but it happens to leave it as an uncached physical address240253 * and we need it to be an uncached virtual, so we'll have to241254 * convert it.242255 */243243- if (!IS_AMO_PHYS_ADDRESS((u64) amos_page)) {256256+ if (!IS_AMO_PHYS_ADDRESS((u64)amos_page)) {244257 dev_err(xpc_part, "previously used amos_page address "245245- "is bad = 0x%p\n", (void *) amos_page);258258+ "is bad = 0x%p\n", (void *)amos_page);246259 return NULL;247260 }248248- amos_page = (AMO_t *) TO_AMO((u64) amos_page);261261+ amos_page = (AMO_t *)TO_AMO((u64)amos_page);249262 }250263251264 /* clear xpc_vars */···256267 xpc_vars->act_nasid = cpuid_to_nasid(0);257268 xpc_vars->act_phys_cpuid = cpu_physical_id(0);258269 xpc_vars->vars_part_pa = __pa(xpc_vars_part);259259- xpc_vars->amos_page_pa = ia64_tpa((u64) amos_page);260260- xpc_vars->amos_page = amos_page; /* save for next load of XPC */261261-270270+ xpc_vars->amos_page_pa = ia64_tpa((u64)amos_page);271271+ xpc_vars->amos_page = amos_page; /* save for next load of XPC */262272263273 /* clear xpc_vars_part */264264- memset((u64 *) xpc_vars_part, 0, sizeof(struct xpc_vars_part) *265265- XP_MAX_PARTITIONS);274274+ memset((u64 *)xpc_vars_part, 0, sizeof(struct xpc_vars_part) *275275+ XP_MAX_PARTITIONS);266276267277 /* initialize the activate IRQ related AMO variables */268278 for (i = 0; i < xp_nasid_mask_words; i++) {269269- (void) xpc_IPI_init(XPC_ACTIVATE_IRQ_AMOS + i);279279+ (void)xpc_IPI_init(XPC_ACTIVATE_IRQ_AMOS + i);270280 }271281272282 /* initialize the engaged remote partitions related AMO variables */273273- (void) xpc_IPI_init(XPC_ENGAGED_PARTITIONS_AMO);274274- (void) xpc_IPI_init(XPC_DISENGAGE_REQUEST_AMO);283283+ (void)xpc_IPI_init(XPC_ENGAGED_PARTITIONS_AMO);284284+ (void)xpc_IPI_init(XPC_DISENGAGE_REQUEST_AMO);275285276286 /* timestamp of when reserved page was setup by XPC */277287 rp->stamp = CURRENT_TIME;···284296 return rp;285297}286298287287-288299/*289300 * Change protections to allow IPI operations (and AMO operations on290301 * Shub 1.1 systems).···294307 int node;295308 int nasid;296309297297-298310 // >>> Change SH_IPI_ACCESS code to use SAL call once it is available.299311300312 if (is_shub2()) {301313 xpc_sh2_IPI_access0 =302302- (u64) HUB_L((u64 *) LOCAL_MMR_ADDR(SH2_IPI_ACCESS0));314314+ (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS0));303315 xpc_sh2_IPI_access1 =304304- (u64) HUB_L((u64 *) LOCAL_MMR_ADDR(SH2_IPI_ACCESS1));316316+ (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS1));305317 xpc_sh2_IPI_access2 =306306- (u64) HUB_L((u64 *) LOCAL_MMR_ADDR(SH2_IPI_ACCESS2));318318+ (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS2));307319 xpc_sh2_IPI_access3 =308308- (u64) HUB_L((u64 *) LOCAL_MMR_ADDR(SH2_IPI_ACCESS3));320320+ (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH2_IPI_ACCESS3));309321310322 for_each_online_node(node) {311323 nasid = cnodeid_to_nasid(node);312312- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS0),313313- -1UL);314314- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS1),315315- -1UL);316316- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS2),317317- -1UL);318318- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS3),319319- -1UL);324324+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS0),325325+ -1UL);326326+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS1),327327+ -1UL);328328+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS2),329329+ -1UL);330330+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS3),331331+ -1UL);320332 }321333322334 } else {323335 xpc_sh1_IPI_access =324324- (u64) HUB_L((u64 *) LOCAL_MMR_ADDR(SH1_IPI_ACCESS));336336+ (u64)HUB_L((u64 *)LOCAL_MMR_ADDR(SH1_IPI_ACCESS));325337326338 for_each_online_node(node) {327339 nasid = cnodeid_to_nasid(node);328328- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS),329329- -1UL);340340+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS),341341+ -1UL);330342331343 /*332344 * Since the BIST collides with memory operations on···333347 */334348 if (enable_shub_wars_1_1()) {335349 /* open up everything */336336- xpc_prot_vec[node] = (u64) HUB_L((u64 *)337337- GLOBAL_MMR_ADDR(nasid,338338- SH1_MD_DQLP_MMR_DIR_PRIVEC0));339339- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid,340340- SH1_MD_DQLP_MMR_DIR_PRIVEC0),341341- -1UL);342342- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid,343343- SH1_MD_DQRP_MMR_DIR_PRIVEC0),344344- -1UL);350350+ xpc_prot_vec[node] = (u64)HUB_L((u64 *)351351+ GLOBAL_MMR_ADDR352352+ (nasid,353353+ SH1_MD_DQLP_MMR_DIR_PRIVEC0));354354+ HUB_S((u64 *)355355+ GLOBAL_MMR_ADDR(nasid,356356+ SH1_MD_DQLP_MMR_DIR_PRIVEC0),357357+ -1UL);358358+ HUB_S((u64 *)359359+ GLOBAL_MMR_ADDR(nasid,360360+ SH1_MD_DQRP_MMR_DIR_PRIVEC0),361361+ -1UL);345362 }346363 }347364 }348365}349349-350366351367/*352368 * Restrict protections to disallow IPI operations (and AMO operations on···360372 int node;361373 int nasid;362374363363-364375 // >>> Change SH_IPI_ACCESS code to use SAL call once it is available.365376366377 if (is_shub2()) {367378368379 for_each_online_node(node) {369380 nasid = cnodeid_to_nasid(node);370370- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS0),371371- xpc_sh2_IPI_access0);372372- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS1),373373- xpc_sh2_IPI_access1);374374- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS2),375375- xpc_sh2_IPI_access2);376376- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS3),377377- xpc_sh2_IPI_access3);381381+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS0),382382+ xpc_sh2_IPI_access0);383383+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS1),384384+ xpc_sh2_IPI_access1);385385+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS2),386386+ xpc_sh2_IPI_access2);387387+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS3),388388+ xpc_sh2_IPI_access3);378389 }379390380391 } else {381392382393 for_each_online_node(node) {383394 nasid = cnodeid_to_nasid(node);384384- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS),385385- xpc_sh1_IPI_access);395395+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS),396396+ xpc_sh1_IPI_access);386397387398 if (enable_shub_wars_1_1()) {388388- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid,389389- SH1_MD_DQLP_MMR_DIR_PRIVEC0),390390- xpc_prot_vec[node]);391391- HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid,392392- SH1_MD_DQRP_MMR_DIR_PRIVEC0),393393- xpc_prot_vec[node]);399399+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid,400400+ SH1_MD_DQLP_MMR_DIR_PRIVEC0),401401+ xpc_prot_vec[node]);402402+ HUB_S((u64 *)GLOBAL_MMR_ADDR(nasid,403403+ SH1_MD_DQRP_MMR_DIR_PRIVEC0),404404+ xpc_prot_vec[node]);394405 }395406 }396407 }397408}398398-399409400410/*401411 * At periodic intervals, scan through all active partitions and ensure···407421 partid_t partid;408422 bte_result_t bres;409423410410-411411- remote_vars = (struct xpc_vars *) xpc_remote_copy_buffer;424424+ remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer;412425413426 for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {414427···422437 part = &xpc_partitions[partid];423438424439 if (part->act_state == XPC_P_INACTIVE ||425425- part->act_state == XPC_P_DEACTIVATING) {440440+ part->act_state == XPC_P_DEACTIVATING) {426441 continue;427442 }428443429444 /* pull the remote_hb cache line */430445 bres = xp_bte_copy(part->remote_vars_pa,431431- (u64) remote_vars,432432- XPC_RP_VARS_SIZE,433433- (BTE_NOTIFY | BTE_WACQUIRE), NULL);446446+ (u64)remote_vars,447447+ XPC_RP_VARS_SIZE,448448+ (BTE_NOTIFY | BTE_WACQUIRE), NULL);434449 if (bres != BTE_SUCCESS) {435450 XPC_DEACTIVATE_PARTITION(part,436436- xpc_map_bte_errors(bres));451451+ xpc_map_bte_errors(bres));437452 continue;438453 }439454···444459 remote_vars->heartbeating_to_mask);445460446461 if (((remote_vars->heartbeat == part->last_heartbeat) &&447447- (remote_vars->heartbeat_offline == 0)) ||448448- !xpc_hb_allowed(sn_partition_id, remote_vars)) {462462+ (remote_vars->heartbeat_offline == 0)) ||463463+ !xpc_hb_allowed(sn_partition_id, remote_vars)) {449464450465 XPC_DEACTIVATE_PARTITION(part, xpcNoHeartbeat);451466 continue;···454469 part->last_heartbeat = remote_vars->heartbeat;455470 }456471}457457-458472459473/*460474 * Get a copy of a portion of the remote partition's rsvd page.···464480 */465481static enum xpc_retval466482xpc_get_remote_rp(int nasid, u64 *discovered_nasids,467467- struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa)483483+ struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa)468484{469485 int bres, i;470470-471486472487 /* get the reserved page's physical address */473488···475492 return xpcNoRsvdPageAddr;476493 }477494478478-479495 /* pull over the reserved page header and part_nasids mask */480480- bres = xp_bte_copy(*remote_rp_pa, (u64) remote_rp,481481- XPC_RP_HEADER_SIZE + xp_nasid_mask_bytes,482482- (BTE_NOTIFY | BTE_WACQUIRE), NULL);496496+ bres = xp_bte_copy(*remote_rp_pa, (u64)remote_rp,497497+ XPC_RP_HEADER_SIZE + xp_nasid_mask_bytes,498498+ (BTE_NOTIFY | BTE_WACQUIRE), NULL);483499 if (bres != BTE_SUCCESS) {484500 return xpc_map_bte_errors(bres);485501 }486502487487-488503 if (discovered_nasids != NULL) {489504 u64 *remote_part_nasids = XPC_RP_PART_NASIDS(remote_rp);490490-491505492506 for (i = 0; i < xp_nasid_mask_words; i++) {493507 discovered_nasids[i] |= remote_part_nasids[i];494508 }495509 }496510497497-498511 /* check that the partid is for another partition */499512500513 if (remote_rp->partid < 1 ||501501- remote_rp->partid > (XP_MAX_PARTITIONS - 1)) {514514+ remote_rp->partid > (XP_MAX_PARTITIONS - 1)) {502515 return xpcInvalidPartid;503516 }504517···502523 return xpcLocalPartid;503524 }504525505505-506526 if (XPC_VERSION_MAJOR(remote_rp->version) !=507507- XPC_VERSION_MAJOR(XPC_RP_VERSION)) {527527+ XPC_VERSION_MAJOR(XPC_RP_VERSION)) {508528 return xpcBadVersion;509529 }510530511531 return xpcSuccess;512532}513513-514533515534/*516535 * Get a copy of the remote partition's XPC variables from the reserved page.···521544{522545 int bres;523546524524-525547 if (remote_vars_pa == 0) {526548 return xpcVarsNotSet;527549 }528550529551 /* pull over the cross partition variables */530530- bres = xp_bte_copy(remote_vars_pa, (u64) remote_vars, XPC_RP_VARS_SIZE,531531- (BTE_NOTIFY | BTE_WACQUIRE), NULL);552552+ bres = xp_bte_copy(remote_vars_pa, (u64)remote_vars, XPC_RP_VARS_SIZE,553553+ (BTE_NOTIFY | BTE_WACQUIRE), NULL);532554 if (bres != BTE_SUCCESS) {533555 return xpc_map_bte_errors(bres);534556 }535557536558 if (XPC_VERSION_MAJOR(remote_vars->version) !=537537- XPC_VERSION_MAJOR(XPC_V_VERSION)) {559559+ XPC_VERSION_MAJOR(XPC_V_VERSION)) {538560 return xpcBadVersion;539561 }540562541563 return xpcSuccess;542564}543565544544-545566/*546567 * Update the remote partition's info.547568 */548569static void549570xpc_update_partition_info(struct xpc_partition *part, u8 remote_rp_version,550550- struct timespec *remote_rp_stamp, u64 remote_rp_pa,551551- u64 remote_vars_pa, struct xpc_vars *remote_vars)571571+ struct timespec *remote_rp_stamp, u64 remote_rp_pa,572572+ u64 remote_vars_pa, struct xpc_vars *remote_vars)552573{553574 part->remote_rp_version = remote_rp_version;554575 dev_dbg(xpc_part, " remote_rp_version = 0x%016x\n",···588613 part->remote_vars_version);589614}590615591591-592616/*593617 * Prior code has determined the nasid which generated an IPI. Inspect594618 * that nasid to determine if its partition needs to be activated or···617643 struct xpc_partition *part;618644 enum xpc_retval ret;619645620620-621646 /* pull over the reserved page structure */622647623623- remote_rp = (struct xpc_rsvd_page *) xpc_remote_copy_buffer;648648+ remote_rp = (struct xpc_rsvd_page *)xpc_remote_copy_buffer;624649625650 ret = xpc_get_remote_rp(nasid, NULL, remote_rp, &remote_rp_pa);626651 if (ret != xpcSuccess) {627652 dev_warn(xpc_part, "unable to get reserved page from nasid %d, "628628- "which sent interrupt, reason=%d\n", nasid, ret);653653+ "which sent interrupt, reason=%d\n", nasid, ret);629654 return;630655 }631656···636663 partid = remote_rp->partid;637664 part = &xpc_partitions[partid];638665639639-640666 /* pull over the cross partition variables */641667642642- remote_vars = (struct xpc_vars *) xpc_remote_copy_buffer;668668+ remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer;643669644670 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars);645671 if (ret != xpcSuccess) {646672647673 dev_warn(xpc_part, "unable to get XPC variables from nasid %d, "648648- "which sent interrupt, reason=%d\n", nasid, ret);674674+ "which sent interrupt, reason=%d\n", nasid, ret);649675650676 XPC_DEACTIVATE_PARTITION(part, ret);651677 return;652678 }653679654654-655680 part->act_IRQ_rcvd++;656681657682 dev_dbg(xpc_part, "partid for nasid %d is %d; IRQs = %d; HB = "658658- "%ld:0x%lx\n", (int) nasid, (int) partid, part->act_IRQ_rcvd,683683+ "%ld:0x%lx\n", (int)nasid, (int)partid, part->act_IRQ_rcvd,659684 remote_vars->heartbeat, remote_vars->heartbeating_to_mask);660685661661- if (xpc_partition_disengaged(part) &&662662- part->act_state == XPC_P_INACTIVE) {686686+ if (xpc_partition_disengaged(part) && part->act_state == XPC_P_INACTIVE) {663687664688 xpc_update_partition_info(part, remote_rp_version,665665- &remote_rp_stamp, remote_rp_pa,666666- remote_vars_pa, remote_vars);689689+ &remote_rp_stamp, remote_rp_pa,690690+ remote_vars_pa, remote_vars);667691668692 if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)) {669693 if (xpc_partition_disengage_requested(1UL << partid)) {···684714685715 if (!XPC_SUPPORTS_RP_STAMP(part->remote_rp_version)) {686716 DBUG_ON(XPC_SUPPORTS_DISENGAGE_REQUEST(part->687687- remote_vars_version));717717+ remote_vars_version));688718689719 if (!XPC_SUPPORTS_RP_STAMP(remote_rp_version)) {690720 DBUG_ON(XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars->691691- version));721721+ version));692722 /* see if the other side rebooted */693723 if (part->remote_amos_page_pa ==694694- remote_vars->amos_page_pa &&695695- xpc_hb_allowed(sn_partition_id,696696- remote_vars)) {724724+ remote_vars->amos_page_pa &&725725+ xpc_hb_allowed(sn_partition_id, remote_vars)) {697726 /* doesn't look that way, so ignore the IPI */698727 return;699728 }···704735 */705736706737 xpc_update_partition_info(part, remote_rp_version,707707- &remote_rp_stamp, remote_rp_pa,708708- remote_vars_pa, remote_vars);738738+ &remote_rp_stamp, remote_rp_pa,739739+ remote_vars_pa, remote_vars);709740 part->reactivate_nasid = nasid;710741 XPC_DEACTIVATE_PARTITION(part, xpcReactivating);711742 return;···725756 xpc_clear_partition_disengage_request(1UL << partid);726757727758 xpc_update_partition_info(part, remote_rp_version,728728- &remote_rp_stamp, remote_rp_pa,729729- remote_vars_pa, remote_vars);759759+ &remote_rp_stamp, remote_rp_pa,760760+ remote_vars_pa, remote_vars);730761 reactivate = 1;731762732763 } else {733764 DBUG_ON(!XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars->version));734765735766 stamp_diff = xpc_compare_stamps(&part->remote_rp_stamp,736736- &remote_rp_stamp);767767+ &remote_rp_stamp);737768 if (stamp_diff != 0) {738769 DBUG_ON(stamp_diff >= 0);739770···744775745776 DBUG_ON(xpc_partition_engaged(1UL << partid));746777 DBUG_ON(xpc_partition_disengage_requested(1UL <<747747- partid));778778+ partid));748779749780 xpc_update_partition_info(part, remote_rp_version,750750- &remote_rp_stamp, remote_rp_pa,751751- remote_vars_pa, remote_vars);781781+ &remote_rp_stamp,782782+ remote_rp_pa, remote_vars_pa,783783+ remote_vars);752784 reactivate = 1;753785 }754786 }755787756788 if (part->disengage_request_timeout > 0 &&757757- !xpc_partition_disengaged(part)) {789789+ !xpc_partition_disengaged(part)) {758790 /* still waiting on other side to disengage from us */759791 return;760792 }···765795 XPC_DEACTIVATE_PARTITION(part, xpcReactivating);766796767797 } else if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version) &&768768- xpc_partition_disengage_requested(1UL << partid)) {798798+ xpc_partition_disengage_requested(1UL << partid)) {769799 XPC_DEACTIVATE_PARTITION(part, xpcOtherGoingDown);770800 }771801}772772-773802774803/*775804 * Loop through the activation AMO variables and process any bits···782813{783814 int word, bit;784815 u64 nasid_mask;785785- u64 nasid; /* remote nasid */816816+ u64 nasid; /* remote nasid */786817 int n_IRQs_detected = 0;787818 AMO_t *act_amos;788819789789-790820 act_amos = xpc_vars->amos_page + XPC_ACTIVATE_IRQ_AMOS;791791-792821793822 /* scan through act AMO variable looking for non-zero entries */794823 for (word = 0; word < xp_nasid_mask_words; word++) {···804837 dev_dbg(xpc_part, "AMO[%d] gave back 0x%lx\n", word,805838 nasid_mask);806839807807-808840 /*809841 * If this nasid has been added to the machine since810842 * our partition was reset, this will retain the···811845 * This is used in the event of module reload.812846 */813847 xpc_mach_nasids[word] |= nasid_mask;814814-815848816849 /* locate the nasid(s) which sent interrupts */817850···827862 return n_IRQs_detected;828863}829864830830-831865/*832866 * See if the other side has responded to a partition disengage request833867 * from us.···836872{837873 partid_t partid = XPC_PARTID(part);838874 int disengaged;839839-840875841876 disengaged = (xpc_partition_engaged(1UL << partid) == 0);842877 if (part->disengage_request_timeout) {···851888 */852889853890 dev_info(xpc_part, "disengage from remote partition %d "854854- "timed out\n", partid);891891+ "timed out\n", partid);855892 xpc_disengage_request_timedout = 1;856893 xpc_clear_partition_engaged(1UL << partid);857894 disengaged = 1;···861898 /* cancel the timer function, provided it's not us */862899 if (!in_interrupt()) {863900 del_singleshot_timer_sync(&part->864864- disengage_request_timer);901901+ disengage_request_timer);865902 }866903867904 DBUG_ON(part->act_state != XPC_P_DEACTIVATING &&868868- part->act_state != XPC_P_INACTIVE);905905+ part->act_state != XPC_P_INACTIVE);869906 if (part->act_state != XPC_P_INACTIVE) {870907 xpc_wakeup_channel_mgr(part);871908 }···877914 return disengaged;878915}879916880880-881917/*882918 * Mark specified partition as active.883919 */···885923{886924 unsigned long irq_flags;887925 enum xpc_retval ret;888888-889926890927 dev_dbg(xpc_part, "setting partition %d to ACTIVE\n", XPC_PARTID(part));891928···901940 return ret;902941}903942904904-905943/*906944 * Notify XPC that the partition is down.907945 */908946void909947xpc_deactivate_partition(const int line, struct xpc_partition *part,910910- enum xpc_retval reason)948948+ enum xpc_retval reason)911949{912950 unsigned long irq_flags;913913-914951915952 spin_lock_irqsave(&part->act_lock, irq_flags);916953···923964 }924965 if (part->act_state == XPC_P_DEACTIVATING) {925966 if ((part->reason == xpcUnloading && reason != xpcUnloading) ||926926- reason == xpcReactivating) {967967+ reason == xpcReactivating) {927968 XPC_SET_REASON(part, reason, line);928969 }929970 spin_unlock_irqrestore(&part->act_lock, irq_flags);···941982942983 /* set a timelimit on the disengage request */943984 part->disengage_request_timeout = jiffies +944944- (xpc_disengage_request_timelimit * HZ);985985+ (xpc_disengage_request_timelimit * HZ);945986 part->disengage_request_timer.expires =946946- part->disengage_request_timeout;987987+ part->disengage_request_timeout;947988 add_timer(&part->disengage_request_timer);948989 }949990···953994 xpc_partition_going_down(part, reason);954995}955996956956-957997/*958998 * Mark specified partition as inactive.959999 */···9601002xpc_mark_partition_inactive(struct xpc_partition *part)9611003{9621004 unsigned long irq_flags;963963-96410059651006 dev_dbg(xpc_part, "setting partition %d to INACTIVE\n",9661007 XPC_PARTID(part));···9691012 spin_unlock_irqrestore(&part->act_lock, irq_flags);9701013 part->remote_rp_pa = 0;9711014}972972-97310159741016/*9751017 * SAL has provided a partition and machine mask. The partition mask···9971041 u64 *discovered_nasids;9981042 enum xpc_retval ret;999104310001000-10011044 remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE +10021002- xp_nasid_mask_bytes,10031003- GFP_KERNEL, &remote_rp_base);10451045+ xp_nasid_mask_bytes,10461046+ GFP_KERNEL, &remote_rp_base);10041047 if (remote_rp == NULL) {10051048 return;10061049 }10071007- remote_vars = (struct xpc_vars *) remote_rp;10081008-10501050+ remote_vars = (struct xpc_vars *)remote_rp;1009105110101052 discovered_nasids = kzalloc(sizeof(u64) * xp_nasid_mask_words,10111011- GFP_KERNEL);10531053+ GFP_KERNEL);10121054 if (discovered_nasids == NULL) {10131055 kfree(remote_rp_base);10141056 return;10151057 }1016105810171017- rp = (struct xpc_rsvd_page *) xpc_rsvd_page;10591059+ rp = (struct xpc_rsvd_page *)xpc_rsvd_page;1018106010191061 /*10201062 * The term 'region' in this context refers to the minimum number of···1035108110361082 for (region = 0; region < max_regions; region++) {1037108310381038- if ((volatile int) xpc_exiting) {10841084+ if ((volatile int)xpc_exiting) {10391085 break;10401086 }1041108710421088 dev_dbg(xpc_part, "searching region %d\n", region);1043108910441090 for (nasid = (region * region_size * 2);10451045- nasid < ((region + 1) * region_size * 2);10461046- nasid += 2) {10911091+ nasid < ((region + 1) * region_size * 2); nasid += 2) {1047109210481048- if ((volatile int) xpc_exiting) {10931093+ if ((volatile int)xpc_exiting) {10491094 break;10501095 }1051109610521097 dev_dbg(xpc_part, "checking nasid %d\n", nasid);10531053-1054109810551099 if (XPC_NASID_IN_ARRAY(nasid, xpc_part_nasids)) {10561100 dev_dbg(xpc_part, "PROM indicates Nasid %d is "···10711119 continue;10721120 }1073112110741074-10751122 /* pull over the reserved page structure */1076112310771124 ret = xpc_get_remote_rp(nasid, discovered_nasids,10781078- remote_rp, &remote_rp_pa);11251125+ remote_rp, &remote_rp_pa);10791126 if (ret != xpcSuccess) {10801127 dev_dbg(xpc_part, "unable to get reserved page "10811128 "from nasid %d, reason=%d\n", nasid,···1090113910911140 partid = remote_rp->partid;10921141 part = &xpc_partitions[partid];10931093-1094114210951143 /* pull over the cross partition variables */10961144···11211171 * get the same page for remote_act_amos_pa after11221172 * module reloads and system reboots.11231173 */11241124- if (sn_register_xp_addr_region(11251125- remote_vars->amos_page_pa,11261126- PAGE_SIZE, 1) < 0) {11271127- dev_dbg(xpc_part, "partition %d failed to "11741174+ if (sn_register_xp_addr_region11751175+ (remote_vars->amos_page_pa, PAGE_SIZE, 1) < 0) {11761176+ dev_dbg(xpc_part,11771177+ "partition %d failed to "11281178 "register xp_addr region 0x%016lx\n",11291179 partid, remote_vars->amos_page_pa);1130118011311181 XPC_SET_REASON(part, xpcPhysAddrRegFailed,11321132- __LINE__);11821182+ __LINE__);11331183 break;11341184 }11351185···11451195 remote_vars->act_phys_cpuid);1146119611471197 if (XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars->11481148- version)) {11981198+ version)) {11491199 part->remote_amos_page_pa =11501150- remote_vars->amos_page_pa;12001200+ remote_vars->amos_page_pa;11511201 xpc_mark_partition_disengaged(part);11521202 xpc_cancel_partition_disengage_request(part);11531203 }···11581208 kfree(discovered_nasids);11591209 kfree(remote_rp_base);11601210}11611161-1162121111631212/*11641213 * Given a partid, get the nasids owned by that partition from the···11701221 u64 part_nasid_pa;11711222 int bte_res;1172122311731173-11741224 part = &xpc_partitions[partid];11751225 if (part->remote_rp_pa == 0) {11761226 return xpcPartitionDown;···1177122911781230 memset(nasid_mask, 0, XP_NASID_MASK_BYTES);1179123111801180- part_nasid_pa = (u64) XPC_RP_PART_NASIDS(part->remote_rp_pa);12321232+ part_nasid_pa = (u64)XPC_RP_PART_NASIDS(part->remote_rp_pa);1181123311821182- bte_res = xp_bte_copy(part_nasid_pa, (u64) nasid_mask,11831183- xp_nasid_mask_bytes, (BTE_NOTIFY | BTE_WACQUIRE), NULL);12341234+ bte_res = xp_bte_copy(part_nasid_pa, (u64)nasid_mask,12351235+ xp_nasid_mask_bytes, (BTE_NOTIFY | BTE_WACQUIRE),12361236+ NULL);1184123711851238 return xpc_map_bte_errors(bte_res);11861239}11871187-