Skip to contentSkip to conversation

atmel_spi driver

PATCH New Haavard Skinnemoen 3 participants 3 messages Dec 7, 2007 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 015e01c838d5$6b2b2bc0$2b00a8c0@ARV127

#1 lore raw
Quoted 7 lines · On Fri, 7 Dec 2007 14:31:04 +0100 "Rini van Zetten"…

Dear Haavard,

I think i found a bug in the atmel_spi driver which is maintained by you. Let me describe.

We have a wifi module connected to the spi bus and got sometimes FIFO overrun errors on the spi bus.
After some investigation i found that the driver loads the TCR (transmit count) register before the RCR (receive count). When the transfer list is not empty the atmel_spi_next_message is called while tx and rx are enabled. As soon as the TCR is loaded, hardware starts transfer and causes a rx fifo overrun because the RCR is not loaded yet. Atached is a patch (for the 2.6.23.9 kernel) which loads the RCR before the TCR. After this patch the fifo overrun disapears at out setup.

Ah, nice catch. Thanks.

Quoted 1 line

Please review it and let me know if you need more details.

Makes sense to me. David, do you think this one should go in before 2.6.24? It may solve some of the other overrun problems people have been seeing as well, especially those happening at low speed.

Btw, Rini, could you sign off the patch as well? Please see Documentation/SubmittingPatches if you don't know what this means.

Haavard

===========[cut here]==============
From: Rini van Zetten <[email protected]>
Date: Fri, 7 Dec 2007 14:41:56 +0100
Subject: [PATCH] atmel_spi: Reload RCR before TCR

We have a wifi module connected to the spi bus and got sometimes FIFO overrun errors on the spi bus.

After some investigation i found that the driver loads the TCR (transmit count) register before the RCR (receive count). When the transfer list is not empty the atmel_spi_next_message is called while tx and rx are enabled. As soon as the TCR is loaded, hardware starts transfer and causes a rx fifo overrun because the RCR is not loaded yet.

Below is a patch (for the 2.6.23.9 kernel) which loads the RCR before the TCR. After this patch the fifo overrun disapears at out setup.

---
 drivers/spi/atmel_spi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/spi/atmel_spi.c +1 -1
index ff6a14b..ff10808 100644
@@ -195,8 +195,8 @@ static void atmel_spi_next_xfer(struct spi_master *master,
 		xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
 		xfer->rx_buf, xfer->rx_dma, spi_readl(as, IMR));
 
-	spi_writel(as, TCR, len);
 	spi_writel(as, RCR, len);
+	spi_writel(as, TCR, len);
 	spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN));
 }
 
Signature · 9 lines
1.5.3.4


-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
#2 lore raw

PATCH 1/1 atmel_spi: Reload RCR before TCR

From: Rini van Zetten <[email protected]>
Date: Fri, 7 Dec 2007 14:41:56 +0100
Subject: [PATCH] atmel_spi: Reload RCR before TCR

We have a wifi module connected to the spi bus and got sometimes FIFO overrun errors on the spi bus.

After some investigation i found that the driver loads the TCR (transmit count) register before the RCR (receive count). When the transfer list is not empty the atmel_spi_next_message is called while tx and rx are enabled. As soon as the TCR is loaded, hardware starts transfer and causes a rx fifo overrun because the RCR is not loaded yet.

Below is a patch (for the 2.6.23.9 kernel) which loads the RCR before the TCR. After this patch the fifo overrun disapears at out setup.

---
 drivers/spi/atmel_spi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/spi/atmel_spi.c +0 -0
index ff6a14b..ff10808 100644
@@ -195,8 +195,8 @@ static void atmel_spi_next_xfer(struct spi_master 

*master,
xfer, xfer->len, xfer->tx_buf, xfer->tx_dma, xfer->rx_buf, xfer->rx_dma, spi_readl(as, IMR));

- spi_writel(as, TCR, len);
spi_writel(as, RCR, len);
+ spi_writel(as, TCR, len);
spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN));
}

Signature · 9 lines
1.5.3.4


-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

A message that is not in the archive (sent off-list or not yet received): 20071207144955.54cf14e4-STKoQgiEtS/[email protected]

#4 lore raw
Quoted 5 lines
Quoted 2 lines

Atached is a patch (for the 2.6.23.9 kernel) which loads the RCR before the TCR. After this patch the fifo overrun disapears at out setup.

Ah, nice catch. Thanks.

Quoted 8 lines
Quoted 1 line

Please review it and let me know if you need more details.

Makes sense to me. David, do you think this one should go in before 2.6.24? It may solve some of the other overrun problems people have been seeing as well, especially those happening at low speed.

Btw, Rini, could you sign off the patch as well? Please see Documentation/SubmittingPatches if you don't know what this means.

Yes, bugfixes like this are clear 2.6.24 material.

I'll forward it for such merge as son as I get a copy with signoff from Rini.

- Dave

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php