From owner-p4-projects@FreeBSD.ORG Wed Oct 4 05:23:23 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C2C9516A4F4; Wed, 4 Oct 2006 05:23:23 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 716FC16A4F1 for ; Wed, 4 Oct 2006 05:23:23 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 17CD443D58 for ; Wed, 4 Oct 2006 05:23:20 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k945NJuO033621 for ; Wed, 4 Oct 2006 05:23:19 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k945NJpR033617 for perforce@freebsd.org; Wed, 4 Oct 2006 05:23:19 GMT (envelope-from imp@freebsd.org) Date: Wed, 4 Oct 2006 05:23:19 GMT Message-Id: <200610040523.k945NJpR033617@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 107238 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Oct 2006 05:23:24 -0000 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.");