summaryrefslogtreecommitdiffstats
path: root/drivers/rpmsg/qcom_smd.c
AgeCommit message (Collapse)AuthorFilesLines
2018-09-27rpmsg: smd: fix memory leak on channel createColin Ian King1-2/+5
Currently a failed allocation of channel->name leads to an immediate return without freeing channel. Fix this by setting ret to -ENOMEM and jumping to an exit path that kfree's channel. Detected by CoverityScan, CID#1473692 ("Resource Leak") Fixes: 53e2822e56c7 ("rpmsg: Introduce Qualcomm SMD backend") Cc: stable@vger.kernel.org Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-08-27rpmsg: Convert to using %pOFn instead of device_node.nameRob Herring1-1/+1
In preparation to remove the node name pointer from struct device_node, convert printf users to use the %pOFn format specifier. Cc: Ohad Ben-Cohen <ohad@wizery.com> Cc: Bjorn Andersson <bjorn.andersson@linaro.org> Cc: linux-remoteproc@vger.kernel.org Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-07-30rpmsg: smd: fix kerneldoc warningsSrinivas Kandagatla1-1/+8
This patch fixes below kerneldoc warnings qcom_smd.c:141: warning: Function parameter or member 'dev' not described in 'qcom_smd_edge' qcom_smd.c:141: warning: Function parameter or member 'name' not described in 'qcom_smd_edge' qcom_smd.c:141: warning: Function parameter or member 'new_channel_event' not described in 'qcom_smd_edge' qcom_smd.c:222: warning: Function parameter or member 'qsept' not described in 'qcom_smd_channel' qcom_smd.c:222: warning: Function parameter or member 'registered' not described in 'qcom_smd_channel' qcom_smd.c:222: warning: Function parameter or member 'state_change_event' not described in 'qcom_smd_channel' qcom_smd.c:222: warning: Function parameter or member 'drvdata' not described in 'qcom_smd_channel' qcom_smd.c:737: warning: Function parameter or member 'wait' not described in '__qcom_smd_send' Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-07-01rpmsg: smd: Add missing include of sizes.hNiklas Cassel1-0/+1
Add missing include of sizes.h. drivers/rpmsg/qcom_smd.c: In function ‘qcom_smd_channel_open’: drivers/rpmsg/qcom_smd.c:809:36: error: ‘SZ_4K’ undeclared (first use in this function) bb_size = min(channel->fifo_size, SZ_4K); ^~~~~ Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-06-04rpmsg: smd: do not use mananged resources for endpoints and channelsSrinivas Kandagatla1-9/+9
All the managed resources would be freed by the time release function is invoked. Handling such memory in qcom_smd_edge_release() would do bad things. Found this issue while testing Audio usecase where the dsp is started up and shutdown in a loop. This patch fixes this issue by using simple kzalloc for allocating channel->name and channel which is then freed in qcom_smd_edge_release(). Without this patch restarting a remoteproc would crash the system. Fixes: 53e2822e56c7 ("rpmsg: Introduce Qualcomm SMD backend") Cc: <stable@vger.kernel.org> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-06-03rpmsg: smd: Switch to SPDX license identifierSuman Anna1-9/+1
Use the appropriate SPDX license identifier in the rpmsg SMD backend driver source file 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-04-25rpmsg: qcom_smd: Access APCS through mailbox frameworkBjorn Andersson1-19/+49
Attempt to acquire the APCS IPC through the mailbox framework and fall back to the old syscon based approach, to allow us to move away from using the syscon. Reviewed-by: Arun Kumar Neelakantam <aneela@codeaurora.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-03-27rpmsg: smd: Use announce_create to process any receive workBjorn Andersson1-0/+18
It is possible that incoming data arrives before the client driver has reached a point in the probe method where adequate context for handling the incoming message has been established. In the event that the client's callback function returns an error the message will be left on the FIFO and by invoking the receive handler after the device has been probed the message will be picked off the FIFO and the callback invoked again. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-03-27rpmsg: smd: Fix container_of macrosBjorn Andersson1-2/+2
The container_of macros should not use the same name for the parameter as the member to use for lookup, as this will result in a compilation error unless the passed parameter has the same name as the member. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-03-27Revert "rpmsg: smd: Create device for all channels"Bjorn Andersson1-0/+5
In an effort to pick up channels that are in a funky state we optimistically tried to open all channels that we found, with the addition that we failed if the other side did not handshake the opening. But as we're starting the modem a second time all channels are found - in a "funky" state - and we try to open them. But the modem firmware requires the IPCRTR to be up in order to initialize. So any channels we try to open before that will fail and will not be opened again. This takes care of the regression, at the cost of reintroducing the previous behavior of handling of channels with "funky" states. Reverts commit c12fc4519f60 ("rpmsg: smd: Create device for all channels") Reported-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-03-20rpmsg: smd: Use spinlock in tx pathBjorn Andersson1-10/+11
By switching the tx_lock to a spinlock we allow clients to use rpmsg_trysend() from atomic context. The mutex was interruptable as it was previously held for the duration of some client waiting for available space in the FIFO, but this was recently changed to only be held temporarily - allowing us to replace it with a spinlock. Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-03-17rpmsg: smd: use put_device() if device_register failArvind Yadav1-1/+2
if device_register() returned an error! Always use put_device() to give up the reference initialized. unregister device for other return error. Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-02-11vfs: do bulk POLL* -> EPOLL* replacementLinus Torvalds1-1/+1
This is the mindless scripted replacement of kernel use of POLL* variables as described by Al, done by this script: for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'` for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done done with de-mangling cleanups yet to come. NOTE! On almost all architectures, the EPOLL* constants have the same values as the POLL* constants do. But they keyword here is "almost". For various bad reasons they aren't the same, and epoll() doesn't actually work quite correctly in some cases due to this on Sparc et al. The next patch from Al will sort out the final differences, and we should be all done. Scripted-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-02-05Merge tag 'rpmsg-v4.16' of git://github.com/andersson/remoteprocLinus Torvalds1-16/+50
Pull rpmsg updates from Bjorn Andersson: "This fixes a few issues found in the SMD and GLINK drivers and corrects the handling of SMD channels that are found in an (previously) unexpected state" * tag 'rpmsg-v4.16' of git://github.com/andersson/remoteproc: rpmsg: smd: Fix double unlock in __qcom_smd_send() rpmsg: glink: Fix missing mutex_init() in qcom_glink_alloc_channel() rpmsg: smd: Don't hold the tx lock during wait rpmsg: smd: Fail send on a closed channel rpmsg: smd: Wake up all waiters rpmsg: smd: Create device for all channels rpmsg: smd: Perform handshake during open rpmsg: glink: smem: Ensure ordering during tx drivers: rpmsg: remove duplicate includes remoteproc: qcom: Use PTR_ERR_OR_ZERO() in glink prob
2018-01-19rpmsg: smd: Fix double unlock in __qcom_smd_send()Dan Carpenter1-5/+5
We're not holding the lock here, so we shouldn't unlock. Fixes: 178f3f75bb4e ("rpmsg: smd: Don't hold the tx lock during wait") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> [bjorn: renamed "out" label to further distinguish the two exit paths] Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-12-18rpmsg: smd: Don't hold the tx lock during waitBjorn Andersson1-0/+7
Holding the tx lock while waiting for tx-drain events from the remote side blocks try_send requests from failing quickly, so temporarily drop the tx lock while waiting. While this allows try_send to fail quickly it also could allow a subsequent send to succeed putting a smaller packet in the FIFO while we're waiting for room for our large packet. But as this lock is per channel we expect that clients with ordering concerns implements their own ordering mechanism. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-12-18rpmsg: smd: Fail send on a closed channelBjorn Andersson1-6/+8
Move the check for a closed channel out from the tx-full loop to fail any send request on a non-open channel. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-12-18rpmsg: smd: Wake up all waitersBjorn Andersson1-2/+2
It's possible to have multiple contexts waiting for new channel events and with an upcoming change it's possible to have multiple contexts waiting for a full FIFO. As such we need to wake them all up. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-12-18rpmsg: smd: Create device for all channelsBjorn Andersson1-5/+0
Rather than selectively creating devices only for the channels that the remote have moved to "opening" state let's create devices for all channels found. The driver model will match drivers to the ones we care about and attempt to open these. The one case where this fails is if the user loads a firmware that lacks a particular channel of the previous firmware that was running, in which case we would find the old channel and attempt to probe it. The channel opening handshake will ensure this will result in a graceful failure. The result of this patch is that we will actively open the RPM channel even though it's left in a state other than "opening" after the boot loader's closing of the channel. Tested-by: Will Newton <will.newton@gmail.com> Reported-by: Jeremy McNicoll <jmcnicol@redhat.com> Reported-by: Will Newton <will.newton@gmail.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-12-18rpmsg: smd: Perform handshake during openBjorn Andersson1-0/+30
Validate the the remote side is opening the channel that we've found by performing a handshake when opening the channel. Tested-by: Will Newton <will.newton@gmail.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-11-28the rest of drivers/*: annotate ->poll() instancesAl Viro1-2/+2
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2017-07-26rpmsg: qcom_smd: add of_node node to edge deviceSrinivas Kandagatla1-0/+1
This patch assigns the device node to the edge device, so that the edge device drivers could read required device tree properties. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-05-17rpmsg: Release rpmsg devices in backendsBjorn Andersson1-0/+11
The rpmsg devices are allocated in the backends and as such must be freed there as well. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-01-18rpmsg: smd: Register rpmsg user space interface for edgesBjorn Andersson1-0/+20
Create and register a rpmsg device for use with the rpmsg user space interface, allowing user space to access SMD channels. Also provide the "rpmsg_name" device attribute to expose the edge name in sysfs, allowing the user to write udev rules for specific rpmsg devices and their children. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-01-18rpmsg: qcom_smd: Implement endpoint "poll"Bjorn Andersson1-0/+16
Add support for polling the status of the write buffer so that user space can use rpmsg character devices in non-blocking mode. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-01-18rpmsg: qcom_smd: Add support for "label" propertyBjorn Andersson1-0/+22
Add support for the "label" property, used to give the edge a name other than the one of the DT node. This allows the implementor to provide consistently named edges when using the rpmsg character device. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-12-13Merge tag 'rpmsg-v4.10' of git://github.com/andersson/remoteprocLinus Torvalds1-12/+5
Pull rpmsg updates from Bjorn Andersson: "Argument validation in public functions, function stubs for COMPILE_TEST-ing clients, preparation for exposing rpmsg endponts to user space and minor Qualcomm SMD fixes" * tag 'rpmsg-v4.10' of git://github.com/andersson/remoteproc: dt-binding: soc: qcom: smd: Add label property rpmsg: qcom_smd: Correct return value for O_NONBLOCK rpmsg: Provide function stubs for API rpmsg: Handle invalid parameters in public API rpmsg: Support drivers without primary endpoint rpmsg: Introduce a driver override mechanism rpmsg: smd: Reduce restrictions when finding channel
2016-12-08rpmsg: qcom_smd: Correct return value for O_NONBLOCKBjorn Andersson1-1/+1
qcom_smd_send() should return -EAGAIN for non-blocking channels with insufficient space, so that we can propagate this event to user space. Fixes: 53e2822e56c7 ("rpmsg: Introduce Qualcomm SMD backend") Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-11-14rpmsg: smd: Expose edge registration functionsBjorn Andersson1-0/+1
The edge registration functions is to be used from a remoteproc driver to register and unregister an edge as the remote processor comes and goes. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-10-31rpmsg: smd: Reduce restrictions when finding channelBjorn Andersson1-11/+4
SMD channels are created by the remotes in "opening" state, but sometimes as we close and try to reopen them they linger in closing state. Following the search for a matching channel the create_ept() will verify that the channel is in a suitable state, so we can lax the restrictions of the search function to work around above difference in behaviour. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2016-09-08rpmsg: Introduce Qualcomm SMD backendBjorn Andersson1-0/+1434
This introduces a new rpmsg backend for the Qualcomm SMD system, allowing communication with various remote processors found in Qualcomm platforms. The implementation is based on, and intends to replace, drivers/soc/qcom/smd.c with the necessary adaptions for fitting with the rpmsg core. Based on original work by Sricharan R <sricharan@codeaurora.org> Cc: Sricharan R <sricharan@codeaurora.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>