From: Feng Tang <feng.tang@intel.com>
To: Greg KH <gregkh@linuxfoundation.org>, linux-serial@vger.kernel.org
Cc: Bin Gao <bin.gao@intel.com>, Feng Tang <feng.tang@intel.com>
Subject: [PATCH 2/2] serial: mrst_max3110: Fix race condition between spi transfers
Date: Wed, 9 Oct 2013 10:39:17 +0800 [thread overview]
Message-ID: <1381286357-13346-2-git-send-email-feng.tang@intel.com> (raw)
In-Reply-To: <1381286357-13346-1-git-send-email-feng.tang@intel.com>
From: Bin Gao <bin.gao@intel.com>
There is a race between termios configuration and xmit that can cause the
intel_mid_ssp_spi driver to stall.
Serializing spi transactions fixes the problem.
Signed-off-by: Bin Gao <bin.gao@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
---
drivers/tty/serial/mrst_max3110.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c
index ee77e73..565779d 100644
--- a/drivers/tty/serial/mrst_max3110.c
+++ b/drivers/tty/serial/mrst_max3110.c
@@ -61,6 +61,7 @@ struct uart_max3110 {
struct task_struct *main_thread;
struct task_struct *read_thread;
struct mutex thread_mutex;
+ struct mutex io_mutex;
u32 baud;
u16 cur_conf;
@@ -90,6 +91,7 @@ static int max3110_write_then_read(struct uart_max3110 *max,
struct spi_transfer x;
int ret;
+ mutex_lock(&max->io_mutex);
spi_message_init(&message);
memset(&x, 0, sizeof x);
x.len = len;
@@ -104,6 +106,7 @@ static int max3110_write_then_read(struct uart_max3110 *max,
/* Do the i/o */
ret = spi_sync(spi, &message);
+ mutex_unlock(&max->io_mutex);
return ret;
}
@@ -805,6 +808,7 @@ static int serial_m3110_probe(struct spi_device *spi)
max->irq = (u16)spi->irq;
mutex_init(&max->thread_mutex);
+ mutex_init(&max->io_mutex);
max->word_7bits = 0;
max->parity = 0;
--
1.7.0.4
prev parent reply other threads:[~2013-10-09 2:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-09 2:39 [PATCH 1/2] serial: mrst_max3110: Check the irq number before enable/disabe irq in PM hooks Feng Tang
2013-10-09 2:39 ` Feng Tang [this message]
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=1381286357-13346-2-git-send-email-feng.tang@intel.com \
--to=feng.tang@intel.com \
--cc=bin.gao@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-serial@vger.kernel.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 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).