diff options
author | David Miller <davem@davemloft.net> | 2007-10-16 04:24:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:42:51 -0400 |
commit | 46644c2477c58906e95281636d04e9cc42b39352 (patch) | |
tree | fd02fa96c5f55fc94a2db71abc0c2c389a69a33e /arch/sparc64/mm/init.c | |
parent | ef229c5a5e7701ab08a6a06258f415b150348bcc (diff) |
SPARC64: SPARSEMEM_VMEMMAP support
[apw@shadowen.org: style fixups]
[apw@shadowen.org: vmemmap sparc64: convert to new config options]
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Acked-by: Christoph Lameter <clameter@sgi.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/sparc64/mm/init.c')
-rw-r--r-- | arch/sparc64/mm/init.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c index f0ab9aab308f..69538d1aa0ad 100644 --- a/arch/sparc64/mm/init.c +++ b/arch/sparc64/mm/init.c | |||
@@ -1645,6 +1645,58 @@ EXPORT_SYMBOL(_PAGE_E); | |||
1645 | unsigned long _PAGE_CACHE __read_mostly; | 1645 | unsigned long _PAGE_CACHE __read_mostly; |
1646 | EXPORT_SYMBOL(_PAGE_CACHE); | 1646 | EXPORT_SYMBOL(_PAGE_CACHE); |
1647 | 1647 | ||
1648 | #ifdef CONFIG_SPARSEMEM_VMEMMAP | ||
1649 | |||
1650 | #define VMEMMAP_CHUNK_SHIFT 22 | ||
1651 | #define VMEMMAP_CHUNK (1UL << VMEMMAP_CHUNK_SHIFT) | ||
1652 | #define VMEMMAP_CHUNK_MASK ~(VMEMMAP_CHUNK - 1UL) | ||
1653 | #define VMEMMAP_ALIGN(x) (((x)+VMEMMAP_CHUNK-1UL)&VMEMMAP_CHUNK_MASK) | ||
1654 | |||
1655 | #define VMEMMAP_SIZE ((((1UL << MAX_PHYSADDR_BITS) >> PAGE_SHIFT) * \ | ||
1656 | sizeof(struct page *)) >> VMEMMAP_CHUNK_SHIFT) | ||
1657 | unsigned long vmemmap_table[VMEMMAP_SIZE]; | ||
1658 | |||
1659 | int __meminit vmemmap_populate(struct page *start, unsigned long nr, int node) | ||
1660 | { | ||
1661 | unsigned long vstart = (unsigned long) start; | ||
1662 | unsigned long vend = (unsigned long) (start + nr); | ||
1663 | unsigned long phys_start = (vstart - VMEMMAP_BASE); | ||
1664 | unsigned long phys_end = (vend - VMEMMAP_BASE); | ||
1665 | unsigned long addr = phys_start & VMEMMAP_CHUNK_MASK; | ||
1666 | unsigned long end = VMEMMAP_ALIGN(phys_end); | ||
1667 | unsigned long pte_base; | ||
1668 | |||
1669 | pte_base = (_PAGE_VALID | _PAGE_SZ4MB_4U | | ||
1670 | _PAGE_CP_4U | _PAGE_CV_4U | | ||
1671 | _PAGE_P_4U | _PAGE_W_4U); | ||
1672 | if (tlb_type == hypervisor) | ||
1673 | pte_base = (_PAGE_VALID | _PAGE_SZ4MB_4V | | ||
1674 | _PAGE_CP_4V | _PAGE_CV_4V | | ||
1675 | _PAGE_P_4V | _PAGE_W_4V); | ||
1676 | |||
1677 | for (; addr < end; addr += VMEMMAP_CHUNK) { | ||
1678 | unsigned long *vmem_pp = | ||
1679 | vmemmap_table + (addr >> VMEMMAP_CHUNK_SHIFT); | ||
1680 | void *block; | ||
1681 | |||
1682 | if (!(*vmem_pp & _PAGE_VALID)) { | ||
1683 | block = vmemmap_alloc_block(1UL << 22, node); | ||
1684 | if (!block) | ||
1685 | return -ENOMEM; | ||
1686 | |||
1687 | *vmem_pp = pte_base | __pa(block); | ||
1688 | |||
1689 | printk(KERN_INFO "[%p-%p] page_structs=%lu " | ||
1690 | "node=%d entry=%lu/%lu\n", start, block, nr, | ||
1691 | node, | ||
1692 | addr >> VMEMMAP_CHUNK_SHIFT, | ||
1693 | VMEMMAP_SIZE >> VMEMMAP_CHUNK_SHIFT); | ||
1694 | } | ||
1695 | } | ||
1696 | return 0; | ||
1697 | } | ||
1698 | #endif /* CONFIG_SPARSEMEM_VMEMMAP */ | ||
1699 | |||
1648 | static void prot_init_common(unsigned long page_none, | 1700 | static void prot_init_common(unsigned long page_none, |
1649 | unsigned long page_shared, | 1701 | unsigned long page_shared, |
1650 | unsigned long page_copy, | 1702 | unsigned long page_copy, |