Commit Graph

64 Commits

Author SHA1 Message Date
Bhaumik Bhatt
f1fb19488f mhi: core: Extend mhi_device_get_sync_atomic() for panic cases
In case of a kernel panic, interrupts are not handled and hence,
any attempt to assert device wake and wait for an M0 state change
relying on interrupts will fail. In order to help solve this
issue for cases where the controller needs to assert device wake
in panic path, extend the mhi_device_get_sync_atomic() API and
allow it to poll the MHI STATUS register for an M0 state change.
Make the appropriate changes wherever the API is in use.

Change-Id: I920d76d1cec879c29180438072e32e18370cf8ff
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2020-09-23 18:22:33 -07:00
qctecmdr
17c9055ecb Merge "cnss2: Save default config space without BME enabled" 2020-08-20 06:51:34 -07:00
Bhaumik Bhatt
59c11dee79 mhi: core: Expose API to check device execution environment
Expose an API for clients to check the device execution
environment by reading the BHI_EXECENV register. This can be
used in situations where the controller decides to check the
state of a device which can abruptly reset without warning.

Change-Id: Ib0841535f8baf7bbdf8e737a816a400ee072ab93
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2020-08-03 13:21:52 -07:00
Bhaumik Bhatt
3422417948 mhi: core: Notify controller for bootup timeouts
During a synchronous power-up, at times the device may not
transition to a desired bootup state and host has to wait for a
longer time to dump registers and figure out any problems that
may have occurred on the device. Allow for the controller to
receive a callback for timeouts seen while waiting for a READY
state or an SBL or AMSS execution environment entry so it can
evaluate any debug approach it wants.

Change-Id: I36f90e478806476bf9ef4335eccb5273df812268
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2020-07-30 10:07:22 -07:00
qctecmdr
6ab83fe5a2 Merge "mhi: core: Use high priority workqueue for all MHI work" 2020-07-15 22:36:45 -07:00
Bhaumik Bhatt
cf2ebfa082 mhi: core: Separate rddm support and dump collection
As of now, there is no way for MHI to know if device supports RDDM
and host controller wishes to skip ramdump collection. Allow for
that by letting the controller set the rddm support boolean which
indicates device side support. If rddm_size is set to zero while
the support for RDDM is present, that indicates disinterest in
ramdump collection if RDDM execution environment is entered.

Change-Id: I0a36219fc7782951aa1b81b9ec0d182ecfb3a916
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2020-07-09 15:18:24 -07:00
Bhaumik Bhatt
05f5909329 mhi: core: Use high priority workqueue for all MHI work
Boot-up and shutdown require faster scheduling of the PM state
worker. Use the high priority workqueue for processing any of
the PM state transitions to ensure faster boot-up or shutdown
handling on MHI host.

Change-Id: Ie311426344d9561d490aa2bf6616aa30b4333e9a
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2020-06-11 15:52:32 -07:00
qctecmdr
757f1d1466 Merge "mhi: core: add mhi_device_get_sync_atomic() to wait until M0" 2020-06-10 23:48:02 -07:00
Manu Gautam
4b88d08c42 mhi: core: add mhi_device_get_sync_atomic() to wait until M0
There is a possibility of client driver's dev_wake request
as part mhi_device_get() racing with M1 state transition
event processing. This can result in a scenario where client
finds MHI state as M0 after mhi_device_get() returns only to
be changed later as M1 event processing is still pending on
different CPU core.
It causes M0 -> M2 -> M0 state transition after mhi_device_get()
has already returned. This isn't expected by client and currently
treats that as fatal error. Also, as per MHI spec host must allow
M1 -> M2 transition for device and it shouldn't abort that.

However, clients can ignore that transition as device is expected
to immediately move from M2 to M0 without entering deep sleep
state. Hence, it must be safe to access their MMIO.
To simplify this logic, introduce mhi_device_get_sync_atomic()
function that can be used by clients to achieve the same and once
it returns success they don't need to have any explicit MHI state
checks.

Change-Id: I0b4a1ad723a0444ee2402bf171fc5ffc46afcdce
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
2020-06-10 10:20:30 +05:30
Hemant Kumar
73ae0cd66e mhi: core: Add support to pre allocate image buffers
This allows controller to keep the memory allocated for bhi
vector table for rddm and fbc images. Memory remains allocated
after controller powers down. Add a controller flag to make the
decision for memory allocation.

Change-Id: Ic8aee54ae57f5f9351158b18cd96faf7eeb81429
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2020-06-05 19:46:07 -07:00
Manu Gautam
d9e89f305b mhi: cntrl: Update device MMIO region length for MHI core
It can be used by MHI core to have a sanity check for
bhi and bhie offsets reported by device.

