linux/arch/arc/mm/init.c
Linus Torvalds e30f419245 ARC port updates for Linux 3.10 (part 1)
* Support for two new platforms based on ARC700
  - Abilis TB10x SoC [Chritisian/Pierrick]
  - Simulator only System-C Model [Mischa]
 
 * ARC specific MM improvements
  - Avoid full TLB flush (ASID increment) on munmap (even single page)
  - VIPT Cache Flushing improvements
    + Delayed dcache flush for non-aliasing dcache (big performance boost)
    + icache flush aliasing agnostic (no need to kill all possible aliases)
 
 * Others
  - Avoid needless rebuild of DTB files for every kernel build
  - Remove builtin cmdline as that is already provided by DeviceTree/bootargs
  - Fixing unaligned access emulation corner case
  - checkpatch fixes [Sachin]
  - Various fixlets [Noam]
  - Minor build failures/cleanups
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQIcBAABAgAGBQJRiydEAAoJEGnX8d3iisJewBkQAJ/cvIjrIuMMdeDo0bokzZN2
 bfsG8U+V7S0CKjqLyUD1bMRXo7rTgus8hp/klVORRXoAwSKiWhkj0p6dqJjCGUGc
 LqtEPlxaLR1X+pe5wKtpB3j6kTpRwictVhFUqkFACUxGZx1GbYFxdeL8+3oDsepW
 lwidBYgoya+Q4puRfmY/sCTtVhJlwTUi6g0lmpaEPWc3T2s83/u1GnlVBYd9B7yA
 fCYkUceC2ZnuRMfH00sRsjQ3USyyYptGpY8U1nv9STFJ3fC+EestBPppAAwAzcm0
 iiRgo3s314EzfeNRgzjjHrbULnVUJWkrdFXPisWepyPyVjsgnVr84YkO3kiEN6l7
 JM1cUCvJUbKZaOb2iUwrlPOqISNjCyY9QZWwqW6PCG3TBpfQsJM2mnXKnPLvV2v2
 5Ttba4+ETZ3rn4pPIuTeC6REr0aV/Zl1LKeWuk8PXz4aljWrlOrifBN6QkXWr4HU
 4z6X3j2nw4T2LzqwbNYF+xLaDaZZpV8UdvQwOkliCxZ04myx135ImvgOim7Hh9j+
 Ow1Jp9mRZha/44qM3jXdZ6Cv55pEOR4oQJsl6OBNUXgb5bnDcFHz1UpZtzoZ2V+s
 RPozsfnleNXxDIJlCGK96+PG5qVTRQvklowsz6aTP8r+EEbQnrRlnrhi82cQWqnM
 sMxzN320zrt/MWXxec89
 =WeDp
 -----END PGP SIGNATURE-----

Merge tag 'arc-v3.10-rc1-part1' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc

Pull ARC port updates from Vineet Gupta:
 "Support for two new platforms based on ARC700:
   - Abilis TB10x SoC [Chritisian/Pierrick]
   - Simulator only System-C Model [Mischa]

  ARC specific MM improvements:
   - Avoid full TLB flush (ASID increment) on munmap (even single page)
   - VIPT Cache Flushing improvements
     + Delayed dcache flush for non-aliasing dcache (big performance boost)
     + icache flush aliasing agnostic (no need to kill all possible aliases)

  Others:
   - Avoid needless rebuild of DTB files for every kernel build
   - Remove builtin cmdline as that is already provided by DeviceTree/bootargs
   - Fixing unaligned access emulation corner case
   - checkpatch fixes [Sachin]
   - Various fixlets [Noam]
   - Minor build failures/cleanups"

* tag 'arc-v3.10-rc1-part1' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc: (35 commits)
  ARC: [mm] Lazy D-cache flush (non aliasing VIPT)
  ARC: [mm] micro-optimize page size icache invalidate
  ARC: [mm] remove the pessimistic all-alias-invalidate icache helpers
  ARC: [mm] consolidate icache/dcache sync code
  ARC: [mm] optimise icache flush for kernel mappings
  ARC: [mm] optimise icache flush for user mappings
  ARC: [mm] optimize needless full mm TLB flush on munmap
  ARC: Add support for nSIM OSCI System C model
  ARC: [TB10x] Adapt device tree to new compatible string
  ARC: [TB10x] Add support for TB10x platform
  ARC: [TB10x] Device tree of TB100 and TB101 Development Kits
  ARC: Prepare interrupt code for external controllers
  ARC: Allow embedded arc-intc to be properly placed in DT intc hierarchy
  ARC: [cmdline] Don't overwrite u-boot provided bootargs
  ARC: [cmdline] Remove CONFIG_CMDLINE
  ARC: [plat-arcfpga] defconfig update
  ARC: unaligned access emulation broken if callee-reg dest of LD/ST
  ARC: unaligned access emulation error handling consolidation
  ARC: Debug/crash-printing Improvements
  ARC: fix typo with clock speed
  ...
2013-05-09 14:36:27 -07:00

166 lines
4.6 KiB
C

