[rtems-libbsd commit] dw_mmc: Implement host acquire/release

Sebastian Huber sebh at rtems.org
Thu Mar 26 13:05:46 UTC 2015


Module:    rtems-libbsd
Branch:    master
Commit:    8179d4c68fed80eb12e4a23af93b18fae98ff7d5
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=8179d4c68fed80eb12e4a23af93b18fae98ff7d5

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Mar 26 13:48:37 2015 +0100

dw_mmc: Implement host acquire/release

This should avoid the "mmc: host bridge didn't serialize us." panic.

---

 rtemsbsd/sys/dev/dw_mmc/dw_mmc.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/rtemsbsd/sys/dev/dw_mmc/dw_mmc.c b/rtemsbsd/sys/dev/dw_mmc/dw_mmc.c
index 681bf95..af75722 100644
--- a/rtemsbsd/sys/dev/dw_mmc/dw_mmc.c
+++ b/rtemsbsd/sys/dev/dw_mmc/dw_mmc.c
@@ -80,6 +80,7 @@ struct dw_mmc_softc {
 	struct mtx sc_mtx;
 	struct mtx bus_mtx;
 	bus_space_handle_t bushandle;
+	int bus_busy;
 	uint32_t biu_clock;
 	uint32_t ciu_clock;
 	uint32_t card_clock;
@@ -124,12 +125,6 @@ DW_MMC_LOCK(struct dw_mmc_softc *sc)
 	mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->dev), \
 	    "dw_mmc", MTX_DEF)
 
-#define	DW_MMC_BUS_LOCK(_sc)		mtx_lock(&(_sc)->bus_mtx)
-#define	DW_MMC_BUS_UNLOCK(_sc)		mtx_unlock(&(_sc)->bus_mtx)
-#define DW_MMC_BUS_LOCK_INIT(_sc) \
-	mtx_init(&_sc->bus_mtx, device_get_nameunit(_sc->dev), \
-	    "dw_mmc", MTX_DEF)
-
 static int
 dw_mmc_poll_reset_completion(struct dw_mmc_softc *sc, uint32_t ctrl_resets)
 {
@@ -356,7 +351,6 @@ dw_mmc_attach(device_t dev)
 	}
 
 	DW_MMC_LOCK_INIT(sc);
-	DW_MMC_BUS_LOCK_INIT(sc);
 
 	dw_mmc_platform_install_intr(sc);
 
@@ -954,8 +948,11 @@ dw_mmc_acquire_host(device_t brdev, device_t reqdev)
 {
 	struct dw_mmc_softc *sc = device_get_softc(brdev);
 
-	DW_MMC_BUS_LOCK(sc);
-
+	DW_MMC_LOCK(sc);
+	while (sc->bus_busy)
+		msleep(sc, &sc->sc_mtx, PZERO, "dw_mmc: acquire host", 0);
+	sc->bus_busy = 1;
+	DW_MMC_UNLOCK(sc);
 	return (0);
 }
 
@@ -964,8 +961,10 @@ dw_mmc_release_host(device_t brdev, device_t reqdev)
 {
 	struct dw_mmc_softc *sc = device_get_softc(brdev);
 
-	DW_MMC_BUS_UNLOCK(sc);
-
+	DW_MMC_LOCK(sc);
+	sc->bus_busy = 0;
+	wakeup(sc);
+	DW_MMC_UNLOCK(sc);
 	return (0);
 }
 



More information about the vc mailing list