Skip to content

Commit

Permalink
sgi-xp: enable building of XPC/XPNET on x86_64
Browse files Browse the repository at this point in the history
Get XPC/XPNET to build on x86_64.  Trying to modprobe them up on a non-UV
or sn2 system will result in a -ENODEV.

Signed-off-by: Dean Nelson <[email protected]>
Cc: Jack Steiner <[email protected]>
Cc: "Luck, Tony" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Dean Nelson authored and torvalds committed Jul 30, 2008
1 parent 81fe788 commit 261f3b4
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 126 deletions.
2 changes: 1 addition & 1 deletion drivers/misc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ config ENCLOSURE_SERVICES

config SGI_XP
tristate "Support communication between SGI SSIs"
depends on IA64_GENERIC || IA64_SGI_SN2
depends on IA64_GENERIC || IA64_SGI_SN2 || IA64_SGI_UV || (X86_64 && SMP)
select IA64_UNCACHED_ALLOCATOR if IA64_GENERIC || IA64_SGI_SN2
select GENERIC_ALLOCATOR if IA64_GENERIC || IA64_SGI_SN2
---help---
Expand Down
14 changes: 10 additions & 4 deletions drivers/misc/sgi-xp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
#

obj-$(CONFIG_SGI_XP) += xp.o
xp-y := xp_main.o xp_uv.o
xp-$(CONFIG_IA64) += xp_sn2.o xp_nofault.o
xp-y := xp_main.o
xp-$(CONFIG_IA64_SGI_SN2) += xp_sn2.o xp_nofault.o
xp-$(CONFIG_IA64_GENERIC) += xp_sn2.o xp_nofault.o xp_uv.o
xp-$(CONFIG_IA64_SGI_UV) += xp_uv.o
xp-$(CONFIG_X86_64) += xp_uv.o

obj-$(CONFIG_SGI_XP) += xpc.o
xpc-y := xpc_main.o xpc_uv.o xpc_channel.o xpc_partition.o
xpc-$(CONFIG_IA64) += xpc_sn2.o
xpc-y := xpc_main.o xpc_channel.o xpc_partition.o
xpc-$(CONFIG_IA64_SGI_SN2) += xpc_sn2.o
xpc-$(CONFIG_IA64_GENERIC) += xpc_sn2.o xpc_uv.o
xpc-$(CONFIG_IA64_SGI_UV) += xpc_uv.o
xpc-$(CONFIG_X86_64) += xpc_uv.o

obj-$(CONFIG_SGI_XP) += xpnet.o
32 changes: 21 additions & 11 deletions drivers/misc/sgi-xp/xp.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
#ifndef _DRIVERS_MISC_SGIXP_XP_H
#define _DRIVERS_MISC_SGIXP_XP_H

#include <linux/cache.h>
#include <linux/hardirq.h>
#include <linux/mutex.h>
#include <asm/sn/types.h>

#ifdef CONFIG_IA64
#include <asm/sn/arch.h>
#include <asm/system.h>
#include <asm/sn/arch.h> /* defines is_shub1() and is_shub2() */
#define is_shub() ia64_platform_is("sn2")
#define is_uv() ia64_platform_is("uv")
#endif

#ifdef USE_DBUG_ON
#define DBUG_ON(condition) BUG_ON(condition)
#else
#define DBUG_ON(condition)
#ifdef CONFIG_X86_64
#include <asm/genapic.h>
#define is_uv() is_uv_system()
#endif

#ifndef is_shub1
Expand All @@ -36,13 +35,19 @@
#endif

#ifndef is_shub
#define is_shub() (is_shub1() || is_shub2())
#define is_shub() 0
#endif

#ifndef is_uv
#define is_uv() 0
#endif

#ifdef USE_DBUG_ON
#define DBUG_ON(condition) BUG_ON(condition)
#else
#define DBUG_ON(condition)
#endif

/*
* Define the maximum number of partitions the system can possibly support.
* It is based on the maximum number of hardware partitionable regions. The
Expand Down Expand Up @@ -200,7 +205,9 @@ enum xp_retval {
xpPayloadTooBig, /* 55: payload too large for message slot */

xpUnsupported, /* 56: unsupported functionality or resource */
xpUnknownReason /* 57: unknown reason - must be last in enum */
xpNeedMoreInfo, /* 57: more info is needed by SAL */

xpUnknownReason /* 58: unknown reason - must be last in enum */
};

