summaryrefslogtreecommitdiff
path: root/sys/dev/sdmmc/sdmmc_scsi.c
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-02-20 19:16:36 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-02-20 19:16:36 +0000
commit66d83ff4bc53d9294e80b91857ce21f39c32f6a7 (patch)
tree5a46367ed6113a650d030fee771ecacc32f9db1d /sys/dev/sdmmc/sdmmc_scsi.c
parentac568282f8bd7ec128aed050203eb3aaa5029f19 (diff)
Let the sdmmc adapters tell the sdmmc layer how much sectors they can
transfer with one command. Build on this and the recent minphys() changes in the sdmmc layer to crank transfers at the maximum possible size instead of a sad DEV_BSIZE. Depending on your controller, this can speed up sdmmc I/O up to 2.5 times.
Diffstat (limited to 'sys/dev/sdmmc/sdmmc_scsi.c')
-rw-r--r--sys/dev/sdmmc/sdmmc_scsi.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/dev/sdmmc/sdmmc_scsi.c b/sys/dev/sdmmc/sdmmc_scsi.c
index 3b324b072b1..8e690ea41ee 100644
--- a/sys/dev/sdmmc/sdmmc_scsi.c
+++ b/sys/dev/sdmmc/sdmmc_scsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdmmc_scsi.c,v 1.14 2009/02/16 21:19:07 miod Exp $ */
+/* $OpenBSD: sdmmc_scsi.c,v 1.15 2009/02/20 19:16:35 miod Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -497,8 +497,15 @@ sdmmc_stimeout(void *arg)
void
sdmmc_scsi_minphys(struct buf *bp, struct scsi_link *sl)
{
- /* XXX limit to max. transfer size supported by card/host? */
- if (bp->b_bcount > DEV_BSIZE)
- bp->b_bcount = DEV_BSIZE;
+ struct sdmmc_softc *sc = sl->adapter_softc;
+ struct sdmmc_scsi_softc *scbus = sc->sc_scsibus;
+ struct sdmmc_scsi_target *tgt = &scbus->sc_tgt[sl->target];
+ struct sdmmc_function *sf = tgt->card;
+
+ /* limit to max. transfer size supported by card/host */
+ if (sc->sc_max_xfer != 0 &&
+ bp->b_bcount > sf->csd.sector_size * sc->sc_max_xfer)
+ bp->b_bcount = sf->csd.sector_size * sc->sc_max_xfer;
+
minphys(bp);
}