Subsystem will restart within short timeframe.
Synchronise subsytem up/down callback notifications
to avoid functionality failures.
Use mutex locks to achieve synchronization.
Change-Id: I5881c7d468507bb8402a2e9f8178b9c31e57e8a5
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
Make sure to use pipe handle from the TX
endpoint rather than using a stored handle.
The stored handle may become invalid if SSR
happens between storing of that handle
and locking the mutex.
Change-Id: I53e8f860c2d50061b6c4e6ce2f944c1e2ed8dff2
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
If a bulk message times out due to interrupt starvation, a late
coming interrupt may access structures that are not valid.
Improve timeout error handling by resetting variables, and changing
relevant logging.
Change-Id: Ie0ee2fd9c2ce1628c69e1975fe713a2a26d9e716
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
During SSR, all channels are removed and ports are disconnected since
slimbus HW is not functional. Return success to clients for such
calls so that client can mark channel/port state constistent with HW
Change-Id: I9b18f8e7ffe233090c9612d0811a7d36645d0329
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
If low-power mode is not entered due to timeout, it is possible that
HW has actually been turned off by ADSP but the response was not
received by driver on apps on time.
Change device state to sleep to make sure HW is woken up for
subsequent runtime-resume operation.
Change-Id: I4e454f7e90e1244985c86286b95202eecfc50a7e
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
QMI timeout can happen if other processor doesn't respond within the
time expected by slimbus driver on apps. It has been noticed that QMI
call to power-on slimbus rarely takes more than 500msec. Timeout
is increased to allow that possibility. Additionally, QMI channel is
drained out of left-over messages and runtime-PM state check is
modified to allow graceful handling of timeout if at all any timeout
still happens.
Change-Id: I392a4fa761735135a261fb543815823cee5eba41
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
If SSR happens, deinitialize and reinitialize BAM pipes used for
TX and RX messaging.
Change-Id: Ia025aafac9072eac887603bccb1acf5465dfb805
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
HW status in config register will provide consistent information
in case HW status changes due to unexpected noise on the lines.
Use that status to initiate capability negotiation rather than
SW status.
This means the negotiation may take place during runtime if HW
experiences noise. Ensure completion objects don't get re-initialized
accidentally due to this since thread responsible for exchanging this
capability can be waiting on it.
Change-Id: Ifee39473b7b4b63de44a392bb4040bcd9b98e2ff
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
Allocate bulk-write transactions in advance for most-commonly
used bulk sizes, and reallocate only if size greater than that is
requested by client.
Change-Id: Ib5a80f3713fe5b94bd6dcf45ffe61e498fada192
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
Slimbus transactions are process-completed in interrupt context.
This involves signaling appropriate transaction from transaction table
and/or invalidating transaction in error case. Due to this, the
transaction need to be accessed from interrupt context as well. Use
irq-safe methods to avoid interrupt accessing the lock while thread
has acquired it.
Change-Id: Ibe800a64a7594cc435d229e05dda91baea8c9b6e
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
During SSR down, work is queued for shutdown
sequence. Sometimes work is getting scheduled
on one CPU while SSR up sequence is running
on other CPU. This is leading to unexpecpted
scenarios and ending with crash.
To overcome this, serialize shutdown sequence
by doing function call instead of workqueue.
And remove ctrl_up signal reset in the shutdown
sequence as it is affecting the transactions
initiated by client.
Change-Id: If73999ad19441e2090c4ad181dbc90e62ad3d9d4
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
Bandwidth intensive operations (such as firmware download) need
lot of messages to be sent over the bus. This API adds support to
queue multiple messages to HW and provides controller implementation
using BAM.
The API can also be used in places where slimbus slaves have strict
ordering/timing restrictions (e.g. send 2 specific register-writes
back-to-back).
Change-Id: I9a0779e0c4b957d4f4e3b31567b983457d367193
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
NGD interrupt can be handled in the interrupt
context as an ISR to process the rx messages faster.
Change-Id: Iaf615520617448160901d0b5de03efc9708d8437
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
Optimize RX path by handling small message responses, and
satellite acknowledgements in interrupt context to avoid multiple
context switches.
Change-Id: I111c7ad81e8023a811854632f165185b06157822
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Rx/Tx pipe resources are freed during DSP down.
Simultaneously BAM ISR due to Rx/Tx interrupt
may access the Rx/Tx pipe resources leading to
pagingfault.
To overcome this, Rx/Tx activity is reorganised by
disabling the interrupt during ADSP down and
freeing, allocating resources during ADSP up.
Change-Id: Id1b77a05a042ef9ca194f78e700670edf6146db6
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
Ensure that master-side port disconnection messages are
sent over the slimbus rather than only disabling the port
itself.
Change-Id: Ica2351a325245531349af7b62b2e9d691c569ff2
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
Master component expects data-length instead of segment length and
those two may differ for some protocols.
Change-Id: Idf48f856f7c58d80304f9f13b642d1bccdb09e83
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Avoid overhead of allocating/freeing structure for transaction
if that transaction is synchronous. For synchronous transactions,
structure is defined on stack using a macro for simplicity. Since
structure is not allocated per transaction and locking is required
only for a few simple instructons, spinlock can be
used to protect the transaction table.
Change-Id: I79ea64b98907ab71fd727d76cf78a2d6feaf0eb0
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Start supporting push-pull data channel protocol in slimbus driver
since the slimbus HW supports it now.
Change-Id: If6b26a696cd2a459a5c5215588711ea037e778ac
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Read complete message at a time instead of
4bytes of a message.Hardware Rx timeout
feature helps to achieve it.
Change-Id: I42d4dc63438816c8ce800c86f359e93cddd5bad3
Signed-off-by: Dilip Kota <c_dkota@codeaurora.org>
Invalid transactions can cause timeout or NACK TX errors.
Clear completion object reference for pending TX messages and print
TX BAM pipe descriptors and status registers for such transactions.
TX timeouts during connect/disconnect port error conditions should
clear completion object reference for acklowledgement receipt
to avoid referring to stale completion object later.
Change-Id: I81018df8cab59b43753c46c8a49a5066b794fda6
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
The current implementaion of data ports management
assumes that the ports are allocated contiguously,
which is not a correct assumption.
This patch addresses this limitation and handles
the data ports which are allocated non-contiguously.
Change-Id: I04e83bc525a50db4d0a37028498be848af018bb5
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
If slimbus satellite device retains its logical address after power
vote, it is safe to assume that BAM HW did not get reinitialized.
Use that logic to disconnect TX/RX message queues to avoid
disconnecting and reconnecting them during every power up/down vote
Change-Id: I906c4f5f01ed076066a084a8aa10d8e4d4825e33
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
During ADSP SSR, client's thread calling runtime-pm resume will
fail since ADSP is unreachable. Make sure such power-up/resume attempt
is blocked until ADSP comes up by using mutex during device-state
transition.
Change-Id: Ie85e52bb2974aaee9654eb8fa1cc60fe37c61b75
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
QMI_SERVER_EXIT notification comes too late (after the DSP has
shutdown). This can result in unclocked access by BAM if there was
in-flight transaction. Use BEFORE_SHUTDOWN notification of SSR
framework instead to make sure in-flight transaction is finished
before DSP turns off its resources.
CRs-Fixed: 730552
Change-Id: If3c2787c74ffa7743772e5e37eac2f768e239050
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Controller power-up uses different code-path when runtime-pm is not
enabled.
Change-Id: Ibe2f119fd8f43edb657f8f623879dea4730811f4
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Provide non-blocking write support so that clients can queue multiple
writes, or larger transfers without performance implications.
TX buffer is created and descriptors out of this buffer
are submitted to HW to transmit data.
Descriptor is returned to 'available' pool of TX buffer when HW
interrupt for transmission status is recieved.
Change-Id: Icc2af6bf4f770c8cadb9bd2ef7be0f95eb22c5d8
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Return right away if resume fails when runtime-pm is not
enabled. Consolidate return paths if controller power-on
vote fails when runtime-pm is enabled.
CRs-Fixed: 677689
Change-Id: Ia8887dd87df6dba4f93638650794bfcdc7d1ff75
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Slave notification thread is used to notify slaves when QMI server
(hosted by slimbus msater driver) on the remote execution environment
has come up. Use that thread's entry point to do QMI service
registration as well since doing so in probe may trigger another
probe by the QMI service leading to boot-up stalling.
Change-Id: I06b1bcfd9aa3d570554971acacd5d7b1dc20fd1c
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
If clients use custom serialization functions, then they may need to
define a version for deserialization support for log extraction.
Add client version support.
Change-Id: Id135f06d4142de39275b5d0caab88708d5496b5e
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
NGD slimbus driver itself can never send out clock pause sequence
for slimbus protocol on the HW lines since it can only be sent by
a manager device (which is controlled by ADSP when NGD driver is
instantiated from apps side).
Previously, clock pause of slimbus framework was coupled with power
down/up. That is not correct, since manager device may or may not
decide to send clock-pause on the HW lines. (e.g. if apps is inactive,
but some client on ADSP is active, clock-pause sequence won't be sent
over the bus.
Decouple power-on/off from clock pause to avoid giving incorrect
impression to clients on apps side about clock-pause state. Mark
clock-pause as unsupported by setting wakup function pointer to NULL
instead since this controller on apps cannot send it on HW lines.
CRs-Fixed: 667165
Change-Id: I382bca153deb2fed1d0f0672adaebde1e122dc68
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Add IPC logging support for improved debugging
per device, and in memory to avoid using kernel
dmesg logs.
Logs are captured in four levels.
1) error level ---> All fatal errors are logged
2) warn level ---> error level logs +
Warning messages are logged
3) Info level ---> Error level +
warn level + the required information
for debugging is logged
4) Debug level ----> error level + warn level +
info level logs + extra information
for debugging are logged
Procedure to change the debug level at runtime:
==============================================
cd sys/devices/ctrl_num(eg:1234).slim
echo <log_level> > debug_mask
Procedure to collect the logs at run time:
=========================================
adb shell cat sys/kernel/debug/ipc_logging/ctrl_num.slim/log_cont
|tee slimbus.txt
CRs-Fixed: 645838
Change-Id: If183533472ee61b2d8cf458d228dd4ae2124dd37
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
External modem may shutdown in cases other than subsystem-restart.
In that case, the power-up notification may not happen.
Handle such a scenario and make sure runtime-pm vote is not held
for more time than required, and that slave-device up/down/reset
notifications happen as expected if slimbus was down.
CRs-Fixed: 645450
Change-Id: I5fef2393c835d06c5ce1dc4f9cb62d418620211b
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Observe the device crash due to the device node
gets created per ADSP SSR when the logical address
query succeeds at the first attempt.
This patch makes sure that the device node creation
happened only once by declaring another variable to
track the logical address retry.
CRs-Fixed: 640381
Change-Id: I3d947fcbc575af7cb431255772aa9cb64d2df6b6
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
When an external modem is used, read the config from dt and use the
value in subsystem restart callback registration.
CRs-Fixed: 612775
Change-Id: I5e40e98a60c304c82741914157191cfb2f0697d5
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
If MDM restarts when it had active framer, bus may lose sync.
Send device-down notification if that happens, and corresponding
reset-device and device-up notifications to slaves so that they
can act to restore their devices' communication over slimbus
CRs-Fixed: 612775
Change-Id: I83f22b9bcf18912c7c9507ea099691ed71d86a9f
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
wait_for_completion_timeout() is not a good option in
kthread as it leads to scheduling the kthread on the every timeout.
Hence modify it to wait_for_completion() from
wait_for_completion_timeout().
Change-Id: Iaa29e997fd1cd5cb02f9ba44e69e1700b31736ae
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
Change the logging of slave_notify completion to debug to avoid
excessive logging.
Change-Id: Ie8e4ec1c7db786a20212f828d1432ea64e87ccd7
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
Slimbus QMI-server can reside on any other remote processor.
Avoid depedency on APR (for APR state) by utilizing QMI server-up
notification for slimbus hardware initialization from apps processor.
Change-Id: I85e268d08e5c4cfc9c53513199784813200f0223
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
REPEAT_CHANGE_VALUE user message is used to transfer high amount of
messaging data efficiently.
CRs-Fixed: 503461
Change-Id: I2762ad858b27ac84597f4eaf22fc6f3d14232d76
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
It's possible that error flags were set alongwith SENT flag for
TX transaction status. In such a scenario, error flag status should
be handled (and SENT flag should be cleared). Move error-flag
handling ahead of SENT flag handling to avoid interrupt being called
twice, and completion being set twice.
Change-Id: I13f28df0a0448790069bd103422dc1cd6c7ac408
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
Remove the sps header file from older location as sps
driver and clients need to use new header file from
new location include/linux.
Resolve the warnings/errors from client drivers due to
new sps header changes.
Change-Id: I1cdb87756abf3425a9bb5d8bf89cd1aa03a01716
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>