Commit graph

547855 commits

Author SHA1 Message Date
Luis de Bethencourt
50a84487c3 tty: serial: apbuart: Fix module autoload for OF platform driver
This platform driver has a OF device ID table but the OF module
alias information is not created so module autoloading won't work.

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 19:09:21 +01:00
Mans Rullgard
9b2256c827 serial: 8250: simplify ralink/alchemy register remap selection
Some SoCs, including Ralink/Mediatek and Alchemy Au1xxx, have a
16550-like UART with a non-standard register layout.  These are
supported by a simple mapping table in 8250_port.c  Rather than
list every SoC type using this access mode in the ifdefs there,
allow selecting the SERIAL_8250_RT288X Kconfig option with any
system and default it to y for the known cases needing it.  The
help text is reworded accordingly.

This change simplifies adding support for other SoCs also using
the same UART.

The name of the option is a little misleading, but not knowing
the true origin of this UART, it is as good a choice as any.

Signed-off-by: Mans Rullgard <mans@mansr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 19:09:21 +01:00
Dmitry Vyukov
facd885c75 tty: fix data race on tty_buffer.commit
Race on buffer data happens when newly committed data is
picked up by an old flush work in the following scenario:
__tty_buffer_request_room does a plain write of tail->commit,
no barriers were executed before that.
At this point flush_to_ldisc reads this new value of commit,
and reads buffer data, no barriers in between.
The committed buffer data is not necessary visible to flush_to_ldisc.

Similar bug happens when tty_schedule_flip commits data.

Update commit with smp_store_release and read commit with
smp_load_acquire, as it is commit that signals data readiness.
This is orthogonal to the existing synchronization on tty_buffer.next,
which is required to not dismiss a buffer with unconsumed data.

The data race was found with KernelThreadSanitizer (KTSAN).

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 19:03:40 +01:00
Dmitry Vyukov
9e6b7cd7e7 tty: fix data race in tty_buffer_flush
tty_buffer_flush frees not acquired buffers.
As the result, for example, read of b->size in tty_buffer_free
can return garbage value which will lead to a huge buffer
hanging in the freelist. This is just the benignest
manifestation of freeing of a not acquired object.
If the object is passed to kfree, heap can be corrupted.

Acquire visibility over the buffer before freeing it.

The data race was found with KernelThreadSanitizer (KTSAN).

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 19:03:40 +01:00
Dmitry Vyukov
7098296a36 tty: fix data race in flush_to_ldisc
flush_to_ldisc reads port->itty and checks that it is not NULL,
concurrently release_tty sets port->itty to NULL. It is possible
that flush_to_ldisc loads port->itty once, ensures that it is
not NULL, but then reloads it again and uses. The second load
can already return NULL, which will cause a crash.

Use READ_ONCE to read port->itty.

The data race was found with KernelThreadSanitizer (KTSAN).

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 19:03:40 +01:00
Kosuke Tatsukawa
e81107d4c6 tty: fix stall caused by missing memory barrier in drivers/tty/n_tty.c
My colleague ran into a program stall on a x86_64 server, where
n_tty_read() was waiting for data even if there was data in the buffer
in the pty.  kernel stack for the stuck process looks like below.
 #0 [ffff88303d107b58] __schedule at ffffffff815c4b20
 #1 [ffff88303d107bd0] schedule at ffffffff815c513e
 #2 [ffff88303d107bf0] schedule_timeout at ffffffff815c7818
 #3 [ffff88303d107ca0] wait_woken at ffffffff81096bd2
 #4 [ffff88303d107ce0] n_tty_read at ffffffff8136fa23
 #5 [ffff88303d107dd0] tty_read at ffffffff81368013
 #6 [ffff88303d107e20] __vfs_read at ffffffff811a3704
 #7 [ffff88303d107ec0] vfs_read at ffffffff811a3a57
 #8 [ffff88303d107f00] sys_read at ffffffff811a4306
 #9 [ffff88303d107f50] entry_SYSCALL_64_fastpath at ffffffff815c86d7

There seems to be two problems causing this issue.

