From owner-svn-src-all@FreeBSD.ORG Fri Jan 9 02:25:20 2015 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 73DF29AB; Fri, 9 Jan 2015 02:25:20 +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 44CC3E01; Fri, 9 Jan 2015 02:25:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t092PKwt053746; Fri, 9 Jan 2015 02:25:20 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t092PKRU053745; Fri, 9 Jan 2015 02:25:20 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201501090225.t092PKRU053745@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: loos set sender to loos@FreeBSD.org using -f From: Luiz Otavio O Souza Date: Fri, 9 Jan 2015 02:25:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r276868 - stable/10/sys/arm/broadcom/bcm2835 X-SVN-Group: stable-10 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: Fri, 09 Jan 2015 02:25:20 -0000 Author: loos Date: Fri Jan 9 02:25:19 2015 New Revision: 276868 URL: https://svnweb.freebsd.org/changeset/base/276868 Log: MFC r273329, r273337 and r274415 Add another wakeup() after actually set the bus as free. This fix a race where the threads waiting for the bus would wake up early and still see bus as busy. While here, give a better description to wmesg for the two use cases we have (bus and io waiting). Fix the mtx_sleep() error checking, catch all errors and not only EWOULDBLOCK. Do not print any message at errors. The errors are properly sent to upper layers which should be able to deal with it, including printing the errors when they need to. The error message was quite annoying while scanning the i2c bus. Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_bsc.c ============================================================================== --- stable/10/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Fri Jan 9 02:10:44 2015 (r276867) +++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Fri Jan 9 02:25:19 2015 (r276868) @@ -395,7 +395,7 @@ bcm_bsc_transfer(device_t dev, struct ii /* If the controller is busy wait until it is available. */ while (sc->sc_flags & BCM_I2C_BUSY) - mtx_sleep(dev, &sc->sc_mtx, 0, "bcm_bsc", 0); + mtx_sleep(dev, &sc->sc_mtx, 0, "bscbusw", 0); /* Now we have control over the BSC controller. */ sc->sc_flags = BCM_I2C_BUSY; @@ -439,19 +439,21 @@ bcm_bsc_transfer(device_t dev, struct ii BCM_BSC_CTRL_ST | read | intr); /* Wait for the transaction to complete. */ - err = mtx_sleep(dev, &sc->sc_mtx, 0, "bcm_bsc", hz); + err = mtx_sleep(dev, &sc->sc_mtx, 0, "bsciow", hz); - /* Check if we have a timeout or an I2C error. */ - if ((sc->sc_flags & BCM_I2C_ERROR) || err == EWOULDBLOCK) { - device_printf(sc->sc_dev, "I2C error\n"); + /* Check for errors. */ + if (err == 0 && (sc->sc_flags & BCM_I2C_ERROR)) err = EIO; + if (err != 0) break; - } } /* Clean the controller flags. */ sc->sc_flags = 0; + /* Wake up the threads waiting for bus. */ + wakeup(dev); + BCM_BSC_UNLOCK(sc); return (err);