Commit de39d711 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] sn: General module.c clean up

From: Pat Gefre <pfg@sgi.com>

General module.c clean up
parent a611e51e
...@@ -39,40 +39,8 @@ int nummodules; ...@@ -39,40 +39,8 @@ int nummodules;
#define SN00_SERIAL_FUDGE 0x3b1af409d513c2 #define SN00_SERIAL_FUDGE 0x3b1af409d513c2
#define SN0_SERIAL_FUDGE 0x6e #define SN0_SERIAL_FUDGE 0x6e
void
encode_int_serial(uint64_t src,uint64_t *dest)
{
uint64_t val;
int i;
val = src + SN00_SERIAL_FUDGE;
for (i = 0; i < sizeof(long long); i++) {
((char*)dest)[i] =
((char*)&val)[sizeof(long long)/2 +
((i%2) ? ((i/2 * -1) - 1) : (i/2))];
}
}
void
decode_int_serial(uint64_t src, uint64_t *dest)
{
uint64_t val;
int i;
for (i = 0; i < sizeof(long long); i++) {
((char*)&val)[sizeof(long long)/2 +
((i%2) ? ((i/2 * -1) - 1) : (i/2))] =
((char*)&src)[i];
}
*dest = val - SN00_SERIAL_FUDGE;
}
static void __init
void
encode_str_serial(const char *src, char *dest) encode_str_serial(const char *src, char *dest)
{ {
int i; int i;
...@@ -85,20 +53,8 @@ encode_str_serial(const char *src, char *dest) ...@@ -85,20 +53,8 @@ encode_str_serial(const char *src, char *dest)
} }
} }
void module_t * __init
decode_str_serial(const char *src, char *dest) module_lookup(moduleid_t id)
{
int i;
for (i = 0; i < MAX_SERIAL_NUM_SIZE; i++) {
dest[MAX_SERIAL_NUM_SIZE/2 +
((i%2) ? ((i/2 * -1) - 1) : (i/2))] = src[i] -
SN0_SERIAL_FUDGE;
}
}
module_t *module_lookup(moduleid_t id)
{ {
int i; int i;
...@@ -127,6 +83,7 @@ module_add_node(geoid_t geoid, cnodeid_t cnodeid) ...@@ -127,6 +83,7 @@ module_add_node(geoid_t geoid, cnodeid_t cnodeid)
int i; int i;
char buffer[16]; char buffer[16];
moduleid_t moduleid; moduleid_t moduleid;
slabid_t slab_number;
memset(buffer, 0, 16); memset(buffer, 0, 16);
moduleid = geo_module(geoid); moduleid = geo_module(geoid);
...@@ -135,14 +92,16 @@ module_add_node(geoid_t geoid, cnodeid_t cnodeid) ...@@ -135,14 +92,16 @@ module_add_node(geoid_t geoid, cnodeid_t cnodeid)
if ((m = module_lookup(moduleid)) == 0) { if ((m = module_lookup(moduleid)) == 0) {
m = kmalloc(sizeof (module_t), GFP_KERNEL); m = kmalloc(sizeof (module_t), GFP_KERNEL);
memset(m, 0 , sizeof(module_t));
ASSERT_ALWAYS(m); ASSERT_ALWAYS(m);
memset(m, 0 , sizeof(module_t));
for (slab_number = 0; slab_number <= MAX_SLABS; slab_number++) {
m->nodes[slab_number] = -1;
}
m->id = moduleid; m->id = moduleid;
spin_lock_init(&m->lock); spin_lock_init(&m->lock);
init_MUTEX(&m->thdcnt);
/* Insert in sorted order by module number */ /* Insert in sorted order by module number */
for (i = nummodules; i > 0 && modules[i - 1]->id > moduleid; i--) for (i = nummodules; i > 0 && modules[i - 1]->id > moduleid; i--)
...@@ -152,17 +111,26 @@ module_add_node(geoid_t geoid, cnodeid_t cnodeid) ...@@ -152,17 +111,26 @@ module_add_node(geoid_t geoid, cnodeid_t cnodeid)
nummodules++; nummodules++;
} }
m->nodes[m->nodecnt] = cnodeid; /*
m->geoid[m->nodecnt] = geoid; * Save this information in the correct slab number of the node in the
m->nodecnt++; * module.
*/
slab_number = geo_slab(geoid);
DPRINTF("slab number added 0x%x\n", slab_number);
if (m->nodes[slab_number] != -1) {
printk("module_add_node .. slab previously found\n");
return NULL;
}
DPRINTF("module_add_node: module %s now has %d nodes\n", buffer, m->nodecnt); m->nodes[slab_number] = cnodeid;
m->geoid[slab_number] = geoid;
return m; return m;
} }
static int __init static int __init
module_probe_snum(module_t *m, nasid_t nasid) module_probe_snum(module_t *m, nasid_t host_nasid, nasid_t nasid)
{ {
lboard_t *board; lboard_t *board;
klmod_serial_num_t *comp; klmod_serial_num_t *comp;
...@@ -171,13 +139,10 @@ module_probe_snum(module_t *m, nasid_t nasid) ...@@ -171,13 +139,10 @@ module_probe_snum(module_t *m, nasid_t nasid)
/* /*
* record brick serial number * record brick serial number
*/ */
board = find_lboard((lboard_t *) KL_CONFIG_INFO(nasid), KLTYPE_SNIA); board = find_lboard((lboard_t *) KL_CONFIG_INFO(host_nasid), KLTYPE_SNIA);
if (! board || KL_CONFIG_DUPLICATE_BOARD(board)) if (! board || KL_CONFIG_DUPLICATE_BOARD(board))
{ {
#if LDEBUG
printf ("module_probe_snum: no IP35 board found!\n");
#endif
return 0; return 0;
} }
...@@ -186,12 +151,6 @@ module_probe_snum(module_t *m, nasid_t nasid) ...@@ -186,12 +151,6 @@ module_probe_snum(module_t *m, nasid_t nasid)
encode_str_serial( serial_number, m->snum.snum_str ); encode_str_serial( serial_number, m->snum.snum_str );
m->snum_valid = 1; m->snum_valid = 1;
} }
#if LDEBUG
else {
printf("module_probe_snum: brick serial number is null!\n");
}
printf("module_probe_snum: brick serial number == %s\n", serial_number);
#endif /* DEBUG */
board = find_lboard((lboard_t *) KL_CONFIG_INFO(nasid), board = find_lboard((lboard_t *) KL_CONFIG_INFO(nasid),
KLTYPE_IOBRICK_XBOW); KLTYPE_IOBRICK_XBOW);
...@@ -202,22 +161,10 @@ module_probe_snum(module_t *m, nasid_t nasid) ...@@ -202,22 +161,10 @@ module_probe_snum(module_t *m, nasid_t nasid)
comp = GET_SNUM_COMP(board); comp = GET_SNUM_COMP(board);
if (comp) { if (comp) {
#if LDEBUG
int i;
printf("********found module with id %x and string", m->id);
for (i = 0; i < MAX_SERIAL_NUM_SIZE; i++)
printf(" %x ", comp->snum.snum_str[i]);
printf("\n"); /* Fudged string is not ASCII */
#endif
if (comp->snum.snum_str[0] != '\0') { if (comp->snum.snum_str[0] != '\0') {
memcpy(m->sys_snum, memcpy(m->sys_snum, comp->snum.snum_str,
comp->snum.snum_str, MAX_SERIAL_NUM_SIZE);
MAX_SERIAL_NUM_SIZE); m->sys_snum_valid = 1;
m->sys_snum_valid = 1;
} }
} }
...@@ -243,21 +190,20 @@ io_module_init(void) ...@@ -243,21 +190,20 @@ io_module_init(void)
nserial = 0; nserial = 0;
/*
* First pass just scan for compute node boards KLTYPE_SNIA.
* We do not support memoryless compute nodes.
*/
for (node = 0; node < numnodes; node++) { for (node = 0; node < numnodes; node++) {
nasid = COMPACT_TO_NASID_NODEID(node); nasid = COMPACT_TO_NASID_NODEID(node);
board = find_lboard((lboard_t *) KL_CONFIG_INFO(nasid), KLTYPE_SNIA); board = find_lboard((lboard_t *) KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
ASSERT(board); ASSERT(board);
m = module_add_node(board->brd_geoid, node); HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, NULL, NULL, "Found Shub lboard 0x%lx nasid 0x%x cnode 0x%x \n", (unsigned long)board, (int)nasid, (int)node));
if (! m->snum_valid && module_probe_snum(m, nasid)) m = module_add_node(board->brd_geoid, node);
if (! m->snum_valid && module_probe_snum(m, nasid, nasid))
nserial++; nserial++;
} }
DPRINTF("********found total of %d serial numbers in the system\n",
nserial);
if (nserial == 0)
DPRINTF(KERN_WARNING "io_module_init: No serial number found.\n");
} }
...@@ -166,7 +166,6 @@ struct module_s { ...@@ -166,7 +166,6 @@ struct module_s {
/* Fields for Module System Controller */ /* Fields for Module System Controller */
int mesgpend; /* Message pending */ int mesgpend; /* Message pending */
int shutdown; /* Shutdown in progress */ int shutdown; /* Shutdown in progress */
struct semaphore thdcnt; /* Threads finished counter */
time_t intrhist[MODULE_HIST_CNT]; time_t intrhist[MODULE_HIST_CNT];
int histptr; int histptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment