From owner-svn-src-head@freebsd.org Sun Apr 8 16:43:57 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15757F8F3D4; Sun, 8 Apr 2018 16:43:57 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BB761734C6; Sun, 8 Apr 2018 16:43:56 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B660812831; Sun, 8 Apr 2018 16:43:56 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w38Ghulf002765; Sun, 8 Apr 2018 16:43:56 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w38GhuSN002764; Sun, 8 Apr 2018 16:43:56 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201804081643.w38GhuSN002764@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Sun, 8 Apr 2018 16:43:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332286 - head/sys/powerpc/ofw X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/powerpc/ofw X-SVN-Commit-Revision: 332286 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Apr 2018 16:43:57 -0000 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;