Commit Graph

13 Commits

Author SHA1 Message Date
Chris Lew
6e96b1b1e2 rpmsg: glink: Add support to handle tx zero copy command
Add support to handle receiving the zero copy data command. This will
extract the device address and size from the header and validate that
it is valid memory the device knows about through the memshare
framework. This command expects the memory that is being passed between
host and memshare has already been shared to the glink memshare list.

Change-Id: Ic17035d415ea65d1062be2db9a7e2fb840b0e658
Signed-off-by: Chris Lew <quic_clew@quicinc.com>
2023-03-10 11:44:53 -08:00
Chris Lew
052dc8dd1f rpmsg: glink: Add an interface for memshare
In the initial version of zero copy, the memshare driver is supposed to
allocate buffers using the rproc device and GLINK should be able to
access the dma buffer through the rproc helpers.

This approach starts to fall apart when reserved memory regions are
needed for larger allocations. The q6v5_pas rproc can sometimes specify
a reserved region to allocate dma from, when this is present there is
no facility in rproc to point to a different dma region when allocating
from memshare.

This patch adds a interface for the memshare driver to register regions
directly with glink. When glink gets a zero copy packet, it can then
query and prepare cpu access using this interface instead of relying
on remoteproc.

This is a temporary interface until sharing buffers between remoteproc,
memshare and glink is accepeted.

Change-Id: I1438cea517fad55d996852cb17cb2f591190cf04
Signed-off-by: Chris Lew <quic_clew@quicinc.com>
2023-03-10 11:43:43 -08:00
Chris Lew
7e077bd977 rpmsg: glink: Add support for rpmsg_rx_done
Add an implementation for the hooks of rpmsg_rx_done. If a client
signals they want to hold onto a buffer with RPMSG_DEFER in the rx_cb,
glink will move that intent to a deferred cleanup list. On the new
rpmsg rx_done call, the glink transport will search this deferred
cleanup list for the matching buffer and release the intent.

Change-Id: I9184c62c552fc271366f2ecdc2901cad1813dc48
Signed-off-by: Chris Lew <quic_clew@quicinc.com>
2023-03-10 11:43:19 -08:00
Chris Lew
172a5750a1 rpmsg: glink: Temporarily expose signals for glink
Expose a direct interface for the signal interface from the glink
transport. This is required for tethered data call functionality. This
change should be reverted once the patch to add the signal interface
into rpmsg is merged upstream.

Change-Id: I1df466579352660a276312a304c9eac88f113c60
Signed-off-by: Chris Lew <quic_clew@quicinc.com>
2022-11-22 12:55:54 -08:00
Deepak Kumar Singh
f6cbe27c1f rpmsg: glink: Use IRQF_NO_SUSPEND and pm_system_wakeup() for glink irq
Glink irq should be wakeup capable, to achieve this irq is marked
with enable_irq_wake().

There are some use cases where glink communication is required in system
suspend path and glink interrupt handler needs to be run immediately.
But wakeup cpabale interrupts even if received during suspend will not
run immediately, this will be marked pending and run when system resumes
from suspend. In such scenario there can be a potential deadock in suspend
path due to any irq thread which is waiting for glink interrupt completion
while glink interrupt cannot be handled immediately.

One such use case is usb plugin interrupt received during suspend, which
calls regulator api to communicate with rpm over glink and waits for rpm
ack. RPM ack cannot be processed because glink interrupt received from rpm
goes in pending state. Suspend path is blocked because regulator irq thread
is still waiting.

So there is requirement to run glink interrupt handler in suspend path at
the same time making it wakeup capable. IRQ frameworks forbids usage of
both IRQF_NO_SUSPEND and enable_irq_wake() together. This patch adds
IRQF_NO_SUSPEND and pm_system_wakeup() for glink irq to implement this
requirement.

Change-Id: I1da199c9e10c640bb84d00e569c4fafc5c104d24
Signed-off-by: Deepak Kumar Singh <deesin@codeaurora.org>
2022-08-10 01:43:52 -07:00
Jay Jayanna
a34dacf4c7 rpmsg: glink: Modify fifo reset order
Glink pipe indices are reset by apps in the remoteproc
subdev stop path. There is a chance that the remote that
is being shutdown is in the middle of reading from the
pipe. This causes the remote that is shutting down
gracefully to crash as index 0 is invalid.

