Skip to content

Commit

Permalink
Pull define-node-cleanup into release branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Luck committed Oct 28, 2005
2 parents fbbb0bd + 59c4223 commit a1e78db
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 178 deletions.
4 changes: 1 addition & 3 deletions arch/ia64/sn/kernel/io_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include "xtalk/hubdev.h"
#include "xtalk/xwidgetdev.h"

nasid_t master_nasid = INVALID_NASID; /* Partition Master */

static struct list_head sn_sysdata_list;

/* sysdata list struct */
Expand Down Expand Up @@ -165,7 +163,7 @@ static void sn_fixup_ionodes(void)
* Get SGI Specific HUB chipset information.
* Inform Prom that this kernel can support domain bus numbering.
*/
for (i = 0; i < numionodes; i++) {
for (i = 0; i < num_cnodes; i++) {
hubdev = (struct hubdev_info *)(NODEPDA(i)->pdinfo);
nasid = cnodeid_to_nasid(i);
hubdev->max_segment_number = 0xffffffff;
Expand Down
160 changes: 51 additions & 109 deletions arch/ia64/sn/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ DEFINE_PER_CPU(struct pda_s, pda_percpu);

#define MAX_PHYS_MEMORY (1UL << IA64_MAX_PHYS_BITS) /* Max physical address supported */

lboard_t *root_lboard[MAX_COMPACT_NODES];

extern void bte_init_node(nodepda_t *, cnodeid_t);

extern void sn_timer_init(void);
Expand Down Expand Up @@ -97,15 +95,15 @@ u8 sn_region_size;
EXPORT_SYMBOL(sn_region_size);
int sn_prom_type; /* 0=hardware, 1=medusa/realprom, 2=medusa/fakeprom */

short physical_node_map[MAX_PHYSNODE_ID];
short physical_node_map[MAX_NUMALINK_NODES];
static unsigned long sn_prom_features[MAX_PROM_FEATURE_SETS];

EXPORT_SYMBOL(physical_node_map);

int numionodes;
int num_cnodes;

static void sn_init_pdas(char **);
static void scan_for_ionodes(void);
static void build_cnode_tables(void);

static nodepda_t *nodepdaindr[MAX_COMPACT_NODES];

Expand Down Expand Up @@ -139,19 +137,6 @@ extern char drive_info[4 * 16];
char drive_info[4 * 16];
#endif

/*
* Get nasid of current cpu early in boot before nodepda is initialized
*/
static int
boot_get_nasid(void)
{
int nasid;

if (ia64_sn_get_sapic_info(get_sapicid(), &nasid, NULL, NULL))
BUG();
return nasid;
}

/*
* This routine can only be used during init, since
* smp_boot_data is an init data structure.
Expand Down Expand Up @@ -223,7 +208,6 @@ void __init early_sn_setup(void)
}

extern int platform_intr_list[];
extern nasid_t master_nasid;
static int __initdata shub_1_1_found = 0;

/*
Expand Down Expand Up @@ -269,7 +253,6 @@ static void __init sn_check_for_wars(void)
void __init sn_setup(char **cmdline_p)
{
long status, ticks_per_sec, drift;
int pxm;
u32 version = sn_sal_rev();
extern void sn_cpu_init(void);

Expand Down Expand Up @@ -300,11 +283,10 @@ void __init sn_setup(char **cmdline_p)

MAX_DMA_ADDRESS = PAGE_OFFSET + MAX_PHYS_MEMORY;

memset(physical_node_map, -1, sizeof(physical_node_map));
for (pxm = 0; pxm < MAX_PXM_DOMAINS; pxm++)
if (pxm_to_nid_map[pxm] != -1)
physical_node_map[pxm_to_nasid(pxm)] =
pxm_to_nid_map[pxm];
/*
* Build the tables for managing cnodes.
*/
build_cnode_tables();

/*
* Old PROMs do not provide an ACPI FADT. Disable legacy keyboard
Expand All @@ -319,8 +301,6 @@ void __init sn_setup(char **cmdline_p)

printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF);

master_nasid = boot_get_nasid();

status =
ia64_sal_freq_base(SAL_FREQ_BASE_REALTIME_CLOCK, &ticks_per_sec,
&drift);
Expand Down Expand Up @@ -378,15 +358,6 @@ static void __init sn_init_pdas(char **cmdline_p)
{
cnodeid_t cnode;

memset(sn_cnodeid_to_nasid, -1,
sizeof(__ia64_per_cpu_var(__sn_cnodeid_to_nasid)));
for_each_online_node(cnode)
sn_cnodeid_to_nasid[cnode] =
pxm_to_nasid(nid_to_pxm_map[cnode]);

numionodes = num_online_nodes();
scan_for_ionodes();

/*
* Allocate & initalize the nodepda for each node.
*/
Expand All @@ -402,7 +373,7 @@ static void __init sn_init_pdas(char **cmdline_p)
/*
* Allocate & initialize nodepda for TIOs. For now, put them on node 0.
*/
for (cnode = num_online_nodes(); cnode < numionodes; cnode++) {
for (cnode = num_online_nodes(); cnode < num_cnodes; cnode++) {
nodepdaindr[cnode] =
alloc_bootmem_node(NODE_DATA(0), sizeof(nodepda_t));
memset(nodepdaindr[cnode], 0, sizeof(nodepda_t));
Expand All @@ -411,7 +382,7 @@ static void __init sn_init_pdas(char **cmdline_p)
/*
* Now copy the array of nodepda pointers to each nodepda.
*/
for (cnode = 0; cnode < numionodes; cnode++)
for (cnode = 0; cnode < num_cnodes; cnode++)
memcpy(nodepdaindr[cnode]->pernode_pdaindr, nodepdaindr,
sizeof(nodepdaindr));

Expand All @@ -428,7 +399,7 @@ static void __init sn_init_pdas(char **cmdline_p)
* Initialize the per node hubdev. This includes IO Nodes and
* headless/memless nodes.
*/
for (cnode = 0; cnode < numionodes; cnode++) {
for (cnode = 0; cnode < num_cnodes; cnode++) {
hubdev_init_node(nodepdaindr[cnode], cnode);
}
}
Expand Down Expand Up @@ -553,87 +524,58 @@ void __init sn_cpu_init(void)
}

/*
* Scan klconfig for ionodes. Add the nasids to the
* physical_node_map and the pda and increment numionodes.
* Build tables for converting between NASIDs and cnodes.
*/
static inline int __init board_needs_cnode(int type)
{
return (type == KLTYPE_SNIA || type == KLTYPE_TIO);
}

static void __init scan_for_ionodes(void)
void __init build_cnode_tables(void)
{
int nasid = 0;
int nasid;
int node;
lboard_t *brd;

/* fakeprom does not support klgraph */
if (IS_RUNNING_ON_FAKE_PROM())
return;

/* Setup ionodes with memory */
for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {
char *klgraph_header;
cnodeid_t cnodeid;

if (physical_node_map[nasid] == -1)
continue;
memset(physical_node_map, -1, sizeof(physical_node_map));
memset(sn_cnodeid_to_nasid, -1,
sizeof(__ia64_per_cpu_var(__sn_cnodeid_to_nasid)));

cnodeid = -1;
klgraph_header = __va(ia64_sn_get_klconfig_addr(nasid));
if (!klgraph_header) {
BUG(); /* All nodes must have klconfig tables! */
}
cnodeid = nasid_to_cnodeid(nasid);
root_lboard[cnodeid] = (lboard_t *)
NODE_OFFSET_TO_LBOARD((nasid),
((kl_config_hdr_t
*) (klgraph_header))->
ch_board_info);
/*
* First populate the tables with C/M bricks. This ensures that
* cnode == node for all C & M bricks.
*/
for_each_online_node(node) {
nasid = pxm_to_nasid(nid_to_pxm_map[node]);
sn_cnodeid_to_nasid[node] = nasid;
physical_node_map[nasid] = node;
}

/* Scan headless/memless IO Nodes. */
for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {
/* if there's no nasid, don't try to read the klconfig on the node */
if (physical_node_map[nasid] == -1)
continue;
brd = find_lboard_any((lboard_t *)
root_lboard[nasid_to_cnodeid(nasid)],
KLTYPE_SNIA);
if (brd) {
brd = KLCF_NEXT_ANY(brd); /* Skip this node's lboard */
if (!brd)
continue;
}

brd = find_lboard_any(brd, KLTYPE_SNIA);
/*
* num_cnodes is total number of C/M/TIO bricks. Because of the 256 node
* limit on the number of nodes, we can't use the generic node numbers
* for this. Note that num_cnodes is incremented below as TIOs or
* headless/memoryless nodes are discovered.
*/
num_cnodes = num_online_nodes();

while (brd) {
sn_cnodeid_to_nasid[numionodes] = brd->brd_nasid;
physical_node_map[brd->brd_nasid] = numionodes;
root_lboard[numionodes] = brd;
numionodes++;
brd = KLCF_NEXT_ANY(brd);
if (!brd)
break;

brd = find_lboard_any(brd, KLTYPE_SNIA);
}
}
/* fakeprom does not support klgraph */
if (IS_RUNNING_ON_FAKE_PROM())
return;

/* Scan for TIO nodes. */
for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {
/* if there's no nasid, don't try to read the klconfig on the node */
if (physical_node_map[nasid] == -1)
continue;
brd = find_lboard_any((lboard_t *)
root_lboard[nasid_to_cnodeid(nasid)],
KLTYPE_TIO);
/* Find TIOs & headless/memoryless nodes and add them to the tables */
for_each_online_node(node) {
kl_config_hdr_t *klgraph_header;
nasid = cnodeid_to_nasid(node);
if ((klgraph_header = ia64_sn_get_klconfig_addr(nasid)) == NULL)
BUG();
brd = NODE_OFFSET_TO_LBOARD(nasid, klgraph_header->ch_board_info);
while (brd) {
sn_cnodeid_to_nasid[numionodes] = brd->brd_nasid;
physical_node_map[brd->brd_nasid] = numionodes;
root_lboard[numionodes] = brd;
numionodes++;
brd = KLCF_NEXT_ANY(brd);
if (!brd)
break;

brd = find_lboard_any(brd, KLTYPE_TIO);
if (board_needs_cnode(brd->brd_type) && physical_node_map[brd->brd_nasid] < 0) {
sn_cnodeid_to_nasid[num_cnodes] = brd->brd_nasid;
physical_node_map[brd->brd_nasid] = num_cnodes++;
}
brd = find_lboard_next(brd);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions arch/ia64/sn/kernel/sn2/sn_hwperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ static int sn_topology_show(struct seq_file *s, void *d)
for_each_online_cpu(j) {
seq_printf(s, j ? ":%d" : ", dist %d",
node_distance(
cpuid_to_cnodeid(i),
cpuid_to_cnodeid(j)));
cpu_to_node(i),
cpu_to_node(j)));
}
seq_putc(s, '\n');
}
Expand Down
5 changes: 2 additions & 3 deletions arch/ia64/sn/kernel/tiocx.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,11 @@ static int __init tiocx_init(void)

bus_register(&tiocx_bus_type);

for (cnodeid = 0; cnodeid < MAX_COMPACT_NODES; cnodeid++) {
for (cnodeid = 0; cnodeid < num_cnodes; cnodeid++) {
nasid_t nasid;
int bt;

if ((nasid = cnodeid_to_nasid(cnodeid)) < 0)
break; /* No more nasids .. bail out of loop */
nasid = cnodeid_to_nasid(cnodeid);

if ((nasid & 0x1) && is_fpga_tio(nasid, &bt)) {
struct hubdev_info *hubdev;
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/sn/kernel/xpc_partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static u64 xpc_sh2_IPI_access3;


/* original protection values for each node */
u64 xpc_prot_vec[MAX_COMPACT_NODES];
u64 xpc_prot_vec[MAX_NUMNODES];


/* this partition's reserved page */
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/mmtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ static irqreturn_t
mmtimer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
int i;
mmtimer_t *base = timers + cpuid_to_cnodeid(smp_processor_id()) *
mmtimer_t *base = timers + cpu_to_node(smp_processor_id()) *
NUM_COMPARATORS;
unsigned long expires = 0;
int result = IRQ_NONE;
Expand Down Expand Up @@ -608,7 +608,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
*/
preempt_disable();

nodeid = cpuid_to_cnodeid(smp_processor_id());
nodeid = cpu_to_node(smp_processor_id());
base = timers + nodeid * NUM_COMPARATORS;
retry:
/* Don't use an allocated timer, or a deleted one that's pending */
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/snsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,15 @@ scdrv_init(void)
dev_t first_dev, dev;
nasid_t event_nasid = ia64_sn_get_console_nasid();

if (alloc_chrdev_region(&first_dev, 0, numionodes,
if (alloc_chrdev_region(&first_dev, 0, num_cnodes,
SYSCTL_BASENAME) < 0) {
printk("%s: failed to register SN system controller device\n",
__FUNCTION__);
return -ENODEV;
}
snsc_class = class_create(THIS_MODULE, SYSCTL_BASENAME);

for (cnode = 0; cnode < numionodes; cnode++) {
for (cnode = 0; cnode < num_cnodes; cnode++) {
geoid = cnodeid_get_geoid(cnode);
devnamep = devname;
format_module_id(devnamep, geo_module(geoid),
Expand Down
Loading

0 comments on commit a1e78db

Please sign in to comment.