Change-Id: Iabcdc53a4c1f7c951721cbec0b1d7285cf19cd72
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
2020-05-20 15:27:53 +05:30
Hemant Kumar
4bb57cb832 mhi: core: Add support to re-try requesting firmware image
In case firmware request fails to find firmware in default
location, re-try with fall back location. This is done by
adding fall back firmware image location in controller
structure and firmware request is sent again using fall
back location. Send a status call back to controller when
re-try is done.

Change-Id: I252fa2721df335cbff11b8894adb9ad8cf7bf54f
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2020-04-20 16:48:49 -07:00
Bhaumik Bhatt
3d46bc93da mhi: core: add log buffer for controller bootup and shutdown
Add support in the MHI controller for a dedicated bootup and
shutdown log buffer and fix log message macros.

Change-Id: I6425107b9e2a048b44d8912051486d3aaa2abdac
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2020-04-01 14:56:01 -07:00
Hemant Kumar
6acfe5605e mhi: core: Prevent MHI reg read upon endpoint crash
MHI reset is triggered as part of EP shutdown. Shutdown
is blocked until MHI RESET bit is cleared in MHI CTRL reg.
There is a possibility of PCIe link going down during this
time. Since MHI RESET bit never gets cleared after 2 sec
wait_event_timeout reads the MHI CTRL reg and this results
into a memory abort. Fix this issue by using a boolean flag
as condition in wait_event_timeout. This flag is set when
MHI reset is triggered and cleared when reset is done.

Change-Id: I5b1831518255a38cde5b60406b5b9e9386b5477e
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2020-02-18 17:28:42 -08:00
qctecmdr
6eec9af592 Merge "mhi: core: serialize execution environment and power off changes" 2020-02-13 18:20:37 -08:00
Bhaumik Bhatt
1c275c41d2 mhi: core: enable doorbell method for time synchronization
Some devices support doorbell method to collect time
synchronization information. Add support from host for the
updated way of handling initialization and advertising
support.

Change-Id: I5bc82b946fd64927a2a88babc8d383e5fa664cf6
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2020-02-11 10:41:42 -08:00
Bhaumik Bhatt
195cc24a22 mhi: core: remove unused timesync device
Remove the unused timesync MHI device as we use the controller
device for timesync related activity instead.

Change-Id: If2bb5937cbf468d8778b89549afdb1d0a9af7782
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2020-02-10 18:24:49 -08:00
Bhaumik Bhatt
39215500c6 mhi: core: serialize execution environment and power off changes
Execution environment and power off changes can be serialized
to avoid changing these important controller variables from
multiple places and serialize handling of all state transitions.

Change-Id: I394e5ff4992d7c911e3889f96057d8467d79509c
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2020-02-06 18:29:21 -08:00
Bhaumik Bhatt
be796937d6 mhi: core: remove firmware loader worker thread
Remove unused firmware loader worker thread as MHI has moved
on to using pre-existing worker thread in order to serialize
the process.

Change-Id: I71349c97680ec1c0bf17e8f37ef8b046487a2b19
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2020-01-24 16:15:31 -08:00
Bhaumik Bhatt
633944b597 mhi: core: prioritize handling special purpose events
Some device requested special purpose events can take a long
time to get processed on host. Fix that by moving to dedicated
worker thread.

Change-Id: Ibfe7c56b85cb58b9ee67e41ea1139702d475ffee
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2020-01-24 16:11:23 -08:00
Hemant Kumar
c4a0f6f2bf mhi: core: Synchronize time sync operation and removal
If time sync is requested by user space when endpoint is shutting
down dev_wake count gets incremented. This is causing assert when
shutdown API checks the dev_wake count and it is still non-zero.
Fix this issue by protecting time sync API and removal of time sync
under tsync_mutex. This helps to take care of a race condition when
time sync is requested while time sync remove in progress and also
makes sure that dev_wake count becomes zero when time sync remove
is done to prevent assert condition.

Change-Id: I4e758611613e541537dd900306aa81dd3b4a9f3a
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2019-12-17 22:43:10 -08:00
Hemant Kumar
99333ce2d7 mhi: core: Add support to offload MHI register write to worker thread
When PCIe endpoint enters L1SS sleep and mhi client on Host tries to
queue a transfer request endpoint takes more than 6ms to come back to
L0 state. This can cause CPU stall if MHI register write is followed
by a write memory barrier. This can cause other tasks to get blocked.
In order to prevent this add register write offload API
mhi_write_reg_offload() which would queue the write and handle write
request from worker thread in AMSS execution environment.

Change-Id: I0a8b06d2ba96d9beb32fa31564aa0cbb26c885e6
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2019-12-16 15:39:10 -08:00
Hemant Kumar
e28112e452 mhi: core: Add write_reg call back for mhi controller
This allows to make a decision if different write call
back needs to be called.