/*
Expand Down Expand Up @@ -339,8 +346,11 @@ xpc_partid_to_nasids(short partid, void *nasids)
}

extern short xp_max_npartitions;
extern short xp_partition_id;
extern u8 xp_region_size;

extern enum xp_retval (*xp_remote_memcpy) (void *, const void *, size_t);
extern int (*xp_cpu_to_nasid) (int);

extern u64 xp_nofault_PIOR_target;
extern int xp_nofault_PIOR(void *);
Expand Down
10 changes: 9 additions & 1 deletion drivers/misc/sgi-xp/xp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*
*/

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
#include "xp.h"
Expand All @@ -36,9 +35,18 @@ struct device *xp = &xp_dbg_subname;
short xp_max_npartitions;
EXPORT_SYMBOL_GPL(xp_max_npartitions);

short xp_partition_id;
EXPORT_SYMBOL_GPL(xp_partition_id);

u8 xp_region_size;
EXPORT_SYMBOL_GPL(xp_region_size);

enum xp_retval (*xp_remote_memcpy) (void *dst, const void *src, size_t len);
EXPORT_SYMBOL_GPL(xp_remote_memcpy);

int (*xp_cpu_to_nasid) (int cpuid);
EXPORT_SYMBOL_GPL(xp_cpu_to_nasid);

/*
* xpc_registrations[] keeps track of xpc_connect()'s done by the kernel-level
* users of XPC.
Expand Down
10 changes: 10 additions & 0 deletions drivers/misc/sgi-xp/xp_sn2.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Architecture specific implementation of common functions.
*/

#include <linux/module.h>
#include <linux/device.h>
#include <asm/sn/bte.h>
#include <asm/sn/sn_sal.h>
Expand Down Expand Up @@ -116,14 +117,23 @@ xp_remote_memcpy_sn2(void *vdst, const void *psrc, size_t len)
return xpBteCopyError;
}

static int
xp_cpu_to_nasid_sn2(int cpuid)
{
return cpuid_to_nasid(cpuid);
}

enum xp_retval
xp_init_sn2(void)
{
BUG_ON(!is_shub());

xp_max_npartitions = XP_MAX_NPARTITIONS_SN2;
xp_partition_id = sn_partition_id;
xp_region_size = sn_region_size;

xp_remote_memcpy = xp_remote_memcpy_sn2;
xp_cpu_to_nasid = xp_cpu_to_nasid_sn2;

return xp_register_nofault_code_sn2();
}
Expand Down
34 changes: 15 additions & 19 deletions drivers/misc/sgi-xp/xpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@
#ifndef _DRIVERS_MISC_SGIXP_XPC_H
#define _DRIVERS_MISC_SGIXP_XPC_H

#include <linux/interrupt.h>
#include <linux/sysctl.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/wait.h>
#include <linux/completion.h>
#include <asm/pgtable.h>
#include <asm/processor.h>
#include <asm/sn/clksupport.h>
#include <asm/sn/addrs.h>
#include <asm/sn/mspec.h>
#include <asm/sn/shub_mmr.h>
#include <linux/timer.h>
#include <linux/sched.h>
#include "xp.h"

