summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2009-02-20 19:16:34 +0000
committermiod <miod@openbsd.org>2009-02-20 19:16:34 +0000
commit46a44037f6918d12e254a014c83708425a455402 (patch)
tree7855b8dc8b88677ef9458f15f2aabb11de106c84
parentpurge /enqueue at startup; ok gilles@ (diff)
downloadwireguard-openbsd-46a44037f6918d12e254a014c83708425a455402.tar.xz
wireguard-openbsd-46a44037f6918d12e254a014c83708425a455402.zip
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.
-rw-r--r--sys/arch/arm/xscale/pxa2x0_mmc.c4
-rw-r--r--sys/dev/sdmmc/sdmmc.c4
-rw-r--r--sys/dev/sdmmc/sdmmc_mem.c14
-rw-r--r--sys/dev/sdmmc/sdmmc_scsi.c15
-rw-r--r--sys/dev/sdmmc/sdmmcchip.h4
-rw-r--r--sys/dev/sdmmc/sdmmcvar.h4
6 files changed, 28 insertions, 17 deletions
diff --git a/sys/arch/arm/xscale/pxa2x0_mmc.c b/sys/arch/arm/xscale/pxa2x0_mmc.c
index be75be2c588..a2dca15ded4 100644
--- a/sys/arch/arm/xscale/pxa2x0_mmc.c
+++ b/sys/arch/arm/xscale/pxa2x0_mmc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pxa2x0_mmc.c,v 1.3 2007/08/22 18:47:16 mglocker Exp $ */
+/* $OpenBSD: pxa2x0_mmc.c,v 1.4 2009/02/20 19:16:34 miod Exp $ */
/*
* Copyright (c) 2007 Uwe Stuehler <uwe@openbsd.org>
@@ -182,6 +182,8 @@ pxammc_attach(struct pxammc_softc *sc, void *aux)
saa.saa_busname = "sdmmc";
saa.sct = &pxammc_functions;
saa.sch = sc;
+ saa.flags = SMF_STOP_AFTER_MULTIPLE;
+ saa.max_xfer = 1;
sc->sc_sdmmc = config_found(&sc->sc_dev, &saa, NULL);
if (sc->sc_sdmmc == NULL) {
diff --git a/sys/dev/sdmmc/sdmmc.c b/sys/dev/sdmmc/sdmmc.c
index 5398b51fab9..a710623b535 100644
--- a/sys/dev/sdmmc/sdmmc.c
+++ b/sys/dev/sdmmc/sdmmc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdmmc.c,v 1.18 2009/01/09 10:58:38 jsg Exp $ */
+/* $OpenBSD: sdmmc.c,v 1.19 2009/02/20 19:16:35 miod Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -102,6 +102,8 @@ sdmmc_attach(struct device *parent, struct device *self, void *aux)
sc->sct = saa->sct;
sc->sch = saa->sch;
+ sc->sc_flags = saa->flags;
+ sc->sc_max_xfer = saa->max_xfer;
SIMPLEQ_INIT(&sc->sf_head);
TAILQ_INIT(&sc->sc_tskq);
diff --git a/sys/dev/sdmmc/sdmmc_mem.c b/sys/dev/sdmmc/sdmmc_mem.c
index 4f7246afa07..682f8e9c5bb 100644
--- a/sys/dev/sdmmc/sdmmc_mem.c
+++ b/sys/dev/sdmmc/sdmmc_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */
+/* $OpenBSD: sdmmc_mem.c,v 1.11 2009/02/20 19:16:35 miod Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -425,9 +425,8 @@ sdmmc_mem_read_block(struct sdmmc_function *sf, int blkno, u_char *data,
if (error != 0)
goto err;
- /* XXX sdhc(4) does not need this */
-#ifdef __zaurus__
- if (cmd.c_opcode == MMC_READ_BLOCK_MULTIPLE) {
+ if (ISSET(sc->sc_flags, SMF_STOP_AFTER_MULTIPLE) &&
+ cmd.c_opcode == MMC_READ_BLOCK_MULTIPLE) {
bzero(&cmd, sizeof cmd);
cmd.c_opcode = MMC_STOP_TRANSMISSION;
cmd.c_arg = MMC_ARG_RCA(sf->rca);
@@ -436,7 +435,6 @@ sdmmc_mem_read_block(struct sdmmc_function *sf, int blkno, u_char *data,
if (error != 0)
goto err;
}
-#endif
do {
bzero(&cmd, sizeof cmd);
@@ -483,9 +481,8 @@ sdmmc_mem_write_block(struct sdmmc_function *sf, int blkno, u_char *data,
if (error != 0)
goto err;
- /* XXX sdhc(4) does not need this */
-#ifdef __zaurus__
- if (cmd.c_opcode == MMC_WRITE_BLOCK_MULTIPLE) {
+ if (ISSET(sc->sc_flags, SMF_STOP_AFTER_MULTIPLE) &&
+ cmd.c_opcode == MMC_WRITE_BLOCK_MULTIPLE) {
bzero(&cmd, sizeof cmd);
cmd.c_opcode = MMC_STOP_TRANSMISSION;
cmd.c_flags = SCF_CMD_AC | SCF_RSP_R1B;
@@ -493,7 +490,6 @@ sdmmc_mem_write_block(struct sdmmc_function *sf, int blkno, u_char *data,
if (error != 0)
goto err;
}
-#endif
do {
bzero(&cmd, sizeof cmd);
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);
}
diff --git a/sys/dev/sdmmc/sdmmcchip.h b/sys/dev/sdmmc/sdmmcchip.h
index 93969149674..1846b1d192a 100644
--- a/sys/dev/sdmmc/sdmmcchip.h
+++ b/sys/dev/sdmmc/sdmmcchip.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdmmcchip.h,v 1.3 2007/05/31 10:09:01 uwe Exp $ */
+/* $OpenBSD: sdmmcchip.h,v 1.4 2009/02/20 19:16:35 miod Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -77,6 +77,8 @@ struct sdmmcbus_attach_args {
const char *saa_busname;
sdmmc_chipset_tag_t sct;
sdmmc_chipset_handle_t sch;
+ int flags;
+ long max_xfer;
};
void sdmmc_needs_discover(struct device *);
diff --git a/sys/dev/sdmmc/sdmmcvar.h b/sys/dev/sdmmc/sdmmcvar.h
index a24335a4eb3..88d335f7724 100644
--- a/sys/dev/sdmmc/sdmmcvar.h
+++ b/sys/dev/sdmmc/sdmmcvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdmmcvar.h,v 1.14 2009/02/06 20:16:41 grange Exp $ */
+/* $OpenBSD: sdmmcvar.h,v 1.15 2009/02/20 19:16:35 miod Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -162,6 +162,7 @@ struct sdmmc_softc {
#define SMF_MEM_MODE 0x0004 /* host in memory mode (SD or MMC) */
#define SMF_CARD_PRESENT 0x0010 /* card presence noticed */
#define SMF_CARD_ATTACHED 0x0020 /* card driver(s) attached */
+#define SMF_STOP_AFTER_MULTIPLE 0x0040 /* send a stop after a multiple cmd */
int sc_function_count; /* number of I/O functions (SDIO) */
struct sdmmc_function *sc_card; /* selected card */
struct sdmmc_function *sc_fn0; /* function 0, the card itself */
@@ -174,6 +175,7 @@ struct sdmmc_softc {
struct lock sc_lock; /* lock around host controller */
void *sc_scsibus; /* SCSI bus emulation softc */
TAILQ_HEAD(, sdmmc_intr_handler) sc_intrq; /* interrupt handlers */
+ long sc_max_xfer; /* maximum transfer size */
};
/*