Change-Id: I888da16e15e30ac1a7cb58d9272d6041b4d30ec7
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2019-12-16 15:18:30 -08:00
Hemant Kumar
285907ab38 mhi: core: Process bandwidth scaling event after force suspend
Bandwidth scaling event is handled by low priority worker. There
is a possibility of low priority worker racing with mission mode
state transition handling. This causes force suspend failure
because dev_wake count is incremented while processing bandwidth
scaling event. As a result l1ss timeout remains disabled and prevents
runtime suspend. Fix this issue by adding a flag to indicate force
suspend completion. This prevents processing of bandwidth scaling
event until force suspend is done. Bandwidth scaling events get
re-played after force suspend is done.

Change-Id: I0f2c415155842cab0449728dd136093be91f7259
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2019-12-11 18:35:22 -08:00
Bhaumik Bhatt
e282b99d0a mhi: core: provide an API to retrieve device failure reason
When device asserts, the subsystem failure reason from device
can be read via an external API using the name of the MHI
controller.

Change-Id: Ic0bcba77e0a7e4c4a7570df3eda21e1f38b80277
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2019-12-06 15:34:27 -08:00
Bhaumik Bhatt
fad0339d3c mhi: core: add support for retrieving device failure reason
Enable the device to populate the subsystem failure reason
string upon assert.

Change-Id: Ia67d03b714b3eb69eb2baa54cb4d5931d5098cd0
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2019-11-25 19:19:14 -08:00
Bhaumik Bhatt
38ef077921 mhi: core: remove the system error worker thread
Remove the system error worker thread and instead have the
execution environment worker handle that transition to serialize
processing and avoid any possible race conditions during
shutdown.

Change-Id: Ia9c0dbcdcd516383e235a63689cb022bbae7117c
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2019-11-04 10:39:48 -08:00
Bhaumik Bhatt
4d2a31e84a mhi: core: ensure device wake gets cleared if unvote was forced
When unvote API is called with the intention of forcing device
wake to be cleared, it may not happen if another client already
has a vote and dev_wake reference count does not go to zero.
Device will not move to low power states unless the unvote is
forced again. Clear wake the next time any client unvotes and
reference count goes to zero using the ignore_override boolean.

Change-Id: I28ea6f327a538eb4db8dd4564ce7b9a1d4ac668d
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2019-10-25 14:51:11 -07:00
qctecmdr
757c4610d1 Merge "mhi: Allow ipc logging in perf build" 2019-10-23 15:32:55 -07:00
qctecmdr
2fe5e49211 Merge "mhi: cntrl: qcom: schedule boot monitor thread conditionally" 2019-10-16 19:13:02 -07:00
Bhaumik Bhatt
16b77022bb mhi: core: add a power down status to notify controller
MHI controller can use power down status to take desired action
when core layer wants to issue a wake up in cases where it is
powering down.

Change-Id: I55c30b2a8bd703dcd6c994220b64023617540ed0
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2019-10-10 14:47:31 -07:00
Hemant Kumar
b05d2150de mhi: core: Add API to print system failure reason
mhi_dump_sfr() API parses the RDDM header and scans RDDM segment
for FW crash string in RDDM header. Helper function
mhi_process_sfr() prints the FW crash reason.

Change-Id: I2af202509da16ce03a0567425cbae5b4a0b05ccc
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2019-10-09 23:55:17 -07:00
Hemant Kumar
5f1c9c906b mhi: Allow ipc logging in perf build
MHI ipc verbose level logs gets compiled out in perf build.
Enable ipc logging when log level is set to MHI_MSG_LVL_VERBOSE.
This allows to enable mhi ipc logging on demand when log level
is changed to MHI_MSG_LVL_VERBOSE form MHI_MSG_LVL_ERROR in perf
build.

Change-Id: I63c6cd6922f12c8d31061de9cbb27e2101e5758b
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2019-10-04 16:57:12 -07:00
Bhaumik Bhatt
efb42990b1 mhi: core: add wait for m2 state change before suspend
Some controllers would like to wait for MHI state to change
to M2 before continuing with suspend. Allow for that by
providing a configurable timeout in milliseconds.

Change-Id: I9b700074de427dfc9f065e795e4fa2db26daae63
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
2019-09-10 13:19:24 -07:00
qctecmdr
6566970415 Merge "mhi: core: add sysfs hook to modify IPC log levels" 2019-09-03 22:54:54 -07:00
qctecmdr
dafa531700 Merge "mhi: core: notify clients whenever device flow control status changes" 2019-08-22 23:45:28 -07:00
Sujeev Dias
f62a5609d2 mhi: core: add sysfs hook to modify IPC log levels
Add option to allow modification of IPC log debug levels
from sysfs.

