tty: n_smux: Mask power collapse support

If power-collapse is supported locally, then SMUX will always set the
power-collapse supported flag in an OPEN ACK which may cause confusion
for the remote side.

Mask power-collapse enabled with the value in the remote open
acknowledge message.

CRs-Fixed: 443770
Change-Id: I8ceb753e25a53d13fa5b5288457e8b1993452a18
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
tty: n_smux: Don't uselessly assign value

Don't give an unnecessary initial value to a local variable.

Change-Id: I1d9e3987970fc2108d6416159bc425da73da0e07
Signed-off-by: David Brown <davidb@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
tty: smux_ctl: close SMUX port during SSR

If a subsystem restart occurs, the SMUX port needs to be closed when the
platform device is removed and then re-opened when the platform device
is probed again.  Without this functionality, the SMUX port state is not
properly reset resulting in a data stall.

Add code to close the SMUX port when the platform device is removed.

CRs-Fixed: 474388
Change-Id: I00039fa517a5cf6b4d9230114cac7c6c9bbba9d1
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
tty: n_smux: Make test functions static

Local test functions should be static to prevent duplicate
symbol collisions with other modules.

Change-Id: I43cf6199fa1fa5fe58e81c9b4e5b5c18f3539341
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
tty: n_smux: Add throughput metrics to unit tests

Add throughput metrics to unit tests to enable profiling the performance
of SMUX round-trip messaging.

Change-Id: I1eb552ca53358ece9f95a99a340409a4464877fb
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
tty: n_smux: fix test pattern validation

Incorrect test pattern code was skipping the test pattern validation
test and not freeing the test buffer resulting a slow memory leak in the
unit test that could lead to out-of-memory failures after several
hundred thousand iterations.

Fix pointer test to properly free memory after test case completion and
fix incorrect test pattern validation code.

Change-Id: If93c2cfd2f82295897b36ffaf98ecaa5b9128cfb
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
tty: n_smux: Add wakeup test case

Reproducing and isolating wakeup issues caused by incorrect UART
configuration and hardware issues currently requires analysis of the
internal logs which is often time consuming.

Add wakeup test case to allow teams to easily reproduce wakeup issues or
verify wakeup functionality.

Change-Id: I614d6ee3eefc6563930c45564b76452e89f65dc8
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
tty: n_smux: Rename SSR unit tests

Running the Subsystem Restart (SSR) unit tests without SSR enabled
causes the system to halt.

Rename SSR unit tests to allow for testing all non-SSR tests
quickly from the command line.

Change-Id: Ib80e9adef8311ebe038f878dfcf2aecd1087a471
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
tty: smux_ctl: Add new SMUX port Support

smux_ctl exposes only one control port to userspace. Enabling of dual
PDN support requires two SMUX ports.

Add new SMUX control port to enable dual PDN support.

CRs-Fixed: 497343
Change-Id: I2a1d48f1e5d2acd1f67d7673d325c4360b783cf4
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
tty: n_smux: After receiving OPEN_ACK flush tx_queue

If a local SMUX client re-opens the channel and tries to send data before
receiving the OPEN_ACK, the transaction will get stuck because the
channel local state is not OPENED.

Add the channel to ready list if tx_queue is not empty after receiving
the OPEN_ACK.

CRs-Fixed: 507379
Change-Id: I357b6edc340c404c890da0c415ed3aeba96dcfe8
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
tty: n_smux: add separate close notifications

When an SMUX port state is closed, the close request is sent to the
remote system.  The port cannot be re-opened until the remote system
acknowledges the close request.  If the client attempts to re-open the
port during this time, then the -EAGAIN error code is returned and the
client must keep retrying to open the port.  An event-driven approach
would be better, but the client does not receive local state
notifications, so this is not possible.

Add local and remote closed notifications so clients can handle the
closing state transitions without using polling.

CRs-Fixed: 510114
Change-Id: I48008804d23dbfd05df0becd4bc1c695e599a835
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
tty: n_smux: fix deadlock between RX and TX workers

smux_handle_rx_open_ack function acquires the channel state spin lock
and tries to add the channel into ready list causing spin lock lockup
between smux_rx_worker thread and smux_tx_worker thread running on
two different CPUs.

Add the channel to ready list after releasing the state spin lock.

CRs-Fixed: 514726
Change-Id: I11729290c5c28a13bed66cf7506b8aaf48a32d2a
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Merge "tty: n_smux: Mask power collapse support"
Merge "tty: n_smux: Don't uselessly assign value"
Merge "tty: smux_ctl: close SMUX port during SSR"
Merge "tty: n_smux: Make test functions static"
Merge "tty: n_smux: Add throughput metrics to unit tests"
Merge "tty: n_smux: fix test pattern validation"
Merge "tty: n_smux: Add wakeup test case"
Merge "tty: n_smux: Rename SSR unit tests"