Currently parity bits are defined to be used with UART_DM_MR2
register with PARITY_MODE Bit as below :
EVEN_PARTIY = 1 and ODD_PARITY = 2
With these values, UART functionality doesn't work after enabling parity.
Hence adding correct used PARITY_MODE bits value as
EVEN_PARITY = 2 and ODD_PARITY = 1
after confirming with UART hardware programming guide.
CRs-Fixed: 410377
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
(cherry picked from commit fd40e5f6313fbc74e8897927be1004faa5d9df08)
Change-Id: I56f1a46ab56a7976ad00fc1329ad766b1182cb4e
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
Some commercial SIMS require a longer stop bit. This change
makes the driver confirm to the standard.
Change-Id: I270a101213d7dd31acf2608786541e3f11e2f2b8
Acked-by: Kaushik Sikdar <ksikdar@qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
(cherry picked from commit 5fca38fe5fc4068842e854fd0111c898e6ec7cd5)
(cherry picked from commit 9747c0d823d5fd6681769febeccf7819c6382d11)
If a channel is logical channel open or close ack is pending in the
transmit queue when a logical channel is closed, then they are currently
purged and the remote and local channel states are mismatched and the
port cannot be re-opened. Note that this issue only occurs during rapid
open/close/open sequences that are typically only seen in remote
loopback stress testing.
Add code to not purge ACK commands from a logical channel unless the
logical channel purge is due to a subsystem restart (at which point the
remote state is known to be power-on default).
Change-Id: I52763323642bb7c505630bb994ecc1e021270d17
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit 0e91408cb6343d5ac18206ff3d6639ccec5464fd)
(cherry picked from commit ef0445e15b20369c7189a61d63fb284c5a51c3fb)
mutex is used uninitialized while unloading N_TTY line discipline
and installing SMUX Line discipline as msm_hs_shutdown() of HSUART
driver is called which is destroying this used mutex. Hence while
SMUX Line discipline is used, and clock off API is called, mutex
slowpath warning is seen. Destroying of mutex shouldn't be done from
msm_hs_shutdown() as initizalition and destroying of the mutex
is done from probe() and remove() of HSUART driver. Hence don't
destroy mutex from msm_hs_shutdown() to fix the issue.
CRs-Fixed: 391551
Change-Id: I74ac1372405e1b893d658ee03e9955858c9e782f
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
(cherry picked from commit d21314cc42558fe60cb0052bb1b645985f6be456)
By default, HSUART Core CLK frequency is set to 7.37MHz. With this
CLK Frequency, it is not possible to get higher baud rate of 3.2 or
4 Mbps. Hence to set higher baud rate, driver calls clk_set_rate()
to set HSUART Core CLK frequency as ( required baud_rate * 16 ).
clk_set_rate() shouldn't be call from atomic context otherwise below
BUG is seen.
BUG: sleeping function called from invalid context at
mutex.c:85 in_atomic(): 1, irqs_disabled(): 128, pid: 1, name: init
[<c00151c4>] (unwind_backtrace+0x0/0x12c) from
[<c07aebbc>] (mutex_lock+0x18/0x3c)
[<c07aebbc>] (mutex_lock+0x18/0x3c) from
[<c0021258>] (clk_set_rate+0x2c/0x178)
[<c0021258>] (clk_set_rate+0x2c/0x178) from
[<c0364a34>] (msm_hs_set_termios+0x820/0xb9c)
[<c0364a34>] (msm_hs_set_termios+0x820/0xb9c)
from [<c0362170>] (uart_change_speed+0x90/0x94)
[<c0362170>] (uart_change_speed+0x90/0x94)
from [<c03626c0>] (uart_startup+0xc8/0x1a0)
[<c03626c0>] (uart_startup+0xc8/0x1a0)
from [<c0363534>] (uart_open+0xe4/0x13c)
[<c0363534>] (uart_open+0xe4/0x13c)
from [<c0343d64>] (tty_open+0x360/0x4ec)
[<c0343d64>] (tty_open+0x360/0x4ec)
from [<c013787c>] (chrdev_open+0x114/0x134)
[<c013787c>] (chrdev_open+0x114/0x134)
from [<c0132844>] (__dentry_open+0x190/0x29c)
[<c0132844>] (__dentry_open+0x190/0x29c)
from [<c0132a00>] (nameidata_to_filp+0x50/0x5c)
[<c0132a00>] (nameidata_to_filp+0x50/0x5c)
from [<c0141b08>] (do_last+0x7ec/0x928)
[<c0141b08>] (do_last+0x7ec/0x928)
from [<c0141d08>] (path_openat+0xc4/0x390)
[<c0141d08>] (path_openat+0xc4/0x390)
from [<c01420b4>] (do_filp_open+0x30/0x7c)
[<c01420b4>] (do_filp_open+0x30/0x7c)
from [<c0132518>] (do_sys_open+0xd8/0x174)
[<c0132518>] (do_sys_open+0xd8/0x174)
from [<c000e380>] (ret_fast_syscall+0x0/0x30)
Hence use mutex to protect msm_set_termios() allowing clk_set_rate()
to be called from non-atomic context.
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
(cherry picked from commit e672516d9348319af27ff1d11834fffb97dd90af)
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
(cherry picked from commit dad1f2594fce0b75695416e93898067bc582d5a3)
Change-Id: Idec64f3d8938148b5c1dd135bde041be5ae3b34d
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
During the userspace freeze process, a fake signal is sent to userspace
applications. In the case of SMUX CTL, the smux_ctl_poll() will set the
POLLERR flag if a signal is received. This incorrectly unblocks the
userspace application that called poll() and the userspace application
will grab a wakelock before doing additional processing which aborts the
freeze process.
Change smux_ctl_poll() to not set POLLERR if a signal is received.
CRs-Fixed: 402651
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit 3cbcfa3d79564063fc4aa52173feeff101926cb9)
Change-Id: I6c2753b97bd8cf694b75d6fd3713adc99da8b266
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
If the remote modem has queued many small packets in the UART FIFO and
the SMUX client cannot provide receive buffers fast enough, then the
auto flow control command may not get processed before the receive queue
has overflowed. In measured cases, an average of 10 packets are
received after flow control is enabled. In the failure cases, up to 19
packets are received which is more than the max queue size (32 packets)
minus the high watermark (16 packets) which causes an overflow.
Use a bigger retry queue and more aggressive watermark values to make
auto flow control more responsive and to allow more packets to get
queued before an overflow occurs.
CRs-Fixed: 394198
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit 0ab6fc1757ae275a7e29c95588c8470fb787ee2a)
Change-Id: I20817f4dab3360f3c62bd83e74594555571a3a9f
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
Increase log buffer size to handle the maximum possible log line size.
This prevents passing in a negative buffer size to sprintf() which is
handled gracefully, but generates a warning message in the kernel log.
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit acd4c77f0311b42a49d254d5308397fd0a39277a)
Change-Id: I6b78092d0dc687184c9a12203441085382fd5c1a
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
Currently UART port is enumerating with platform device ID. It is not
necessary that TTY<ID> is same as available UART device ID. Provide
optional support which allows to override used platform device ID with
uart port by userid to get TTY based Uart device as /dev/ttyHS<userid>
instead of /dev/ttyHS<ID>.This support helps third party application/test
framework to use the same TTY uart device name across different platform
without changing in those applications as it is not necessary that on
different platform used UART device would be having same TTY<ID> name.
The userid value should be from 0 to 256
CRs-Fixed: 386736
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
(cherry picked from commit 51690e5e8c2d6199a0e1162aa2c0317a2c6a9f89)
Change-Id: I3d9546ceab48345d0e3456c6223e3ff82e5a2f8b
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
flushing console messages into uart is very slow.
If you boot up without connecting the earjack-debugger, skip to
write console message into uart. So We can reduce the bootup time
by about 2 seconds. But unfortunately this patch is mako specific
patch, not generic
without this patch:
[ 1.001648] msm_serial_hsl: console setup on port #0
[ 2.344452] console [ttyHSL0] enabled
with this patch:
[ 0.966091] msm_serial_hsl: console setup on port #0
[ 0.966854] console [ttyHSL0] enabled
Change-Id: Iba2628fe7b9e08583d98e804ee6bc3bd87aee9a7
pm_restore_console() is called from the suspend/resume path, and this
calls vt_move_to_console(), which calls vt_waitactive().
There's a race in this path which causes the process which requests the
suspend to sleep indefinitely waiting for an event which already
happened:
P1 P2
vt_move_to_console()
set_console()
schedule_console_callback()
vt_waitactive()
check n == fg_console +1
console_callback()
switch_screen()
vt_event_post() // no waiters
vt_event_wait() // forever
Fix the race by ensuring we're registered for the event before we check
if it's already completed.
Change-Id: I83ad994a12d40759d6ff3d46796446853c2a88de
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
You might be listen to noise between console start and earjck detection
if earjack connection on sleep. this hack is noise reduction in that case.
Change-Id: I83013a156514b607ce7e4d7e45978cdaa13376ef
Always enable the console on resume. We need to restore previous
status of console on resume. console is stopped and console should be
not enabled on resume in that case.
Change-Id: I6715443fce4cd06e564cbfeebb6d6b187013abcc
tty_buffer_request_room is well protected, but while after it returns,
it releases the port->lock. tty->buf.tail might be modified
by either irq handler or other threads. The patch adds more protection
by holding the lock across tty buffer finding and buffer filling.
Signed-off-by: Alek Du <alek.du@intel.com>
Signed-off-by: Xiaobing Tu <xiaobing.tu@intel.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Change-Id: I7561321a1e78c9730232f98085e01fc1749a48f5
CRs-Fixed: 387308
Signed-off-by: Vamsi Krishna <vskrishn@codeaurora.org>
There is a corner case in the tty driver where the value of
tty->receive_room is not being updated before writing data to
the line discipline. When this happens, data is lost because
of failure to re-submit any remaining data to the ldisc.
This fix is dependent on a new tty flag that is set only when
the tty driver is used for efs sync betweem the mdm modem and
the applications processor.
CRs-Fixed: 358868
Change-Id: I0ba02980504b4d8187b8c83111c2c883d194efa2
Signed-off-by: Joel King <joelking@codeaurora.org>
If subsystem restart (SSR) is in progress and the line discipline is
removed, then the platform devices may get removed twice leading to a
kernel panic.
Add conditional logic to properly handle platform device removal if line
discipline is removed while a subsystem restart is in progress.
CRs-Fixed: 386491
Change-Id: I1ddc89175509e333098f849b0f76e09660644573
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Control the UART AHB clock regardless of whether a GSBI
resource is present, as the AHB clock is needed to access
the UARTDM core registers in addition to the GSBI
registers.
Change-Id: Idca5ac07c133b67ac7c02ca3304a46794659e010
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Subsystem restart is handled by sending DISCONNECT notifications to
clients. In addition, a subsystem restart may trigger the mdm helper to
unload the line discipline to capture a memory dump before reloading the
line discipline. This requires SMUX clients to handle two different
disconnect cases properly.
To converge the two use cases and simplify client code, both a subsystem
restart and line discipline unload will result in removing the platform
devices. The platform devices are re-added after the line discipline is
loaded or the subsystem restart has been completed.
CRs-Fixed: 386186
Change-Id: Ic61c97acef2a9909f180ac4c81e944351ba9d348
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Userspace clients hold a wakelock while calling read. If data isn't
available, read() blocks preventing the release of the wakelock and
preventing the system from going into low power mode.
Implement poll() method to enable clients to call poll() to block and
wait for data without a wakelock. Once poll() returns, then a wakelock
can be acquired and read() called without blocking which allows
minimizing the time a wakelock is held.
CRs-fixed: 379519
Change-Id: Icea23783ee2d03e2beac81bdb1b735e4edfd1d22
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
MASK_RX bit is set to prevent transmitted data from looped back.
Set the TX and RX mode to T=0 mode; not T=1 mode.
Change-Id: Ida78fb56cf4b51c0fa88cb57da58c0dcc5db51c9
Acked-by: Ho Lee <holee@qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Port open call for smux is blocking. There is a 5 seconds default
timeout for the open call. The total number of retries for opening
the port makes the total wait time to be 11 minutes. This timeout
becomes an issue if QSC does not come up in time. Adding a device
attribute lets the user space control/reduce the timeout value.
CRs-Fixed: 372629
Change-Id: Ib20bf05da740c99dbb7e94b4df96d256ecadad34
Signed-off-by: Angshuman Sarkar <angshuman@codeaurora.org>
Add GSBI8 device and its related interfaces with their configuration
i.e. clock, ADM, GPIO. GSBI8 UARTDM interface can be used for external
Bluetooth SoC.
CRs-Fixed: 375285
Change-Id: I15819862072c92d8ff6f397fdf081f1b619ec235
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
During a subsystem restart or a line-discipline unload with active data
transfer, the logical channel purge function (smux_lch_purge) could lead
to a deadlock while flushing the workqueues if it is called with
mutex_lha0 locked and one of the worker functions calls a function that
locks mutex_lha0. In addition, the local mode was reset which is not
expected behavior.
This change aborts all work functions in the case of a reset allowing
the flush to be performed without any locks held. Once the flush is
complete, then the appropriate locks can be obtained before the reset
flag is cleared and work items can once again get scheduled.
Change-Id: I2afbcc3885907cd0cc8695f7c7a85b61a999e1fb
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Use SR[TXEMT] in addition to ISR[TX_READY] when determining
whether new data can be transmitted to work around a
condition where ISR[TX_READY] may not always give an
accurate indication of the state of the queue.
Change-Id: Ia3a590a485647a005c7c019660f11566208c2667
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
After completing a wakeup, trigger the TX worker to start sending
pending data.
Without the fix, the TX worker will wait until either other activity or
a power-down transmit before sending pending TX data.
Change-Id: Ica90b35d9a3169992db49ff493f783c27a2989da
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Removed the ACK from the protocol when a sleep request is received when
already in the turning-off state to avoid an extra wakeup just to send
the ACK.
This case happens when both the local and remote sides transition to the
turning-off state and send a sleep request. Both sides will then
receive the sleep request at which point they can immediately transition
to the off side without having to perform a wakeup just to send the ACK.
Change-Id: I3fe4a82da34b68ef51ee9aa0c00507361b0717ed
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Temporarily increase the Application processor inactivity timeout to
prevent a local inactivity timeout while the external modem is booting.
This is necessary to allow releasing a power-collapse ACK change without
breaking SMUX until the external modem changes have also been mainlined.
Once the external modem changes have been mainlined, then this timeout
will be reduced to 250ms to improve power consumption when idle.
Change-Id: Ic9e12c849dd53955c6ff4a1eaff0a2ec761ffa35
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Log power packets in addition to power state changes.
Change-Id: I46b8d86df881b328bb9124611bdbf1a0db2928f9
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
The wakeup worker and TX worker both run on the same single-threaded
workqueue, so the wakeup worker needs to reschedule after sending a
wakeup character to allow pending characters to get flushed.
Without this change, a burst of wakeup characters will be sent once the
exponential back-off delay is 32ms after which the wakeup worker
reschedules itself as a delayed work item.
Change-Id: I4260c7f5b2f1f90e87575eac4b407be2bc6adb1d
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
If the receive retry queue size gets too large, then automatically
enable flow control to prevent having to drop buffers.
Change-Id: If27599015b362ce013e177ee350e026933390d72
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Use temporary values to allow using arguments with side effects in the
unit test macros.
Change-Id: Iebe7586e1d3469fcf9729b77ddedc701c71a2bd3
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Clarify test messages for list-empty reporting to avoid confusing
the list-empty flag with an event count value.
Change-Id: I31aeb6feb89ada5f7d5b691432b5d8f4aba64cc8
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Add range checking of the channel ID for packet logging. This prevents
out-of-bounds array access when reading the channel state.
Change-Id: Ic91b29e89ef9997525f6283b8212408cccd646f8
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Hold mutex lock while flushing TTY to avoid race condition with
unloading the line discipline.
Change-Id: I2327be9bd39119d14c3e607e8ace201d51755e08
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Only SMUX_DATA_CTL_0 is currently used from userspace.
Change-Id: Iab9e4fa9b096d34a67fb6662418aec0be1381adb
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Disable debug logging that was only necessary for bring-up.
Change-Id: I5a31a982efdd1bb1915571158cc164a3856b097d
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
SMUX_CTL module currently does not handle removal of the driver
gracefully. If there are any pending blocked calls on wait_event,
and the line discipline is removed, this results in accessing
destroyed wake queues.
Add support for aborting wait in response to device removal.
Change-Id: I3213306f6ed401f3abe5770ce324d9329e4dbc3f
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
UIM (User Identity Module) driver makes use of existing MSM serial
driver. It configures UIM clock during startup and shutdown of
UART device.
Change-Id: If1b249639e9969273882ad000ef9b1495b8c7013
Acked-by: Ho Lee <holee@qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Stub out get_console_state if the console feature is turned
off to prevent a compilation warning in debug code.
Change-Id: Iad3d9303850bedd56db0ffc6f08dc5e8c9442373
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Handle below error cases with UART Tx transfer:
1. Application doing I/O to UART port and is being terminated abnormally.
2. Used ADM Channel for UART TX transfer stalls.
In both above conditions, queued Tx command to ADM is not flushed. Hence
restarting of application shows list corruption for queueing next UART
Tx command to ADM. This change fixes it by having state machine for UART
Tx, identifying such condition and flushing the queue Tx command before
closing the UART device.
Change-Id: I4e567a539d890dffed50b5837dde58d5cd62d641
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Reset the power-collapse-enabled flag to allow renegotiation when the
remote modem restarts.
Without this change, the external modem will boot assuming that power
collapse is disabled, but the Apps will have the previous state cached
and may not send the proper power-collapse-enabled handshaking.
Change-Id: I58acbfa51b60fde23d328239fd6b330bf0bcc63f
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
The modem driver that handles subsystem restart uses the name
"external_modem" for the external modem.
Change-Id: I4a8199bd259b1aa2ee9310fc29c55c9db4f4cbab
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Remove power command from list before deleting the packet.
Without this fix, if there is a pending power command during a subsystem
restart or a line-discipline unload, then the code will end up in an
infinite loop until the watchdog kicks in and an access after-free check
fails.
Change-Id: Ib8f24598ce1273411a2674d5d61634ffb1944bb1
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Increase the HSL TX path timeout to account for the fact
that the TX buffer size is specified in words rather than
bytes, and that some implementations may have a larger TX
queue size than what was assumed in the original timeout
calculation.
Change-Id: Ie459a2fcdd8a85c2e97ff3a87d60a9c30ce50ec3
CRs-Fixed: 359256
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Add support for broadcast logical channel ID used with the dedicated
power-control commands.
Without this support, power commands sent on the broadcast channel may
get dropped which is currently only a test case issue.
Change-Id: I798ed8a315b3f864fa9afa20ef073b2ab5cab293
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Add dedicated power logging macro to aid in power-related debugging.
Change-Id: I21d8c8b55a8d7c0645d1241773cb8127a48c58c4
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Remove duplicate setting of the pkt.flags field which is harmless, but
redundant.
Change-Id: I6d2579216a03c4ca5ca3b06092ed8a9208d3e891
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
UART clock rate is set to zero while disabling the uart clock for
subsystem restart feature. It is required to set the uart clock rate
to 7372800 Hz while enabling UART clock. Hence use uart_change_pm in
serial core to call msm_hsl_power api to achieve the same.
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>