CRs-Fixed: 2509935
Change-Id: I002d6da2e7dd2e0357672f16290ef43be798bf89
Acked-by: Bhaumik Vasav Bhatt <bbhatt@qti.qualcomm.com>
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-08-22 12:27:13 -07:00
Sujeev Dias
d535d1cd0b mhi: core: remove support for bandwidth request from mhi_cb
Remove the bandwidth request entry from mhi_cb status callback
as it is no longer required.

CRs-Fixed: 2479785
Change-Id: Id5363d6162cc32ae33294bcf0a0226863495f66c
Acked-by: Bhaumik Vasav Bhatt <bbhatt@qti.qualcomm.com>
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-08-21 16:26:20 -07:00
Sujeev Dias
b4183bf400 mhi: core: device requested bandwidth scaling support
Device can request scaling for the PCIe link speeds and width
through MHI. Added support for handling the same.

CRs-Fixed: 2479785
Change-Id: Ia22f2d048c862e5c5aa057503b8072cf4cebf835
Acked-by: Bhaumik Vasav Bhatt <bbhatt@qti.qualcomm.com>
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-08-21 12:41:55 -07:00
Sujeev Dias
4018bcbb62 mhi: core: notify clients whenever device flow control status changes
MHI clients needs notification immediately when device flow control
status (DTR, RTS) changes.

CRs-Fixed: 2466740
Change-Id: Ifecded159fd7936f4d265d65e9c2c16c32c7b19c
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-08-20 16:35:44 -07:00
qctecmdr
41aa58a648 Merge "mhi: core: add support for priority based event rings" 2019-08-20 11:35:30 -07:00
Sujeev Dias
9871bb4b98 mhi: core: add support for priority based event rings
Expand the priority for event rings to allow support for low and
high priority event rings. Low priority events are processed in
a worker thread and high priority events use tasklets scheduled
with high priority.

CRs-Fixed: 2490298
Change-Id: Id9d0a8d3d1e84154643f101e150e1d8c40bb6f94
Acked-by: Bhaumik Vasav Bhatt <bbhatt@qti.qualcomm.com>
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-08-09 11:32:44 -07:00
Sujeev Dias
dc64b4e1fc mhi: core: add support to pause or resume data transfer
Some MHI clients needs support to suspend transfers during
device suspend. Adding support to pause or resume pending transfers
without needing to reset the channel state.

CRs-Fixed: 2492779
Change-Id: I961d27d29331f07bf3a08b80ec1133f3b9a59e81
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-07-19 14:36:11 -07:00
Sujeev Dias
f60b827cf8 mhi: core: add support for early error notifications
Some MHI based devices transfer time sensitive data and require
early termination of active transfers even before MHI teardown
happens. This change immediately transitions MHI into an error
state and notify such devices.

CRs-Fixed: 2459916
Change-Id: Ic647bd34e01f39389f3eda0f8a0dc096190fe39b
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-06-19 20:05:05 -07:00
Sujeev Dias
536f885cf7 mhi: core: notify mission mode transition to control driver
MHI control driver require notification from core layer soon as
device enter mission mode transition.

CRs-Fixed: 2457211
Change-Id: Ifbfc60164ffd52290e23b395ea6aa590ec19f26a
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-06-18 01:33:49 -07:00
qctecmdr
efe0d604eb Merge "mhi: core: get bhie offset from devicetree node" 2019-06-14 02:29:31 -07:00
Sujeev Dias
d4275441d0 mhi: core: add support for dynamic execution environment (EE)
Some MHI based modems have different EE definitions than the
default EE value. Add devicetree support to parse device EE
definition.

CRs-Fixed: 2464900
Change-Id: I4ba14a6701d22b8aa11315f8ac245a7250b030ef
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-06-12 21:36:54 -07:00
Sujeev Dias
c3894ffe9a mhi: core: add time synchronized logs support
Whenever important events such as state changes occur on device,
it can help in debug to compare device timestamps and co-relate
those with host-side processing. Add support to log remote time
for these important events from MHI core layer.

CRs-Fixed: 2377061
Change-Id: Ieffd28e8049266e05a6c7397238083f02b2c095f
Acked-by: Bhaumik Vasav Bhatt <bbhatt@qti.qualcomm.com>
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-06-10 21:21:52 -07:00
Sujeev Dias
403e587ee0 mhi: core: calculate times based on given timer frequencies
Query timer frequencies for host and device and calculate time
based on them.

CRs-Fixed: 2377061
Change-Id: I8dba580505870f82bb6e2529d1e01c85c4aafd29
Acked-by: Bhaumik Vasav Bhatt <bbhatt@qti.qualcomm.com>
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-06-10 21:21:17 -07:00
Sujeev Dias
5e9d60aa63 mhi: core: parse MHI controller version during MHI registration
During registration read and store the controller version so
control driver can select appropriate firmware info.

CRs-Fixed: 2454278
Change-Id: Ia20cb7dc1774a5a8919d03bcd8bb65f8b9846f64
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2019-05-20 11:03:32 -07:00