Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Oct 2014 13:36:53 +0000 (UTC)
From:      Luiz Otavio O Souza <loos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r273329 - head/sys/arm/broadcom/bcm2835
Message-ID:  <201410201336.s9KDarfB063375@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: loos
Date: Mon Oct 20 13:36:52 2014
New Revision: 273329
URL: https://svnweb.freebsd.org/changeset/base/273329

Log:
  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).
  
  MFC after:	1 week

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
==============================================================================
--- head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c	Mon Oct 20 13:18:52 2014	(r273328)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c	Mon Oct 20 13:36:52 2014	(r273329)
@@ -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,7 +439,7 @@ 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) {
@@ -452,6 +452,9 @@ bcm_bsc_transfer(device_t dev, struct ii
 	/* Clean the controller flags. */
 	sc->sc_flags = 0;
 
+	/* Wake up the threads waiting for bus. */
+	wakeup(dev);
+
 	BCM_BSC_UNLOCK(sc);
 
 	return (err);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410201336.s9KDarfB063375>