From patchwork Sat May 12 00:17:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8540 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 5BAAC23E20 for ; Sat, 12 May 2012 00:19:23 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 16E53A18C2B for ; Sat, 12 May 2012 00:19:23 +0000 (UTC) Received: by yenq6 with SMTP id q6so4055006yen.11 for ; Fri, 11 May 2012 17:19:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:x-gm-message-state; bh=vkKB1pMq3bkSrEiqaDA1NWR5qNvoHIvzOA3/zvB0oX4=; b=WpZYxyrZofygtcwxIVuDbNiEm0Wn4T3cvFQpF+biku4aoyl5DyXEZ/nmjswxb3yTHb 6QZPUowtiypq6W6Pw+orHJwlatrZZQ62aDALdLTzKYh0dINq4N4LcHOehTufFiwAovrb iNpb5nxb/+rZm7hoADRmctygPqCAYBUzAkjZdUMupnIKfbvaPR0YeU4cy5ibRnSQRLKX ORkSows6EvOVucFOvlMIIVquvWVOR6vX7GAVoTYQOz0fpD9eYxmcvKrFQs22kJhUjyx7 iXT6t9o2t9x6qhpD1jm723tzD4Jdy1QJoE+Y33m4LW9P+75K5ssIvBfn2wZjE+92Oo1x BNCA== Received: by 10.50.220.136 with SMTP id pw8mr11552igc.1.1336781962410; Fri, 11 May 2012 17:19:22 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.73.147 with SMTP id q19csp211519ibj; Fri, 11 May 2012 17:19:21 -0700 (PDT) Received: by 10.68.132.103 with SMTP id ot7mr282415pbb.59.1336781961745; Fri, 11 May 2012 17:19:21 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id p7si16168274pbk.254.2012.05.11.17.19.21 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 May 2012 17:19:21 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by mail-pb0-f50.google.com with SMTP id rr4so4860541pbb.37 for ; Fri, 11 May 2012 17:19:21 -0700 (PDT) Received: by 10.68.192.39 with SMTP id hd7mr303175pbc.49.1336781961458; Fri, 11 May 2012 17:19:21 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id pn5sm14218955pbb.71.2012.05.11.17.19.19 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 May 2012 17:19:20 -0700 (PDT) Date: Fri, 11 May 2012 17:17:54 -0700 From: Anton Vorontsov To: Greg Kroah-Hartman , Kees Cook , Colin Cross Cc: Arnd Bergmann , John Stultz , arve@android.com, Rebecca Schultz Zavin , Jesper Juhl , Randy Dunlap , Stephen Boyd , Thomas Meyer , Andrew Morton , Marco Stornelli , WANG Cong , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: [PATCH 06/11] persistent_ram: Make it possible to use memory outside of bootmem Message-ID: <20120512001754.GF14782@lizard> References: <20120512001506.GA8653@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120512001506.GA8653@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQl8SpMeF2oip0TzY1bRXmeUGJIm7obyxqjUgR++7vWP8ufbqPyjQnPzlewGX0KeOzdbrKS3 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 --- drivers/staging/android/persistent_ram.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/persistent_ram.c b/drivers/staging/android/persistent_ram.c index ab8bff1..c16d7c2 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);