aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rpmsg/qcom_glink_native.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-11-15rpmsg: glink: The mbox client knows_txdoneBjorn Andersson1-0/+1
As the GLINK driver is ticking the txdone of the mailbox channel (to implement the doorbell) it needs to set knows_txdone. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-11-14rpmsg: glink: Add missing MODULE_LICENSEBjorn Andersson1-0/+3
The qcom_glink_native driver is missing a MODULE_LICENSE(), correct this. Fixes: 835764ddd9af ("rpmsg: glink: Move the common glink protocol implementation to glink_native.c") Cc: stable@vger.kernel.org Reported-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-10-30rpmsg: glink: Use best fit intent during txChris Lew1-3/+8
Intents can vary in size, try to find the best fitting remote intent instead of first fit when sending a message to the remote proc. Signed-off-by: Chris Lew <clew@codeaurora.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-10-30rpmsg: glink: Add support to preallocate intentsChris Lew1-8/+27
The base intents prequeued during channel creation may not satisfy a channel's throughput requirement. Add support for intents dt-binding to allow channels to specify the size and amount of intents to prequeue during endpoint announcement. Signed-off-by: Chris Lew <clew@codeaurora.org> [bjorn: Altered how defaults are expressed] Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-10-30rpmsg: glink: Initialize the "intent_req_comp" completion variableArun Kumar Neelakantam1-0/+1
The "intent_req_comp" variable is used without initialization which results in NULL pointer dereference in qcom_glink_request_intent(). we need to initialize the completion variable before using it. Fixes: 27b9c5b66b23 ("rpmsg: glink: Request for intents when unavailable") Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-10-10rpmsg: glink: Fix memory leak in qcom_glink_alloc_intent()Dan Carpenter1-3/+8
We need to free "intent" and "intent->data" on a couple error paths. Fixes: 933b45da5d1d ("rpmsg: glink: Add support for TX intents") Acked-by: Sricharan R <sricharan@codeaurora.org> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-10-10rpmsg: glink: Unlock on error in qcom_glink_request_intent()Dan Carpenter1-1/+2
If qcom_glink_tx() fails, then we need to unlock before returning the error code. Fixes: 27b9c5b66b23 ("rpmsg: glink: Request for intents when unavailable") Acked-by: Sricharan R <sricharan@codeaurora.org> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-09-04rpmsg: glink: initialize ret to zero to ensure error status check is correctColin Ian King1-3/+1
The new switch cases for RPM_CMD_RX_DONE, RPM_CMD_RX_DONE_W_REUSE, RPM_CMD_RX_INTENT_REQ_ACK, RPM_CMD_INTENT and RPM_CMD_RX_INTENT_REQ from 4 recent commits are not setting ret and so a later non-zero check on ret is testing on a garbage value in ret. Fix this by initializing ret to zero. Detected by CoverityScan CID#1455249 ("Uninitialized scalar variable") Fixes: 933b45da5d1d ("rpmsg: glink: Add support for TX intents) Fixes: dacbb35e930f ("glink: Receive and store the remote intent buffers") Fixes: 27b9c5b66b23 ("rpmsg: glink: Request for intents when unavailable") Fixes: 88c6060f5a7f ("rpmsg: glink: Handle remote rx done command") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-09-04rpmsg: glink: fix null pointer dereference on a null intentColin Ian King1-1/+1
In the case where glink->intentless is true and the call to qcom_glink_tx fails then we have a condition where ret is non-zero and intent is null, causing a null pointer deference when setting intent->in_use to false. Add an extra check to only dereference intent if intent is non-null. Detected by: CoverityScan CID#1455247 ("Explicit null dereferenced") Fixes: 88c6060f5a7f ("rpmsg: glink: Handle remote rx done command") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-31rpmsg: glink: Export symbols from common codeBjorn Andersson1-0/+3
The common code needs to export the probe and remove symbols in order for the SMEM and RPM drivers to access them when compiled as a module. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-30rpmsg: glink: Release idr lock before returning on errorBjorn Andersson1-1/+1
The idr_lock should be released in the case that we don't find the given channel. Fixes: 44f6df922a26 ("rpmsg: glink: Fix idr_lock from mutex to spinlock") Reported-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-08-29rpmsg: glink: Handle remote rx done commandSricharan R1-0/+42
Once the remote side sends a rx done ack, check for the intent reuse information from it and suitably discard or reuse the remote passed intent buffers. 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-29rpmsg: glink: Request for intents when unavailableSricharan R1-2/+74
While sending data, we search for suitable sized intent to map and simply fail if a intent is not found. Instead request for a intent of required size and wait till one is alloted. 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-29rpmsg: glink: Use the intents passed by remoteSricharan R1-2/+33
While sending data, use the remote intent id buffer of suitable size that was passed by remote previously. 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-29rpmsg: glink: Receive and store the remote intent buffersSricharan R1-1/+70
Just like we allocating and sending intent ids to remote, remote side allocates and sends us the intents as well. So save the intent ids and use it later while sending data targeting the appropriate intents based on the size. 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-29rpmsg: glink: Add announce_create ops and preallocate intentsSricharan R1-0/+21
Preallocate local intent buffers and pass the intent ids to the remote. This way there are some default intents available for the remote to start sending data without having to wait by sending intent requests. Do this by adding the rpmsg announce_create ops, which gets called right after the rpmsg device gets probed. 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-29rpmsg: glink: Add rx done commandSricharan R1-0/+83
Send RX data receive ack to remote and also inform that local intent buffer is used and freed. This informs the remote to request for next set of intent buffers before doing a send operation. 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-29rpmsg: glink: Make RX FIFO peak accessor to take an offsetBjorn Andersson1-8/+7
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-29rpmsg: glink: Use the local intents when receiving dataSricharan R1-25/+50
So previously on request from remote side, we allocated local intent buffers and passed the ids to the remote. Now when we receive data buffers from remote directed to that intent id, copy the data to the corresponding preallocated intent buffer. 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-29rpmsg: glink: Add support for TX intentsSricharan R1-1/+166
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-29rpmsg: glink: Fix idr_lock from mutex to spinlockSricharan R1-20/+42
The channel members lcids, rcids synchronised using the idr_lock is accessed in both atomic/non-atomic contexts. The readers are not currently synchronised. That no correct, so add the readers as well under the lock and use a spinlock. 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-29rpmsg: glink: Add support for transport version negotiationSricharan R1-5/+70
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-29rpmsg: glink: Introduce glink smem based transportBjorn Andersson1-0/+5
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-29rpmsg: glink: Do a mbox_free_channel in removeSricharan R1-0/+1
mbox_request_channel is done in probe, so free the channel in remove. 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-29rpmsg: glink: Return -EAGAIN when there is no FIFO spaceSricharan R1-1/+1
The TX FIFO can be full, if the remote client has not read enough data (or) reading it slowly. So its nessecary to return -EAGAIN to the local client to enable retry. 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-29rpmsg: glink: Allow unaligned data accessBjorn Andersson1-6/+0
Glink protocol requires that each message is aligned on a 8 byte offset. This is purely a restriction from glink, so in order to support clients which do not adher to this, allow data packets of any size, but align the head index accordingly, effectively removing the alignment restriction. 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-29rpmsg: glink: Move the common glink protocol implementation to glink_native.cBjorn Andersson1-0/+1017
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>