Pull up following revision(s) (requested by jmcneill in ticket #794):

sys/dev/sdmmc/sdmmc.c: revision 1.25
	sys/dev/sdmmc/sdmmc.c: revision 1.26
	sys/dev/sdmmc/ld_sdmmc.c: revision 1.13
	sys/dev/sdmmc/ld_sdmmc.c: revision 1.16
- Be a bit more verbose about errors, also pass through error code
  from lower layer like other drivers.
- need to call lddone with splbio and kernel lock held
- sdmmc_task_thread isn't MPSAFE so instead of just wrapping the callback
  in KERNEL_LOCK/KERNEL_UNLOCK_ONE, remove KTHREAD_MPSAFE. While here, use
  PRI_BIO instead of PRI_NONE for the task thread priority. Since this is
  how all transfers are queued, and we have a 1 second timeout on the task
  being picked up off the queue (!), better not to rely on a PRI_NONE thread.
This commit is contained in:
msaitoh 2015-05-26 01:29:53 +00:00
parent 877753fcd1
commit 302a800941
2 changed files with 17 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_sdmmc.c,v 1.12 2013/10/12 16:49:01 christos Exp $ */
/* $NetBSD: ld_sdmmc.c,v 1.12.4.1 2015/05/26 01:29:53 msaitoh Exp $ */
/*
* Copyright (c) 2008 KIYOHARA Takashi
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.12 2013/10/12 16:49:01 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.12.4.1 2015/05/26 01:29:53 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_sdmmc.h"
@ -118,7 +118,7 @@ ld_sdmmc_attach(device_t parent, device_t self, void *aux)
sa->sf->cid.rev, sa->sf->cid.psn, sa->sf->cid.mdt);
aprint_naive("\n");
callout_init(&sc->sc_task.task_callout, CALLOUT_MPSAFE);
callout_init(&sc->sc_task.task_callout, 0);
sc->sc_hwunit = 0; /* always 0? */
sc->sc_sf = sa->sf;
@ -211,11 +211,14 @@ ld_sdmmc_dobio(void *arg)
/* is everything done in terms of blocks? */
if (bp->b_rawblkno >= sc->sc_sf->csd.capacity) {
/* trying to read or write past end of device */
DPRINTF(("%s: blkno exceeds capacity 0x%x\n",
device_xname(sc->sc_ld.sc_dv), sc->sc_sf->csd.capacity));
bp->b_error = EIO; /* XXX */
aprint_error_dev(sc->sc_ld.sc_dv,
"blkno 0x%" PRIu64 " exceeds capacity %d\n",
bp->b_rawblkno, sc->sc_sf->csd.capacity);
bp->b_error = EINVAL;
bp->b_resid = bp->b_bcount;
s = splbio();
lddone(&sc->sc_ld, bp);
splx(s);
return;
}
@ -229,14 +232,14 @@ ld_sdmmc_dobio(void *arg)
if (error) {
DPRINTF(("%s: error %d\n", device_xname(sc->sc_ld.sc_dv),
error));
bp->b_error = EIO; /* XXXX */
bp->b_error = error;
bp->b_resid = bp->b_bcount;
} else {
bp->b_resid = 0;
}
splx(s);
lddone(&sc->sc_ld, bp);
splx(s);
}
static void
@ -255,9 +258,11 @@ ld_sdmmc_timeout(void *arg)
bp->b_error = EIO; /* XXXX */
bp->b_resid = bp->b_bcount;
sdmmc_del_task(&task->task);
splx(s);
aprint_error_dev(sc->sc_ld.sc_dv, "task timeout");
lddone(&sc->sc_ld, bp);
splx(s);
}
static int

View File

@ -1,4 +1,4 @@
/* $NetBSD: sdmmc.c,v 1.22.4.2 2015/03/09 09:29:33 snj Exp $ */
/* $NetBSD: sdmmc.c,v 1.22.4.3 2015/05/26 01:29:53 msaitoh Exp $ */
/* $OpenBSD: sdmmc.c,v 1.18 2009/01/09 10:58:38 jsg Exp $ */
/*
@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.22.4.2 2015/03/09 09:29:33 snj Exp $");
__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.22.4.3 2015/05/26 01:29:53 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_sdmmc.h"
@ -217,7 +217,7 @@ sdmmc_doattach(device_t dev)
{
struct sdmmc_softc *sc = device_private(dev);
if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL,
if (kthread_create(PRI_BIO, 0, NULL,
sdmmc_task_thread, sc, &sc->sc_tskq_lwp, "%s", device_xname(dev))) {
aprint_error_dev(dev, "couldn't create task thread\n");
}