* [PATCH] spi/omap2-mcpsi: Always call spi_finalize_current_message()
@ 2015-04-22 13:39 Fionn Cleary
[not found] ` <87vbgo2ser.fsf-/Zw1syy4LHg@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Fionn Cleary @ 2015-04-22 13:39 UTC (permalink / raw)
To: broonie-GFdadSzt00ze9xe1eoZjHA; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1.1: Type: text/plain, Size: 380 bytes --]
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
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-spi-omap2-mcpsi-Always-call-spi_finalize_current_mess.patch --]
[-- Type: text/x-diff, Size: 1928 bytes --]
>From 2ec7ba94e9045a78de14192690134fc3d53c38f0 Mon Sep 17 00:00:00 2001
From: Fionn Cleary <fionn.cleary-6oiIBCxl0MMjD8S081q9vkEOCMrvLtNR@public.gmane.org>
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-6oiIBCxl0MMjD8S081q9vkEOCMrvLtNR@public.gmane.org>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH] spi/omap2-mcpsi: Always call spi_finalize_current_message()
@ 2015-04-23 19:13 Fionn Cleary
[not found] ` <87h9s63bff.fsf-/Zw1syy4LHg@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Fionn Cleary @ 2015-04-23 19:13 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
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-6oiIBCxl0MMjD8S081q9vkEOCMrvLtNR@public.gmane.org>
---
drivers/spi/spi-omap2-mcspi.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 102cff5..f7b13e1 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1216,6 +1216,7 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master,
struct omap2_mcspi *mcspi;
struct omap2_mcspi_dma *mcspi_dma;
struct spi_transfer *t;
+ int status;
spi = m->spi;
mcspi = spi_master_get_devdata(master);
@@ -1235,7 +1236,8 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master,
tx_buf ? "tx" : "",
rx_buf ? "rx" : "",
t->bits_per_word);
- return -EINVAL;
+ status = -EINVAL;
+ goto out;
}
if (m->is_dma_mapped || len < DMA_MIN_BYTES)
@@ -1247,7 +1249,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;
+ status = -EINVAL;
+ goto out;
}
}
if (mcspi_dma->dma_rx && rx_buf != NULL) {
@@ -1259,14 +1262,19 @@ 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;
+ status = -EINVAL;
+ goto out;
}
}
}
omap2_mcspi_work(mcspi, m);
+ /* spi_finalize_current_message() changes the status inside the
+ * spi_message, save the status here. */
+ status = m->status;
+out:
spi_finalize_current_message(master);
- return 0;
+ return status;
}
static int omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
--
1.9.1
--
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] 4+ messages in thread
end of thread, other threads:[~2015-04-24 9:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-22 13:39 [PATCH] spi/omap2-mcpsi: Always call spi_finalize_current_message() Fionn Cleary
[not found] ` <87vbgo2ser.fsf-/Zw1syy4LHg@public.gmane.org>
2015-04-22 14:11 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2015-04-23 19:13 Fionn Cleary
[not found] ` <87h9s63bff.fsf-/Zw1syy4LHg@public.gmane.org>
2015-04-24 9:59 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.