From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 21 11:10:50 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A94E51065670; Thu, 21 Jun 2012 11:10:50 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 92F728FC16; Thu, 21 Jun 2012 11:10:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5LBAoXJ008920; Thu, 21 Jun 2012 11:10:50 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5LBAoM4008918; Thu, 21 Jun 2012 11:10:50 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206211110.q5LBAoM4008918@svn.freebsd.org> From: Marius Strobl Date: Thu, 21 Jun 2012 11:10:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237382 - stable/9/sys/arm/at91 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 11:10:50 -0000 Author: marius Date: Thu Jun 21 11:10:49 2012 New Revision: 237382 URL: http://svn.freebsd.org/changeset/base/237382 Log: MFC: r237239 Revert the part of r236495 (MFC'ed to stable/9 in r237095) that introduced checking of SPI_SR_TXEMPTY for TX transfer completion as for reasons unknown this occasionally causes SPI_SR_RXBUFF and SPI_SR_ENDRX to not rise. In any case, once the RX part of the transfer is done it's obvious that the preceding TX part had finished and checking of SPI_SR_TXEMPTY was introduced to rule out a possible cause for the data corruption mentioned in r236495 but which didn't turn out to be the problem anyway. Modified: stable/9/sys/arm/at91/at91_spi.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/arm/at91/at91_spi.c ============================================================================== --- stable/9/sys/arm/at91/at91_spi.c Thu Jun 21 11:06:31 2012 (r237381) +++ stable/9/sys/arm/at91/at91_spi.c Thu Jun 21 11:10:49 2012 (r237382) @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include @@ -59,7 +58,6 @@ struct at91_spi_softc bus_dma_tag_t dmatag; /* bus dma tag for transfers */ bus_dmamap_t map[4]; /* Maps for the transaction */ struct sx xfer_mtx; /* Enforce one transfer at a time */ - uint32_t xfer_mask; /* Bits to wait on for completion */ uint32_t xfer_done; /* interrupt<->mainthread signaling */ }; @@ -124,7 +122,6 @@ at91_spi_attach(device_t dev) * Set up the hardware. */ - sc->xfer_mask = SPI_SR_RXBUFF | (at91_is_rm92() ? 0 : SPI_SR_TXEMPTY); WR4(sc, SPI_CR, SPI_CR_SWRST); /* "Software Reset must be Written Twice" erratum */ WR4(sc, SPI_CR, SPI_CR_SWRST); @@ -272,7 +269,6 @@ at91_spi_transfer(device_t dev, device_t struct at91_spi_softc *sc; bus_addr_t addr; int err, i, j, mode[4]; - uint32_t mask; KASSERT(cmd->tx_cmd_sz == cmd->rx_cmd_sz, ("%s: TX/RX command sizes should be equal", __func__)); @@ -356,12 +352,11 @@ at91_spi_transfer(device_t dev, device_t * Start the transfer, wait for it to complete. */ sc->xfer_done = 0; - mask = sc->xfer_mask; - WR4(sc, SPI_IER, mask); + WR4(sc, SPI_IER, SPI_SR_RXBUFF); WR4(sc, PDC_PTCR, PDC_PTCR_TXTEN | PDC_PTCR_RXTEN); do err = tsleep(&sc->xfer_done, PCATCH | PZERO, "at91_spi", hz); - while (sc->xfer_done != mask && err != EINTR); + while (sc->xfer_done == 0 && err != EINTR); /* * Stop the transfer and clean things up. @@ -383,20 +378,19 @@ static void at91_spi_intr(void *arg) { struct at91_spi_softc *sc; - uint32_t mask, sr; + uint32_t sr; sc = (struct at91_spi_softc*)arg; - mask = sc->xfer_mask; sr = RD4(sc, SPI_SR) & RD4(sc, SPI_IMR); - if ((sr & mask) != 0) { - sc->xfer_done |= sr & mask; - WR4(sc, SPI_IDR, mask); + if ((sr & SPI_SR_RXBUFF) != 0) { + sc->xfer_done = 1; + WR4(sc, SPI_IDR, SPI_SR_RXBUFF); wakeup(&sc->xfer_done); } - if ((sr & ~mask) != 0) { + if ((sr & ~SPI_SR_RXBUFF) != 0) { device_printf(sc->dev, "Unexpected ISR %#x\n", sr); - WR4(sc, SPI_IDR, sr & ~mask); + WR4(sc, SPI_IDR, sr & ~SPI_SR_RXBUFF); } }