Skip to contentSkip to conversation

spi/omap2-mcpsi: Always call spi_finalize_current_message()

PATCH In review Fionn Cleary 2 participants 2 messages Apr 22, 2015 1 message not in the archive SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi/omap2-mcpsi: Always call spi_finalize_current_message()

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

Quoted 1 line

From 2ec7ba94e9045a78de14192690134fc3d53c38f0 Mon Sep 17 00:00:00 2001

From: Fionn Cleary <[email protected]>
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().

---
 drivers/spi/spi-omap2-mcspi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/spi/spi-omap2-mcspi.c +8 -4
index 3bc3cba..4acce76 100644
@@ -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)
Signature · 1 line
1.9.1

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

#2 lore raw
Quoted 8 lines · Fionn Cleary

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.