From owner-svn-src-all@FreeBSD.ORG Sat Dec 27 13:52:34 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BA701327; Sat, 27 Dec 2014 13:52:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A5CC466270; Sat, 27 Dec 2014 13:52:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBRDqYjM098449; Sat, 27 Dec 2014 13:52:34 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBRDqY6M098448; Sat, 27 Dec 2014 13:52:34 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201412271352.sBRDqY6M098448@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: loos set sender to loos@FreeBSD.org using -f From: Luiz Otavio O Souza Date: Sat, 27 Dec 2014 13:52:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r276297 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Dec 2014 13:52:34 -0000 Author: loos Date: Sat Dec 27 13:52:33 2014 New Revision: 276297 URL: https://svnweb.freebsd.org/changeset/base/276297 Log: On interrupt handler, save the actual data read from mbox. The previous macro wasn't needed and was being used with swapped arguments which always give the same result (0) defeating the overflow check. On initialization, do not use bcm_mbox_intr() to read the pending messages, with the new semaphore based implementation this will lead to semaphore being incremented on the channels that contain pending data and will make the first read for that channel return stale data. This fixes the hang that happens on boot while initializing the cpufreq on Raspberry Pi. Modified: head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c Sat Dec 27 13:17:27 2014 (r276296) +++ head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c Sat Dec 27 13:52:33 2014 (r276297) @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); mtx_unlock(&(sc)->lock); \ } while(0) +#undef DEBUG #ifdef DEBUG #define dprintf(fmt, args...) printf(fmt, ##args) #else @@ -116,7 +117,7 @@ bcm_mbox_intr(void *arg) continue; } dprintf("bcm_mbox_intr: chan %d, data %08x\n", chan, data); - sc->msg[chan] = MBOX_MSG(data, 0xf); + sc->msg[chan] = msg; sema_post(&sc->sema[chan]); } } @@ -174,7 +175,8 @@ bcm_mbox_attach(device_t dev) } /* Read all pending messages */ - bcm_mbox_intr(sc); + while ((mbox_read_4(sc, REG_STATUS) & STATUS_EMPTY) == 0) + (void)mbox_read_4(sc, REG_READ); mbox_write_4(sc, REG_CONFIG, CONFIG_DATA_IRQ);