Commit Graph

78 Commits

Author SHA1 Message Date
Dilip Kota e4cf4f803e slim-msm: Synchronize SSR callbacks
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>
2017-05-05 19:20:28 +00:00
Dilip Kota 9a5cd01d7b slim-msm-ngd:Avoid using stale pipe handle
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>
2016-07-04 05:32:48 -07:00
Sagar Dharia 4881556669 slim: msm: Improve bulk message timeout error handling
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>
2016-02-16 22:50:46 -08:00
Sagar Dharia 7e1d0cce12 slim: msm: Return success for ch-remove type of messages during SSR
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>
2016-02-07 23:13:30 -08:00
Sagar Dharia c98b1ff7ad slim: msm: Set Device state to sleep in case of a suspend-timeout
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>
2016-01-04 23:12:54 -08:00
Sagar Dharia 61b972d477 slim_msm: Gracefully handle QMI timeout failures
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>
2015-12-17 02:14:01 -08:00
Naveen Kaje b2afdcea82 slimbus: msm: Deinit/Reinit BAM pipe after SSR
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>
2015-10-26 00:41:08 -07:00
Linux Build Service Account 8ecc331c39 Merge "slimbus: ngd: Rely on HW status for capability negotiation message" 2015-09-21 07:11:03 -07:00
Sagar Dharia 198210a222 slimbus: ngd: Rely on HW status for capability negotiation message
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>
2015-09-16 12:24:02 +05:30
Sagar Dharia 870f6f29c2 slimbus: ngd: Optimize bulk write transactions
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>
2015-09-15 23:51:39 -07:00
Linux Build Service Account c4efea8690 Merge "slim_ngd: Serialize shutdown sequence during SSR down" 2015-08-01 20:09:03 -07:00
Sagar Dharia 56b3d9e2f2 slimbus: Use irq-safe methods for transaction lock
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>
2015-07-19 10:44:19 -07:00
Dilip Kota bd4ffadb36 slim_ngd: Serialize shutdown sequence during SSR down
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>
2015-07-18 03:49:22 -07:00
Linux Build Service Account 369dfc05f2 Merge "slim_msm: Optimize RX path for slimbus" 2015-07-06 21:52:00 -07:00
Linux Build Service Account 9d81827781 Merge "slimbus: Support multiple message transactions per call" 2015-07-05 02:35:39 -07:00
Sagar Dharia 159728155d slimbus: Support multiple message transactions per call
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>
2015-07-03 02:26:49 -07:00
Naveen Kaje bb3f71b37f slim-msm-ngd: Change the NGD interrupt to be an ISR
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>
2015-07-03 12:59:58 +05:30
Sagar Dharia f7011a0df4 slim_msm: Optimize RX path for slimbus
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>
2015-07-01 16:52:28 +05:30
Dilip Kota 4bff71fc33 slim_msm: Reorganise Rx/Tx tear-down during DSP-SSR
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>
2015-06-10 08:27:50 +05:30
Naveen Kaje 84db5256a6 slim-msm: send port disconnect messages over slimbus
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>
2015-04-29 12:35:15 -06:00
Sagar Dharia e95bc325be slim_ngd: Send data-length instead of segment for defining channel
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>
2015-04-16 11:48:07 -06:00
Sagar Dharia 68e2f99712 slimbus: Optimize transaction handling in the framework
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>
2015-02-13 15:59:21 -07:00
Linux Build Service Account 2fe5bd6ef7 Merge "slimbus: Support push-pull data channel protocol" 2015-01-15 23:26:24 -08:00
Sagar Dharia 6b4bbcba3a slimbus: Support push-pull data channel protocol
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>
2014-12-16 12:34:21 -07:00
Dilip Kota e291556030 slim_ngd: Increase Rx throughput
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>
2014-12-09 20:39:08 -08:00
Sagar Dharia bc4c3bf0bf slim_ngd: Handle invalid/timeout TX errors gracefully
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>
2014-12-02 17:49:19 -07:00
Kiran Gunda 88d8ba18ff slim_msm: effective management of data ports
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>
2014-11-21 01:26:11 -08:00
Linux Build Service Account 78469aec5b Merge "slim_ngd: Avoid unnecessary pipe connect/disconnect for msg queues" 2014-11-20 15:36:48 -08:00
Sagar Dharia e04d0b0faa slim_ngd: Avoid unnecessary pipe connect/disconnect for msg queues
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>
2014-11-14 15:47:35 -07:00
Sagar Dharia bc2e68fb8e slim_ngd: Ensure device state consistency with runtime-pm during SSR
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>
2014-11-13 14:49:25 -07:00
Sagar Dharia 1e095a5bdb slim_ngd: Use DSP before-shutdown notification for DSP SSR
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>
2014-11-03 13:48:06 -07:00
Sagar Dharia dc3ac13724 ngd_slim: Ignore pm_runtime_get error when runtime-pm is not enabled
Controller power-up uses different code-path when runtime-pm is not
enabled.