Remove the fifo reset from the remoteproc subdev stop
path. Register a function pointer with remoteproc for the
subdev to be called during prepare stage of ssr. Split
the glink probe to have pipes initialization, rx thread
creation and setting up glink structures happen in prepare
stage and version negotiation and char device creation in
prepare stage.

Given that the pipes get re-initialized during prepare
stage, the fifo indices will be intact until after the
remote has been shutdown completely and reset before the
remote is up again.

Spliting glink probe to prepare (in BEFORE_POWERUP) and
start (in AFTER_POWERUP) stage in spss results in glink
link up callback arriving earlier on spss when one of the
destination services is not yet created. This results in
spss not finishing the boot flow after ssr.

Adding glink fifo reset to be called as part of BEFORE_SHUTDOWN
if the underlying driver has callbacks setup for it as is the
case in spss rpmsg driver.

Change-Id: I74cae7ce49cb212af9e7ec2391956339c3427aec
Signed-off-by: Jay Jayanna <jayanna@codeaurora.org>
2022-08-10 01:43:52 -07:00
Chris Lew
a2420135bd rpmsg: glink: Add pipe reset functionality
Some remote procs do not initialize the pipe when they are started
and assume the data in the pipe descriptors is valid. Add an optional
handler to clear the pipe descriptors and call this during removal
of the glink device to ensure a clean restart of glink.

Change-Id: I62871cc5d6fd052e234843645299fdc87a71185f
Signed-off-by: Chris Lew <clew@codeaurora.org>
2022-08-10 01:43:50 -07:00
Suman Anna
84369fbe62 rpmsg: glink: Switch to SPDX license identifier
Use the appropriate SPDX license identifier in various rpmsg
glink driver source files and drop the previous boilerplate
license text.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-06-03 17:37:15 -07:00
Bjorn Andersson
b88eee975a rpmsg: glink: Make RX FIFO peak accessor to take an offset
To fully read the received rx data from FIFO both the command and data
has to be read. Currently we read command, data separately and process
them. By adding an offset parameter to RX FIFO peak accessor, command
and data can be read together, simplifying things.  So introduce this.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:13 -07:00
Sricharan R
933b45da5d rpmsg: glink: Add support for TX intents
Intents are nothing but pre-allocated buffers of appropriate size that
are allocated on the local side and communicated to the remote side and
the remote stores the list of intent ids that it is informed.

Later when remote side is intenting to send data, it picks up a right
intent (based on the size) and sends the data buffer and the intent id.
Local side receives the data and copies it to the local intent buffer.

The whole idea is to avoid stalls on the transport for allocating
memory, used for copy based transports.

When the remote request to allocate buffers using CMD_RX_INTENT_REQ, we
allocate buffers of requested size, store the buffer id locally and also
communicate the intent id to the remote.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:13 -07:00
Sricharan R
d31ad615f6 rpmsg: glink: Add support for transport version negotiation
G-link supports a version number and feature flags for each transport.
A combination of the version number and feature flags enable/disable:

 (*) G-Link software updates for each edge
 (*) Individual features for each edge

Endpoints negotiate both the version and the supported flags when
the transport is opened and they cannot be changed after negotiation has
been completed.

Each full implementation of G-Link must support a minimum of the current
version, the previous version, and the base negotiation version called v0.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:34:12 -07:00
Bjorn Andersson
caf989c350 rpmsg: glink: Introduce glink smem based transport
The glink protocol supports different types of transports (shared
memory). With the core protocol remaining the same, the way the
transport's memory is probed and accessed is different. So add support
for glink's smem based transports.

Adding a new smem transport register function and the fifo accessors for
the same.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 20:33:57 -07:00
Bjorn Andersson
835764ddd9 rpmsg: glink: Move the common glink protocol implementation to glink_native.c
Move the common part of glink core protocol implementation to
glink_native.c that can be shared with the smem based glink
transport in the later patches.

Acked-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29 14:29:33 -07:00