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>
dwc3 msm core driver shall start USB host or device mode with dwc3
controller driver. This shall fail specifically USB host mode due
to any error with xhci controller initialization. In this case HCD
would be unbinded causing NULL pointer deference when trying to
override its PM ops with dwc3_msm_override_pm_ops() API. To avoid
NULL pointer dereference add NULL check with dwc3_msm_override_pm_ops()
API.
Change-Id: Ia96e945d58b1bf1d5434b004ac3d3090b24c6208
Signed-off-by: Mayank Rana <quic_mrana@quicinc.com>
mdwc->gsi_ev_buff is seen NULL when dwc3_msm_notify_event() is getting
called from dwc3 driver's probe context as mdwc->gsi_ev_buff is being
allocated at end of dwc3_msm_core_init(). dwc3_otg_start_peripheral()
setups GSI event buffers with USB controller. Fix NULL pointer issue
by adding explicit check against NULL with mdwc->gsi_ev_buff.
Change-Id: Ia15b677b5fa55e4281a78fb877283fe37c9ad95f
Signed-off-by: Mayank Rana <quic_mrana@quicinc.com>
memremap() API shall return valid address or NULL. If return value
is NULL then it would result into NULL pointer dereference while
accessing ebc_trb_pool. Fix this unlikely issue by adding check
against NULL with return value from memremap() API.
Change-Id: I42ad1a735c0d4958a7251f27223af6cc0aa670dc
Signed-off-by: Mayank Rana <quic_mrana@quicinc.com>
CONFIG_ANDROID was removed from the tree in commit 1045a06724 ("remove
CONFIG_ANDROID") and subsequent commits. Therefore, remove it from
generic_vm_defconfig also.
Change-Id: I9bc17e6ab6610056446ca5155539c07f01aacbd8
Signed-off-by: Guru Das Srinagesh <quic_gurus@quicinc.com>
Since asm-generic high level MMIO accessors are used in arm64,
unsigned long data needs to do force conversion before call the
accessors to avoid compile errors.
Change-Id: I402bf10c0d0ff7065d4514273a1c99382815abdb
Signed-off-by: Huang Yiwei <quic_hyiwei@quicinc.com>
Add the new interconnect common module for kalama and pineapple.
Change-Id: I5b0036c2fd9f1fe40af2312da892a7abf058022e
Signed-off-by: Huang Yiwei <quic_hyiwei@quicinc.com>
Since icc-common.c can be compiled as module, add the missing
MODULE_LICENSE to avoid compile errors.
Change-Id: I8b681046b65e69cb138e56e7ef88564c3deaedb9
Signed-off-by: Huang Yiwei <quic_hyiwei@quicinc.com>