First, in drivers/tty/n_tty.c, __receive_buf() stores the data and
updates ldata->commit_head using smp_store_release() and then checks
the wait queue using waitqueue_active().  However, since there is no
memory barrier, __receive_buf() could return without calling
wake_up_interactive_poll(), and at the same time, n_tty_read() could
start to wait in wait_woken() as in the following chart.

        __receive_buf()                         n_tty_read()
------------------------------------------------------------------------
if (waitqueue_active(&tty->read_wait))
/* Memory operations issued after the
   RELEASE may be completed before the
   RELEASE operation has completed */
                                        add_wait_queue(&tty->read_wait, &wait);
                                        ...
                                        if (!input_available_p(tty, 0)) {
smp_store_release(&ldata->commit_head,
                  ldata->read_head);
                                        ...
                                        timeout = wait_woken(&wait,
                                          TASK_INTERRUPTIBLE, timeout);
------------------------------------------------------------------------

The second problem is that n_tty_read() also lacks a memory barrier
call and could also cause __receive_buf() to return without calling
wake_up_interactive_poll(), and n_tty_read() to wait in wait_woken()
as in the chart below.

        __receive_buf()                         n_tty_read()
------------------------------------------------------------------------
                                        spin_lock_irqsave(&q->lock, flags);
                                        /* from add_wait_queue() */
                                        ...
                                        if (!input_available_p(tty, 0)) {
                                        /* Memory operations issued after the
                                           RELEASE may be completed before the
                                           RELEASE operation has completed */
smp_store_release(&ldata->commit_head,
                  ldata->read_head);
if (waitqueue_active(&tty->read_wait))
                                        __add_wait_queue(q, wait);
                                        spin_unlock_irqrestore(&q->lock,flags);
                                        /* from add_wait_queue() */
                                        ...
                                        timeout = wait_woken(&wait,
                                          TASK_INTERRUPTIBLE, timeout);
------------------------------------------------------------------------

There are also other places in drivers/tty/n_tty.c which have similar
calls to waitqueue_active(), so instead of adding many memory barrier
calls, this patch simply removes the call to waitqueue_active(),
leaving just wake_up*() behind.

This fixes both problems because, even though the memory access before
or after the spinlocks in both wake_up*() and add_wait_queue() can
sneak into the critical section, it cannot go past it and the critical
section assures that they will be serialized (please see "INTER-CPU
ACQUIRING BARRIER EFFECTS" in Documentation/memory-barriers.txt for a
better explanation).  Moreover, the resulting code is much simpler.

Latency measurement using a ping-pong test over a pty doesn't show any
visible performance drop.

Signed-off-by: Kosuke Tatsukawa <tatsu@ab.jp.nec.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 19:03:40 +01:00
Uwe Kleine-König
8f1bd8f2ad serial: atmel: fix error path of probe function
If atmel_init_gpios fails the port has already been marked as busy (in
line 2629), so this must be undone in the error path.

This bug was introduced because I created the patch that finally
became 722ccf416a ("serial: atmel: fix error handling when
mctrl_gpio_init fails") on top of 3.19 which didn't have commit
6fbb9bdf0f ("tty/serial: at91: fix error handling in
atmel_serial_probe()") yet.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fixes: 722ccf416a ("serial: atmel: fix error handling when mctrl_gpio_init fails")
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:51:42 +01:00
Leon Yu
c1a752ba2d tty: don't leak cdev in tty_cdev_add()
Commit a3a10ce342 ("Avoid usb reset crashes by making tty_io cdevs truly
dynamic") which mixes using cdev_alloc() and cdev_init() is problematic.
Subsequent call to cdev_init() after cdev_alloc() sets kobj release method
from cdev_dynamic_release() to cdev_default_release() and thus makes it
impossible to free allocated cdev.

This patch also consolidates error path of cdev_add() as cdev can also leak
here if things went wrong.

Signed-off-by: Leon Yu <chianglungyu@gmail.com>
Fixes: a3a10ce342 ("Avoid usb reset crashes by making tty_io cdevs truly dynamic")
Acked-by: Richard Watts <rrw@kynesim.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:51:42 +01:00
Fabio Estevam
0c727a4204 Revert "serial: imx: remove unbalanced clk_prepare"
This reverts commit 9e7b399d65.

Commit ("9e7b399d6528ea") causes the following warning and sometimes
also hangs the system:

------------[ cut here ]------------
 WARNING: CPU: 0 PID: 0 at kernel/locking/mutex.c:868 mutex_trylock+0x20c/0x22c()
 DEBUG_LOCKS_WARN_ON(in_interrupt())
 Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.2.0-rc7-next-20150818-00001-g14418a6 #4
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
Backtrace:
[<80012f08>] (dump_backtrace) from [<800130a4>] (show_stack+0x18/0x1c)
r6:00000364 r5:00000000 r4:00000000 r3:00000000
[<8001308c>] (show_stack) from [<807902b8>] (dump_stack+0x88/0xa4)
[<80790230>] (dump_stack) from [<8002a604>] (warn_slowpath_common+0x80/0xbc)
r5:807945c4 r4:80ab3b50
[<8002a584>] (warn_slowpath_common) from [<8002a6e4>] (warn_slowpath_fmt+0x38/0x40)
r8:00000000 r7:8131100c r6:8054c3cc r5:8131300c r4:80b0a570
[<8002a6b0>] (warn_slowpath_fmt) from [<807945c4>] (mutex_trylock+0x20c/0x22c)
r3:8095d0d8 r2:8095ab28
[<807943b8>] (mutex_trylock) from [<8054c3cc>] (clk_prepare_lock+0x14/0xf4)
r7:8131100c r6:be3f0c80 r5:00000037 r4:be3f0c80
[<8054c3b8>] (clk_prepare_lock) from [<8054dbfc>] (clk_prepare+0x18/0x30)
r5:00000037 r4:be3f0c80
[<8054dbe4>] (clk_prepare) from [<8036a600>] (imx_console_write+0x30/0x244)
r4:812d0bc8 r3:8132b9a4

To reproduce the problem we only need to let the board idle for something
like 30 seconds.

Tested on a imx6q-sabresd.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:51:42 +01:00
Uwe Kleine-König
ce59e48fdb serial: mctrl_gpio: implement interrupt handling
This allows to reduce the per-driver boiler plate considerably.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:47:51 +01:00
Uwe Kleine-König
7d8c70d804 serial: mctrl-gpio: rename init function
This is done before adding more functionality to the init function with
the existing name. As this new functionality conflicts with stuff
drivers are required to implement themselves up to I want to convert
them one by one to make reviewing and reverting more easy in case I
broke something.

Once mctrl_gpio_init is there and all drivers are converted
mctrl_gpio_init_noauto can be removed again.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:46:43 +01:00
Uwe Kleine-König
dc2454f7eb serial: mxs-auart+imx: allow compile testing on non-Freescale architectures
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:46:43 +01:00
Uwe Kleine-König
c8d1f02245 serial: atmel: allow compile testing on non-atmel architectures
This commit also fixes compiler warnings and errors seen when building
on x86_64.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:45:18 +01:00
Lucas Stach
abc7882aac serial: imx: also update RX stats in DMA path
The RX bytecount was only updated in the PIO path and thus
the device erroneously reported a value of 0 if DMA is in
use.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Acked-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:44:29 +01:00
Lucas Stach
7e11577ef6 serial: imx: re-enable DMA support without hardware flow control
The commit enabling DMA support even if no flow control is present
was reverted on the grounds that it uncovered a number of bugs in
the code that lead to hanging tty devices and/or missing characters.

After tracking down the issues it is clear that those were generic
bugs and had nothing to do with flow control being present or not,
only that allowing DMA without hardware flow control increased
the exposure of that code a lot.

Now that those bugs are fixed, it should be safe to re-enable DMA
support.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Acked-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:43:30 +01:00
Lucas Stach
905c0decad serial: imx: don't use idle condition detect for DMA transfers
The reference manual states that idle condition detect should not be used
with DMA transfers, as the ROM SDMA scripts don't check those conditions.

The RAM SDMA scripts worked around this, but the change broke compatibility
with the ROM scripts.

The previous commits fixed the DMA burst sizes, so that the aging timer is
now working as described in the reference manual. With this fixed we can
remove the hack of using the idle condition detect to stop the DMA transfer
if there are no new characters incoming.

This should work with both the ROM and RAM SDMA scripts.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Acked-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:43:06 +01:00
Lucas Stach
184bd70bbc serial: imx: configure proper DMA burst sizes
Triggering the DMA engine for every byte is horribly inefficient.
Also it doesn't allow to use the aging timer for the RX FIFO as this
requires the DMA engine to leave one byte remaining in the FIFO when
doing a normal burst transfer.

Adjust watermark levels so that the DMA engine can do at least 8 byte
burst transfers. This is a conservative value, as the both TX and RX
FIFOs are able to contain 32 bytes.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Acked-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:43:06 +01:00
Lucas Stach
976b39cd5b serial: imx: always restart DMA if more data is available
Simplify the DMA restart logic to always queue up the next transfer
immediately if there is at least one more byte available in the FIFO,
so that the transfer will finish in a limited time.

This way the driver stops to rely on zero length transfers to signal
transfers ends. Those will go away when the idle detect DMA requests
are disabled.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Acked-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:42:26 +01:00
Lucas Stach
86a04ba642 serial: imx: set up aging timer interrupt as DMA trigger
The DMA transfer is only started once we are sure it will finish
in a limited time, i.e. only after we received a RRDY interrupt.

In order to allow the watermark level to be raised the aging
timer and the corresponding interrupt need to be set up as an
additional trigger, so that the transfer is also started if the
incoming amount of bytes never reach the watermark.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Acked-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:41:09 +01:00
Lucas Stach
cc32382d9f serial: imx: make setup_ufcr more useful
This function currently doesn't use its parameter.

Change prototype to pass in watermark levels, so we can reuse this
function in the DMA setup paths. Also relocate to be near the calling
functions.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Acked-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:41:09 +01:00
Heikki Krogerus
7693c79ce0 serial: 8250_dw: don't set UPF_BOOT_AUTOCONF flag
serial8250_register_8250_port adds it to all ports it
registers. No need to set it separately.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:38:45 +01:00
Heikki Krogerus
2338a75e0f serial: 8250_dw: cleanup dw8250_setup_port
Using the same style of declaring variables as used in the
other functions of the driver. Passing uart_port to the
function instead of uart_8250_port, as it is the one mostly
needed.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:38:45 +01:00
Heikki Krogerus
83ce95ef5e serial: 8250_dw: cleanup dw8250_idma_filter
Remove the extra return.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:38:45 +01:00
Heikki Krogerus
1edb3cf21f serial: 8250_dw: rename and comment the fallback dma filter
Adding comment where the purpose of the function is
explained.

The dma parameters are not used, so removing them, and also
moving the assignment of the function to the same place
where the other dw8250_data structures members are being set
in dw8250_probe.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:38:45 +01:00
Heikki Krogerus
c73942e22a serial: 8250_dw: proper support for UARTs without busy functionality
If the DW_apb_uart is configured with UART_16550_COMPATIBLE
configuration parameter set, then the Busy Functionality is
not available. These UARTs will never generate the Busy
detect indication interrupt, and therefore don't need
handling for it.

This creates a small optimization for the DW_apb_uarts
configured without the busy functionality, but more
importantly, it removes the small but real risk of hitting
potential issues caused by busy functionality handling when
no busy functionality exist.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:38:45 +01:00
Heikki Krogerus
9e08fa50b2 serial: 8250_dw: add dw8250_quirks function
Merging the DT and ACPI specific probe functions into
dw8250_quirks. Those functions did not have that much code
any more and some of the quirks need to be shared. This
will also allow platforms without DT or ACPI to use the
driver.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:38:45 +01:00
Heikki Krogerus
4f042054fa serial: 8250_dw: only setup the port from one place
This adds a flag "skip_autocfg" that the platforms that do
not have the ADDITIONAL_FEATURES implemented can use to skip
the port setup. It's then enough to call dw8250_setup_port
just from dw8250_probe based on that flag.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:38:45 +01:00
Heikki Krogerus
2559318caa serial: 8250_dw: hook the DMA in one place
Instead of assigning the dma member in dw8250_probe_of and
dw8250_probe_acpi separately, assigning it in dw8250_probe.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:38:45 +01:00
Heikki Krogerus
1bd8edba10 serial: 8250_dw: adapt to unified device property interface
This makes the properties available for all types of
platforms instead of just the ones using DT.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:38:45 +01:00
Heikki Krogerus
78d3da75d5 serial: 8250_dw: add separate pointer for the uart_port to dw8250_probe
For convenience, adding separate pointer for the "port"
member of struct uart_8250_port that is being filled in the
probe function.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 18:38:45 +01:00
Scott Wood
d05f15707b serial: 8250: Add OF earlycon support
This allows earlycon to be used without needing to specify the I/O
address on the kernel command line, if linux,stdout-path is specified
in the chosen node.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:49:27 +01:00
Lucas Stach
913c6c0e94 serial: imx: add earlycon support
Earlycon allows to have an early debugging console that doesn't need
to be statically configured in the kernel config, like earlyprintk,
but is set up through the stdout-path DT property.

This allows to have the early debugging always built into the
kernel and enabled on demand without clashing between different boards
or architectures.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:49:27 +01:00
Abhimanyu Kapur
4cad4c57e0 ARM64: TTY: hvc_dcc: Add support for ARM64 dcc
Add support for debug communications channel based
hvc console for arm64 cpus.

Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
Signed-off-by: Timur Tabi <timur@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:49:27 +01:00
Timur Tabi
3d27070108 hvc_dcc: don't ignore errors during initialization
hvc_instantiate() and hvc_alloc() return errors if they fail, so don't
ignore them.

Signed-off-by: Timur Tabi <timur@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:49:27 +01:00
Alexandre Belloni
9af92fbff3 tty/serial: at91: move ATMEL_MAX_UART
Move ATMEL_MAX_UART from platform_data/atmel.h to atmel_serial.c as this is
the only file using it and it is common practise from tty/serial drivers to
define it directly in the driver file.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:47:49 +01:00
Martin Sperl
ed4492fa91 serial: of-serial: compile correctly when 8250 driver is compiled as module
If the 8250 driver is compiled as a module then
CONFIG_SERIAL_8250_MODULE is defined and not CONFIG_SERIAL_8250.

This results in all those code sections that require CONFIG_SERIAL_8250
to be defined are not included.

This patch fixes the situation and allows 8250 and of-serial to
be compiled as a module with the same functionality as when
compiled into the kernel.

Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:47:49 +01:00
Tobias Klauser
d144aff136 serial: altera_uart: Use of_property_read_u32 instead of open-coding it
Use of_property_read_u32 instead of of_get_property with return value
checks and endianness conversion. Also remove the !CONFIG_OF
implementation of altera_uart_get_of_uartclk as of_property_read_u32
will return a non-zero value for !CONFIG_OF.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:47:49 +01:00
Matt Redfearn
acccab429b devicetree: Add JZ4760/JZ4775 to Ingenic SoC UART binding
Add these variants of the UART as compatible strings

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>

blah
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:47:49 +01:00
Matt Redfearn
c74997bdfe serial: 8250_ingenic: Enable FIFO for Ingenic UARTs
Enable the TX/RX FIFOs present on UARTs in Ingenic SoCs.
FIFO sizes vary per device so match these based on
the OF compatible string

Enabling the FIFOs permits much faster transfer with
lower CPU overhead.

Tested on Ingenic JZ4780 on the MIPS Ci20 Creator board

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:47:49 +01:00
Matt Redfearn
129a45b1a9 serial: 8250_ingenic: Enable hardware flow control
The Ingenic UART is similar to a standard 16550, but hardware flow control
requires setting a couple of additional, non-standard bits in the MCR.

The non-standard "modem control enable" and "hardware flow control
mode" bits are set when writing to the MCR register, based
on whether the modem control interrupt is active.

Additionally the non-16550 compliant parts of the uart need to be
masked from higher layers.

Tested on Ingenic JZ4780 on MIPS Creator Ci20 board

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:47:49 +01:00
Javier Martinez Canillas
20b5af9350 serial: sc16is7xx: Remove unnecessary MODULE_ALIAS()
The driver has a I2C device id table that is used to create the modaliases
and also "sc16is7xx" is not a supported I2C id, so it's never used.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:44:52 +01:00
Axel Lin
57e7e2a64a serial: mux: Convert to uart_console_device instead of open-coded
The implementation of mux_console_device() is very similar to
uart_console_device(). Setting .data field in mux_console then we can
convert to use uart_console_device().

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:44:52 +01:00
Fabio Estevam
7401349608 serial: 68328serial: Use NULL for pointers
Compare pointer-typed values to NULL rather than 0

The semantic patch that makes this change is available
in scripts/coccinelle/null/badzero.cocci.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:44:52 +01:00
Robert Baldyga
09557c0169 serial: samsung: Fix UART status handling in DMA mode
So far, when interrupt occured in DMA mode, it was handled by terminating
DMA transfer and draining data remaining in RX FIFO. It worked well
until interrupt was caused by timeout, but the same interrupt can be
alse caused by special condition (eg. 'break'), which requires special
handling. In such case handling mechanism was the same - DMA transaction
was terminated and FIFO was drained, but any special conditions were
ingnored. Because of this in DMA mode there was no ability to use,
for example, Magic SysRq.

This patch fixes this problem by using s3c24xx_serial_rx_drain_fifo()
function instead of uart_rx_drain_fifo(), which does the same thing
(drains RX FIFO) plus checks UART status to detect special conditions
(such as 'break'). Thanks to this we have exactly the same UART status
handling in both DMA and PIO mode.

This change additionally simplifies RX handling code, as we no longer
need uart_rx_drain_fifo() function, so we can remove it.

Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:44:52 +01:00
Robert Baldyga
01732dd25c serial: samsung: introduce s3c24xx_serial_rx_drain_fifo() function
This patch introduces s3c24xx_serial_rx_drain_fifo() which reads data
from RX FIFO and writes it to tty buffer. It also checks for special
conditions (such as 'break') and handles it. This function has been
separated from s3c24xx_serial_rx_chars_pio() as it contains code which
can be used also in DMA mode.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:44:52 +01:00
Robert Baldyga
620bb21448 serial: samsung: remove unneded 'ignore_char' label
This label does nothing special and we don't need to have it anymore.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:44:52 +01:00
Robert Baldyga
e4678afeff serial: samsung: remove unused 'irq' parameter
This parameter is not used anywhere, so we can get rid of it.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:44:52 +01:00
Geert Uytterhoeven
ff4411296e serial: sh-sci: Add DT support to DMA setup
Add support for obtaining DMA channel information from the device tree.

This requires switching from the legacy sh_dmae_slave structures with
hardcoded channel numbers and the corresponding filter function to:
  1. dma_request_slave_channel_compat(),
       - On legacy platforms, dma_request_slave_channel_compat() uses
	 the passed DMA channel numbers that originate from platform
	 device data,
       - On DT-based platforms, dma_request_slave_channel_compat() will
	 retrieve the information from DT.
  2. and the generic dmaengine_slave_config() configuration method,
     which requires filling in DMA register ports and slave bus widths.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:36:10 +01:00
Muhammad Hamza Farooq
e7327c09de serial: sh-sci: Pause DMA engine and get DMA status again
Occasionally, DMA transaction completes _after_ DMA engine is stopped.
Verify if the transaction has not finished before forcing the engine to
stop and push the data

Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:36:10 +01:00
Muhammad Hamza Farooq
3b963042b6 serial: sh-sci: Do not terminate DMA engine when race condition occurs
When DMA packet completion and timer expiry take place at the same time,
do not terminate the DMA engine, leading by submission of new
descriptors, as the DMA communication hasn't necessarily stopped here.

Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04 17:36:10 +01:00