linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	 Paul Burton <paulburton@kernel.org>,
	 Brendan Higgins <brendan.higgins@linux.dev>,
	 David Gow <davidgow@google.com>, Rae Moar <rmoar@google.com>
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	linux-mm@kvack.org
Subject: [PATCH 1/2] MIPS: mm: Avoid blocking DMA zone with memory map memblock allocation
Date: Wed, 12 Feb 2025 13:49:12 +0100	[thread overview]
Message-ID: <20250212-kunit-mips-v1-1-eb49c9d76615@linutronix.de> (raw)
In-Reply-To: <20250212-kunit-mips-v1-0-eb49c9d76615@linutronix.de>

On MIPS the memblock allocator is configured to allocate bottom-up.
The memory map is allocated by the mm core through memblock and uses
MEMBLOCK_LOW_LIMIT as minimal address. This constant is defined as zero because
it assumes that "we are using top down, so it is safe to use 0 here".
So the memory map is allocated as close to 0 as possible, right where the DMA
zone will end up. As the memory map is allocated permanently and also larger
than the DMA zone, it makes the DMA zone unusable.

Temporarily switch to top-down allocation for the call to free_area_init() so
the memory map allocation does not fall into the DMA zone.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

---

Another solution would be to change alloc_node_mem_map() in the mm core
to use __pa(MAX_DMA_ADDRESS) for the min_addr when calling
memmap_alloc(), as is done by the other callers of memmap_alloc().
Looping in the memblock maintainers for discussion.

This is reliably reproducible in QEMU. To reproduce, use the kunit
configuration from patch 2 of this series and run it like so:

./tools/testing/kunit/kunit.py run --arch mips64el --cross_compile $CROSS_COMPILE cs_dsp_wmfwV3_err_halo.wmfw_v2_coeff_description_exceeds_block

To: Mike Rapoport <rppt@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
---
 arch/mips/mm/init.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 4583d1a2a73e7ff36a42f6017d9aef008e45df6e..712eb4762917261416f1fca2d9925a42107ef6c1 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -435,7 +435,9 @@ void __init paging_init(void)
 #endif
 	high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
 
+	memblock_set_bottom_up(false);
 	free_area_init(max_zone_pfns);
+	memblock_set_bottom_up(true);
 }
 
 #ifdef CONFIG_64BIT

-- 
2.48.1



      reply	other threads:[~2025-02-12 12:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12 12:49 [PATCH 0/2] kunit: qemu_configs: Add MIPS configurations Thomas Weißschuh
2025-02-12 12:49 ` Thomas Weißschuh [this message]

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=20250212-kunit-mips-v1-1-eb49c9d76615@linutronix.de \
    --to=thomas.weissschuh@linutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=brendan.higgins@linux.dev \
    --cc=davidgow@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=paulburton@kernel.org \
    --cc=rmoar@google.com \
    --cc=rppt@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /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