summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/mips64/mm/init.c12
-rw-r--r--arch/mips64/sgi-ip27/TODO2
-rw-r--r--arch/mips64/sgi-ip27/ip27-memory.c200
3 files changed, 198 insertions, 16 deletions
diff --git a/arch/mips64/mm/init.c b/arch/mips64/mm/init.c
index e788d3b36..000ba906f 100644
--- a/arch/mips64/mm/init.c
+++ b/arch/mips64/mm/init.c
@@ -1,4 +1,4 @@
-/* $Id: init.c,v 1.10 2000/01/29 01:41:59 ralf Exp $
+/* $Id: init.c,v 1.11 2000/02/04 07:40:24 ralf Exp $
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
@@ -38,7 +38,7 @@
#endif
#include <asm/mmu_context.h>
-static unsigned long totalram_pages = 0;
+unsigned long totalram_pages = 0;
extern void show_net_buffers(void);
@@ -61,7 +61,7 @@ void __bad_pmd(pgd_t *pgd)
pgd_set(pgd, (pmd_t *) BAD_PAGETABLE);
}
-extern inline void pgd_init(unsigned long page)
+void pgd_init(unsigned long page)
{
unsigned long *p, *end;
@@ -93,7 +93,7 @@ pgd_t *get_pgd_slow(void)
return ret;
}
-extern inline void pmd_init(unsigned long addr)
+void pmd_init(unsigned long addr)
{
unsigned long *p, *end;
@@ -213,7 +213,7 @@ asmlinkage int sys_cacheflush(void *addr, int bytes, int cache)
*/
unsigned long empty_zero_page, zero_page_mask;
-static inline unsigned long setup_zero_pages(void)
+unsigned long setup_zero_pages(void)
{
unsigned long order, size, pg;
@@ -337,6 +337,7 @@ void show_mem(void)
#endif
}
+#ifndef CONFIG_DISCONTIGMEM
/* References to section boundaries */
extern char _ftext, _etext, _fdata, _edata;
@@ -399,6 +400,7 @@ void __init mem_init(void)
datasize >> 10,
initsize >> 10);
}
+#endif /* !CONFIG_DISCONTIGMEM */
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
diff --git a/arch/mips64/sgi-ip27/TODO b/arch/mips64/sgi-ip27/TODO
index 7f9c63a5d..5f2961f3a 100644
--- a/arch/mips64/sgi-ip27/TODO
+++ b/arch/mips64/sgi-ip27/TODO
@@ -7,3 +7,5 @@ Qlogic scsi controllers.
ip27-init.c:find_lbaord_real.
5. Is it okay to set calias space on all nodes as 0, instead of 8k as
in irix?
+6. Investigate why things do not work without the setup_test() call
+being invoked on all nodes in ip27-memory.c.
diff --git a/arch/mips64/sgi-ip27/ip27-memory.c b/arch/mips64/sgi-ip27/ip27-memory.c
index 12aba0173..6b50860e3 100644
--- a/arch/mips64/sgi-ip27/ip27-memory.c
+++ b/arch/mips64/sgi-ip27/ip27-memory.c
@@ -15,14 +15,17 @@
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/bootmem.h>
+#include <linux/swap.h>
#include <asm/page.h>
#include <asm/bootinfo.h>
#include <asm/addrspace.h>
+#include <asm/pgtable.h>
#include <asm/sn/types.h>
#include <asm/sn/addrs.h>
#include <asm/sn/klconfig.h>
#include <asm/sn/arch.h>
+#include <asm/mmzone.h>
typedef unsigned long pfn_t; /* into <asm/sn/types.h> */
#define KDM_TO_PHYS(x) ((x) & TO_PHYS_MASK) /* into asm/addrspace.h */
@@ -38,9 +41,22 @@ extern char _end;
#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
+#define SLOT_IGNORED 0xffff
short slot_lastfilled_cache[MAX_COMPACT_NODES];
unsigned short slot_psize_cache[MAX_COMPACT_NODES][MAX_MEM_SLOTS];
+static pfn_t numpages;
+static pfn_t pagenr = 0;
+
+plat_pg_data_t plat_node_data[MAX_COMPACT_NODES];
+bootmem_data_t plat_node_bdata[MAX_COMPACT_NODES];
+
+int numa_debug(void)
+{
+ printk("NUMA debug\n");
+ *(int *)0 = 0;
+ return(0);
+}
/*
* Return pfn of first free page of memory on a node. PROM may allocate
@@ -72,6 +88,14 @@ pfn_t slot_getsize(cnodeid_t node, int slot)
}
/*
+ * Return highest slot filled
+ */
+int node_getlastslot(cnodeid_t node)
+{
+ return (int) slot_lastfilled_cache[node];
+}
+
+/*
* Return the pfn of the last free page of memory on a node.
*/
pfn_t node_getmaxclick(cnodeid_t node)
@@ -85,6 +109,8 @@ pfn_t node_getmaxclick(cnodeid_t node)
*/
for (slot = (node_getnumslots(node) - 1); slot >= 0; slot--) {
if ((slot_psize = slot_getsize(node, slot))) {
+ if (slot_psize == SLOT_IGNORED)
+ continue;
/* Return the basepfn + the slot size, minus 1. */
return slot_getbasepfn(node, slot) + slot_psize - 1;
}
@@ -135,15 +161,33 @@ static pfn_t slot_psize_compute(cnodeid_t node, int slot)
pfn_t szmem(pfn_t fpage, pfn_t maxpmem)
{
- int node, slot;
- int numslots;
- pfn_t num_pages = 0;
- pfn_t slot_psize;
+ cnodeid_t node;
+ int slot, numslots;
+ pfn_t num_pages = 0, slot_psize;
+ pfn_t slot0sz = 0, nodebytes; /* Hack to detect problem configs */
+ int ignore;
for (node = 0; node < numnodes; node++) {
numslots = node_getnumslots(node);
+ ignore = nodebytes = 0;
for (slot = 0; slot < numslots; slot++) {
slot_psize = slot_psize_compute(node, slot);
+ if (slot == 0) slot0sz = slot_psize;
+ /*
+ * We need to refine the hack when we have replicated
+ * kernel text.
+ */
+ nodebytes += SLOT_SIZE;
+ if ((nodebytes >> PAGE_SHIFT) * (sizeof(struct page)) >
+ (slot0sz << PAGE_SHIFT))
+ ignore = 1;
+ if (ignore && slot_psize) {
+ printk("Ignoring slot %d onwards on node %d\n",
+ slot, node);
+ slot_psize_cache[node][slot] = SLOT_IGNORED;
+ slot = numslots;
+ continue;
+ }
num_pages += slot_psize;
slot_psize_cache[node][slot] =
(unsigned short) slot_psize;
@@ -158,6 +202,24 @@ pfn_t szmem(pfn_t fpage, pfn_t maxpmem)
}
/*
+ * HACK ALERT - Things do not work if this is not here. Maybe this is
+ * acting as a pseudocacheflush operation. The write pattern seems to
+ * be important, writing a 0 does not help.
+ */
+void setup_test(cnodeid_t node, pfn_t start, pfn_t end)
+{
+ unsigned long *ptr = __va(start << PAGE_SHIFT);
+ unsigned long size = 4 * 1024 * 1024; /* 4M L2 caches */
+
+ while (size) {
+ size -= sizeof(unsigned long);
+ *ptr = (0xdeadbeefbabeb000UL|node);
+ /* *ptr = 0; */
+ ptr++;
+ }
+}
+
+/*
* Currently, the intranode memory hole support assumes that each slot
* contains at least 32 MBytes of memory. We assume all bootmem data
* fits on the first slot.
@@ -166,16 +228,21 @@ void __init prom_meminit(void)
{
extern void mlreset(void);
cnodeid_t node;
- pfn_t slot_firstpfn, slot_lastpfn, slot_freepfn, numpages;
+ pfn_t slot_firstpfn, slot_lastpfn, slot_freepfn;
unsigned long bootmap_size;
mlreset();
numpages = szmem(0, 0);
for (node = (numnodes - 1); node >= 0; node--) {
+ NODE_DATA(node)->bdata = plat_node_bdata + node;
slot_firstpfn = slot_getbasepfn(node, 0);
slot_lastpfn = slot_firstpfn + slot_getsize(node, 0);
slot_freepfn = node_getfirstfree(node);
+ /* Foll line hack for non discontigmem; remove once discontigmem
+ * becomes the default. */
max_low_pfn = (slot_lastpfn - slot_firstpfn);
+ if (node != 0)
+ setup_test(node, slot_freepfn, slot_lastpfn);
bootmap_size = init_bootmem_node(node, slot_freepfn,
slot_firstpfn, slot_lastpfn);
free_bootmem_node(node, slot_firstpfn << PAGE_SHIFT,
@@ -199,12 +266,123 @@ prom_free_prom_memory (void)
#ifdef CONFIG_DISCONTIGMEM
-plat_pg_data_t plat_node_data[MAX_COMPACT_NODES];
+void __init paging_init(void)
+{
+ cnodeid_t node;
+ unsigned int zones_size[MAX_NR_ZONES] = {0, 0, 0};
-int numa_debug(void)
+ /* Initialize the entire pgd. */
+ pgd_init((unsigned long)swapper_pg_dir);
+ pgd_init((unsigned long)swapper_pg_dir + PAGE_SIZE / 2);
+ pmd_init((unsigned long)invalid_pmd_table);
+
+ for (node = 0; node < numnodes; node++) {
+ pfn_t start_pfn = slot_getbasepfn(node, 0);
+ pfn_t end_pfn = node_getmaxclick(node);
+
+ zones_size[ZONE_DMA] = end_pfn + 1 - start_pfn;
+ PLAT_NODE_DATA(node)->physstart = (start_pfn << PAGE_SHIFT);
+ PLAT_NODE_DATA(node)->size = (zones_size[ZONE_DMA] << PAGE_SHIFT);
+ free_area_init_node(node, NODE_DATA(node), zones_size,
+ start_pfn << PAGE_SHIFT);
+ PLAT_NODE_DATA(node)->start_mapnr =
+ (NODE_DATA(node)->node_mem_map - mem_map);
+ if ((PLAT_NODE_DATA(node)->start_mapnr +
+ PLAT_NODE_DATA(node)->size) > pagenr)
+ pagenr = PLAT_NODE_DATA(node)->start_mapnr +
+ PLAT_NODE_DATA(node)->size;
+ }
+}
+
+void __init mem_init(void)
{
- printk("NUMA debug\n");
- *(int *)0 = 0;
- return(0);
+ extern char _ftext, _etext, _fdata, _edata;
+ extern char __init_begin, __init_end;
+ extern unsigned long totalram_pages;
+ extern unsigned long setup_zero_pages(void);
+ cnodeid_t nid;
+ unsigned long tmp, ram;
+ unsigned long codesize, reservedpages, datasize, initsize;
+ int slot, numslots;
+ struct page *pg, *pslot;
+ pfn_t pgnr;
+
+ num_physpages = numpages; /* memory already sized by szmem */
+ max_mapnr = pagenr; /* already found during paging_init */
+ high_memory = (void *) __va(max_mapnr << PAGE_SHIFT);
+
+ for (nid = 0; nid < numnodes; nid++) {
+
+ /*
+ * This will free up the bootmem, ie, slot 0 memory.
+ */
+ totalram_pages += free_all_bootmem_node(nid);
+
+ /*
+ * We need to manually do the other slots.
+ */
+ pg = NODE_DATA(nid)->node_mem_map + slot_getsize(nid, 0);
+ pgnr = PLAT_NODE_DATA(nid)->start_mapnr + slot_getsize(nid, 0);
+ numslots = node_getlastslot(nid);
+ for (slot = 1; slot <= numslots; slot++) {
+ pslot = NODE_DATA(nid)->node_mem_map +
+ slot_getbasepfn(nid, slot) - slot_getbasepfn(nid, 0);
+
+ /*
+ * Mark holes in previous slot. May also want to
+ * free up the pages that hold the memmap entries.
+ */
+ while (pg < pslot) {
+ pg->flags |= (1<<PG_skip);
+ pg++; pgnr++;
+ }
+
+ /*
+ * Free valid memory in current slot.
+ */
+ pslot += slot_getsize(nid, slot);
+ while (pg < pslot) {
+ if (!page_is_ram(pgnr))
+ continue;
+ ClearPageReserved(pg);
+ atomic_set(&pg->count, 1);
+ __free_page(pg);
+ totalram_pages++;
+ pg++; pgnr++;
+ }
+ }
+ }
+
+ totalram_pages -= setup_zero_pages(); /* This comes from node 0 */
+
+ reservedpages = ram = 0;
+ for (nid = 0; nid < numnodes; nid++) {
+ for (tmp = PLAT_NODE_DATA(nid)->start_mapnr; tmp <
+ ((PLAT_NODE_DATA(nid)->start_mapnr) +
+ (PLAT_NODE_DATA(nid)->size >> PAGE_SHIFT)); tmp++) {
+ /* Ignore holes */
+ if (PageSkip(mem_map+tmp))
+ continue;
+ if (page_is_ram(tmp)) {
+ ram++;
+ if (PageReserved(mem_map+tmp))
+ reservedpages++;
+ }
+ }
+ }
+
+ codesize = (unsigned long) &_etext - (unsigned long) &_ftext;
+ datasize = (unsigned long) &_edata - (unsigned long) &_fdata;
+ initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
+
+ printk("Memory: %luk/%luk available (%ldk kernel code, %ldk reserved, "
+ "%ldk data, %ldk init)\n",
+ (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
+ ram << (PAGE_SHIFT-10),
+ codesize >> 10,
+ reservedpages << (PAGE_SHIFT-10),
+ datasize >> 10,
+ initsize >> 10);
}
-#endif
+
+#endif /* CONFIG_DISCONTIGMEM */