/*
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/bootmem.h>
#include <linux/memblock.h>
#include <linux/swap.h>
#include <linux/module.h>
#include <asm/page.h>
#include <asm/pgalloc.h>
#include <asm/sections.h>
#include <asm/arcregs.h>
pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE);
char empty_zero_page[PAGE_SIZE] __aligned(PAGE_SIZE);
EXPORT_SYMBOL(empty_zero_page);
/* Default tot mem from .config */
static unsigned long arc_mem_sz = 0x20000000; /* some default */
/* User can over-ride above with "mem=nnn[KkMm]" in cmdline */
static int __init setup_mem_sz(char *str)
{
arc_mem_sz = memparse(str, NULL) & PAGE_MASK;
/* early console might not be setup yet - it will show up later */
pr_info("\"mem=%s\": mem sz set to %ldM\n", str, TO_MB(arc_mem_sz));
return 0;
}
early_param("mem", setup_mem_sz);
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
{
arc_mem_sz = size & PAGE_MASK;
pr_info("Memory size set via devicetree %ldM\n", TO_MB(arc_mem_sz));
}
/*
* First memory setup routine called from setup_arch()
* 1. setup swapper's mm @init_mm
* 2. Count the pages we have and setup bootmem allocator
* 3. zone setup
*/
void __init setup_arch_memory(void)
{
unsigned long zones_size[MAX_NR_ZONES] = { 0, 0 };
unsigned long end_mem = CONFIG_LINUX_LINK_BASE + arc_mem_sz;
init_mm.start_code = (unsigned long)_text;
init_mm.end_code = (unsigned long)_etext;
init_mm.end_data = (unsigned long)_edata;
init_mm.brk = (unsigned long)_end;
/*
* We do it here, so that memory is correctly instantiated
* even if "mem=xxx" cmline over-ride is given and/or
* DT has memory node. Each causes an update to @arc_mem_sz
* and we finally add memory one here
*/
memblock_add(CONFIG_LINUX_LINK_BASE, arc_mem_sz);
/*------------- externs in mm need setting up ---------------*/
/* first page of system - kernel .vector starts here */
min_low_pfn = PFN_DOWN(CONFIG_LINUX_LINK_BASE);
/* Last usable page of low mem (no HIGHMEM yet for ARC port) */
max_low_pfn = max_pfn = PFN_DOWN(end_mem);
max_mapnr = num_physpages = max_low_pfn - min_low_pfn;
/*------------- reserve kernel image -----------------------*/
memblock_reserve(CONFIG_LINUX_LINK_BASE,
__pa(_end) - CONFIG_LINUX_LINK_BASE);
memblock_dump_all();
/*-------------- node setup --------------------------------*/
memset(zones_size, 0, sizeof(zones_size));
zones_size[ZONE_NORMAL] = num_physpages;
/*
* We can't use the helper free_area_init(zones[]) because it uses
* PAGE_OFFSET to compute the @min_low_pfn which would be wrong
* when our kernel doesn't start at PAGE_OFFSET, i.e.
* PAGE_OFFSET != CONFIG_LINUX_LINK_BASE
*/
free_area_init_node(0, /* node-id */
zones_size, /* num pages per zone */
min_low_pfn, /* first pfn of node */
NULL); /* NO holes */
}
/*
* mem_init - initializes memory
*
* Frees up bootmem
* Calculates and displays memory available/used
*/
void __init mem_init(void)
{
int codesize, datasize, initsize, reserved_pages, free_pages;
int tmp;
high_memory = (void *)(CONFIG_LINUX_LINK_BASE + arc_mem_sz);
totalram_pages = free_all_bootmem();
/* count all reserved pages [kernel code/data/mem_map..] */
reserved_pages = 0;
for (tmp = 0; tmp < max_mapnr; tmp++)
if (PageReserved(mem_map + tmp))
reserved_pages++;
/* XXX: nr_free_pages() is equivalent */
free_pages = max_mapnr - reserved_pages;
/*
* For the purpose of display below, split the "reserve mem"
* kernel code/data is already shown explicitly,
* Show any other reservations (mem_map[ ] et al)
*/
reserved_pages -= (((unsigned int)_end - CONFIG_LINUX_LINK_BASE) >>
PAGE_SHIFT);
codesize = _etext - _text;
datasize = _end - _etext;
initsize = __init_end - __init_begin;
pr_info("Memory Available: %dM / %ldM (%dK code, %dK data, %dK init, %dK reserv)\n",
PAGES_TO_MB(free_pages),
TO_MB(arc_mem_sz),
TO_KB(codesize), TO_KB(datasize), TO_KB(initsize),
PAGES_TO_KB(reserved_pages));
}
/*
* free_initmem: Free all the __init memory.
*/
void __init_refok free_initmem(void)
{
free_initmem_default(0);
}
#ifdef CONFIG_BLK_DEV_INITRD
void __init free_initrd_mem(unsigned long start, unsigned long end)
{
free_reserved_area(start, end, 0, "initrd");
}
#endif
#ifdef CONFIG_OF_FLATTREE
void __init early_init_dt_setup_initrd_arch(unsigned long start,
unsigned long end)
{
pr_err("%s(%lx, %lx)\n", __func__, start, end);
}
#endif /* CONFIG_OF_FLATTREE */