Move to IPC logs for the MHI host driver to enable better and
persistent logging that can ensure bootup logs are not lost and
allow ease of pulling logs from crashdumps.
Change-Id: I334335f56acb850f418e5a37b0538545c5b9ea30
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
When an invalid BW request is sent by the device to the host
to proccess, a value of 0x1 is written to the bw_scale_db
register.
Change-Id: I362e9b308142fe5a9107d46789d26cb38933e858
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
In RDDM EE, device can not process MHI reset
issued by host. In case of MHI power off, host
is issuing MHI reset and polls for it to get
cleared until it times out. Since this timeout
can not be avoided in case of RDDM, skip the
MHI reset in this scenarios.
Change-Id: Ide4311ba8705861179bfbfef650f00fa0f97c062
Signed-off-by: Hemant Kumar <quic_hemantk@quicinc.com>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Currently fatal error notification is done from
fast resume path. This does not cover RDDM EE
change via BHI Intvec. As a result of the some
critical clients are unable to perform cleanup
and does not come up after recovery. In case
if RDDM EE change never comes notify clients
from mhi force reset context.
Change-Id: Iea1f1d86e9a28c08e8d58100715004f3b2abfd96
Signed-off-by: Hemant Kumar <quic_hemantk@quicinc.com>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
This optional runtime PM last busy update callback to the
controller is provided to keep the busy timestamps up to date
from MHI core driver such that it can reset the autosuspend
timer for runtime PM.
Change-Id: Ifc9abce860739b92d29fc257afd169d08a738379
Signed-off-by: Bhaumik Bhatt <quic_bbhatt@quicinc.com>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
This reverts commit 4547a749be.
This is done to ensure internal usecases with WLAN are not
impacted with high power usage. Runtime PM get also results in a
WoW exit and is also unnecessary as we already have the if
suspended check and the pending packets counter in place to take
care of rejecting suspends if they occur. The only major benefit
of this patch was to ensure controller is able to mark last busy
timestamp for runtime PM. If needed, support for it can be added
in a future patch to allow controller to update the timestamp.
Change-Id: I3e16ab3631468edd0fda3657adf0f5ae55f0be16
Signed-off-by: Bhaumik Bhatt <quic_bbhatt@quicinc.com>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Data terminal ready driver should not be started until other
client drivers are probed so that they can get the necessary
notifications when updates are made available to them by the
device via incoming messages. Adjust flow of the driver and
ensure DTR driver starts after all other devices are created
by core driver.
Change-Id: I9e0bcb87a3b59a66fede0c82ded94a704d16c2a1
Signed-off-by: Bhaumik Bhatt <quic_bbhatt@quicinc.com>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Take irqsave lock after TRE is generated to avoid deadlock due to
core getting interrupts enabled as local_bh_enable must not be
called with irqs disabled based on upstream patch.
Change-Id: Id0c34ccddbfa99700ec32319d141cecd3dfbe1f1
Signed-off-by: Hemant Kumar <quic_hemantk@quicinc.com>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Include channel number and update the TRE WP print to read the
IOVA properly in order to improve readability.
Change-Id: I80d9c7c2d8722efabb47ccf4b580bd65ab3c9728
Signed-off-by: Bhaumik Bhatt <quic_bbhatt@quicinc.com>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Certain offload channels such as ones for satellite driver
usecases are required to be configured as bidrectional channels.
Allow it to ensure devices are created for them and the channels
are probed.
Added __attribute__((__fallthrough__)) statements to suppress
compiler error.
Change-Id: I782e3e933765099e8ee9eb1670cce321a3dffd8b
Signed-off-by: Bhaumik Bhatt <quic_bbhatt@quicinc.com>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Add update transfer state APIs and do not check for channel state
in the channel context as device can update it once MHI master
reset has taken place. Instead, rely on local channel and PM
states prior to sending any channel update commands.
Change-Id: Ib3416323e0f1b01ff37c9bd176e72daa4dea9d8d
Signed-off-by: Bhaumik Bhatt <quic_bbhatt@quicinc.com>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Protect WP accesses such that multiple threads queueing buffers
for incoming data do not race and access the same WP twice.
Ensure read and write locks for the channel are not taken in
succession by dropping the read lock from parse_xfer_event() such
that a callback given to client can potentially queue buffers and
acquire the write lock in that process. Any queueing of buffers
should be done without channel read lock acquired as it can
result in multiple locks and a soft lockup.
Change-Id: Iaa5849da70acd6ece06469312186edc194c7f050
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Add a new MHI_BUS_MISC Kconfig entry and support to build
miscellaneous MHI features in Makefile if enabled. It can be
enabled only if necessary for certain controllers and is tied to
module init/exit and MHI registration.
Change-Id: I36429eed9e786681150aceb494bcd06cf3d09ca9
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
There is a race condition where mhi_prepare_channel() updates the
read and write pointers as the base address and in parallel, if
an M0 transition occurs, the tasklet goes ahead and rings
doorbells for all channels with a delta in TRE rings assuming
they are already enabled. This causes a null pointer access. Fix
it by adding a channel enabled check before ringing channel
doorbells.
Change-Id: Idd1f39627a509590e892bf5c853761d351d3d823
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
If a device crash occurs when in suspended state, the interrupt
handler cannot access registers to act on it. Once controller is
done with PCIe resume and calls mhi_pm_resume(), MHI host can
check for the RDDM entry and handle it as needed.
Change-Id: I6127b75b51c3ef932e601391daebd0657e1a04eb
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Adding new API to perform host reset request to device
to collect device side dumps.
Use mhi_soc_reset() API in place of register write
Currently, a direct register write is used when ramdump collection
in panic path occurs. Replace that with new mhi_soc_reset() API
such that a controller defined reset() function is exercised if
one is present and the regular SOC reset is done if it is not.
Change-Id: Ibd15b231072a9b811ced0031387d605184806e9a
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Vivek Pernamitta <vpernami@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Skip power down if RDDM is supported and power up fails as the
CNSS handling requires it.
Change-Id: I88a2f9e0ea29dd04f76a3a6facb421ac61789bce
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Wake doorbell register write operation is done with spin
lock held. This adds implicit CPU memory barrier after the
write which goes over the link. In case the endpoint is in
L1SS sleep (retention), it takes around 2.5 ms for link to
comeback and respond to this write operation. Due to memory
barrier CPU would stall for 2.5ms and this starves any other
task waiting to run on same core. Fix this issue by offloading
device wake doorbell write to a high priority work queue.
This offloading is enabled only for device supporting legacy
M state mode.
Change-Id: I4447cf1afa4bc2c95991e003196ecd1e45926c66
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Currently, a direct register write is used when ramdump collection
in panic path occurs. Replace that with new mhi_soc_reset() API
such that a controller defined reset() function is exercised if
one is present and the regular SOC reset is done if it is not.
Change-Id: I6590598b63211ef8c12fa666e2ce0f690ddaf1c9
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
If suspend ack does not arrive on time, MHI host currently bails
out silently. Panic if this happens such that issues can be pin-
pointed to root causes.
Change-Id: Ic2201aafc2a55d572311ec9ee8a8b9c8a60a1da4
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
If data processing of an event is scheduled out because core
is busy handling multiple irqs, this can starves the processing
of MHI M0 state change event on another core. Fix this issue by
disabling irq on the core processing data events.
Change-Id: I4d784d2c343d4a9c50741f3e72df4c373993ae79
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
It cannot be guaranteed that certain legacy mode controllers stay
in M0 while a BW request is being processed. Ensure that those
pending BW requests are addressed when M0 entry occurs after a BW
request is processed but not responded to.
Change-Id: I15ebc4e61e59ceeb5e8740b60bb95606945b0b3c
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Add missing checks in the MHI core driver to panic on certain use
cases such as a bad or malformed TRE or unexpected states and
exit from out of order command completions.
Change-Id: I873ed04c4fce57b1ec42175666ffadd496ad3fdf
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Certain log messages will help improve the debug experience when
attempting to solve issues related to tracking data or control
packets in MHI. Add logs to improve this aspect.
Change-Id: Ic8608d68e37436b23e7c2364cb9e38db22c3844f
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
There is a typo and a wrong struct type was used for the DTR
driver features. Update it and use the correct mhi_device type in
place of the dtr_device pointer. Also fix a circular dependency on
DTR and MHI misc by using the traditional status callback route to
notify the DTR client driver.
Changes for misc.c,mhi_misc.h are already present in commit f1f4164c4f
("bus: mhi: host: Add snapshot of MHI bus misc driver"), and
for mhi_dtr.c in commit 0ff9eadd9c ("bus: mhi: devices:
Add snapshot of MHI devices driver").
Change-Id: I877d0ed009bbde30605bbd306deaf53588f1611f
Signed-off-by: Bhaumik Bhatt <quic_bbhatt@quicinc.com>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Allow the miscellaneous driver to use the time synchronization
feature by providing core support.
Change-Id: I63cad0be5f303f07dc785862d48dc64d2ca0c33b
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
DTR signaling client driver needs certain entries in the MHI
device structure and an mhi_callback entry. Add those to support
DTR signaling.
Change-Id: Id74395348200e84bc9af0b251799c06eeb738193
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Add support for controllers to enable retrieval of the subsystem
failure reason if an error from device is reported.
Change-Id: I27d88ceaeeb512fc578b78bcf85e7ba7cb27a4ff
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Offload channels where the client drivers manage their own
context information need event ring information in the MHI
device structure that is currently not exposed to them. Add
those to enable these drivers to function properly.
Change-Id: Icc80344518591ca74c75ab932ac15eca9a77d0ad
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Parent device must be used to request firmware from the file-
system otherwise the request does not go through. Make these
necessary changes to allow boot-up for all MHI controllers.
Change-Id: Ia78398c5d2d472a2f6f7e3e652f62b75927bd379
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
MHI fast suspend state change counter can be used to track the
number of times device enters the state. Introduce and use it for
accurate tracking of MHI low power states.
Change-Id: Ibaa0428d5ba13b7776a0c9af58a357f59bb9eda5
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Session ID to be used during BHI transfers to recognize a
particular session are currently not being stored in the MHI
controller structure. Store them to allow for tracking and other
future usage.
Change-Id: I45a55f39226be3a21ff1e3317a899da1a63f3439
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Processing of some events requires the use of a sleeping function.
In order to handle those events, work is queued using high priority
workqueue. Sleepable events also require use of a dedicated event
ring.
Replaced 'TO_MHI_STATE_STR' with 'mhi_state_str' to aid in
compilation.
Change-Id: I3c42bc5b33b179de79911f8ec21b9a351116a112
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Currently this macro is defined in internal MHI header as
a TRE length mask. Moving it to external header allows MHI
client drivers to set this upper bound for the transmit
buffer size.
Change-Id: I24c7bce37cb8f103c1436201d825bec4a36eb122
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
This allows controller to keep the memory allocated for bhi
vector table for rddm and fbc images. Memory remains allocated
after controller powers down and is freed when the controller
unregisters with MHI. Add a controller flag to make the
decision for memory allocation.
Change-Id: I974e44d3b927da1003e232455067c50fdf6fb42b
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
SW event ring elements are added and doorbells are rung during
ready state transition from host. HW event ring elements are
added and doorbells are rung in mission mode transition. All
event ring doorbells are rung in M0 state change transition.
Move this common code to a helper API mhi_setup_event_rings().
Pass a boolean for adding event ring elements. When this flag
is false, only ring doorbells for all event rings and do not
populate the event rings.
Change-Id: Ib201007179c2cb772decb2456d3510602ea63fd6
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Default processing priority for an event ring is set to schedule
a regular priority tasklet. In order to distinguish going forward
and provide support for scheduling a high priority tasklet or any
further requirements that may come up, introduce support for
different event ring priorities.
Change-Id: I53325bc141269832444ba28a4941c050ceebe394
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
In case firmware request fails to find firmware at the default
location, re-try once with a fallback location. This is done by
adding fallback firmware image location in controller structure
and firmware request is sent again using fallback location.
Send a status call back to controller when re-try is done to
notify them as some features may not be available.
Change-Id: I6c832c121e7bfaf798c06d0341541a2677653fd0
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
Do not allow clearing the channel context twice from
mhi_driver_remove(), if already done before disable transition is
initiated. This prevents kernel warnings such as "trying to free
invalid coherent area" from occurring.
Change-Id: I85dec0557a287c9207b56d2b2243d53b6a40ff1c
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
When lookup fails, print the service path along with the
service name since the service name might not be unique.
Change-Id: I614d6c0a8d6cb8a83b47795315811fbf47bb6e48
Signed-off-by: Siddharth Gupta <sidgup@codeaurora.org>
Signed-off-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
A remote endpoint should not need to know when a client socket is freed
if the socket never established commnication with the endpoint. Add a
mode to keep track of which endpoints a socket communicates with.
There are three modes a socket can be in:
INIT - Socket has not sent anything or only local messages,
only send client close to local services.
SINGLE - Socket has sent messages to a single ept, send event
to this single ept.
MULTI - Socket has sent messages to multiple epts, broadcast
release of this socket.
Server state changes should be broadcast throughout the system. Change
the ipc state of a port when it sends a NEW SERVER control packet. This
ensures the DEL CLIENT control packet is propagated correctly for
servers.
Change-Id: I416742cff598bf7aa9da2baa2e86a53b18367870
Signed-off-by: Chris Lew <quic_clew@quicinc.com>
There is a race where broadcast packets can be sent to a node that has
not sent the hello message to the remote processor. This breaks the
protocol expectation. Add a status variable to track when the hello
packet has been sent.
An alternative solution attempted was to remove the nodes from the
broadcast list until the hello packet is sent. This is not a valid
solution because hello messages are broadcasted if the ns is restarted
or started late. There needs to be a status variable separate from the
broadcast list.
Change-Id: I2a55e587f324e64e2bde4ea634de66008f190de1
Signed-off-by: Chris Lew <quic_clew@quicinc.com>