linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2, resend for stable 1/1] spi: dw-mid: clear BUSY flag fist and test other one
@ 2015-03-06 12:42 Andy Shevchenko
       [not found] ` <1425645721-18142-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2015-03-06 12:42 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA, Mark Brown; +Cc: 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.

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)
Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/spi/spi-dw-mid.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
index 3ce39d1..4f8c798 100644
--- a/drivers/spi/spi-dw-mid.c
+++ b/drivers/spi/spi-dw-mid.c
@@ -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);
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2, resend for stable 1/1] spi: dw-mid: clear BUSY flag fist and test other one
       [not found] ` <1425645721-18142-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2015-03-07 11:22   ` Mark Brown
       [not found]     ` <20150307112238.GK28806-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2015-03-07 11:22 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 398 bytes --]

On Fri, Mar 06, 2015 at 02:42:01PM +0200, Andy Shevchenko wrote:
> 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?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2, resend for stable 1/1] spi: dw-mid: clear BUSY flag fist and test other one
       [not found]     ` <20150307112238.GK28806-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2015-03-07 19:14       ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2015-03-07 19:14 UTC (permalink / raw)
  To: Mark Brown; +Cc: Andy Shevchenko, linux-spi-u79uwXL29TY76Z2rM5mHXA

On Sat, Mar 7, 2015 at 1:22 PM, Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> On Fri, Mar 06, 2015 at 02:42:01PM +0200, Andy Shevchenko wrote:
>> 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 ).

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-07 19:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-06 12:42 [PATCH v2, resend for stable 1/1] spi: dw-mid: clear BUSY flag fist and test other one Andy Shevchenko
     [not found] ` <1425645721-18142-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-03-07 11:22   ` Mark Brown
     [not found]     ` <20150307112238.GK28806-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-03-07 19:14       ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).