devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
To: linux-kernel@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, linux-gpio@vger.kernel.org,
	devicetree@vger.kernel.org,
	"Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
	"Albert Herranz" <albert_herranz@yahoo.es>,
	"Tom Lendacky" <thomas.lendacky@amd.com>,
	"Borislav Petkov" <bp@suse.de>,
	"Brijesh Singh" <brijesh.singh@amd.com>,
	"Thomas Gleixner" <tglx@linutronix.de>
Subject: [PATCH v2 1/6] resource: Extend the PPC32 reserved memory hack
Date: Mon, 22 Jan 2018 06:04:06 +0100	[thread overview]
Message-ID: <20180122050411.32460-2-j.neuschaefer@gmx.net> (raw)
In-Reply-To: <20180122050411.32460-1-j.neuschaefer@gmx.net>

On the Nintendo Wii, there are two ranges of physical memory, and MMIO
in between, but Linux on ppc32 doesn't support discontiguous memory.
Therefore a hack was introduced in commit c5df7f775148 ("powerpc: allow
ioremap within reserved memory regions") and commit de32400dd26e ("wii:
use both mem1 and mem2 as ram"):

 - Treat the area from the start of the first memory area (MEM1) to the
   end of the second (MEM2) as one big memory area, but mark the part
   that doesn't belong to MEM1 or MEM2 as reserved.
 - Only on the Wii, allow ioremap to be used on reserved memory.

This hack, however, doesn't account for the "resource"-based API in
kernel/resource.c, because __request_region performs its own checks.

Extend the hack to kernel/resource.c, to allow more drivers to allocate
their MMIO regions on the Wii.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Cc: Albert Herranz <albert_herranz@yahoo.es>
---

v2:
- CC Albert Herranz, who introduced this hack in 2009.
---
 kernel/resource.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index 54ba6de3757c..bb3d329329da 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1134,6 +1134,24 @@ resource_size_t resource_alignment(struct resource *res)
 
 static DECLARE_WAIT_QUEUE_HEAD(muxed_resource_wait);
 
+/*
+ * On some ppc32 platforms (Nintendo Wii), reserved memory is used to work
+ * around the fact that Linux doesn't support discontiguous memory (all memory
+ * is treated as one large area with holes punched in it), and reserved memory
+ * is allowed to be allocated.
+ */
+#ifdef CONFIG_PPC32
+static bool conflict_ignored(struct resource *conflict)
+{
+	extern int __allow_ioremap_reserved;
+
+	return __allow_ioremap_reserved &&
+		(conflict->flags & IORESOURCE_SYSRAM);
+}
+#else
+static bool conflict_ignored(struct resource *conflict) { return false; }
+#endif
+
 /**
  * __request_region - create a new busy resource region
  * @parent: parent resource descriptor
@@ -1166,8 +1184,9 @@ struct resource * __request_region(struct resource *parent,
 		res->desc = parent->desc;
 
 		conflict = __request_resource(parent, res);
-		if (!conflict)
+		if (!conflict || conflict_ignored(conflict))
 			break;
+
 		if (conflict != parent) {
 			if (!(conflict->flags & IORESOURCE_BUSY)) {
 				parent = conflict;
-- 
2.15.1

  reply	other threads:[~2018-01-22  5:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22  5:04 [PATCH v2 0/6] Nintendo Wii GPIO driver Jonathan Neuschäfer
2018-01-22  5:04 ` Jonathan Neuschäfer [this message]
     [not found]   ` <20180122050411.32460-2-j.neuschaefer-hi6Y0CQ0nG0@public.gmane.org>
2018-01-23 12:58     ` [PATCH v2 1/6] resource: Extend the PPC32 reserved memory hack Michael Ellerman
2018-01-23 16:37       ` Jonathan Neuschäfer
2018-01-24  1:23         ` Michael Ellerman
2018-01-27  8:00           ` Jonathan Neuschäfer
2018-01-22  5:04 ` [PATCH v2 2/6] powerpc: wii: Explicitly configure GPIO owner for poweroff pin Jonathan Neuschäfer
2018-01-22  5:04 ` [PATCH v2 3/6] gpio: Add GPIO driver for Nintendo Wii Jonathan Neuschäfer
2018-01-28 17:31   ` Andy Shevchenko
2018-01-31  8:37     ` Jonathan Neuschäfer
2018-02-07 12:29   ` Linus Walleij
2018-02-07 12:54     ` Jonathan Neuschäfer
2018-01-22  5:04 ` [PATCH v2 4/6] dt-bindings: gpio: Add binding for Wii GPIO controller Jonathan Neuschäfer
2018-02-07 12:26   ` Linus Walleij
2018-01-22  5:04 ` [PATCH v2 5/6] powerpc: wii.dts: Add ngpios property Jonathan Neuschäfer
     [not found] ` <20180122050411.32460-1-j.neuschaefer-hi6Y0CQ0nG0@public.gmane.org>
2018-01-22  5:04   ` [PATCH v2 6/6] powerpc: wii.dts: Add GPIO line names Jonathan Neuschäfer

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=20180122050411.32460-2-j.neuschaefer@gmx.net \
    --to=j.neuschaefer@gmx.net \
    --cc=albert_herranz@yahoo.es \
    --cc=bp@suse.de \
    --cc=brijesh.singh@amd.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    /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;
as well as URLs for NNTP newsgroup(s).