Date: Wed, 4 Oct 2006 05:23:19 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 107238 for review Message-ID: <200610040523.k945NJpR033617@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=107238 Change 107238 by imp@imp_lighthouse on 2006/10/04 05:22:50 Keep track of the last selected card and short-circuit any attempt to select the card again. Also, never deselect the card unless the bus code wants the mmc bus. This should save two command round trips per I/O. Since we're doing 8k transfers, this saves us 2 of the 34 commands. Not a lot, but every little bit helps. Affected files ... .. //depot/projects/arm/src/sys/dev/mmc/mmc.c#21 edit Differences ... ==== //depot/projects/arm/src/sys/dev/mmc/mmc.c#21 (text+ko) ==== @@ -46,6 +46,7 @@ struct mtx sc_mtx; struct intr_config_hook config_intrhook; device_t owner; + uint32_t last_rca; }; /* @@ -124,6 +125,7 @@ { struct mmc_softc *sc; int err; + int rca; err = MMCBR_ACQUIRE_HOST(device_get_parent(busdev), dev); if (err) @@ -136,12 +138,26 @@ MMC_UNLOCK(sc); if (busdev != dev) { - // XXX Should do lazy selection. - mmc_wait_for_command(sc, MMC_SELECT_CARD, - mmc_get_rca(dev) << 16, MMC_RSP_R1 | MMC_CMD_AC, - NULL, CMD_RETRIES); + // Keep track of the last rca that we've selected. If + // we're asked to do it again, don't. We never unselect + // unless the bus code itself wants the mmc bus. + rca = mmc_get_rca(dev); + if (sc->last_rca != rca) { + mmc_wait_for_command(sc, MMC_SELECT_CARD, rca << 16, + MMC_RSP_R1 | MMC_CMD_AC, NULL, CMD_RETRIES); + sc->last_rca = rca; + } + // XXX should set bus width here? + } else { + // If there's a card selected, stand down. + if (sc->last_rca != 0) { + mmc_wait_for_command(sc, MMC_SELECT_CARD, 0, + MMC_RSP_R1 | MMC_CMD_AC, NULL, CMD_RETRIES); + sc->last_rca = 0; + } // XXX should set bus width here? } + return (0); } @@ -153,11 +169,6 @@ sc = device_get_softc(busdev); - if (busdev != dev) { - // XXX Should do lazy deselection. - mmc_wait_for_command(sc, MMC_DESELECT_CARD, 0, - MMC_RSP_R1 | MMC_CMD_AC, NULL, CMD_RETRIES); - } MMC_LOCK(sc); if (!sc->owner) panic("mmc: releasing unowned bus.");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610040523.k945NJpR033617>