Replace place_marker with update_marker api to capture
suspend resume kpi of pheripherals like usb, ethernet and
pcie.
Change-Id: Ida46d41273967aa5efccd06f13f6219adfba4a4e
Signed-off-by: Sanjay Dwivedi <sanjaykd@codeaurora.org>
Workqueue tasks can be executed in the order in which
they are submitted using a WQ_UNBOUND workqueue with
max_active set to one. Adding these properties for mhi_sm_wq
so that all MHI change events are handled in order.
Change-Id: Ic86a81adb379f711d787cd40dfad4a4a8f6e961d
Signed-off-by: Nitesh Gupta <nitegupt@codeaurora.org>
Change involves to avoid free of mhi netdev client, ipc handles
as part of mhi_dev_net_state_cb(). These are not re-allocated in
mhi_dev_net_interface_init() as mhi_net_ctxt.client_handle is
already valid which is called during device reset scenario.
Change-Id: I6f660c8dccd47a93c115c39d2898f450c5d61635
Signed-off-by: Subramanian Ananthanarayanan <skananth@codeaurora.org>
Allocate high priority work queue for mhi_sm_wq such that
MHI state change events are handled with priority.
Change-Id: I3d95e23b3daafce5a8888e5203caa75f1744351b
Signed-off-by: Nitesh Gupta <nitegupt@codeaurora.org>
BHI_INTVEC will be reset to 0xFFFFFFFF when the
link gets initialized in PBL. This might happen
if the device gets rebooted when the link is in
D3 cold. This will prevent EP PCIE HLOS driver
from sending an MSI to host to request for a reset,
which is required in the device reboot case.
This change is the device-side part of the fix,
which is to wait for the host to re-init the
BHI_INTVEC value after link resumes from D3 cold.
Change-Id: I286804d597b24d521b291119077e1ec81af32a27
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
Fix Null pointer access when host rescans the device
by not changing the channel state info if channel is
already in disconnected or configured state.
Change-Id: I5e897d7694f958e2b9613abfd23cbc0e975e81a3
Signed-off-by: Ajay Prathi <aprathi@codeaurora.org>
Add logs and Boot KPI Markers in MHI driver for MHI
Initialization. This is required for KPI consistency
and KPI calculation and getting KPI data.
Change-Id: Ie6ab9b69f4ab3fb548cc9a2f0bf74ba935a88e0c
Signed-off-by: Nitesh Gupta <nitegupt@codeaurora.org>
Do not flush completion events to host when the channel is
stopped or closed as the flush function might use invalid
data for the channel. Also add a check for channel state
in the write API.
Change-Id: I0e882fab4891cac60ddbb17f4be1dfeb502ecf92
Signed-off-by: Siva Kumar Akkireddi <sivaa@codeaurora.org>
ipa_clnt_hndl array supports only 4 channels. Few targets can
support more MHI HW channels and can cause out of bound access
for higher MHI channels.
Increase ipa_clnt_hndl array size to accommodate the maximum
number of supported MHI HW channels.
Change-Id: Ifb4b17c40a7ac690b9a7fd864b7eb0ade2e5de43
Signed-off-by: Nitesh Gupta <nitegupt@codeaurora.org>
Call IPA API to disable DMA for proper reference count
management in the IPA driver.
Change-Id: I9bb741dc8d3c24dfd6e03b1c324eb47dccc2526c
Signed-off-by: Siva Kumar Akkireddi <sivaa@codeaurora.org>
Delete the memory while closing channels
to avoid memory leak, which is allocated
in mhi dev net read and write request.
Change-Id: I5605ef5bd498ac934185ce88a3d21e410e0b61b7
Signed-off-by: Ajay Prathi <aprathi@codeaurora.org>
Host might update NHWER value before issuing M0 to device.
So, update number of HW event rings after M0 is received from host.
Change-Id: I2e0b28a82e299e66b0167977c4c4ed9d7b6c889e
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
Update maximum number of hardware channels supported by
the device to support QMAP flow control that is mapped
to hardware channel 109/110.
Change-Id: I6d20c5a6f1b2a58ff18aab660a827fdec95e0b7a
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Currently the MHI device driver maps the MHI hardware channel
with IPA's GSI channel. This can be done directly by IPA and
reduces the dependency between the two modules.
Change-Id: Ib51b2a264fdc69418889d2ebdbf1db823edf33be
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
MHI channels are opened at mhi start up,
before host opens the channels which results
in race conditions, when mhi device is switching
on or off, and if mhi netdev uses the channel before
the channel is initialised from host results in crash.
Add code to register for mhi channel state change,
open mhi channels and create network interface
when the state change notification comes from host to
fix the race condition.
Change-Id: Id497d8fe6721709369aa57802c399bcd154b19b6
Signed-off-by: Ajay Prathi <aprathi@codeaurora.org>
If netdev interface_init gets called by mhi,
when the channels are not actually closed.
trying to do a reinit results in error from mhi
(like re-opening a already opened channel).
that leads to kernel crashes.
Add a check to avoid re-allocating netdev interface if it
has been already allocated.
Change-Id: I3835312a3e1fb09e979cc1dcf0b23815d77b7b57
Signed-off-by: Siva Kumar Akkireddi <sivaa@codeaurora.org>
Descriptor is being accessed with out any check.
Add proper check before accessing descriptor variable.
Change-Id: I742fc4f8d7c252902277bdea8e479f2ac4dfc6e7
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
Update mask to clear the control interrupt including
the doorbell write interrupt. Without clearing this
interrupt it shows up as pending when restoring the
MHI registers as part of transition from D3 state to D0.
Change-Id: I3110ddf2c8500af54656dc80b71718288ecdb4c1
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
After the device receives a M3 event it updates the channel
state field on the host to suspend and releases the wakelock
before sending the M3 completion and can cause the system
to suspend before sending the M3 completion. Update to release
the wakelock after completing the M3 request to MHI and IPA MHI.
Change-Id: I084778805f5219a51045f093ddc71b3cecefede2
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
During PCIe enumeration the device waits for the Bus Master Enable
to be set by the host and currently polls for this bit to be set.
The host driver could take longer to enable the Bus Master Enable
and can cause the device to timeout when set to polling mode.
Therefore rely on the Bus Master Enable interrupt that is triggered
on the device after host set this bit.
Change-Id: I15b106ca0bc06a75370d1e1b4a83e2d39af97fb8
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Rename enum name from IPA_CLIENT_MHI_QMAP to IPA_CLIENT_MHI_LOW_LAT.
Change-Id: Ie2c1d421ba55af7f016875a0314078ca002cba9e
Signed-off-by: Bojun Pan <bojunp@codeaurora.org>
Add hardware channels used to pass control messages for
QMAP flow control. Also update the maximum number of
channels supported in MHI and remove unused channel
enum name.
Change-Id: Iaa0778400cebb4b65e184451b7026053ba9e6524
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
QDSS hardware channel is used for debug purpose
between host and device.
Change-Id: I470df439d8d4185e8bd900a4c5209ac7045a04e2
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Update channel state notification broadcast to software channels
only as there are no clients listening to the broadcast for the
HW channel state updates. State updates include channel start,
stop and reset commands.
Change-Id: Ic378acf4a7afc80b7c9e7acdfbf822608983a427
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Some usecases of MHI use EDMA instead of IPA DMA.
EP PCIe triggers MSI via CPU. For usecases that uses EMDA,
possible NOC congestion can happen as multiple masters
(Controller, CPU) are accessing NOC for data transfers and
triggering MSI that might lead to NOC timeouts during high
throughput data transfers.
Add MSI trigger support for MHI to make sure that data transfers
and MSI (via EDMA) are triggerred by single master (PCIe controller)
for EDMA usecase.
Change-Id: Ie704522847a9a48e943ec78aea5a807d573dee8d
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
Event ring can be shared by multiple channels. Synchronize
completion event updates to the event ring to avoid race
condition when the same ring is updated in the read and
write path.
Change-Id: Ib626bb45206766f34e7ae5224148b8dea962fc11
Signed-off-by: Siva Kumar Akkireddi <sivaa@codeaurora.org>
Channel state updates to MHI clients are provided using
uevents. Add uevent support and skip node creation for
IPCR IN/OUT channels.
Change-Id: I6e472d6d06f5d231da33fe00018f5ae458f60ddf
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
MHI control state can be updated to CONNECTED via the IPA
callback before MHI sets it to CONFIGURED. Check if it
is already updated in the callback to CONNECTED before setting it
to CONFIGURED.
Change-Id: Ia8506d2d1a700a1e122137f9fffe4ba16fb852c2
Signed-off-by: Siva Kumar Akkireddi <sivaa@codeaurora.org>
To handle bursty traffic the following changes are done
in the asynchronous read/write path in the MHI driver:
* Queue the transfer completion event within the write
API instead of the transfer completion callback.
* When conditions are met, flush the completion events (schedule dma)
to host from within the write API.
* Switch to a circular buffer to hold the completion events
instead of a linked list of buffers.
* Set the size of the completion event buffer equal to the
channel event ring size.
Change-Id: I3cbc9cb6a2c040825c4b16ef4fb758bf95c7e642
Signed-off-by: Siva Kumar Akkireddi <sivaa@codeaurora.org>
CV2X channels are used to transfer latency sensitive information
between host and modem using the IPA HW-accelerated path.
Change-Id: I3fd15de5115c4e861469f19623a7d81893020f4a
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
Wait for pending (async) writes to complete before closing a channel.
If channel is closed, do not call client callback or send completion events
to host.
Change-Id: Iddb8320d56a6f3f1476615c097c610c883b54915
Signed-off-by: Siva Kumar Akkireddi <sivaa@codeaurora.org>
PCIe specification supports L1ss sleep/exit. This enables
MHI clients the ability to request link inactivity notification
by programming the link inactivity timer with the PCIe end point.
MHI device driver then switches to M2 state and suspends all
activity for transfers on the device and requests PCIe end point
driver to disable the end point. Upon link activity
PCIe end point driver exits L1ss sleep and notifies MHI
device to transition to M0 state and handle the host
requests. Prevent suspend when enabling endpoint.
Change-Id: I0955ae284382b51be3dadeb61129013f4e7fc863
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
MHI state and channel state are distinct. Use separate
functions to update the respective state info.
Change-Id: I66ccda03914b2978c59c56493d6862a89c4194f3
Signed-off-by: Siva Kumar Akkireddi <sivaa@codeaurora.org>
After MHI device receives a reset command the internal
state machine suspends all activity on the channel and
processes the device reset. Clients are notified on
the channel close. Existing close function checks if
there are pending data to be read but since the device
is in the process of cleaning the transfer buffers
and the channels are suspended this check is not required.
Change-Id: Iafc5249762b1468ee2cca4ac141522ce0356d403
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
In certain cases clients are blocked on read or poll once
the channel disconnect is received. During poll cases return
client with POLLHUP error. For the read case when client
is blocked on read wake up the thread.
Change-Id: Ideded84420b4995251773110ec083a80f9a3a76e
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Currently ipa_mhi_destroy() is issued during MHI device reset.
There could be a condition where the switch to M0 event is
in progress while the MHI device reset is received. Calling
ipa_mhi_destroy() followed by processing the M0 transition
causes IPA to assert since ipa_mhi_destroy() was already
issued. Therefore flush the workqueue that is processing
the switch to M0 transition before calling ipa_mhi_destroy().
Change-Id: I298fdc67cb5d660ba8b722016a0b4d9deb32142a
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Check if handle passed from clients is valid before dereference.
Change-Id: I68a1a826f7b85a7e24f2cb75916c50e6788536e9
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Remove restriction to expose the MBIM channel after a channel
connect. The group and owner permission is updated to
radio and radio during boot up and may cause the update
to not be reflected.
Change-Id: Id612fd24b41a414e59f149e9dd16eb17f0407ca5
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Support waking up the host from D3_hot using inband PME
over PCIe for EP mode.
Change-Id: Ic6ed00e0f8d6d9ec3c83be922970d82c0b1b2a6c
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Expose both the MHI channel pairs for the current
state whether its connected, disconnected. It allows
clients to be aware of the individual channel states
so it can issue an open once both the channels are
available.
Change-Id: I752b23ba6ea516a78c25ee0f6b125a41788a5885
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
This patch changes '%d' to '%lu' to match their data types.
Change-Id: I1d766e60ece7d58b21b14ba97c5de1f3ebc2b57e
Signed-off-by: Arun KS <arunks@codeaurora.org>
Enable the MHI channels after host has issued a channel
connect to prevent clients from issuing a MHI open when
channel is not ready. Support enabling broadcast for DUN
and ADB for channel connect and disconnect.
Change-Id: I725d21e703a5ac850bbce54dd19562fa7058d37b
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
This fixes the format specifiers to match the data type.
Change-Id: Ibc713344d560e784067da812539f5e75be997e4f
Signed-off-by: Arun KS <arunks@codeaurora.org>
This patch fixes '%d' to '%lu' to match the data type.
Change-Id: I86d57c19f7736a66508d27d933a0e6c9ce7aeff5
Signed-off-by: Arun KS <arunks@codeaurora.org>
Add uevent notification for DUN and ADB client.
Change-Id: Id65333c81ff8ca9d03518abea7c3c10d596acd00
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Host can generate Ethernet packets over the network stack. Add
support to assign proper protocol for ethernet packets. Also, add
support for mhi net device for random mac address generation.
Change-Id: Icd29e7df9aff0529ebaf4897560d9a9acec76fd7
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
Add support in the UCI driver to wait when a write to host cannot
be scheduled immediately due to write request struct unavailability.
Also add support to specify the number of write request structs
per-channel.
Change-Id: Id08de6b0bdb944cfbed208ddf08566a6b677487c
Signed-off-by: Siva Kumar Akkireddi <sivaa@codeaurora.org>