devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
	linux-kernel@vger.kernel.org,
	"Tom Lendacky" <thomas.lendacky@amd.com>,
	"Brijesh Singh" <brijesh.singh@amd.com>,
	devicetree@vger.kernel.org,
	"Albert Herranz" <albert_herranz@yahoo.es>,
	linux-gpio@vger.kernel.org,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Borislav Petkov" <bp@suse.de>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 1/6] resource: Extend the PPC32 reserved memory hack
Date: Sat, 27 Jan 2018 09:00:34 +0100	[thread overview]
Message-ID: <20180127080034.byqfvrwyuibrc4ii@latitude> (raw)
In-Reply-To: <87po60uk1y.fsf@concordia.ellerman.id.au>

[-- Attachment #1: Type: text/plain, Size: 3227 bytes --]

On Wed, Jan 24, 2018 at 12:23:05PM +1100, Michael Ellerman wrote:
> Jonathan Neuschäfer <j.neuschaefer@gmx.net> writes:
[...]
> > Do you have any pointer on how to implement discontiguous memory
> > support? CONFIG_ARCH_SPARSEMEM_ENABLE seems relevant.
> 
> I'm not really sure what the key impediment to it working is.
> 
> You don't need to go all the way to SPARSEMEM, there is DISCONTIGMEM
> which IIUI is quite a bit simpler.
> 
> I'd actually be interested to know what happens (ie. breaks) if you just
> add the two memblocks and leave the hole in between. Is it the generic
> code that breaks or is it something in the powerpc code? If it's the
> later maybe we can do a small fix/hack to work around that.

Ok, I did some experimentation.

First, I made wii_memory_fixups return early, before actually doing
anything[1].

[    0.000000] __ioremap(): phys addr 0xc003000 is RAM lr flipper_pic_init
[    0.000000] flipper-pic: controller at 0x0c003000 mapped to 0x  (null)
[    0.000000] Unable to handle kernel paging request for data at address 0x00000004

* __ioremap_caller detects overlap with RAM like this: p < virt_to_phys(high_memory)
* flipper_pic_init gets NULL from ioremap, but doesn't check for NULL


Then I hacked up __ioremap_caller to use memblock_is_map_memory[2],
because it considers memblocks correctly. The result was that the system
boots further, but then enters the sleep mode where the power LED shines
yellow. In this mode the ARM runs but the PPC doesn't. The same thing
would happen if GPIO 3 ("DC_DC"[3]) was pulled low. These are the last few
lines:

[    0.770324] io scheduler mq-deadline registered
[    0.772472] io scheduler kyber registered

I don't know what exactly is triggering this effect.


Thanks for your help,
Jonathan Neuschäfer


[1]: diff --git a/arch/powerpc/platforms/embedded6xx/wii.c b/arch/powerpc/platforms/embedded6xx/wii.c
index 6e6db1e16d71..cddd5606a63d 100644
--- a/arch/powerpc/platforms/embedded6xx/wii.c
+++ b/arch/powerpc/platforms/embedded6xx/wii.c
@@ -81,6 +81,9 @@ void __init wii_memory_fixups(void)
 	BUG_ON(memblock.memory.cnt != 2);
 	BUG_ON(!page_aligned(p[0].base) || !page_aligned(p[1].base));
 
+	/* don't fix the memory map */
+	return;
+
 	/* trim unaligned tail */
 	memblock_remove(ALIGN(p[1].base + p[1].size, PAGE_SIZE),
 			(phys_addr_t)ULLONG_MAX);
[2]: diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index f6c7f54c0515..bff581003c50 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -154,8 +154,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, unsigned long flags,
 	 * Don't allow anybody to remap normal RAM that we're using.
 	 * mem_init() sets high_memory so only do the check after that.
 	 */
-	if (slab_is_available() && (p < virt_to_phys(high_memory)) &&
-	    !(__allow_ioremap_reserved && memblock_is_region_reserved(p, size))) {
+	if (slab_is_available() && memblock_is_map_memory(p)) {
 		printk("__ioremap(): phys addr 0x%llx is RAM lr %ps\n",
 		       (unsigned long long)p, __builtin_return_address(0));
 		return NULL;
[3]: http://wiibrew.org/wiki/Hardware/Hollywood_GPIOs

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2018-01-27  8:00 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 ` [PATCH v2 1/6] resource: Extend the PPC32 reserved memory hack Jonathan Neuschäfer
     [not found]   ` <20180122050411.32460-2-j.neuschaefer-hi6Y0CQ0nG0@public.gmane.org>
2018-01-23 12:58     ` 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 [this message]
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=20180127080034.byqfvrwyuibrc4ii@latitude \
    --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=mpe@ellerman.id.au \
    --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).