Changes to add Bt support for WaRP Murata chip

Preliminary changes from Scott Kerr of Murata to enable Bluetooth
functioning

Signed-off-by: Diego Rondini <diego.rondini@kynetics.it>
Additional changes to add Bt support for WaRP Murata chip

Changes from Scott Kerr of Murata to workaround Bluetooth UART flow
control problem.

Signed-off-by: Diego Rondini <diego.rondini@kynetics.it>
Merge branch 'warp/jb4.3_1.1.0-ga' into warp/murata-bt/jb4.3_1.1.0-ga
ENGR00296217 serial: imx: use the atomic bit operation to sync the TX

Check the DMA status (DMA_IN_PROGRESS) is not strict enough, the two
TXs may also submit the DMA operation to the SDMA at the same time.
And the SDMA will hang at this case.

This patch uses the bit operation to sync the DMA TX.

Also make it always wake up the process in the TX callback.

Signed-off-by: Huang Shijie <b32955@freescale.com>
MLK-9816-01 dmaengine: imx: fix loop mode issue

MLK-9816-01 dmaengine: imx: fix loop mode issue

Fix loop mode issue that calling dmaengine_tx_status() can get
right state.residue value.
(cherry-picked: 37e17f10b35c34317def08704e4b4edf5aa23894)

Signed-off-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: Robin Gong <b38343@freescale.com>
serial: imx: Fix recursive locking bug

serial: imx: Fix recursive locking bug

commit 9ec1882df2 (tty: serial: imx: console write routing is unsafe
on SMP) introduced a recursive locking bug in imx_console_write().

The callchain is:

imx_rxint()
  spin_lock_irqsave(&sport->port.lock,flags);
  ...
  uart_handle_sysrq_char();
    sysrq_function();
      printk();
        imx_console_write();
          spin_lock_irqsave(&sport->port.lock,flags); <--- DEAD

The bad news is that the kernel debugging facilities can dectect the
problem, but the printks never surface on the serial console for
obvious reasons.

There is a similar issue with oops_in_progress. If the kernel crashes
we really don't want to be stuck on the lock and unable to tell what
happened.

In general most UP originated drivers miss these checks and nobody
ever notices because CONFIG_PROVE_LOCKING seems to be still ignored by
a large number of developers.

The solution is to avoid locking in the sysrq case and trylock in the
oops_in_progress case.

This scheme is used in other drivers as well and it would be nice if
we could move this to a common place, so the usual copy/paste/modify
bugs can be avoided.

Now there is another issue with this scheme:
CPU0                         CPU1
printk()
                     rxint()
                       sysrq_detection() -> sets port->sysrq
                     return from interrupt
  console_write()
     if (port->sysrq)
            avoid locking

port->sysrq is reset with the next receive character. So as long as
the port->sysrq is not reset and this can take an endless amount of
time if after the break no futher receive character follows, all
console writes happen unlocked.

While the current writer is protected against other console writers by
the console sem, it's unprotected against open/close or other
operations which fiddle with the port. That's what the above mentioned
commit tried to solve.

That's an issue in all drivers which use that scheme and unfortunately
there is no easy workaround. The only solution is to have a separate
indicator port->sysrq_cpu. uart_handle_sysrq_char() then sets it to
smp_processor_id() before calling into handle_sysrq() and resets it to
-1 after that. Then change the locking check to:

     if (port->sysrq_cpu == smp_processor_id())
             locked = 0;
     else if (oops_in_progress)
         locked = spin_trylock_irqsave(port->lock, flags);
     else
     spin_lock_irqsave(port->lock, flags);

That would force all other cpus into the spin_lock path. Problem
solved, but that's way beyond the scope of this fix and really wants
to be implemented in a common function which calls the uart specific
write function to avoid another gazillion of hard to debug
copy/paste/modify bugs.

(cherry-picked from 677fe555cbfb188af58cce105f4dae9505e58c31, there have
 some collsion, change it in manual)

Reported-and-tested-by: Tim Sander <tim@krieglstein.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable <stable@vger.kernel.org>  # 3.6+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Fugang Duan <B38611@freescale.com>
MLK-9816-02 tty: serial: imx: optimize the rx performance

MLK-9816-02 tty: serial: imx: optimize the rx performance

Optimize the uart rx performance that use SDMA loop mode instead
of normal mode. After the changes, uart rx fifo overrun issue disappear
even if hw flow control is disabled.

(cherry-picked and merge: 3a3eadcc2ab02029236fd0a5ae1c4e9369781157)

Signed-off-by: Fugang Duan <B38611@freescale.com>
Merge Bluetooth changes