serial: resolved race condition between spi transfers
authorMark F. Brown <mark.f.brown@intel.com>
Thu, 1 Mar 2012 22:10:43 +0000 (14:10 -0800)
committerbuildbot <buildbot@intel.com>
Sat, 10 Mar 2012 02:23:24 +0000 (18:23 -0800)
BZ: 25983

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.

Change-Id: I42204edbad571d109840eaab2ffcc884e8890885
Signed-off-by: Mark F. Brown <mark.f.brown@intel.com>
Reviewed-on: http://android.intel.com:8080/37363
Reviewed-by: Ng, Cheon-woei <cheon-woei.ng@intel.com>
Tested-by: Ng, Cheon-woei <cheon-woei.ng@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/tty/serial/mrst_max3110.c

index ef3a7d5..8288712 100644 (file)
@@ -57,6 +57,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;
@@ -87,6 +88,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;
@@ -101,6 +103,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;
 }
 
@@ -817,6 +820,7 @@ static int __devinit 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;