diff --git a/drivers/staging/android/persistent_ram.c b/drivers/staging/android/persistent_ram.c index ab8bff19dca0f18c54460970612b362add98d1b5..c16d7c2b1d9789541245144a7a89f5bc5f43be94 100644 --- a/drivers/staging/android/persistent_ram.c +++ b/drivers/staging/android/persistent_ram.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "persistent_ram.h" struct persistent_ram_buffer { @@ -349,10 +350,25 @@ static void *persistent_ram_vmap(phys_addr_t start, size_t size) return vaddr; } +static void *persistent_ram_iomap(phys_addr_t start, size_t size) +{ + if (!request_mem_region(start, size, "persistent_ram")) { + pr_err("request mem region (0x%llx@0x%llx) failed\n", + (unsigned long long)size, (unsigned long long)start); + return NULL; + } + + return ioremap(start, size); +} + static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size, struct persistent_ram_zone *prz) { - prz->vaddr = persistent_ram_vmap(start, size); + if (pfn_valid(start >> PAGE_SHIFT)) + prz->vaddr = persistent_ram_vmap(start, size); + else + prz->vaddr = persistent_ram_iomap(start, size); + if (!prz->vaddr) { pr_err("%s: Failed to map 0x%llx pages at 0x%llx\n", __func__, (unsigned long long)size, (unsigned long long)start);