Change-Id: Ibe2f119fd8f43edb657f8f623879dea4730811f4
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
2014-09-16 17:06:28 -06:00
Sagar Dharia 6085240248 slim_msm: support non-blocking writes from slimbus MSM controller
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>
2014-07-15 15:57:28 -06:00
Sagar Dharia 7241199fd0 ngd_slim: Fix return paths in transfer function
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>
2014-07-03 09:34:03 -06:00
Sagar Dharia 59f078c679 ngd_slim: Register with QMI service in the slave-notification thread
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>
2014-06-20 13:21:32 -06:00
Eric Holmberg 9f4800553d msm: ipc_logging: add client version support
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>
2014-05-27 13:56:54 -06:00
Sagar Dharia 53eb18ad35 ngd_slim: Decouple clock pause from power down/up
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>
2014-05-19 16:42:42 -06:00
Kiran Gunda b970f20dce slim_msm_ngd: Add IPC logging support
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>
2014-04-17 12:51:07 +05:30
Linux Build Service Account 2a9b24f26b Merge "Slim_ngd: Don't create the device node per SSR" 2014-04-09 05:20:13 -07:00
Sagar Dharia a88867c2a0 slim_msm: Handle external-modem shutdown differently than restart
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>
2014-04-08 18:27:08 -06:00
Kiran Gunda 320e892680 Slim_ngd: Don't create the device node per SSR
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>
2014-04-08 18:47:24 +05:30
Naveen Kaje c5eab7ea9b msm-slim-ngd: Read configurable external modem identifier
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>
2014-03-26 15:50:58 -06:00
Sagar Dharia 186f5c0eae slim_ngd: notify slaves in some MDM restart scenarios
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>
2014-03-26 15:48:38 -06:00
Kiran Gunda c04d87105e Slim_ngd: Modify waiting mechanism in kthread
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>
2014-03-20 14:17:12 +05:30
Naveen Kaje d366c37be6 slim-ngd: change log level of slave_notify completion
Change the logging of slave_notify completion to debug to avoid
excessive logging.

Change-Id: Ie8e4ec1c7db786a20212f828d1432ea64e87ccd7
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
2014-03-14 16:40:17 -06:00
Sagar Dharia 9f8c6e83d2 slim_ngd: Use QMI server up notification instead of APR for probing
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>
2014-03-10 20:37:34 +05:30
Sagar Dharia 0bd06ffe30 slim_ngd: Support REPEAT_CHANGE_VALUE user message
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>
2014-02-12 20:33:06 -07:00
Sagar Dharia 6665eb703c slim_ngd: Handle error flags before handling SENT flag
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>
2014-02-12 19:02:29 -07:00
Dipen Parmar 7f918cb5c7 msm: sps: remove sps header file
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>
2014-02-05 15:31:11 -08:00
Linux Build Service Account f2f2c38e38 Merge "slim_ngd: Fix logical address notification mechanism" 2014-01-28 01:16:48 -08:00