Index: ld_sdmmc.c =================================================================== RCS file: /cvsroot/src/sys/dev/sdmmc/ld_sdmmc.c,v retrieving revision 1.42 diff -p -u -r1.42 ld_sdmmc.c --- ld_sdmmc.c 16 May 2022 10:03:23 -0000 1.42 +++ ld_sdmmc.c 22 Jan 2024 18:17:12 -0000 @@ -611,6 +611,8 @@ ld_sdmmc_cachesync(struct ld_softc *ld, goto out; } + mutex_exit(&sc->sc_lock); + /* Set up the task and schedule it. */ task->task_poll = poll; task->task_errorp = &error; @@ -618,6 +620,8 @@ ld_sdmmc_cachesync(struct ld_softc *ld, sdmmc_add_task(sc->sc_sf->sc, &task->task); + mutex_enter(&sc->sc_lock); + /* * Wait for the task to complete. If the device is yanked, * detach will notify us. Keep the busy count up until we're @@ -626,7 +630,7 @@ ld_sdmmc_cachesync(struct ld_softc *ld, */ sc->sc_busy++; KASSERT(sc->sc_busy <= LD_SDMMC_MAXTASKCNT); - while (error == -1) + while (task->task.onqueue) cv_wait(&sc->sc_cv, &sc->sc_lock); if (--sc->sc_busy == 0) cv_broadcast(&sc->sc_cv); Index: sdmmc.c =================================================================== RCS file: /cvsroot/src/sys/dev/sdmmc/sdmmc.c,v retrieving revision 1.43 diff -p -u -r1.43 sdmmc.c --- sdmmc.c 7 Aug 2021 16:19:16 -0000 1.43 +++ sdmmc.c 22 Jan 2024 18:17:12 -0000 @@ -265,6 +314,13 @@ sdmmc_add_task(struct sdmmc_softc *sc, s } KASSERT(task->sc == NULL); KASSERT(!task->onqueue); + + if (curlwp == sc->sc_tskq_lwp) { + mutex_exit(&sc->sc_tskq_mtx); + (*task->func)(task->arg); + return; + } + task->onqueue = 1; task->sc = sc; TAILQ_INSERT_TAIL(&sc->sc_tskq, task, next);