summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/serial_core.c
Commit message (Collapse)AuthorAgeFilesLines
* TTY: call tty_port_destroy in the rest of driversJiri Slaby2012-11-151-0/+6
| | | | | | | | | | | | | | | | After commit "TTY: move tty buffers to tty_port", the tty buffers are not freed in some drivers. This is because tty_port_destructor is not called whenever a tty_port is freed. This was an assumption I counted with but was unfortunately untrue. So fix the drivers to fulfil this assumption. To be sure, the TTY buffers (and later some stuff) are gone along with the tty_port, we have to call tty_port_destroy at tear-down places. This is mostly where the structure containing a tty_port is freed. This patch does exactly that -- put tty_port_destroy at those places. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cast before shifting on port ioAlan Cox2012-11-151-1/+1
| | | | | | | | Without this we will shift data into oblivion and give wrong results on some configurations Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* uart: add other serial core layer get attributesAlan Cox2012-10-301-0/+145
| | | | | Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* uart: tidy the uart_get_info APIAlan Cox2012-10-301-14/+15
| | | | | | | | | | | | | We pass both port and state because the original caller had both to hand. With all the attribute callers this won't be true so do the conversion in the function itself. The current callers all do lock/query/unlock. This won't be true for future set based cases but there are plenty of get ones that will exist so split the code with a helper for the future cases. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* uart: update the sysfs handler to use uart_get_infoAlan Cox2012-10-301-5/+5
| | | | | | | | | | | | | | The two patches needed are now in the tree. The first added the sysfs interface and directly accesses the uartclk. The second provides a proper interface for getting the values. Wire them together. This formes a basis for both get and set methods for any of the other uart properties and we can now fill them out further. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty/serial/core: Introduce poll_init callbackAnton Vorontsov2012-09-261-0/+17
| | | | | | | | | | | | | | | | | | | It was noticed that polling drivers (like KGDB) are not able to use serial ports if the ports were not previously initialized via console. I.e. when booting with console=ttyAMA0 kgdboc=ttyAMA0, everything works fine, but with console=ttyFOO kgdboc=ttyAMA0, the kgdboc doesn't work. This is because we don't initialize the hardware. Calling ->startup() is not an option, because drivers request interrupts there, and drivers fail to handle situations when tty isn't opened with interrupts enabled. So, we have to implement a new callback (actually, tty_ops already have a similar callback), which does everything needed to initialize just the hardware. Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: Fix race in uart_handle_dcd_changeAlan Cox2012-09-211-4/+7
| | | | | | | | | | | | | If a serial driver is called post hangup with a second DCD event then we will attempt to get the ldisc of NULL. Check we have a tty before trying to do anything with it. This is still only safe within the uart layer if the caller holds the relevant uart locks. We could do with a version where the tty is passed for more general use. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty_register_device_attr updated for tty-nextTomas Hlavacek2012-09-061-4/+4
| | | | | | | | | | Added tty_device_create_release() and bound to dev->release in tty_register_device_attr(). Added tty_port_register_device_attr() and used in uart_add_one_port() instead of tty_register_device_attr(). Signed-off-by: Tomas Hlavacek <tmshlvck@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: uartclk value from serial_core exposed to sysfsTomas Hlavacek2012-09-061-2/+32
| | | | | | | | | | | Added file /sys/devices/.../tty/ttySX/uartclk to allow reading uartclk value in struct uart_port in serial_core via sysfs. tty_register_device() has been generalized and refactored in order to add support for setting drvdata and attribute_group to the device. Signed-off-by: Tomas Hlavacek <tmshlvck@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: fix sizeof(pointer)Fengguang Wu2012-09-061-1/+1
| | | | | | | | | | | sizeof when applied to a pointer typed expression gives the size of the pointer. Generated by: scripts/coccinelle/misc/noderef.cocci Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: add a new helper functionHuang Shijie2012-09-051-2/+2
| | | | | | | | | | In most of the time, the driver needs to check if the cts flow control is enabled. But now, the driver checks the ASYNC_CTS_FLOW flag manually, which is not a grace way. So add a new wraper function to make the code tidy and clean. Signed-off-by: Huang Shijie <shijie8@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: Split the serial_core helpers for setserial into twoAlan Cox2012-09-051-71/+87
| | | | | | | | | We want them split so that we can call them from setserial functionality where we copy to/from user space and do the locking, but also from sysfs where in future we'll want to came them within a sysfs context. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* TTY: use tty_port_register_deviceJiri Slaby2012-08-131-1/+2
| | | | | | | | | | | | | | | | | Currently we have no way to assign tty->port while performing tty installation. There are two ways to provide the link tty_struct => tty_port. Either by calling tty_port_install from tty->ops->install or tty_port_register_device called instead of tty_register_device when the device is being set up after connected. In this patch we modify most of the drivers to do the latter. When the drivers use tty_register_device and we have tty_port already, we switch to tty_port_register_device. So we have the tty_struct => tty_port link for free for those. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: move the termios object into the ttyAlan Cox2012-07-161-14/+14
| | | | | | | | | | | | This will let us sort out a whole pile of tty related races. The alternative would be to keep points and refcount the termios objects. However 1. They are tiny anyway 2. Many devices don't use the stored copies 3. We can remove a pty special case Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: Update buffer overrun statistics.Corbin2012-06-121-2/+4
| | | | | | | | | | | | Currently, serial drivers don't report buffer overruns. When a buffer overrun occurs, tty_insert_flip_char returns 0, and no attempt is made to insert that same character again (i.e. it is lost). This patch reports buffer overruns via the buf_overrun field in the port's icount structure. Signed-off-by: Corbin Atkinson <corbin.atkinson@xxxxxx> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Revert "serial_core: Update buffer overrun statistics."Greg Kroah-Hartman2012-05-151-4/+2
| | | | | | | | | | | | | | This reverts commit 642180871bc91afebb6ccf40d1615a7dd33699a3. Buffer overruns are for hardware reported overruns, not software ones, which will only happen if we run out of memory and you will get lots of -ENOMEM errors at the same time. Thanks to Alan Cox for catching this. Reported-by: Alan Cox <alan@linux.intel.com> Cc: Corbin Atkinson <corbinat@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: Allow uart_register/unregister/registerAlan Cox2012-05-141-0/+1
| | | | | | | | | | This is legitimate but because we don't clear the drv->state pointer in the unregister code causes a bogus BUG(). Resolves-bug: https://bugzilla.kernel.org/show_bug.cgi?id=42880 Signed-off-by: Alan Cox <alan@linux.intel.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: Update buffer overrun statistics.Corbin Atkinson2012-05-091-2/+4
| | | | | | | | | | Currently, serial drivers don't report buffer overruns. When a buffer overrun occurs, tty_insert_flip_char returns 0, and no attempt is made to insert that same character again (i.e. it is lost). This patch reports buffer overruns via the buf_overrun field in the port's icount structure. Signed-off-by: Corbin Atkinson <corbin.atkinson@ni.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* TTY: remove re-assignments to tty_driver membersJiri Slaby2012-03-081-1/+0
| | | | | | | | | | | | | | All num, magic and owner are set by alloc_tty_driver. No need to re-set them on each allocation site. pti driver sets something different to what it passes to alloc_tty_driver. It is not a bug, since we don't use the lines parameter in any way. Anyway this is fixed, and now we do the right thing. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Tilman Schmidt <tilman@imap.cc> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: Fix wakeup init logic to speed up startupSimon Glass2012-01-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The synchronize_rcu() call resulting from making every serial driver wake-up capable (commit b3b708fa) slows boot down on my Tegra2x system (with CONFIG_PREEMPT disabled). But this is avoidable since it is the device_set_wakeup_enable() and then subsequence disable which causes the delay. We might as well just make the device wakeup capable but not actually enable it for wakeup until needed. Effectively the current code does this: device_set_wakeup_capable(dev, 1); device_set_wakeup_enable(dev, 1); device_set_wakeup_enable(dev, 0); We can just drop the last two lines. Before this change my boot log says: [ 0.227062] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 0.702928] serial8250.0: ttyS0 at MMIO 0x70006040 (irq = 69) is a Tegra after: [ 0.227264] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 0.227983] serial8250.0: ttyS0 at MMIO 0x70006040 (irq = 69) is a Tegra for saving of 450ms. Suggested-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* serial: use DIV_ROUND_CLOSEST instead of open coding itUwe Kleine-König2012-01-041-1/+1
| | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial, extract uart_port_startupJiri Slaby2011-11-151-15/+28
| | | | | | | | | | | | | | | Extract ASYNC_INITIALIZED/TTY_IO_ERROR handling from uart_startup. This will be useful for tty port helpers. These flags are handled by the helpers instead. So we create a new function uart_port_startup without touching these flags there. And we keep uart_startup with the exact behavior as before. We need that one because we start/stop the device from other paths than open/close/hangup. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial, fill uart_port_shutdownJiri Slaby2011-11-151-18/+24
| | | | | | | | | | | | | | | | | | | | | Let's fill the port_ops->shutdown. We will need this for hangup and close port helpers. We don't need to touch DTR/RTS registers in uart_port_shutdown. They are set to off from port_close_start properly already. Also we don't need to pin the TTY_IO_ERROR bit. This will be done in close/hangup paths. We leave uart_shutdown as is, because it is used (and will be) from several paths now. Like from suspend. The point is to not touch ASYNC_INITIALIZED bit. It will be set (and checked) properly by the tty port helpers. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial, define uart_port_activate/shutdownJiri Slaby2011-11-151-0/+11
| | | | | | | | | | This is a preparation for the next patches which will move the stuff from uart_open and uart_close/hangup here. Then we will use tty_port_* helpers. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial, inline uart_getJiri Slaby2011-11-151-44/+22
| | | | | | | | | | We need to expand uart_get into uart_open. We need it to move on with conversion to use tty_port_open helper. After we do this, the code will be much more similar to what tty_port_open does. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial, do not touch tty->alt_speedJiri Slaby2011-11-151-3/+1
| | | | | | | | It is not used at all, so no need to play any games with that. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial, document few functionsJiri Slaby2011-11-151-0/+20
| | | | | | | | Just put a kernel-doc comment to uart_change_pm and uart_insert_char. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial, use tty_port_close_start helperJiri Slaby2011-11-151-39/+1
| | | | | | | | | | | | | | | | | | After the previous patches, the code is almost identical. There are few differences in the helper code: 1) flush_buffer when flow_stopped * when a user doesn't care about the data, delete it anyways 2) ASYNCB_INITIALIZED test before wait_until_sent_from * obviously, there is nothing to wait for if the port is dead 3) drain_delay wait * we don't set drain_delay So we can use the helper now. It indeed removes a bunch of duplicated code. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial, switch closing_wait and close_delay to jiffiesJiri Slaby2011-11-151-9/+10
| | | | | | | | | | As the tty_port helpers think closing_wait and close_delay are in jiffies and we want to use the helpers (next patches), we have to switch the closing_wait and close_delay from ms to jiffies now. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial, cleanup include fileJiri Slaby2011-11-151-0/+82
| | | | | | | | | | | | | | | | | | There are some functions (uart_handle_dcd_change, _handle_cts_change, _insert_char) which are big enough to not be inlined. So move them from .h to .c. We need to export them so that modules can actually use them. They will be even bigger when we introduce tty refcounting to them. While at it, cleanup the "Proud member of Uglyhacks'R'US". It means, define uart_handle_sysrq_char only when SUPPORT_SYSRQ is set. Otherwise define it as a macro. This is needed for some arm driver where the second parameter is undefined if expanded. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Merge branch 'tty-next' of ↵Linus Torvalds2011-10-261-51/+21
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty * 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (79 commits) TTY: serial_core: Fix crash if DCD drop during suspend tty/serial: atmel_serial: bootconsole removed from auto-enumerates Revert "TTY: call tty_driver_lookup_tty unconditionally" tty/serial: atmel_serial: add device tree support tty/serial: atmel_serial: auto-enumerate ports tty/serial: atmel_serial: whitespace and braces modifications tty/serial: atmel_serial: change platform_data variable name tty/serial: RS485 bindings for device tree TTY: call tty_driver_lookup_tty unconditionally TTY: pty, release tty in all ptmx_open fail paths TTY: make tty_add_file non-failing TTY: drop driver reference in tty_open fail path 8250_pci: Fix kernel panic when pch_uart is disabled h8300: drivers/serial/Kconfig was moved parport_pc: release IO region properly if unsupported ITE887x card is found tty: Support compat_ioctl get/set termios_locked hvc_console: display printk messages on console. TTY: snyclinkmp: forever loop in tx_load_dma_buffer() tty/n_gsm: avoid fifo overflow in gsm_dlci_data_output tty/n_gsm: fix a bug in gsm_dlci_data_output (adaption = 2 case) ... Fix up Conflicts in: - drivers/tty/serial/8250_pci.c Trivial conflict with removed duplicate device ID - drivers/tty/serial/atmel_serial.c Annoying silly conflict between "specify the port num via platform_data" and other changes to atmel_console_init
| * TTY: serial_core: Fix crash if DCD drop during suspendDoug Anderson2011-10-191-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This crash was showing up 100% of the time on Tegra CPUs when an agetty was running on the serial port and the console was not running on the serial port. The reason the Tegra saw it so reliably is that the Tegra CPU internally ties DTR to DCD/DSR. That means when we dropped DTR during suspend we would get always get an immediate DCD drop. The specific order of operations that were running: * uart_suspend_port() would be called to put the uart in suspend mode * we'd drop DTR (ops->set_mctrl(uport, 0)). * the DTR drop would be looped back in the CPU to be a DCD drop. * the DCD drop would look to the serial driver as a hangup * the hangup would call uart_shutdown() * ... suspend / resume happens ... * uart_resume_port() would be called and run the code in the (port->flags & ASYNC_SUSPENDED) block, which would startup the port (and enable tx again). * Since the UART would be available for tx, we'd immediately get an interrupt, eventually calling transmit_chars() * The transmit_chars() function would crash. The first crash would be a dereference of a NULL tty member, but since the port has been shutdown that was just a symptom. I have proposed a patch that would fix the Tegra CPUs here (see https://lkml.org/lkml/2011/10/11/444 - tty/serial: Prevent drop of DCD on suspend for Tegra UARTs). However, even with that fix it is still possible for systems that have an externally visible DCD line to see a crash if the DCD drops at just the right time during suspend: thus this patch is still useful. Signed-off-by: Doug Anderson <dianders@chromium.org> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| * serial-core: power up uart port early before we do set_termios when resumingNing Jiang2011-09-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following patch removed uart_change_pm() in uart_resume_port(): commit 5933a161abcb8d83a2c145177f48027c3c0a8995 Author: Yin Kangkai <kangkai.yin@linux.intel.com> serial-core: reset the console speed on resume It will break the pxa serial driver when the system resumes from suspend mode as it will try to set baud rate divider register in set_termios but with clock off. The register value can not be set correctly on some platform if the clock is disabled. The pxa driver will check the value and report the following warning: ------------[ cut here ]------------ WARNING: at drivers/tty/serial/pxa.c:545 serial_pxa_set_termios+0x1dc/0x250() Modules linked in: [<c0281f30>] (unwind_backtrace+0x0/0xf0) from [<c029341c>] (warn_slowpath_common+0x4c/0x64) [<c029341c>] (warn_slowpath_common+0x4c/0x64) from [<c029344c>] (warn_slowpath_null+0x18/0x1c) [<c029344c>] (warn_slowpath_null+0x18/0x1c) from [<c044b1e4>] (serial_pxa_set_termios+0x1dc/0x250) [<c044b1e4>] (serial_pxa_set_termios+0x1dc/0x250) from [<c044a840>] (uart_resume_port+0x128/0x2dc) [<c044a840>] (uart_resume_port+0x128/0x2dc) from [<c044bbe0>] (serial_pxa_resume+0x18/0x24) [<c044bbe0>] (serial_pxa_resume+0x18/0x24) from [<c0454d34>] (platform_pm_resume+0x40/0x4c) [<c0454d34>] (platform_pm_resume+0x40/0x4c) from [<c0457ebc>] (pm_op+0x68/0xb4) [<c0457ebc>] (pm_op+0x68/0xb4) from [<c0458368>] (device_resume+0xb0/0xec) [<c0458368>] (device_resume+0xb0/0xec) from [<c04584c8>] (dpm_resume+0xe0/0x194) [<c04584c8>] (dpm_resume+0xe0/0x194) from [<c0458588>] (dpm_resume_end+0xc/0x18) [<c0458588>] (dpm_resume_end+0xc/0x18) from [<c02c518c>] (suspend_devices_and_enter+0x16c/0x1ac) [<c02c518c>] (suspend_devices_and_enter+0x16c/0x1ac) from [<c02c5278>] (enter_state+0xac/0xdc) [<c02c5278>] (enter_state+0xac/0xdc) from [<c02c48ec>] (state_store+0xa0/0xbc) [<c02c48ec>] (state_store+0xa0/0xbc) from [<c0408f7c>] (kobj_attr_store+0x18/0x1c) [<c0408f7c>] (kobj_attr_store+0x18/0x1c) from [<c034a6a4>] (sysfs_write_file+0x108/0x140) [<c034a6a4>] (sysfs_write_file+0x108/0x140) from [<c02fb798>] (vfs_write+0xac/0x134) [<c02fb798>] (vfs_write+0xac/0x134) from [<c02fb8cc>] (sys_write+0x3c/0x68) [<c02fb8cc>] (sys_write+0x3c/0x68) from [<c027c700>] (ret_fast_syscall+0x0/0x2c) ---[ end trace 88289eceb4675b04 ]--- This patch fix the problem by adding the power on opertion back for uart console when console_suspend_enabled is true. Signed-off-by: Ning Jiang <ning.jiang@marvell.com> Tested-by: Mayank Rana <mrana@codeaurora.org> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| * TTY: serial: Move mutex_unlock in uart_close functionNobuhiro Iwamatsu2011-09-221-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When mutex_lock is not called, mutex_unlock is sometimes called. This deletes unnecessary goto and makes modifications so that mutex_unlock is called. [ 8.304000] WARNING: at kernel/muex-debug.c:78 [ 8.304000] Modules linked in: [ 8.304000] [ 8.304000] Pid : 114, Comm: modprobe [ 8.304000] CPU : 0 Not tainted (3.1.0-rc3-next-20110826 #810) [ 8.304000] [ 8.304000] PC is at debug_mutex_unlock+0xf4/0x120 [ 8.304000] PR is at debug_mutex_unlock+0xe6/0x120 [ 8.304000] PC : 80051114 SP : 9f02de58 SR : 400081f1 TEA : 295cf4f2 [ 8.304000] R0 : 00000001 R1 : 00000000 R2 : 0000000f R3 : 00000000 [ 8.304000] R4 : 9fc63158 R5 : 00000000 R6 : 00000001 R7 : 9fe1de78 [ 8.304000] R8 : 805c6b2c R9 : 80003920 R10 : 00000000 R11 : 805c6b2c [ 8.304000] R12 : 80425ca0 R13 : 00000000 R14 : 9f02de58 [ 8.304000] MACH: 00000003 MACL: 00000000 GBR : 296e1678 PR : 80051106 [ 8.304000] [ 8.304000] Call trace: [ 8.304000] [<804236c6>] __mutex_unlock_slowpath+0x46/0x120 [ 8.304000] [<804237aa>] mutex_unlock+0xa/0x20 [ 8.304000] [<80240ed6>] uart_close+0x76/0x2c0 [ 8.304000] [<80223b98>] tty_release+0xf8/0x5c0 [ 8.304000] [<800a93a6>] lookup_object+0x26/0xa0 [ 8.304000] [<80063f6a>] call_rcu+0x8a/0xc0 [ 8.304000] [<800a944a>] put_object+0x2a/0x60 [ 8.304000] [<80003920>] arch_local_irq_restore+0x0/0x40 [ 8.304000] [<800af320>] fput+0x180/0x2c0 [ 8.304000] [<800af248>] fput+0xa8/0x2c0 [ 8.304000] [<800ab1a8>] filp_close+0x48/0xc0 [ 8.304000] [<800ab29a>] sys_close+0x7a/0x100 [ 8.304000] [<8000825a>] syscall_call+0xc/0x10 [ 8.304000] [<800ab220>] sys_close+0x0/0x100 [ 8.304000] [ 8.304000] Code: [ 8.304000] 8005110e: mov.l @r1, r1 [ 8.304000] 80051110: tst r1, r1 [ 8.304000] 80051112: bf 80051116 [ 8.304000] ->80051114: trapa #62 [ 8.304000] 80051116: mov.l @r8, r1 [ 8.304000] 80051118: tst r1, r1 [ 8.304000] 8005111a: bt.s 8005104c [ 8.304000] 8005111c: mov #0, r1 [ 8.304000] 8005111e: bra 80051056 [ 8.304000] [ 8.304000] ---[ end trace e8f8e04c313f429b ]--- Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| * TTY: use tty_wait_until_sent_from_close in other driversJiri Slaby2011-08-251-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's use the newly added helper to avoid stalls in drivers which are not yet ported to tty_port helpers. Those which are broken (call tty_wait_until_sent with irqs disabled) are left untouched. They are in a deeper trouble than we are trying to solve here. This includes amiserial, 68328serial, 68360serial and crisv10. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| * TTY: serial, move locking in uart_closeJiri Slaby2011-08-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So now, when we handle CLOSING flag, there is no point to hold port->mutex over the start of uart_close. Yes, there are still several things to reason about: * port->count etc is and always was protected by a spinlock * ->stop_rx is protected by a spinlock. Otherwise it would race with interrupts. * uart_wait_until_sent -- that one is already called without port->mutex from set_termios and tty_set_ldisc. Should anything be protected there, it would be tx_empty. And by a spinlock. 8250 does this internally... This step is needed to fix system stalls. To not create an AB-BA lock dependency (see next patches). Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| * TTY: serial, use ASYNCB_CLOSING in uart_closeJiri Slaby2011-08-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to move port->mutex locking after wait_until_sent in uart_close (for rationale see next patches). But if we did it now, we would introduce a race between close and open. This is exactly why port->mutex is locked at the top of uart_close. To avoid the race, we add ASYNCB_CLOSING to uart_close. Like every other sane TTY driver. Thanks to tty_port_block_til_ready used in uart_open we will have this for free. Then we can move the port->mutex lock. Also note that this will make the conversion to tty_port helpers easier. They are currently handling ASYNC_CLOSING flag correctly. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| * tty: serial8250: remove UPIO_DWAPB{,32}Jamie Iles2011-08-231-4/+0
| | | | | | | | | | | | | | | | | | | | Now that platforms can override the port IRQ handler and the only user of these UPIO modes has been converted over, kill off UPIO_DWAPB and UPIO_DWAPB32. Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Jamie Iles <jamie@jamieiles.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| * TTY: remove tty_lockedJiri Slaby2011-08-231-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | We used it really only serial and ami_serial. The rest of the callsites were BUG/WARN_ONs to check if BTM is held. Now that we pruned tty_locked from both of the real users, we can get rid of tty_lock along with __big_tty_mutex_owner. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Arnd Bergmann <arnd@arndb.de> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| * TTY: serial, remove tasklet for tty_wakeupJiri Slaby2011-08-231-19/+1
| | | | | | | | | | | | | | | | | | | | tty_wakeup can be called from any context. So there is no need to have an extra tasklet for calling that. Hence save some space and remove the tasklet completely. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| * TTY: serial, remove BTM from wait_until_sentJiri Slaby2011-08-231-23/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During the BKL removal process, the BKL was switched to tty_lock (BTM). Now we should start pruning the BTM further. Let's start with wait_until_sent of the serial layer. This will allow us to switch to the tty port helpers and thus clean it up much. In wait_until_sent there are some uport members accessed, but neither of them is protected by BTM at the location they are set ('=>' means function call): * uport->fifosize (set in tty_ioctl => uart_ioctl => uart_set_info) * uport->type (set in add_one_port prior to tty_register_device) * uport->timeout (set usually in tty_ioctl => tty_mode_ioctl => tty_set_termios => uart_set_termios => uart_change_speed => uport->ops->set_termios => uart_update_timeout) * call to uport->ops->tx_empty() If the tx_empty hook needs some lock to protect accesses to registers, it should take &uport->lock spinlock like 8250 does. Otherwise there still might be races e.g. with ISRs. This should also fix the issue Andreas is seeing (BTM in comparison to BKL doesn't have any hidden functionality like unlocking during sleeping). Signed-off-by: Jiri Slaby <jslaby@suse.cz> References: https://lkml.org/lkml/2011/5/25/562 Cc: Alan Cox <alan@linux.intel.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Cc: Andreas Bombe <aeb@debian.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* | TTY: serial, document ignoring of uart->ops->startup errorJiri Slaby2011-08-231-0/+5
|/ | | | | | | | | | | | | | | | | | When a user has SYS_ADMIN capabilities and uart->ops->startup returns an error in uart_startup, we silently drop the error. We then return 0 and behave as if it didn't fail. (Not quite, since we set TTY_IO_ERROR bit and leave ASYNC_INITIALIZED bit cleared.) This all is to allow setserial to work with improperly configured or unconfigured ports. User can thus set port properties and reconfigure properly. This patch only documents this behavior. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Russel King <linux@arm.linux.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial_core, remove superfluous set_task_stateJiri Slaby2011-04-251-1/+0
| | | | | | | | | | msleep* is guaranteed to return with TASK_RUNNING task state. And since there is no other set_task_state in the paths of uart_wait_until_sent, we need not to set_task_state to TASK_RUNNING. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial_core, remove invalid testJiri Slaby2011-04-251-9/+0
| | | | | | | | | | | | | | | tty->index (named here as line) is set up in initialize_tty_struct. The value is checked in get_tty_driver for the found driver as: if (device < base || device >= base + p->num) continue; *index = device - base; So index/line can never be more than driver->num. Hence remove this test from uart_open. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Serial: Remove unused code.Govindraj.R2011-04-191-11/+0
| | | | | | | | Remove stale code in serial_core layer. Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Govindraj.R <govindraj.raja@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* tty: remove invalid location line in file headerJovi Zhang2011-04-191-2/+0
| | | | | | | | remove invalid location line in each file header after location moved from driver/char to driver/tty Signed-off-by: Jovi Zhang <bookjovi@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* serial: core, remove uart_update_termiosJiri Slaby2011-04-191-24/+1
| | | | | | | | | | | | | | Now, uart_update_termios is empty, so it's time to remove it. We no longer need a live tty in .dtr_rts. So this should prune all the bugs where tty is zeroed in port->tty during tty_port_block_til_ready. There is one thing to note. We don't set ASYNC_NORMAL_ACTIVE now. It's because this is done already in tty_port_block_til_ready. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* serial: core, do not set DTR/RTS twice on startupJiri Slaby2011-04-191-14/+0
| | | | | | | | | | | | | | In .dtr_rts we do: uart_set_mctrl(uport, TIOCM_DTR | TIOCM_RTS) and call uart_update_termios. It does: uart_set_mctrl(port, TIOCM_DTR | TIOCM_RTS) once again. As the only callsite of uart_update_termios is .dtr_rts, remove the uart_set_mctrl from uart_update_termios to not set it twice. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* serial: core, move termios handling to uart_startupJiri Slaby2011-04-191-15/+9
| | | | | | | | | | | | | | | | | | | | | | | | | We should not fiddle with speed and cflags in .dtr_rts hook. Actually we might not have tty at that moment already. So move the console cflag copy and speed setup into uart_startup. Actually the speed setup is already there, but we need to call it unconditionally (uart_startup is called from uart_open with hw_init = 0). This means we move uart_change_speed before dtr/rts setup in .dtr_rts. But this should not matter as the setup should be called after uart_change_speed anyway. Before: After: dtr/rts setup (dtr_rts) uart_change_speed (startup) uart_change_speed (update_termios) dtr/rts setup (dtr_rts) dtr/rts setup (update_termios) dtr/rts setup (update_termios) The second setup will dismiss with the next patch. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* TTY: serial_core, remove unused variableJiri Slaby2011-04-191-4/+0
| | | | | | | | | | drivers/tty/serial/serial_core.c:1980:2: warning: Value stored to 'tty' is never read tty = port->tty; ^ ~~~~~~~~~ Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Govindraj.R <govindraj.raja@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
OpenPOWER on IntegriCloud