aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Vorontsov <anton.vorontsov@linaro.org>2012-05-11 20:17:54 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-14 11:56:05 -0400
commit24c3d2f342edbc10fee9f8ab9e0a033393686543 (patch)
tree793b36b3249ef7d352b938163aa74d43025410e5
parent2b1321e4714cc03d298e1b06c1457f8786c083ed (diff)
staging: android: persistent_ram: Make it possible to use memory outside of bootmem
This includes devices' memory (e.g. framebuffers or memory mapped EEPROMs on a local bus), as well as the normal RAM that we don't use for the main memory. For the normal (but unused) ram we could use kmaps, but this assumes highmem support, so we don't bother and just use the memory via ioremap. As a side effect, the following hack is possible: when used together with pstore_ram (new ramoops) module, we can limit the normal RAM region with mem= and then point ramoops to use the rest of the memory, e.g. mem=128M ramoops.mem_address=0x8000000 Sure, we could just reserve the region with memblock_reserve() early in the arch/ code, and then register a pstore_ram platform device pointing to the reserved region. It's still a viable option if platform wants to do so. Also, we might want to use IO accessors in case of a real device, but for now we don't bother (the old ramoops wasn't using it either, so at least we don't make things worse). Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/android/persistent_ram.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/staging/android/persistent_ram.c b/drivers/staging/android/persistent_ram.c
index ab8bff19dca..c16d7c2b1d9 100644
--- a/drivers/staging/android/persistent_ram.c
+++ b/drivers/staging/android/persistent_ram.c
@@ -23,6 +23,7 @@
23#include <linux/rslib.h> 23#include <linux/rslib.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/vmalloc.h> 25#include <linux/vmalloc.h>
26#include <asm/page.h>
26#include "persistent_ram.h" 27#include "persistent_ram.h"
27 28
28struct persistent_ram_buffer { 29struct persistent_ram_buffer {
@@ -349,10 +350,25 @@ static void *persistent_ram_vmap(phys_addr_t start, size_t size)
349 return vaddr; 350 return vaddr;
350} 351}
351 352
353static void *persistent_ram_iomap(phys_addr_t start, size_t size)
354{
355 if (!request_mem_region(start, size, "persistent_ram")) {
356 pr_err("request mem region (0x%llx@0x%llx) failed\n",
357 (unsigned long long)size, (unsigned long long)start);
358 return NULL;
359 }
360
361 return ioremap(start, size);
362}
363
352static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size, 364static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size,
353 struct persistent_ram_zone *prz) 365 struct persistent_ram_zone *prz)
354{ 366{
355 prz->vaddr = persistent_ram_vmap(start, size); 367 if (pfn_valid(start >> PAGE_SHIFT))
368 prz->vaddr = persistent_ram_vmap(start, size);
369 else
370 prz->vaddr = persistent_ram_iomap(start, size);
371
356 if (!prz->vaddr) { 372 if (!prz->vaddr) {
357 pr_err("%s: Failed to map 0x%llx pages at 0x%llx\n", __func__, 373 pr_err("%s: Failed to map 0x%llx pages at 0x%llx\n", __func__,
358 (unsigned long long)size, (unsigned long long)start); 374 (unsigned long long)size, (unsigned long long)start);