Skip to contentSkip to conversation

spi: dw-mid: clear BUSY flag fist and test other one

PATCH RESEND Applied Andy Shevchenko 3 participants 3 messages Mar 6, 2015 – Mar 7, 2015 2 messages not in the archive SPI

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v2 1/1 spi: dw-mid: clear BUSY flag fist and test other one

The logic of DMA completion is broken now since test_and_clear_bit() never returns the other bit is set. It means condition are always false and we have spi_finalize_current_transfer() called per each DMA completion which is wrong.

The patch fixes logic by clearing BUSY bit first and then check for the other one.

Fixes 30c8eb52cc4a (spi: dw-mid: split rx and tx callbacks when DMA)
---
 drivers/spi/spi-dw-mid.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/spi/spi-dw-mid.c +4 -2
index 3ce39d1..4f8c798 100644
@@ -108,7 +108,8 @@ static void dw_spi_dma_tx_done(void *arg)
 {
 	struct dw_spi *dws = arg;
 
-	if (test_and_clear_bit(TX_BUSY, &dws->dma_chan_busy) & BIT(RX_BUSY))
+	clear_bit(TX_BUSY, &dws->dma_chan_busy);
+	if (test_bit(RX_BUSY, &dws->dma_chan_busy))
 		return;
 	dw_spi_xfer_done(dws);
 }
@@ -156,7 +157,8 @@ static void dw_spi_dma_rx_done(void *arg)
 {
 	struct dw_spi *dws = arg;
 
-	if (test_and_clear_bit(RX_BUSY, &dws->dma_chan_busy) & BIT(TX_BUSY))
+	clear_bit(RX_BUSY, &dws->dma_chan_busy);
+	if (test_bit(TX_BUSY, &dws->dma_chan_busy))
 		return;
 	dw_spi_xfer_done(dws);
 }
Signature · 6 lines
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1425645721-18142-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]

Applied
#2 lore raw
Quoted 3 lines · Andy Shevchenko

The logic of DMA completion is broken now since test_and_clear_bit() never returns the other bit is set. It means condition are always false and we have spi_finalize_current_transfer() called per each DMA completion which is wrong.

Applied, thanks. I assume you're also going to resend the other bits if they're still valid?

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

#4 lore raw
Quoted 7 lines · Mark Brown
Quoted 3 lines · Andy Shevchenko

The logic of DMA completion is broken now since test_and_clear_bit() never returns the other bit is set. It means condition are always false and we have spi_finalize_current_transfer() called per each DMA completion which is wrong.

Applied, thanks. I assume you're also going to resend the other bits if they're still valid?

Yes, they are.
I will do next working day (On Monday I think ).

Signature · 6 lines
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html