svn commit: r332286 - head/sys/powerpc/ofw
Justin Hibbits
jhibbits at FreeBSD.org
Sun Apr 8 16:43:57 UTC 2018
Author: jhibbits
Date: Sun Apr 8 16:43:56 2018
New Revision: 332286
URL: https://svnweb.freebsd.org/changeset/base/332286
Log:
powerpc/ofw: Fix malloc inside lock
Summary:
Currently ofw_real_bounce_alloc() is requesting memory, using WAITOK, holding a
non-sleepable locks, called 'OF Bounce Page'.
Fix this by allocating the pages outside of the lock, and only updating the
global variables while holding the lock.
Submitted by: Breno Leitao
Differential Revision: https://reviews.freebsd.org/D14955
Modified:
head/sys/powerpc/ofw/ofw_real.c
Modified: head/sys/powerpc/ofw/ofw_real.c
==============================================================================
--- head/sys/powerpc/ofw/ofw_real.c Sun Apr 8 16:34:10 2018 (r332285)
+++ head/sys/powerpc/ofw/ofw_real.c Sun Apr 8 16:43:56 2018 (r332286)
@@ -197,6 +197,8 @@ ofw_real_stop(void)
static void
ofw_real_bounce_alloc(void *junk)
{
+ caddr_t temp;
+
/*
* Check that ofw_real is actually in use before allocating wads
* of memory. Do this by checking if our mutex has been set up.
@@ -208,12 +210,15 @@ ofw_real_bounce_alloc(void *junk)
* Allocate a page of contiguous, wired physical memory that can
* fit into a 32-bit address space and accessed from real mode.
*/
+ temp = contigmalloc(4 * PAGE_SIZE, M_OFWREAL, 0, 0,
+ ulmin(platform_real_maxaddr(), BUS_SPACE_MAXADDR_32BIT), PAGE_SIZE,
+ 4 * PAGE_SIZE);
+ if (temp == NULL)
+ panic("%s: Not able to allocated contiguous memory\n", __func__);
mtx_lock(&of_bounce_mtx);
- of_bounce_virt = contigmalloc(4 * PAGE_SIZE, M_OFWREAL, 0, 0,
- ulmin(platform_real_maxaddr(), BUS_SPACE_MAXADDR_32BIT), PAGE_SIZE,
- 4 * PAGE_SIZE);
+ of_bounce_virt = temp;
of_bounce_phys = vtophys(of_bounce_virt);
of_bounce_size = 4 * PAGE_SIZE;
More information about the svn-src-head
mailing list