From owner-svn-src-head@freebsd.org Sun Jun 18 21:03:36 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4F05FD8E62F; Sun, 18 Jun 2017 21:03:36 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2ACF37C6C8; Sun, 18 Jun 2017 21:03:36 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5IL3ZOI049295; Sun, 18 Jun 2017 21:03:35 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5IL3Zh5049294; Sun, 18 Jun 2017 21:03:35 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201706182103.v5IL3Zh5049294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sun, 18 Jun 2017 21:03:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320080 - head/sys/arm/at91 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Jun 2017 21:03:36 -0000 Author: imp Date: Sun Jun 18 21:03:35 2017 New Revision: 320080 URL: https://svnweb.freebsd.org/changeset/base/320080 Log: Load the transmit dma buffer at attach time as well. We don't need to load and unload it all the time since the buffer never changes. In addition, we were loading it with a hardware spin lock held, which makes the sleepable lock in busdma (for the bounce pages) trigger a witness warning, as well as ipend being called with it held by uart, which made it impossible to unload. These differences don't matter with the v4 busdma implementation, but they do with the v6 implementation since the latter likes to bounce transactions more, and will always do so for Atmel's driver. It's more efficient as well as being more correct. Modified: head/sys/arm/at91/uart_dev_at91usart.c Modified: head/sys/arm/at91/uart_dev_at91usart.c ============================================================================== --- head/sys/arm/at91/uart_dev_at91usart.c Sun Jun 18 20:55:46 2017 (r320079) +++ head/sys/arm/at91/uart_dev_at91usart.c Sun Jun 18 21:03:35 2017 (r320080) @@ -72,6 +72,7 @@ struct at91_usart_softc { struct uart_softc base; bus_dma_tag_t tx_tag; bus_dmamap_t tx_map; + bus_addr_t tx_paddr; uint32_t flags; #define HAS_TIMEOUT 0x1 #define USE_RTS0_WORKAROUND 0x2 @@ -472,6 +473,9 @@ at91_usart_bus_attach(struct uart_softc *sc) err = bus_dmamap_create(atsc->tx_tag, 0, &atsc->tx_map); if (err != 0) goto errout; + if (bus_dmamap_load(atsc->tx_tag, atsc->tx_map, sc->sc_txbuf, + sc->sc_txfifosz, at91_getaddr, &atsc->tx_paddr, 0) != 0) + goto errout; if (atsc->flags & HAS_TIMEOUT) { /* @@ -547,29 +551,22 @@ errout: static int at91_usart_bus_transmit(struct uart_softc *sc) { - bus_addr_t addr; struct at91_usart_softc *atsc; int err; err = 0; atsc = (struct at91_usart_softc *)sc; uart_lock(sc->sc_hwmtx); - if (bus_dmamap_load(atsc->tx_tag, atsc->tx_map, sc->sc_txbuf, - sc->sc_txdatasz, at91_getaddr, &addr, 0) != 0) { - err = EAGAIN; - goto errout; - } bus_dmamap_sync(atsc->tx_tag, atsc->tx_map, BUS_DMASYNC_PREWRITE); sc->sc_txbusy = 1; /* * Setup the PDC to transfer the data and interrupt us when it * is done. We've already requested the interrupt. */ - WR4(&sc->sc_bas, PDC_TPR, addr); + WR4(&sc->sc_bas, PDC_TPR, atsc->tx_paddr); WR4(&sc->sc_bas, PDC_TCR, sc->sc_txdatasz); WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_TXTEN); WR4(&sc->sc_bas, USART_IER, USART_CSR_ENDTX); -errout: uart_unlock(sc->sc_hwmtx); return (err); } @@ -666,7 +663,6 @@ at91_usart_bus_ipend(struct uart_softc *sc) if (csr & USART_CSR_ENDTX) { bus_dmamap_sync(atsc->tx_tag, atsc->tx_map, BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(atsc->tx_tag, atsc->tx_map); } if (csr & (USART_CSR_TXRDY | USART_CSR_ENDTX)) { if (sc->sc_txbusy)