diff options
author | Visa Hankala <visa@cvs.openbsd.org> | 2017-09-23 04:56:43 +0000 |
---|---|---|
committer | Visa Hankala <visa@cvs.openbsd.org> | 2017-09-23 04:56:43 +0000 |
commit | dd193077bf1771ede04d1ae29e4478a37fa1b399 (patch) | |
tree | ac64ab9e31d22aa84c62391be14c14069f19d18b /sys | |
parent | 7e685889b9914c68684d96e036dfa71f4b565792 (diff) |
Fix controller locking so that it covers the DMA map and bounce buffer.
Those are shared by SD/MMC buses.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/octeon/dev/octmmc.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/arch/octeon/dev/octmmc.c b/sys/arch/octeon/dev/octmmc.c index dc6d835acae..fcedfa7939c 100644 --- a/sys/arch/octeon/dev/octmmc.c +++ b/sys/arch/octeon/dev/octmmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: octmmc.c,v 1.7 2017/09/22 14:41:37 visa Exp $ */ +/* $OpenBSD: octmmc.c,v 1.8 2017/09/23 04:56:42 visa Exp $ */ /* * Copyright (c) 2016, 2017 Visa Hankala @@ -578,6 +578,9 @@ octmmc_exec_dma(struct octmmc_bus *bus, struct sdmmc_command *cmd) return; } + s = splsdmmc(); + octmmc_acquire(bus); + /* * Attempt to use the buffer directly for DMA. In case the region * is not physically contiguous, bounce the data. @@ -587,16 +590,13 @@ octmmc_exec_dma(struct octmmc_bus *bus, struct sdmmc_command *cmd) cmd->c_error = bus_dmamap_load(sc->sc_dmat, sc->sc_dma_data, sc->sc_bounce_buf, cmd->c_datalen, NULL, BUS_DMA_WAITOK); if (cmd->c_error != 0) - return; + goto dma_out; bounce = 1; if (!ISSET(cmd->c_flags, SCF_CMD_READ)) memcpy(sc->sc_bounce_buf, cmd->c_data, cmd->c_datalen); } - s = splsdmmc(); - octmmc_acquire(bus); - bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_data, 0, cmd->c_datalen, ISSET(cmd->c_flags, SCF_CMD_READ) ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); @@ -700,10 +700,11 @@ unload_dma: Octeon_unlock_secondary_cache(curcpu(), locked_block, OCTMMC_BLOCK_SIZE); + bus_dmamap_unload(sc->sc_dmat, sc->sc_dma_data); + +dma_out: octmmc_release(bus); splx(s); - - bus_dmamap_unload(sc->sc_dmat, sc->sc_dma_data); } void |