linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] openrisc: Fix boot oops when DEBUG_VM is enabled
@ 2020-06-17  9:02 Stafford Horne
  2020-06-17 12:04 ` Michel Lespinasse
  0 siblings, 1 reply; 2+ messages in thread
From: Stafford Horne @ 2020-06-17  9:02 UTC (permalink / raw)
  To: LKML
  Cc: Stafford Horne, Michel Lespinasse, Jonas Bonn,
	Stefan Kristiansson, Jason Gunthorpe, Steven Price,
	Thomas Hellstrom, Robin Murphy, Andrew Morton, Vlastimil Babka,
	Daniel Jordan, openrisc

Since v5.8-rc1 OpenRISC Linux fails to boot when DEBUG_VM is enabled.
This has been bisected to commit 42fc541404f2 ("mmap locking API: add
mmap_assert_locked() and mmap_assert_write_locked()").

The added locking checks exposed the issue that OpenRISC was not taking
this mmap lock when during page walks for DMA operations.  This patch
locks and unlocks the mmap lock for page walking.

Fixes: 42fc541404f2 ("mmap locking API: add mmap_assert_locked() and mmap_assert_write_locked()"
Cc: Michel Lespinasse <walken@google.com>
Signed-off-by: Stafford Horne <shorne@gmail.com>
---
 arch/openrisc/kernel/dma.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/openrisc/kernel/dma.c b/arch/openrisc/kernel/dma.c
index c152a68811dd..345727638d52 100644
--- a/arch/openrisc/kernel/dma.c
+++ b/arch/openrisc/kernel/dma.c
@@ -74,8 +74,11 @@ void *arch_dma_set_uncached(void *cpu_addr, size_t size)
 	 * We need to iterate through the pages, clearing the dcache for
 	 * them and setting the cache-inhibit bit.
 	 */
+	mmap_read_lock(&init_mm);
 	error = walk_page_range(&init_mm, va, va + size, &set_nocache_walk_ops,
 			NULL);
+	mmap_read_unlock(&init_mm);
+
 	if (error)
 		return ERR_PTR(error);
 	return cpu_addr;
@@ -85,9 +88,11 @@ void arch_dma_clear_uncached(void *cpu_addr, size_t size)
 {
 	unsigned long va = (unsigned long)cpu_addr;
 
+	mmap_read_lock(&init_mm);
 	/* walk_page_range shouldn't be able to fail here */
 	WARN_ON(walk_page_range(&init_mm, va, va + size,
 			&clear_nocache_walk_ops, NULL));
+	mmap_read_unlock(&init_mm);
 }
 
 void arch_sync_dma_for_device(phys_addr_t addr, size_t size,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] openrisc: Fix boot oops when DEBUG_VM is enabled
  2020-06-17  9:02 [PATCH] openrisc: Fix boot oops when DEBUG_VM is enabled Stafford Horne
@ 2020-06-17 12:04 ` Michel Lespinasse
  0 siblings, 0 replies; 2+ messages in thread
From: Michel Lespinasse @ 2020-06-17 12:04 UTC (permalink / raw)
  To: Stafford Horne
  Cc: LKML, Jonas Bonn, Stefan Kristiansson, Jason Gunthorpe,
	Steven Price, Thomas Hellstrom, Robin Murphy, Andrew Morton,
	Vlastimil Babka, Daniel Jordan, openrisc

On Wed, Jun 17, 2020 at 2:03 AM Stafford Horne <shorne@gmail.com> wrote:
> Since v5.8-rc1 OpenRISC Linux fails to boot when DEBUG_VM is enabled.
> This has been bisected to commit 42fc541404f2 ("mmap locking API: add
> mmap_assert_locked() and mmap_assert_write_locked()").
>
> The added locking checks exposed the issue that OpenRISC was not taking
> this mmap lock when during page walks for DMA operations.  This patch
> locks and unlocks the mmap lock for page walking.
>
> Fixes: 42fc541404f2 ("mmap locking API: add mmap_assert_locked() and mmap_assert_write_locked()"
> Cc: Michel Lespinasse <walken@google.com>
> Signed-off-by: Stafford Horne <shorne@gmail.com>

Thanks for the fix.

Reviewed-by: Michel Lespinasse <walken@google.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-17 12:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17  9:02 [PATCH] openrisc: Fix boot oops when DEBUG_VM is enabled Stafford Horne
2020-06-17 12:04 ` Michel Lespinasse

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).