All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fionn Cleary <clearyf-/Zw1syy4LHg@public.gmane.org>
To: broonie-GFdadSzt00ze9xe1eoZjHA@public.gmane.org
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] spi/omap2-mcpsi: Always call spi_finalize_current_message()
Date: Wed, 22 Apr 2015 15:39:56 +0200	[thread overview]
Message-ID: <87vbgo2ser.fsf@tcd.ie> (raw)


[-- 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


             reply	other threads:[~2015-04-22 13:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22 13:39 Fionn Cleary [this message]
     [not found] ` <87vbgo2ser.fsf-/Zw1syy4LHg@public.gmane.org>
2015-04-22 14:11   ` [PATCH] spi/omap2-mcpsi: Always call spi_finalize_current_message() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vbgo2ser.fsf@tcd.ie \
    --to=clearyf-/zw1syy4lhg@public.gmane.org \
    --cc=broonie-GFdadSzt00ze9xe1eoZjHA@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.