summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-03-26 13:48:37 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-03-26 13:53:24 +0100
commit8179d4c68fed80eb12e4a23af93b18fae98ff7d5 (patch)
tree473d0a768008670148f14085047cf0936a2c10d4
parentmmc: Remove RTEMS special cases (diff)
downloadrtems-libbsd-8179d4c68fed80eb12e4a23af93b18fae98ff7d5.tar.bz2
dw_mmc: Implement host acquire/release
This should avoid the "mmc: host bridge didn't serialize us." panic.
-rw-r--r--rtemsbsd/sys/dev/dw_mmc/dw_mmc.c21
1 files 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 681bf95a..af75722b 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);
}