Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Jun 2012 11:10:50 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r237382 - stable/9/sys/arm/at91
Message-ID:  <201206211110.q5LBAoM4008918@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <arm/at91/at91_spireg.h>
 #include <arm/at91/at91_pdcreg.h>
-#include <arm/at91/at91var.h>
 
 #include <dev/spibus/spi.h>
 
@@ -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);
 	}
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206211110.q5LBAoM4008918>