Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jan 2015 02:25:20 +0000 (UTC)
From:      Luiz Otavio O Souza <loos@FreeBSD.org>
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
Message-ID:  <201501090225.t092PKRU053745@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



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