From: Bryan Freed <bfreed@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: sergiu@chromium.org, akpm@linux-foundation.org, msb@chromium.org,
marco.stornelli@gmail.com, seiji.aguchi@hds.com,
Bryan Freed <bfreed@chromium.org>
Subject: [PATCH] ramoops: Add support for ARM systems.
Date: Fri, 28 Oct 2011 16:21:50 -0700 [thread overview]
Message-ID: <1319844110-23062-2-git-send-email-bfreed@chromium.org> (raw)
In-Reply-To: <1319844110-23062-1-git-send-email-bfreed@chromium.org>
The ramoops driver erroneously (I belive) uses ioremap() to map physical RAM
to a virtual address. This happens to work on x86 which has this additional
support, but it does not work on ARM.
Add support for ARM by using xlate_dev_mem_ptr() for systems (like ARM) where
page_is_ram() returns true. This is what the /dev/mem driver uses, and we use
that driver to access the data.
Signed-off-by: Bryan Freed <bfreed@chromium.org>
---
drivers/char/ramoops.c | 67 +++++++++++++++++++++++++++++++++++++----------
1 files changed, 52 insertions(+), 15 deletions(-)
diff --git a/drivers/char/ramoops.c b/drivers/char/ramoops.c
index 810aff9..7c50309 100644
--- a/drivers/char/ramoops.c
+++ b/drivers/char/ramoops.c
@@ -31,6 +31,7 @@
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/ramoops.h>
+#include <linux/mm.h>
#define RAMOOPS_KERNMSG_HDR "===="
#define MIN_MEM_SIZE 4096UL
@@ -113,6 +114,53 @@ static void ramoops_do_dump(struct kmsg_dumper *dumper,
cxt->count = (cxt->count + 1) % cxt->max_count;
}
+void __weak unxlate_dev_mem_ptr(unsigned long phys, void *addr)
+{
+}
+
+/*
+ * For systems that recognize the region as RAM (eg, ARM), the
+ * region is already reserved and mapped. Just xlate it here
+ * as /dev/mem does it in drivers/char/mem.c.
+ *
+ * For systems that do not recognize the region as RAM (eg, x86),
+ * reserve and map the region here so /dev/mem can xlate it.
+ */
+static int map_context(struct ramoops_context *cxt)
+{
+ if (page_is_ram(cxt->phys_addr << PAGE_SHIFT)) {
+ cxt->virt_addr = xlate_dev_mem_ptr(cxt->phys_addr);
+ if (!cxt->virt_addr) {
+ pr_err("xlate_dev_mem_ptr failed\n");
+ return -EINVAL;
+ }
+ } else {
+ if (!request_mem_region(cxt->phys_addr, cxt->size, "ramoops")) {
+ pr_err("request mem region failed\n");
+ return -EINVAL;
+ }
+
+ cxt->virt_addr = ioremap(cxt->phys_addr, cxt->size);
+ if (!cxt->virt_addr) {
+ pr_err("ioremap failed\n");
+ release_mem_region(cxt->phys_addr, cxt->size);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+static void unmap_context(struct ramoops_context *cxt)
+{
+ if (page_is_ram(cxt->phys_addr << PAGE_SHIFT)) {
+ unxlate_dev_mem_ptr(cxt->phys_addr, cxt->virt_addr);
+ } else {
+ iounmap(cxt->virt_addr);
+ release_mem_region(cxt->phys_addr, cxt->size);
+ }
+}
+
static int __init ramoops_probe(struct platform_device *pdev)
{
struct ramoops_platform_data *pdata = pdev->dev.platform_data;
@@ -156,17 +204,9 @@ static int __init ramoops_probe(struct platform_device *pdev)
record_size = pdata->record_size;
dump_oops = pdata->dump_oops;
- if (!request_mem_region(cxt->phys_addr, cxt->size, "ramoops")) {
- pr_err("request mem region failed\n");
- err = -EINVAL;
+ err = map_context(cxt);
+ if (err)
goto fail3;
- }
-
- cxt->virt_addr = ioremap(cxt->phys_addr, cxt->size);
- if (!cxt->virt_addr) {
- pr_err("ioremap failed\n");
- goto fail2;
- }
cxt->dump.dump = ramoops_do_dump;
err = kmsg_dump_register(&cxt->dump);
@@ -178,9 +218,7 @@ static int __init ramoops_probe(struct platform_device *pdev)
return 0;
fail1:
- iounmap(cxt->virt_addr);
-fail2:
- release_mem_region(cxt->phys_addr, cxt->size);
+ unmap_context(cxt);
fail3:
return err;
}
@@ -192,8 +230,7 @@ static int __exit ramoops_remove(struct platform_device *pdev)
if (kmsg_dump_unregister(&cxt->dump) < 0)
pr_warn("could not unregister kmsg_dumper\n");
- iounmap(cxt->virt_addr);
- release_mem_region(cxt->phys_addr, cxt->size);
+ unmap_context(cxt);
return 0;
}
--
1.7.3.1
next prev parent reply other threads:[~2011-10-28 23:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-28 23:21 [PATCH] ramoops appears geared to not support ARM Bryan Freed
2011-10-28 23:21 ` Bryan Freed [this message]
2011-10-29 8:39 ` Marco Stornelli
2011-10-29 9:34 ` Russell King - ARM Linux
2011-10-29 11:04 ` Marco Stornelli
2011-10-29 11:55 ` Russell King - ARM Linux
2011-10-29 12:42 ` Marco Stornelli
2011-10-29 12:53 ` Russell King - ARM Linux
2011-10-29 14:22 ` Marco Stornelli
[not found] ` <CAEYUcX1PUgniJLqYXKM5pf_9T06OPFg4q0ZUCFc8Deu1J_R9-A@mail.gmail.com>
2011-10-30 11:33 ` Marco Stornelli
2011-10-31 6:03 ` Bryan Freed
2011-10-31 8:57 ` Marco Stornelli
2011-10-31 23:03 ` Bryan Freed
2011-11-01 8:52 ` Marco Stornelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1319844110-23062-2-git-send-email-bfreed@chromium.org \
--to=bfreed@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marco.stornelli@gmail.com \
--cc=msb@chromium.org \
--cc=seiji.aguchi@hds.com \
--cc=sergiu@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®