spi: sirf: fix the issue while transferring more than 256 words
PATCH 1/1 spi: sirf: fix the issue while transferring more than 256 words
From: Qipan Li <[email protected]>
currently, spi irq handler only does rx processing and fetching data from rx fifo when "FRM_END" irq happens. FRM_END indicates one transfer completes. if rx size is less than 256, it works well.
but the problem is that spi rx fifo size is only 256 bytes, then if data size of one frame is more than 256, before FRM_END comes, rx fifo will be filled with RXFIFO_OFLOW overflow interrupt, it will make us lose some data due to fifo overflow.
Explicitly we need do fetch work from device rx fifo in irq handler not only in "FRM_END" irq but also in "THD_REACH" irq. THD_REACH means rx fifo has come to its threshold and will come to overflow if we don't take data from it in time.
In this patch, we fix this issue. we take data from rx fifo when either FRM_END or RX_THD_REACH irq comes, we put data into tx fifo when either TX_FIFO_EMPTY or TX_THD_REACH irq comes.
--- drivers/spi/spi-sirf.c | 43 +++++++++++++------------------------------ 1 files changed, 13 insertions(+), 30 deletions(-)
drivers/spi/spi-sirf.c +13 -30
@@ -142,9 +142,6 @@ struct sirfsoc_spi {unsigned int left_tx_cnt;unsigned int left_rx_cnt; -/* tasklet to push tx msg into FIFO */ -struct tasklet_struct tasklet_tx; -int chipselect[0 ]; };
@@ -236,17 +233,6 @@ static void spi_sirfsoc_tx_word_u32(struct sirfsoc_spi *sspi) sspi->left_tx_cnt--; } -static void spi_sirfsoc_tasklet_tx (unsigned long arg) -{ -struct sirfsoc_spi *sspi = (struct sirfsoc_spi *)arg; - -/* Fill Tx FIFO while there are left words to be transmitted */ -while (!((readl (sspi->base +SIRFSOC_SPI_TXFIFO_STATUS ) & -SIRFSOC_SPI_FIFO_FULL )) && - sspi->left_tx_cnt) - sspi->tx_word (sspi); -} -static irqreturn_t spi_sirfsoc_irq (int irq,void *dev_id) {struct sirfsoc_spi *sspi = dev_id;
@@ -261,25 +247,25 @@ static irqreturn_t spi_sirfsoc_irq(int irq, void *dev_id)writel (0x0 , sspi->base +SIRFSOC_SPI_INT_EN ); } -if (spi_stat &SIRFSOC_SPI_FRM_END ) { +if (spi_stat & (SIRFSOC_SPI_FRM_END + |SIRFSOC_SPI_RXFIFO_THD_REACH ))while (!((readl (sspi->base +SIRFSOC_SPI_RXFIFO_STATUS ) &SIRFSOC_SPI_FIFO_EMPTY )) && sspi->left_rx_cnt) sspi->rx_word (sspi); -/* Received all words */ -if ((sspi->left_rx_cnt ==0 ) && (sspi->left_tx_cnt ==0 )) { -complete (&sspi->done); -writel (0x0 , sspi->base +SIRFSOC_SPI_INT_EN ); - } - } - -if (spi_stat &SIRFSOC_SPI_RXFIFO_THD_REACH || - spi_stat &SIRFSOC_SPI_TXFIFO_THD_REACH || - spi_stat &SIRFSOC_SPI_RX_FIFO_FULL || - spi_stat &SIRFSOC_SPI_TXFIFO_EMPTY ) -tasklet_schedule (&sspi->tasklet_tx); +if (spi_stat & (SIRFSOC_SPI_FIFO_EMPTY + |SIRFSOC_SPI_TXFIFO_THD_REACH )) +while (!((readl (sspi->base +SIRFSOC_SPI_TXFIFO_STATUS ) + &SIRFSOC_SPI_FIFO_FULL )) && + sspi->left_tx_cnt) + sspi->tx_word (sspi); +/* Received all words */ +if ((sspi->left_rx_cnt ==0 ) && (sspi->left_tx_cnt ==0 )) { +complete (&sspi->done); +writel (0x0 , sspi->base +SIRFSOC_SPI_INT_EN ); + }return IRQ_HANDLED ; }
@@ -573,9 +559,6 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)init_completion (&sspi->done); -tasklet_init (&sspi->tasklet_tx, spi_sirfsoc_tasklet_tx, - (unsigned long )sspi); -writel (SIRFSOC_SPI_FIFO_RESET , sspi->base +SIRFSOC_SPI_RXFIFO_OP );writel (SIRFSOC_SPI_FIFO_RESET , sspi->base +SIRFSOC_SPI_TXFIFO_OP );writel (SIRFSOC_SPI_FIFO_START , sspi->base +SIRFSOC_SPI_RXFIFO_OP );
Signature · 6 lines
1.7.5.4 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
PATCH 1/1 spi: sirf: fix the issue while transferring more than 256 words
ping Mark, Ping Grant.
2013/3/18 Barry Song <[email protected]>:
Quoted 107 lines
From: Qipan Li <[email protected]>
currently, spi irq handler only does rx processing and fetching data from rx fifo when "
FRM_END" irq happens.FRM_ENDindicates one transfer completes. if rx size is less than 256, it works well.
but the problem is that spi rx fifo size is only 256 bytes, then if data size of one frame is more than 256, beforeFRM_ENDcomes, rx fifo will be filled withRXFIFO_OFLOWoverflow interrupt, it will make us lose some data due to fifo overflow.
Explicitly we need do fetch work from device rx fifo in irq handler not only in "FRM_END" irq but also in "THD_REACH" irq.THD_REACHmeans rx fifo has come to its threshold and will come to overflow if we don't take data from it in time.In this patch, we fix this issue. we take data from rx fifo when either
FRM_ENDorRX_THD_REACHirq comes, we put data into tx fifo when eitherTX_FIFO_EMPTYorTX_THD_REACHirq comes.Signed-off-by Qipan Li <[email protected]>Signed-off-by Zhiwu Song <[email protected]>Signed-off-by Barry Song <[email protected]>--- drivers/spi/spi-sirf.c | 43 +++++++++++++------------------------------ 1 files changed, 13 insertions(+), 30 deletions(-)drivers/spi/spi-sirf.c +13
-31@@ -142,9 +142,6 @@ struct sirfsoc_spi {unsigned int left_tx_cnt;unsigned int left_rx_cnt; -/* tasklet to push tx msg into FIFO */ -struct tasklet_struct tasklet_tx; -int chipselect[0 ]; };@@ -236,17 +233,6 @@ static void spi_sirfsoc_tx_word_u32(struct sirfsoc_spi *sspi) sspi->left_tx_cnt--; } -static void spi_sirfsoc_tasklet_tx (unsigned long arg) -{ -struct sirfsoc_spi *sspi = (struct sirfsoc_spi *)arg; - -/* Fill Tx FIFO while there are left words to be transmitted */ -while (!((readl (sspi->base +SIRFSOC_SPI_TXFIFO_STATUS ) & -SIRFSOC_SPI_FIFO_FULL )) && - sspi->left_tx_cnt) - sspi->tx_word (sspi); -} -static irqreturn_t spi_sirfsoc_irq (int irq,void *dev_id) {struct sirfsoc_spi *sspi = dev_id;@@ -261,25 +247,25 @@ static irqreturn_t spi_sirfsoc_irq(int irq, void *dev_id)writel (0x0 , sspi->base +SIRFSOC_SPI_INT_EN ); } -if (spi_stat &SIRFSOC_SPI_FRM_END ) { +if (spi_stat & (SIRFSOC_SPI_FRM_END + |SIRFSOC_SPI_RXFIFO_THD_REACH ))while (!((readl (sspi->base +SIRFSOC_SPI_RXFIFO_STATUS ) &SIRFSOC_SPI_FIFO_EMPTY )) && sspi->left_rx_cnt) sspi->rx_word (sspi); -/* Received all words */ -if ((sspi->left_rx_cnt ==0 ) && (sspi->left_tx_cnt ==0 )) { -complete (&sspi->done); -writel (0x0 , sspi->base +SIRFSOC_SPI_INT_EN ); - } - } - -if (spi_stat &SIRFSOC_SPI_RXFIFO_THD_REACH || - spi_stat &SIRFSOC_SPI_TXFIFO_THD_REACH || - spi_stat &SIRFSOC_SPI_RX_FIFO_FULL || - spi_stat &SIRFSOC_SPI_TXFIFO_EMPTY ) -tasklet_schedule (&sspi->tasklet_tx); +if (spi_stat & (SIRFSOC_SPI_FIFO_EMPTY + |SIRFSOC_SPI_TXFIFO_THD_REACH )) +while (!((readl (sspi->base +SIRFSOC_SPI_TXFIFO_STATUS ) + &SIRFSOC_SPI_FIFO_FULL )) && + sspi->left_tx_cnt) + sspi->tx_word (sspi); +/* Received all words */ +if ((sspi->left_rx_cnt ==0 ) && (sspi->left_tx_cnt ==0 )) { +complete (&sspi->done); +writel (0x0 , sspi->base +SIRFSOC_SPI_INT_EN ); + }return IRQ_HANDLED ; }@@ -573,9 +559,6 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)init_completion (&sspi->done); -tasklet_init (&sspi->tasklet_tx, spi_sirfsoc_tasklet_tx, - (unsigned long )sspi); -writel (SIRFSOC_SPI_FIFO_RESET , sspi->base +SIRFSOC_SPI_RXFIFO_OP );writel (SIRFSOC_SPI_FIFO_RESET , sspi->base +SIRFSOC_SPI_TXFIFO_OP );writel (SIRFSOC_SPI_FIFO_START , sspi->base +SIRFSOC_SPI_RXFIFO_OP ); --1.7.5.4
Mark Brown
maintainerPATCH 1/1 spi: sirf: fix the issue while transferring more than 256 words
Quoted 1 line · Barry Song
ping Mark, Ping Grant.
Don't top post, don't send contentless pings. At a guess you didn't CC
me...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130516/d62e5de4/attachment.sig>
PATCH 1/1 spi: sirf: fix the issue while transferring more than 256 words
2013/5/17 Mark Brown <[email protected]>:
Quoted 5 lines · Barry Song
Quoted 1 line
ping Mark, Ping Grant.
Don't top post, don't send contentless pings. At a guess you didn't CC me...
yes. i missed you in CC. sorry for that, Mark. so do you want me to resend it?
-barry
Mark Brown
maintainerPATCH 1/1 spi: sirf: fix the issue while transferring more than 256 words
Quoted 6 lines · Barry Song
2013/5/17 Mark Brown <[email protected]>:
Quoted 2 lines
Don't top post, don't send contentless pings. At a guess you didn't CC me...
yes. i missed you in CC. sorry for that, Mark. so do you want me to resend it?
Yes, please.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130517/84799da4/attachment-0001.sig>