From owner-p4-projects@FreeBSD.ORG Wed Oct 25 21:02:34 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 644AA16A4EE; Wed, 25 Oct 2006 21:02:34 +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 2AC4616A4EB for ; Wed, 25 Oct 2006 21:02:34 +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 255EF43D5C for ; Wed, 25 Oct 2006 21:02:27 +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 k9PL2RGG082987 for ; Wed, 25 Oct 2006 21:02:27 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k9PL2RTK082984 for perforce@freebsd.org; Wed, 25 Oct 2006 21:02:27 GMT (envelope-from imp@freebsd.org) Date: Wed, 25 Oct 2006 21:02:27 GMT Message-Id: <200610252102.k9PL2RTK082984@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 108436 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, 25 Oct 2006 21:02:34 -0000 http://perforce.freebsd.org/chv.cgi?CH=108436 Change 108436 by imp@imp_lighthouse on 2006/10/25 21:02:14 Use the busdma callback mechanism correctly. o flush cache after I'm sure that the uio is loaded. o do all hackware frobbing inside the callback o DO NOT ASSUME that the callback has happened after load_uio has returned. o protect more with the sc_mtx mutex. o handle EINPROGRESS gracefully Affected files ... .. //depot/projects/arm/src/sys/arm/at91/at91_ssc.c#13 edit Differences ... ==== //depot/projects/arm/src/sys/arm/at91/at91_ssc.c#13 (text+ko) ==== @@ -144,7 +144,7 @@ */ err = bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, 2048, 1, 2048, BUS_DMA_ALLOCNOW, - NULL, NULL, &sc->tag); + busdma_lock_mutex, &sc->sc_mtx, &sc->tag); if (err != 0) goto out; err = bus_dmamap_create(sc->tag, 0, &sc->tx_map); @@ -240,12 +240,12 @@ status = RD4(sc, SSC_SR); if (status == 0) return; + AT91_SSC_LOCK(sc); if (status & SSC_SR_ENDTX) { WR4(sc, SSC_IDR, SSC_SR_ENDTX); sc->txdone++; wakeup(&sc->txdone); } - AT91_SSC_LOCK(sc); AT91_SSC_UNLOCK(sc); wakeup(sc); return; @@ -286,8 +286,12 @@ sc = arg; if (error != 0) return; + bus_dmamap_sync(sc->tag, sc->tx_map, BUS_DMASYNC_PREWRITE); WR4(sc, PDC_TPR, segs[0].ds_addr); WR4(sc, PDC_TCR, size); + WR4(sc, SSC_IER, SSC_SR_ENDTX); + WR4(sc, SSC_CR, SSC_CR_TXEN); + WR4(sc, PDC_PTCR, PDC_PTCR_TXTEN); } static int @@ -308,17 +312,16 @@ return (EINVAL); WR4(sc, SSC_CR, SSC_CR_TXDIS); WR4(sc, PDC_PTCR, PDC_PTCR_TXTDIS); + txdone = sc->txdone; err = bus_dmamap_load_uio(sc->tag, sc->tx_map, uio, at91_ssc_loadwrite, sc, 0); - if (err != 0) + if (err != 0 && err != EINPROGRESS) return (err); - WR4(sc, SSC_IER, SSC_SR_ENDTX); - WR4(sc, SSC_CR, SSC_CR_TXEN); - WR4(sc, PDC_PTCR, PDC_PTCR_TXTEN); - txdone = sc->txdone; do { - err = msleep(&sc->txdone, NULL, PCATCH | PZERO, "sscwr", hz); + err = msleep(&sc->txdone, &sc->sc_mtx, PCATCH | PZERO, + "sscwr", hz); } while (txdone == sc->txdone && err != EINTR); + bus_dmamap_sync(sc->tag, sc->tx_map, BUS_DMASYNC_POSTWRITE); if (err == 0) uio->uio_resid = 0; return err;