diff mbox

spi/omap2-mcpsi: Always call spi_finalize_current_message()

Message ID 87vbgo2ser.fsf@tcd.ie (mailing list archive)
State New, archived
Headers show

Commit Message

Fionn Cleary April 22, 2015, 1:39 p.m. UTC
Hi,

While testing the omap2-mcspi driver I discovered that triggering the
error conditions in omap2_mcspi_transfer_one_message() will result in
the queue for the bus locking up while waiting for
spi_finalize_current_message().  This patch ensure that
spi_finalize_current_message() is always called for all error conditions
in omap2_mcspi_transfer_one_message().

Regards,
Fionn

Comments

Mark Brown April 22, 2015, 2:11 p.m. UTC | #1
On Wed, Apr 22, 2015 at 03:39:56PM +0200, Fionn Cleary wrote:
> Hi,
> 
> While testing the omap2-mcspi driver I discovered that triggering the
> error conditions in omap2_mcspi_transfer_one_message() will result in
> the queue for the bus locking up while waiting for
> spi_finalize_current_message().  This patch ensure that
> spi_finalize_current_message() is always called for all error conditions
> in omap2_mcspi_transfer_one_message().

Please follow the patch submission process covered in SubmittingPatches
- please send to the maintainer and send in the format covered there.
diff mbox

Patch

From 2ec7ba94e9045a78de14192690134fc3d53c38f0 Mon Sep 17 00:00:00 2001
From: Fionn Cleary <fionn.cleary@streamunlimited.com>
Date: Wed, 22 Apr 2015 13:40:53 +0200
Subject: [PATCH] spi/omap2-mcpsi: Always call spi_finalize_current_message()

The spi queue waits forever for spi_finalize_current_message() to be
called, blocking the bus.  Ensure that all error paths from
omap2_mcspi_transfer_one_message() call spi_finalize_current_message().

Signed-off-by: Fionn Cleary <fionn.cleary@streamunlimited.com>
---
 drivers/spi/spi-omap2-mcspi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 3bc3cba..4acce76 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1234,7 +1234,8 @@  static int omap2_mcspi_transfer_one_message(struct spi_master *master,
 					tx_buf ? "tx" : "",
 					rx_buf ? "rx" : "",
 					t->bits_per_word);
-			return -EINVAL;
+			m->status = -EINVAL;
+			goto out;
 		}
 
 		if (m->is_dma_mapped || len < DMA_MIN_BYTES)
@@ -1246,7 +1247,8 @@  static int omap2_mcspi_transfer_one_message(struct spi_master *master,
 			if (dma_mapping_error(mcspi->dev, t->tx_dma)) {
 				dev_dbg(mcspi->dev, "dma %cX %d bytes error\n",
 						'T', len);
-				return -EINVAL;
+				m->status = -EINVAL;
+				goto out;
 			}
 		}
 		if (mcspi_dma->dma_rx && rx_buf != NULL) {
@@ -1258,14 +1260,16 @@  static int omap2_mcspi_transfer_one_message(struct spi_master *master,
 				if (tx_buf != NULL)
 					dma_unmap_single(mcspi->dev, t->tx_dma,
 							len, DMA_TO_DEVICE);
-				return -EINVAL;
+				m->status = -EINVAL;
+				goto out;
 			}
 		}
 	}
 
 	omap2_mcspi_work(mcspi, m);
+out:
 	spi_finalize_current_message(master);
-	return 0;
+	return m->status;
 }
 
 static int omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
-- 
1.9.1