summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/serial_core.c
Commit message (Collapse)AuthorAgeFilesLines
* serial: core: Use spin_lock_irq() in uart_set_termios()Peter Hurley2014-09-231-5/+4
| | | | | | | | uart_set_termios() is called with interrupts enabled; no need to save and restore the interrupt state when taking the uart port lock. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: core: Privatize tty->hw_stoppedPeter Hurley2014-09-231-15/+13
| | | | | | | | | | | | | | tty->hw_stopped is not used by the tty core and is thread-unsafe; hw_stopped is a member of a bitfield whose fields are updated non-atomically and no lock is suitable for serializing updates. Replace serial core usage of tty->hw_stopped with uport->hw_stopped. Use int storage which works around Alpha EV4/5 non-atomic byte storage, since uart_port uses different locks to protect certain fields within the structure. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: core: Privatize modem status enable flagsPeter Hurley2014-09-231-12/+17
| | | | | | | | | | | | | | The serial core uses the tty port flags, ASYNC_CTS_FLOW and ASYNC_CD_CHECK, to track whether CTS and DCD changes should be ignored or handled. However, the tty port flags are not safe for atomic bit operations and no lock provides serialized updates. Introduce the struct uart_port status field to track CTS and DCD enable states, and serialize access with uart port lock. Substitute uart_cts_enabled() helper for tty_port_cts_enabled(). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: core: Document and assert lock requirements for irq helpersPeter Hurley2014-09-231-0/+8
| | | | | | | | | | | | | The serial core provides two helper functions, uart_handle_dcd_change() and uart_handle_cts_change(), for UART drivers to use at interrupt time. The serial core expects the UART driver to hold the uart port lock when calling these helpers to prevent state corruption. If lockdep enabled, trigger a warning if the uart port lock is not held when calling these helper functions. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: core: Unwrap tertiary assignment in uart_handle_dcd_change()Peter Hurley2014-09-081-5/+8
| | | | | | | | Prepare for spin lock assertion; move non-trivial assignment into function body. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: core: Remove unsafe x_char optimizationPeter Hurley2014-09-081-6/+2
| | | | | | | | | | | uart_unthrottle() attempts to avoid sending START and the previous x_char if the previous x_char has not yet been sent. However, this optimization could leave the sender in a throttled state; for example, if the sender is throttled and this unthrottle coincides with a manual tcflow(TCION) from user-space, then neither START would be sent. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: core: Fix x_char racePeter Hurley2014-09-081-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | The UART driver is expected to clear port->x_char after transmission while holding the port->lock. However, the serial core fails to take the port->lock before assigning port->xchar. This allows for the following race CPU 0 | CPU 1 | | serial8250_handle_irq | ... | serial8250_tx_chars | if (port->x_char) | serial_out(up, UART_TX, port->x_char) uart_send_xchar | port->x_char = ch | | port->x_char = 0 port->ops->start_tx() | | The x_char on CPU 0 will never be sent. Take the port->lock in uart_send_xchar() before assigning port->x_char. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: Style fixPeter Hurley2014-09-081-2/+1
| | | | | | | Unwrap if() conditional; no functional change. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Revert "serial: uart: add hw flow control support configuration"Peter Hurley2014-09-081-9/+3
| | | | | | | | | | | | | | | | | | | | This reverts commit 06aa82e498c144c7784a6f3d3b55458b272d6146. This commit purports to enable auto CTS flow control for the 8250 UART driver. However, the 8250 UART driver already supports auto CTS flow control via UART_CAP_AFE and UART_CAP_EFR. Indeed, this patch introduces another DT attribute for which an existing firmware flag already exists ("auto-flow-control"). Furthermore, the use of UPF_HARD_FLOW requires the UART driver to define .throttle and .unthrottle methods, neither of which are defined for the 8250 UART driver (which will result in a NULL ptr dereference). Finally, this patch supposes to fix existing bugs in the serial core for auto CTS-enabled hardware, but does not include the class of hardware for which these bugs exist. CC: Murali Karicheri <m-karicheri2@ti.com> CC: Rob Herring <robh+dt@kernel.org> Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: serial_core.c: printk replacementSudip Mukherjee2014-09-081-15/+11
| | | | | | | | | | | | printk replaced with corresponding dev_* . fixed two broken user-visible strings used by the corresponding printk. the null check for uport->dev and port->dev is removed as dev_* will check for null while printing. printing of dev_name(uport->dev) and dev_name(port->dev) also removed as those are being printed by dev_* . Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge tag 'devicetree-for-linus' of git://git.secretlab.ca/git/linuxLinus Torvalds2014-08-141-0/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull device tree updates from Grant Likely: "The branch contains the following device tree changes the v3.17 merge window: Group changes to the device tree. In preparation for adding device tree overlay support, OF_DYNAMIC is reworked so that a set of device tree changes can be prepared and applied to the tree all at once. OF_RECONFIG notifiers see the most significant change here so that users always get a consistent view of the tree. Notifiers generation is moved from before a change to after it, and notifiers for a group of changes are emitted after the entire block of changes have been applied Automatic console selection from DT. Console drivers can now use of_console_check() to see if the device node is specified as a console device. If so then it gets added as a preferred console. UART devices get this support automatically when uart_add_one_port() is called. DT unit tests no longer depend on pre-loaded data in the device tree. Data is loaded dynamically at the start of unit tests, and then unloaded again when the tests have completed. Also contains a few bugfixes for reserved regions and early memory setup" * tag 'devicetree-for-linus' of git://git.secretlab.ca/git/linux: (21 commits) of: Fixing OF Selftest build error drivers: of: add automated assignment of reserved regions to client devices of: Use proper types for checking memory overflow of: typo fix in __of_prop_dup() Adding selftest testdata dynamically into live tree of: Add todo tasklist for Devicetree of: Transactional DT support. of: Reorder device tree changes and notifiers of: Move dynamic node fixups out of powerpc and into common code of: Make sure attached nodes don't carry along extra children of: Make devicetree sysfs update functions consistent. of: Create unlocked versions of node and property add/remove functions OF: Utility helper functions for dynamic nodes of: Move CONFIG_OF_DYNAMIC code into a separate file of: rename of_aliases_mutex to just of_mutex of/platform: Fix of_platform_device_destroy iteration of devices of: Migrate of_find_node_by_name() users to for_each_node_by_name() tty: Update hypervisor tty drivers to use core stdout parsing code. arm/versatile: Add the uart as the stdout device. of: Enable console on serial ports specified by /chosen/stdout-path ...
| * of: Enable console on serial ports specified by /chosen/stdout-pathGrant Likely2014-06-261-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the devicetree specifies a serial port as a stdout device, then the kernel can use it as the default console if nothing else was selected on the command line. For any serial port that uses the uart_add_one_port() feature, the uart_add_one_port() has all the information needed to automatically enable the console device, which is what this patch does. With this change applied, a device tree platform can be booted without any console= parameters on the command line and the kernel will still be able to determine its console. Tested on QEMU Versatile model and i.MX Signed-off-by: Grant Likely <grant.likely@linaro.org> Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
* | serial/core: Fix too big allocation for attribute memberYoshihiro YUNOMAE2014-07-231-1/+1
| | | | | | | | | | | | | | | | | | | | Current code allocates too much data for tty_groups member of uart_port struct, so fix it. Signed-off-by: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | Serial: allow port drivers to have a default attribute groupGreg Kroah-Hartman2014-07-171-7/+17
| | | | | | | | | | | | | | | | | | | | Some serial drivers (like 8250), want to add sysfs files. We need to do so in a race-free way, so allow any port to be able to specify an attribute group that should be added at device creation time. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | tty: serial: Fix termios/port flags mismatchPeter Hurley2014-07-101-2/+3
| | | | | | | | | | | | | | | | | | Uart port drivers may reconfigure termios settings based on available hardware support; set/clear ASYNC_CTS_FLOW and ASYNC_CHECK_CD _after_ calling the port driver's .set_termios method. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | tty: Remove tty_hung_up_p() tests from tty drivers' open()Peter Hurley2014-07-101-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since at least before 2.6.30, it has not been possible to observe a hung up file pointer in a tty driver's open() method unless/until the driver open() releases the tty_lock() (eg., before blocking). This is because tty_open() adds the file pointer while holding the tty_lock() _and_ doesn't release the lock until after calling the tty driver's open() method. [ Before tty_lock(), this was lock_kernel(). ] Since __tty_hangup() first waits on the tty_lock() before enumerating and hanging up the open file pointers, either __tty_hangup() will wait for the tty_lock() or tty_open() will not yet have added the file pointer. For example, CPU 0 | CPU 1 | tty_open | __tty_hangup .. | .. tty_lock | .. tty_reopen | tty_lock / blocks .. | tty_add_file(tty, filp) | .. | tty->ops->open(tty, filp) | tty_port_open | tty_port_block_til_ready | .. | while (1) | .. | tty_unlock | / unblocks schedule | for each filp on tty->tty_files | f_ops = tty_hung_up_fops; | .. | tty_unlock tty_lock | .. | tty_unlock | Note that since tty_port_block_til_ready() and similar drop the tty_lock while blocking, when woken, the file pointer must then be tested for having been hung up. Also, fix bit-rotted drivers that used extra_count to track the port->count bump. CC: Mikael Starvik <starvik@axis.com> CC: Samuel Ortiz <samuel@sortiz.org> CC: "David S. Miller" <davem@davemloft.net> Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Acked-by: Jesper Nilsson <jesper.nilsson@axis.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | tty: Move tty->closing from port lock critical sectionPeter Hurley2014-07-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tty->closing informs the line discipline that the hardware will be shutting down imminently, and to disable further input other than soft flow control (but to still allow additional output). However, the tty lock is the necessary lock for preventing concurrent changes to tty->closing. As shown by the call-tree audit [1] of functions that modify tty->closing, the tty lock is already held for those functions. [1] Call-tree audit of functions that modify tty->closing * does not include call tree to tty_port_close(), tty_port_close_start(), or tty_port_close_end() which is already documented in 'tty: Document locking for tty_port_close{,start,end}' that shows callers to those 3 functions hold the tty lock tty_release() tty->ops->close() --+ | __tty_hangup() | tty->ops->close() --+ | mp_close():drivers/staging/sb105x/sb_pci_mp.c dngc_tty_close():drivers/staging/dgnc/dgnc_tty.c dgap_tty_close():drivers/staging/dgap/dgap_tty.c dgrp_tty_close():drivers/staging/dgrp/dgrp_tty.c rp_close():drivers/tty/rocket.c hvsi_close():drivers/tty/hvc/hvsi.c rs_close():drivers/tty/serial/68328serial.c rs_close():drivers/tty/serial/crisv10.c uart_close():drivers/tty/serial/serial_core.c isdn_tty_close():drivers/isdn/i4l/isdn_tty.c tty3215_close():drivers/s390/char/con3215.c tty_open() tty_ldisc_setup() ----+ | __tty_hangup() | tty_ldisc_hangup() ---+ | tty_set_ldisc() --------+ tty_ldisc_restore() --+ | +- tty_ldisc_open() ld->ops->open() --+ | +- n_tty_open() Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | serial: core: Preserve termios c_cflag for console resumePeter Hurley2014-07-101-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a tty is opened for the serial console, the termios c_cflag settings are inherited from the console line settings. However, if the tty is subsequently closed, the termios settings are lost. This results in a garbled console if the console is later suspended and resumed. Preserve the termios c_cflag for the serial console when the tty is shutdown; this reflects the most recent line settings. Fixes: Bugzilla #69751, 'serial console does not wake from S3' Reported-by: Valerio Vanni <valerio.vanni@inwind.it> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | serial: core: Make enable_ms() optionalAlexander Shiyan2014-07-091-6/+11
|/ | | | | | | | This patch makes enable_ms() optional, so we can eliminate a lot of empty enable_ms() implementations from driver code. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: uart: add hw flow control support configurationMurali Karicheri2014-05-281-3/+9
| | | | | | | | | | | | | | | | | | | | | | 8250 uart driver currently supports only software assisted hw flow control. The software assisted hw flow control maintains a hw_stopped flag in the tty structure to stop and start transmission and use modem status interrupt for the event to drive the handshake signals. This is not needed if hw has flow control capabilities. This patch adds a DT attribute for enabling hw flow control for a uart port. Also skip stop and start if this flag is present in flag field of the port structure. Signed-off-by: Murali Karicheri <m-karicheri2@ti.com> CC: Rob Herring <robh+dt@kernel.org> CC: Pawel Moll <pawel.moll@arm.com> CC: Mark Rutland <mark.rutland@arm.com> CC: Ian Campbell <ijc+devicetree@hellion.org.uk> CC: Kumar Gala <galak@codeaurora.org> CC: Randy Dunlap <rdunlap@infradead.org> CC: Jiri Slaby <jslaby@suse.cz> CC: Santosh Shilimkar <santosh.shilimkar@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge 3.15-rc3 into tty-nextGreg Kroah-Hartman2014-04-271-18/+21
|\
| * serial_core: fix uart PORT_UNKNOWN handlingThomas Pfaff2014-04-241-18/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While porting a RS485 driver from 2.6.29 to 3.14, i noticed that the serial tty driver could break it by using uart ports that it does not own : 1. uart_change_pm ist called during uart_open and calls the uart pm function without checking for PORT_UNKNOWN. The fix is to move uart_change_pm from uart_open to uart_port_startup. 2. The return code from the uart request_port call in uart_set_info is not handled properly, leading to the situation that the serial driver also thinks it owns the uart ports. This can triggered by doing following actions : setserial /dev/ttyS0 uart none # release the uart ports modprobe lirc-serial # or any other device that uses the uart setserial /dev/ttyS0 uart 16550 # gives no error and the uart tty driver # can use the ports as well Signed-off-by: Thomas Pfaff <tpfaff@pcs.com> Reviewed-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | serial_core: Commonalize crlf when working w/ a non open console portDoug Anderson2014-04-241-0/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In (efe2f29 kgdboc,kdb: Allow kdb to work on a non open console port) support was added to directly use the "write_char" functions when doing kdb over a non-open console port. This is great, but it ends up bypassing the normal code in uart_console_write() that adds a carriage return before any newlines. There appears to have been a trend to add this support directly in some console driver's poll_put_char() functions. This had a few side effects, including: - In this case we were doing LFCR, not CRLF. This was fixed in uart_console_write() back in (d358788 [SERIAL] kernel console should send CRLF not LFCR) - Not all serial drivers had the LFCR code in their poll_put_char() functions. In my case I was running serial/samsung.c which lacked it. I've moved the handling to uart_poll_put_char() to fix the above problems. Now when I use kdb (and don't point console= to the same UART) I no longer get: [0]kdb> [0]kdb> [0]kdb> Signed-off-by: Doug Anderson <dianders@chromium.org> Reviewed-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: Fix pm imbalance on unbindGeert Uytterhoeven2014-04-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | When a serial port is closed, uart_close() takes care of shutting down the hardware, and powering it down. When a serial port is unbound while in use, uart_close() bypasses all of this, as this is supposed to be done through uart_hangup() (invoked via tty_vhangup() in uart_remove_one_port()). However, uart_hangup() does not set the hardware's power state, leaving it powered up. This may also lead to unbounded nesting counts in clock and power management, depending on their internal implementation. Make sure to power down the port in uart_hangup(), except when the port is used as a serial console. For serial consoles, this operation must be postponed until after the port becomes completely unused. This case is not fixed yet, as it depends on a (future) fix for the tty->count vs. port->count imbalance on failed uart_open(). After this, the module clock used by the sh-sci driver is disabled on unbind while the serial port is in use. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: Fix conditional start_tx on ring buffer not emptySeth Bollinger2014-04-161-2/+1
| | | | | | | | | | | If the serial_core ring buffer empties just as the tty layer receives an XOFF, then start_tx will never be called when the tty layer receives an XON as the serial_core ring buffer is empty. This will possibly leave a few bytes trapped in the fifo for drivers that disable the transmitter when flow controlled. Signed-off-by: Seth Bollinger <sethb@digi.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: Avoid NULL pointer dereference in uart_close()Geert Uytterhoeven2014-03-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When unbinding a serial driver that's being used as a serial console, the kernel may crash with a NULL pointer dereference in a uart_*() function called from uart_close () (e.g. uart_flush_buffer() or uart_chars_in_buffer()). To fix this, let uart_close() check for port->count == 0. If this is the case, bail out early. Else tty_port_close_start() will make the port counts inconsistent, printing out warnings like tty_port_close_start: tty->count = 1 port count = 0. and tty_port_close_start: count = -1 and once uport == NULL, it will also crash. Also fix the related crash in pr_debug() by checking for a non-NULL uport first. Detailed description: On driver unbind, uart_remove_one_port() is called. Basically it; - marks the port dead, - calls tty_vhangup(), - sets state->uart_port = NULL. What will happen depends on whether the port is just in use by e.g. getty, or was also opened as a console. A. If the tty was not opened as a console: - tty_vhangup() will (in __tty_hangup()): - mark all file descriptors for this tty hung up by pointing them to hung_up_tty_fops, - call uart_hangup(), which sets port->count to 0. - A subsequent uart_open() (this may be through /dev/ttyS*, or through /dev/console if this is a serial console) will fail with -ENXIO as the port was marked dead, - uart_close() after the failed uart_open() will return early, as tty_hung_up_p() (called from tty_port_close_start()) will notice it was hung up. B. If the tty was also opened as a console: - tty_vhangup() will (in __tty_hangup()): - mark non-console file descriptors for this tty hung up by pointing them to hung_up_tty_fops, - NOT call uart_hangup(), but instead call uart_close() for every non-console file descriptor, so port->count will still have a non-zero value afterwards. - A subsequent uart_open() will fail with -ENXIO as the port was marked dead, - uart_close() after the failed uart_open() starts to misbehave: - tty_hung_up_p() will not notice it was hung up, - As port->count is non-zero, tty_port_close_start() will decrease port->count, making the tty and port counts inconsistent. Later, warnings like these will be printed: tty_port_close_start: tty->count = 1 port count = 0. and tty_port_close_start: count = -1 - If all of this happens after state->uart_port was set to zero, a NULL pointer dereference will happen. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: Get a reference for port->tty in uart_remove_one_port()Geert Uytterhoeven2014-03-171-1/+5
| | | | | | Suggested-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: Grammar s/ports/port's/Geert Uytterhoeven2014-03-171-1/+1
| | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-serial@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: Spelling s/contro/control/Geert Uytterhoeven2014-03-171-1/+1
| | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-serial@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: Unregister console in uart_remove_one_port()Geert Uytterhoeven2014-02-281-0/+6
| | | | | | | | | | | | If the serial port being removed is used as a console, it must also be unregistered from the console subsystem using unregister_console(). uart_ops.release_port() will release resources (e.g. iounmap() the serial port registers), causing a crash on subsequent kernel output if the console is still registered. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial_core: Don't re-initialize a previously initialized spinlock.Randy Witt2013-12-081-2/+6
| | | | | | | | | | | | | | | | The uart_set_options() code unconditionally initalizes the spinlock on the port. This can cause a deadlock in some situations. One instance that exposed the problem, was when writing to /sys/module/kgdboc/parameters/kgdboc to use ttyS0 when the console is already running on ttyS0. If the spinlock is re-initialized while the lock is held due to output to the console, there is a deadlock. Assume the spinlock is initialized if the port is a console. Signed-off-by: Randy Witt <rewitt@declaratino.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: report base_baud after initializationKees Cook2013-07-261-2/+2
| | | | | | | | | Some serial ports will not use the standard base baud rate. Report this after initialization so it might be discovered and used for early console configuration. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: Move "uart_console" def to core header file.Sourav Poddar2013-05-201-6/+0
| | | | | | | | | | | | | | Move "uart_console" definition to serial core header file, so that it can be used by serial drivers. Get rid of the uart_console defintion from mpc52xx_uart driver. Cc: Santosh Shilimkar <santosh.shilimkar@ti.com> Cc: Rajendra nayak <rnayak@ti.com> Reviewed-by: Felipe Balbi <balbi@ti.com> Reviewed-by: Kevin Hilman <khilman@linaro.org> Tested-by: Kevin Hilman <khilman@linaro.org> Signed-off-by: Sourav Poddar <sourav.poddar@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge branch 'for-linus' of ↵Linus Torvalds2013-05-011-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs Pull VFS updates from Al Viro, Misc cleanups all over the place, mainly wrt /proc interfaces (switch create_proc_entry to proc_create(), get rid of the deprecated create_proc_read_entry() in favor of using proc_create_data() and seq_file etc). 7kloc removed. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (204 commits) don't bother with deferred freeing of fdtables proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h proc: Make the PROC_I() and PDE() macros internal to procfs proc: Supply a function to remove a proc entry by PDE take cgroup_open() and cpuset_open() to fs/proc/base.c ppc: Clean up scanlog ppc: Clean up rtas_flash driver somewhat hostap: proc: Use remove_proc_subtree() drm: proc: Use remove_proc_subtree() drm: proc: Use minor->index to label things, not PDE->name drm: Constify drm_proc_list[] zoran: Don't print proc_dir_entry data in debug reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show() proc: Supply an accessor for getting the data from a PDE's parent airo: Use remove_proc_subtree() rtl8192u: Don't need to save device proc dir PDE rtl8187se: Use a dir under /proc/net/r8180/ proc: Add proc_mkdir_data() proc: Move some bits from linux/proc_fs.h to linux/{of.h,signal.h,tty.h} proc: Move PDE_NET() to fs/proc/proc_net.c ...
| * procfs: new helper - PDE_DATA(inode)Al Viro2013-04-091-1/+1
| | | | | | | | | | | | | | | | | | | | The only part of proc_dir_entry the code outside of fs/proc really cares about is PDE(inode)->data. Provide a helper for that; static inline for now, eventually will be moved to fs/proc, along with the knowledge of struct proc_dir_entry layout. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | serial_core.c: add put_device() after device_find_child()Federico Vaga2013-04-151-0/+4
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The serial core uses device_find_child() but does not drop the reference to the retrieved child after using it. This patch add the missing put_device(). What I have done to test this issue. I used a machine with an AMBA PL011 serial driver. I tested the patch on next-20120408 because the last branch [next-20120415] does not boot on this board. For test purpose, I added some pr_info() messages to print the refcount after device_find_child() (lines: 1937,2009), and after put_device() (lines: 1947, 2021). Boot the machine *without* put_device(). Then: echo reboot > /sys/power/disk echo disk > /sys/power/state [ 87.058575] uart_suspend_port:1937 refcount 4 [ 87.058582] uart_suspend_port:1947 refcount 4 [ 87.098083] uart_resume_port:2009refcount 5 [ 87.098088] uart_resume_port:2021 refcount 5 echo disk > /sys/power/state [ 103.055574] uart_suspend_port:1937 refcount 6 [ 103.055580] uart_suspend_port:1947 refcount 6 [ 103.095322] uart_resume_port:2009 refcount 7 [ 103.095327] uart_resume_port:2021 refcount 7 echo disk > /sys/power/state [ 252.459580] uart_suspend_port:1937 refcount 8 [ 252.459586] uart_suspend_port:1947 refcount 8 [ 252.499611] uart_resume_port:2009 refcount 9 [ 252.499616] uart_resume_port:2021 refcount 9 The refcount continuously increased. Boot the machine *with* this patch. Then: echo reboot > /sys/power/disk echo disk > /sys/power/state [ 159.333559] uart_suspend_port:1937 refcount 4 [ 159.333566] uart_suspend_port:1947 refcount 3 [ 159.372751] uart_resume_port:2009 refcount 4 [ 159.372755] uart_resume_port:2021 refcount 3 echo disk > /sys/power/state [ 185.713614] uart_suspend_port:1937 refcount 4 [ 185.713621] uart_suspend_port:1947 refcount 3 [ 185.752935] uart_resume_port:2009 refcount 4 [ 185.752940] uart_resume_port:2021 refcount 3 echo disk > /sys/power/state [ 207.458584] uart_suspend_port:1937 refcount 4 [ 207.458591] uart_suspend_port:1947 refcount 3 [ 207.498598] uart_resume_port:2009 refcount 4 [ 207.498605] uart_resume_port:2021 refcount 3 The refcount correctly handled. Signed-off-by: Federico Vaga <federico.vaga@gmail.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: Remove ancient hardpps()Peter Hurley2013-02-131-4/+0
| | | | | | | | | | | | hardpps() functionality is provided through the N_PPS line discipline now. The new function signature was added in commit 025b40ab (2011-01-12). There was no previous macro or function hardpps(), at least since before the initial commit of v2.6.12 in 2005. It's unlikely this code has been compiled since. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: George Spelvin <linux@horizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* pps: Additional cleanups in uart_handle_dcd_changeGeorge Spelvin2013-02-131-10/+7
| | | | | | | | | An extension of the previous commit, there is no semantic change here, just fewer lines of source code. Signed-off-by: George Spelvin <linux@horizon.com> Acked-by: Rodolfo Giometti <giometti@enneenne.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* pps: Move timestamp read into PPS code properGeorge Spelvin2013-02-131-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The PPS (Pulse-Per-Second) line discipline has developed a number of unhealthy attachments to core tty data and functions, ultimately leading to its breakage. The previous patches fixed the crashing. This one reduces coupling further by eliminating the timestamp parameter from the dcd_change ldisc method. This reduces header file linkage and makes the extension more generic, and the timestamp read is delayed only slightly, from just before the ldisc->ops->dcd_change method call to just after. Fix attendant build breakage in drivers/tty/n_tty.c drivers/tty/tty_buffer.c drivers/staging/speakup/selection.c drivers/staging/dgrp/dgrp_*.c Cc: William Hubbs <w.d.hubbs@gmail.com> Cc: Chris Brannon <chris@the-brannons.com> Cc: Kirk Reiser <kirk@braille.uwo.ca> Cc: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: George Spelvin <linux@horizon.com> Acked-by: Rodolfo Giometti <giometti@enneenne.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* drivers/tty/serial: extern function which for release resource, need check ↵Chen Gang2013-01-151-1/+8
| | | | | | | | | | | | | | | | | | pointer, before free it for extern function uart_remove_one_port: need check pointer whether be NULL, before the main work. just like what the other extern function uart_add_one_port has done. uart_add_one_port and uart_remove_one_port are pair information: for the callers (such as drivers/tty/serial/jsm: jsm_tty.c, jsm_driver.c) they realy assume that: they still can call uart_remove_one_port, after uart_add_one_port failed we (as an extern function), have to understand it (just like kfree). Signed-off-by: Chen Gang <gang.chen@asianux.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* TTY: move low_latency to tty_portJiri Slaby2013-01-151-4/+3
| | | | | | | | | | One point is to have less places where we actually need tty pointer. The other is that low_latency is bound to buffer processing and buffers are now in tty_port. So it makes sense to move low_latency to tty_port too. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* TTY: switch tty_insert_flip_charJiri Slaby2013-01-151-3/+3
| | | | | | | | | | | | | Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty in many call sites. Only tty_port will needed and hence no more tty_port_tty_get in those paths. tty_insert_flip_char is the next one to proceed. This one is used all over the code, so the patch is huge. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: Fix comments that reference BKL, eventd, old pathsKevin Cernekee2013-01-151-9/+9
| | | | | | Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: serial core: decouple pm states from ACPILinus Walleij2013-01-151-14/+16
| | | | | | | | | | | | The serial core is using power states lifted from ACPI for no good reason. Remove this reference from the documentation and alter all users to use an enum specific to the serial core instead, and define it in <linux/serial_core.h>. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Alan Cox <alan@linux.intel.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge branch 'omap-serial' of git://git.linaro.org/people/rmk/linux-armLinus Torvalds2012-12-121-14/+57
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull ARM OMAP serial updates from Russell King: "This series is a major reworking of the OMAP serial driver code fixing various bugs in the hardware-assisted flow control, extending up into serial_core for a couple of issues. These fixes have been done as a set of progressive changes and transformations in the hope that no new bugs will be introduced by this series. The problems are many-fold, from the driver not being informed about updated settings, to the driver not knowing what the intentions of the upper layers are. The first four patches tackle the serial_core layer, allowing it to provide the necessary information to drivers, and the remaining patches allow the OMAP serial driver to take advantage of this. This brings hardware assisted RTS/CTS and XON/OFF flow control into a useful state. These patches have been in linux-next for most of the last cycle; indeed they predate the previous merge window. They've also been posted to the OMAP people." * 'omap-serial' of git://git.linaro.org/people/rmk/linux-arm: (21 commits) SERIAL: omap: fix hardware assisted flow control SERIAL: omap: simplify (2) SERIAL: omap: move xon/xoff setting earlier SERIAL: omap: always set TCR SERIAL: omap: simplify SERIAL: omap: don't read back LCR/MCR/EFR SERIAL: omap: serial_omap_configure_xonxoff() contents into set_termios SERIAL: omap: configure xon/xoff before setting modem control lines SERIAL: omap: remove OMAP_UART_SYSC_RESET and OMAP_UART_FIFO_CLR SERIAL: omap: move driver private definitions and structures to driver SERIAL: omap: remove 'irq_pending' bitfield SERIAL: omap: fix MCR TCRTLR bit handling SERIAL: omap: fix set_mctrl() breakage SERIAL: omap: no need to re-read EFR SERIAL: omap: remove setting of EFR SCD bit SERIAL: omap: allow hardware assisted IXANY mode to be disabled SERIAL: omap: allow hardware assisted rts/cts modes to be disabled SERIAL: core: add throttle/unthrottle callbacks for hardware assisted flow control SERIAL: core: add hardware assisted h/w flow control support SERIAL: core: add hardware assisted s/w flow control support ... Conflicts: drivers/tty/serial/omap-serial.c
| * SERIAL: core: add throttle/unthrottle callbacks for hardware assisted flow ↵Russell King2012-11-041-4/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | control Add two callbacks for hardware assisted flow control; we need to know when the tty layers want us to stop and restart due to their buffer levels. Call a driver specific throttle/unthrottle function if and only if the driver indicates that it is using an enabled hardware assisted flow control method, otherwise fall back to the non-hardware assisted methods. Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
| * SERIAL: core: add hardware assisted h/w flow control supportRussell King2012-11-041-0/+7
| | | | | | | | | | | | | | | | | | Ports which are handling h/w flow control in hardware must not have their RTS state altered depending on the tty's hardware-stopped state. Avoid this additional logic when setting the termios state. Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
| * SERIAL: core: add hardware assisted s/w flow control supportRussell King2012-11-041-2/+14
| | | | | | | | | | | | | | | | | | | | Ports which are capable of handling s/w flow control in hardware to know when the s/w flow control termios settings are changed. Add a flag to allow the low level serial drivers to indicate that they support this, and these changes should be propagated to them. Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
| * SERIAL: core: use local variable uport in uart_set_termios()Russell King2012-11-041-8/+9
| | | | | | | | | | | | | | This is to make the following change more clear. Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* | drivers/tty/serial/serial_core.c: clean up HIGH_BITS_OFFSET usageAndrew Morton2012-11-261-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | serial_core.c usually does if (HIGH_BITS_OFFSET) expr-involving-HIGH_BITS_OFFSET() at least to avoid generating useless code on 32-bit machines, where HIGH_BITS_OFFSET is zero. Do that in uart_get_attr_port(). Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
OpenPOWER on IntegriCloud