/*
Expand Down Expand Up @@ -179,7 +172,8 @@ struct xpc_vars_part_sn2 {
#define XPC_RP_HEADER_SIZE L1_CACHE_ALIGN(sizeof(struct xpc_rsvd_page))
#define XPC_RP_VARS_SIZE L1_CACHE_ALIGN(sizeof(struct xpc_vars_sn2))

#define XPC_RP_PART_NASIDS(_rp) ((u64 *)((u8 *)(_rp) + XPC_RP_HEADER_SIZE))
#define XPC_RP_PART_NASIDS(_rp) ((unsigned long *)((u8 *)(_rp) + \
XPC_RP_HEADER_SIZE))
#define XPC_RP_MACH_NASIDS(_rp) (XPC_RP_PART_NASIDS(_rp) + \
xpc_nasid_mask_nlongs)
#define XPC_RP_VARS(_rp) ((struct xpc_vars_sn2 *) \
Expand All @@ -202,13 +196,13 @@ struct xpc_vars_part_sn2 {
/*
* Define a Get/Put value pair (pointers) used with a message queue.
*/
struct xpc_gp {
struct xpc_gp_sn2 {
s64 get; /* Get value */
s64 put; /* Put value */
};

#define XPC_GP_SIZE \
L1_CACHE_ALIGN(sizeof(struct xpc_gp) * XPC_MAX_NCHANNELS)
L1_CACHE_ALIGN(sizeof(struct xpc_gp_sn2) * XPC_MAX_NCHANNELS)

/*
* Define a structure that contains arguments associated with opening and
Expand Down Expand Up @@ -340,10 +334,10 @@ struct xpc_channel_sn2 {

/* various flavors of local and remote Get/Put values */

struct xpc_gp *local_GP; /* local Get/Put values */
struct xpc_gp remote_GP; /* remote Get/Put values */
struct xpc_gp w_local_GP; /* working local Get/Put values */
struct xpc_gp w_remote_GP; /* working remote Get/Put values */
struct xpc_gp_sn2 *local_GP; /* local Get/Put values */
struct xpc_gp_sn2 remote_GP; /* remote Get/Put values */
struct xpc_gp_sn2 w_local_GP; /* working local Get/Put values */
struct xpc_gp_sn2 w_remote_GP; /* working remote Get/Put values */
s64 next_msg_to_pull; /* Put value of next msg to pull */

struct mutex msg_to_pull_mutex; /* next msg to pull serialization */
Expand Down Expand Up @@ -506,9 +500,9 @@ struct xpc_partition_sn2 {
u8 remote_vars_version; /* version# of partition's vars */

void *local_GPs_base; /* base address of kmalloc'd space */
struct xpc_gp *local_GPs; /* local Get/Put values */
struct xpc_gp_sn2 *local_GPs; /* local Get/Put values */
void *remote_GPs_base; /* base address of kmalloc'd space */
struct xpc_gp *remote_GPs; /* copy of remote partition's local */
struct xpc_gp_sn2 *remote_GPs; /* copy of remote partition's local */
/* Get/Put values */
u64 remote_GPs_pa; /* phys address of remote partition's local */
/* Get/Put values */
Expand Down Expand Up @@ -629,6 +623,8 @@ extern void xpc_activate_partition(struct xpc_partition *);
extern void xpc_activate_kthreads(struct xpc_channel *, int);
extern void xpc_create_kthreads(struct xpc_channel *, int, int);
extern void xpc_disconnect_wait(int);
extern enum xp_retval (*xpc_get_partition_rsvd_page_pa) (u64, u64 *, u64 *,
size_t *);
extern enum xp_retval (*xpc_rsvd_page_init) (struct xpc_rsvd_page *);
extern void (*xpc_heartbeat_init) (void);
extern void (*xpc_heartbeat_exit) (void);
Expand Down
18 changes: 6 additions & 12 deletions drivers/misc/sgi-xp/xpc_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@
*
*/

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/cache.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <linux/completion.h>
#include <asm/sn/sn_sal.h>
#include <linux/device.h>
#include "xpc.h"

/*
Expand Down Expand Up @@ -373,8 +366,9 @@ xpc_process_openclose_chctl_flags(struct xpc_partition *part, int ch_number,
dev_dbg(xpc_chan, "XPC_CHCTL_OPENREPLY (local_msgqueue_pa="
"0x%lx, local_nentries=%d, remote_nentries=%d) "
"received from partid=%d, channel=%d\n",
args->local_msgqueue_pa, args->local_nentries,
args->remote_nentries, ch->partid, ch->number);
(unsigned long)args->local_msgqueue_pa,
args->local_nentries, args->remote_nentries,
ch->partid, ch->number);

if (ch->flags & (XPC_C_DISCONNECTING | XPC_C_DISCONNECTED)) {
spin_unlock_irqrestore(&ch->lock, irq_flags);
Expand Down Expand Up @@ -940,7 +934,7 @@ xpc_deliver_msg(struct xpc_channel *ch)
if (ch->func != NULL) {
dev_dbg(xpc_chan, "ch->func() called, msg=0x%p, "
"msg_number=%ld, partid=%d, channel=%d\n",
(void *)msg, msg->number, ch->partid,
msg, (signed long)msg->number, ch->partid,
ch->number);

/* deliver the message to its intended recipient */
Expand All @@ -949,7 +943,7 @@ xpc_deliver_msg(struct xpc_channel *ch)

dev_dbg(xpc_chan, "ch->func() returned, msg=0x%p, "
"msg_number=%ld, partid=%d, channel=%d\n",
(void *)msg, msg->number, ch->partid,
msg, (signed long)msg->number, ch->partid,
ch->number);
}

Expand Down
Loading

0 comments on commit 261f3b4

Please sign in to comment.