summaryrefslogtreecommitdiffstats
path: root/include/linux/rpmsg.h
Commit message (Collapse)AuthorAgeFilesLines
* rpmsg: Fix calling device_lock() on non-initialized deviceKrzysztof Kozlowski2022-05-061-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | driver_set_override() helper uses device_lock() so it should not be called before rpmsg_register_device() (which calls device_register()). Effect can be seen with CONFIG_DEBUG_MUTEXES: DEBUG_LOCKS_WARN_ON(lock->magic != lock) WARNING: CPU: 3 PID: 57 at kernel/locking/mutex.c:582 __mutex_lock+0x1ec/0x430 ... Call trace: __mutex_lock+0x1ec/0x430 mutex_lock_nested+0x44/0x50 driver_set_override+0x124/0x150 qcom_glink_native_probe+0x30c/0x3b0 glink_rpm_probe+0x274/0x350 platform_probe+0x6c/0xe0 really_probe+0x17c/0x3d0 __driver_probe_device+0x114/0x190 driver_probe_device+0x3c/0xf0 ... Refactor the rpmsg_register_device() function to use two-step device registering (initialization + add) and call driver_set_override() in proper moment. This moves the code around, so while at it also NULL-ify the rpdev->driver_override in error path to be sure it won't be kfree() second time. Fixes: 42cd402b8fd4 ("rpmsg: Fix kfree() of static memory on setting driver_override") Reported-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Link: https://lore.kernel.org/r/20220429195946.1061725-2-krzysztof.kozlowski@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* rpmsg: Fix kfree() of static memory on setting driver_overrideKrzysztof Kozlowski2022-04-221-2/+4
| | | | | | | | | | | | | | | The driver_override field from platform driver should not be initialized from static memory (string literal) because the core later kfree() it, for example when driver_override is set via sysfs. Use dedicated helper to set driver_override properly. Fixes: 950a7388f02b ("rpmsg: Turn name service into a stand alone driver") Fixes: c0cdc19f84a4 ("rpmsg: Driver for user space endpoint interface") Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20220419113435.246203-13-krzysztof.kozlowski@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge tag 'rpmsg-v5.16' of ↵Linus Torvalds2021-11-101-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux Pull rpmsg updates from Bjorn Andersson: "For the GLINK implementation this adds support for splitting outgoing messages that are too large to fit in the fifo, it introduces the use of "read notifications", to avoid polling in the case where the outgoing fifo is full and a few bugs are squashed. The return value of rpmsg_create_ept() for when RPMSG is disabled is corrected to return a valid error, the Mediatek rpmsg driver is updated to match the DT binding and a couple of cleanups are done in the virtio rpmsg driver" * tag 'rpmsg-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux: rpmsg: glink: Send READ_NOTIFY command in FIFO full case rpmsg: glink: Remove channel decouple from rpdev release rpmsg: glink: Remove the rpmsg dev in close_ack rpmsg: glink: Add TX_DATA_CONT command while sending rpmsg: virtio_rpmsg_bus: use dev_warn_ratelimited for msg with no recipient rpmsg: virtio: Remove unused including <linux/of_device.h> rpmsg: Change naming of mediatek rpmsg property rpmsg: Fix rpmsg_create_ept return when RPMSG config is not defined rpmsg: glink: Replace strncpy() with strscpy_pad()
| * rpmsg: Fix rpmsg_create_ept return when RPMSG config is not definedArnaud Pouliquen2021-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | According to the description of the rpmsg_create_ept in rpmsg_core.c the function should return NULL on error. Fixes: 2c8a57088045 ("rpmsg: Provide function stubs for API") Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Link: https://lore.kernel.org/r/20210712123912.10672-1-arnaud.pouliquen@foss.st.com Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* | rpmsg: core: add API to get MTUArnaud Pouliquen2021-10-211-0/+10
|/ | | | | | | | | | | | Return the rpmsg buffer MTU for sending message, so rpmsg users can split a long message in several sub rpmsg buffers. Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Acked-by: Suman Anna <s-anna@ti.com> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Link: https://lore.kernel.org/r/20211015094701.5732-2-arnaud.pouliquen@foss.st.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* rpmsg: Move RPMSG_ADDR_ANY in user APIArnaud Pouliquen2021-03-171-2/+1
| | | | | | | | | | | As the RPMSG_ADDR_ANY is a valid src or dst address that can be set by user applications, migrate its definition in user API. Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Link: https://lore.kernel.org/r/20210311140413.31725-3-arnaud.pouliquen@foss.st.com Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Make rpmsg_{register|unregister}_device() publicMathieu Poirier2020-11-241-4/+8
| | | | | | | | | | | | | | Make function rpmsg_register_device() and rpmsg_unregister_device() functions public so that they can be used by other clients. While doing so get rid of two obsolete function, i.e register_rpmsg_device() and unregister_rpmsg_device(), to prevent confusion. Tested-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Link: https://lore.kernel.org/r/20201120214245.172963-8-mathieu.poirier@linaro.org Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Introduce __rpmsg{16|32|64} typesMathieu Poirier2020-11-241-0/+51
| | | | | | | | | | | | | | Introduce __rpmsg{16|32|64} types along with byte order conversion functions based on an rpmsg_device operation as a foundation to make RPMSG modular and transport agnostic. Tested-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Suggested-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Link: https://lore.kernel.org/r/20201120214245.172963-2-mathieu.poirier@linaro.org Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Switch to SPDX license identifierSuman Anna2018-06-031-26/+1
| | | | | | | | Use the appropriate SPDX license identifier in the rpmsg core 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>
* the rest of drivers/*: annotate ->poll() instancesAl Viro2017-11-281-2/+2
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* rpmsg: Introduce "poll" to endpoint opsBjorn Andersson2017-01-181-0/+13
| | | | | | | | This allows rpmsg backends to implement polling of the outgoing buffer, which provides poll support to user space when using the rpmsg character device. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Provide function stubs for APIBjorn Andersson2016-10-311-10/+113
| | | | | | | Provide function stubs for the rpmsg API to allow clients to be compile tested without having CONFIG_RPMSG enabled. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Introduce a driver override mechanismBjorn Andersson2016-10-311-0/+2
| | | | | | | Similar to other subsystems it's useful to provide a mechanism to force a specific driver match on a device, so introduce this. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Allow callback to return errorsBjorn Andersson2016-09-081-2/+2
| | | | | | | | Some rpmsg backends support holding on to and redelivering messages upon failed handling of them, so provide a way for the callback to report and error and allow the backends to handle this. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Move virtio specifics from public headerBjorn Andersson2016-09-081-52/+0
| | | | | | | Move virtio rpmsg implementation details from the public header file to the virtio rpmsg implementation. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: virtio: Hide vrp pointer from the public APIBjorn Andersson2016-09-081-3/+0
| | | | | | | | Create a container struct virtio_rpmsg_channel around the rpmsg_channel to keep virtio backend information separate from the rpmsg and public API. This makes the public structures independant of virtio. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Hide rpmsg indirection tablesBjorn Andersson2016-09-081-47/+0
| | | | | | | Move the device and endpoint indirection tables to the rpmsg internal header file, to hide them from the public API. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Move endpoint related interface to rpmsg coreBjorn Andersson2016-09-081-142/+6
| | | | | | | | Move the rpmsg_send() and rpmsg_destroy_ept() interface to the rpmsg core, so that we eventually can hide the rpmsg_endpoint ops from the public API. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Indirection table for rpmsg_endpoint operationsBjorn Andersson2016-09-081-24/+38
| | | | | | | | Add indirection table for rpmsg_endpoint related operations and move virtio implementation behind this, this finishes of the decoupling of the virtio implementation from the public API. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Introduce indirection table for rpmsg_device operationsBjorn Andersson2016-09-081-0/+23
| | | | | | | | To allow for multiple backend implementations add an indireection table for rpmsg_device related operations and move the virtio implementation behind this table. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Clean up rpmsg device vs channel namingBjorn Andersson2016-09-081-15/+17
| | | | | | | | The rpmsg device representing struct is called rpmsg_channel and the variable name used throughout is rpdev, with the communication happening on endpoints it's clearer to just call this a "device" in a public API. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Make rpmsg_create_ept() take channel_info structBjorn Andersson2016-09-081-1/+14
| | | | | | | | | | As we introduce support for additional rpmsg backends, some of these only supports point-to-point "links" represented by a name. By making rpmsg_create_ept() take a channel_info struct we allow for these backends to either be passed a source address, a destination address or a name identifier. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: rpmsg_send() operations takes rpmsg_endpointBjorn Andersson2016-09-081-30/+40
| | | | | | | | | | | | | | | The rpmsg_send() operations has been taking a rpmsg_device, but this forces users of secondary rpmsg_endpoints to use the rpmsg_sendto() interface - by extracting source and destination from the given data structures. If we instead pass the rpmsg_endpoint to these functions a service can use rpmsg_sendto() to respond to messages, even on secondary endpoints. In addition this would allow us to support operations on multiple channels in future backends that does not support off-channel operations. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: Drop prototypes for non-existing functionsBjorn Andersson2016-08-121-2/+0
| | | | | | | The (un)register_rpmsg_device() functions never made it to mainline, so drop them for now. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: align code with open parenthesisAnna, Suman2016-08-121-3/+3
| | | | | | | | | | This patch fixes most of the existing alignment checkpatch check warnings of the type "Alignment should match open parenthesis" in the virtio rpmsg bus code. A couple of them have been left as is to not exceed the 80-char limit. Signed-off-by: Suman Anna <s-anna@ti.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: add helper macro module_rpmsg_driverAndrew F. Davis2016-05-061-0/+12
| | | | | | | | | | | | This patch introduces the module_rpmsg_driver macro which is a convenience macro for rpmsg driver modules similar to module_platform_driver. It is intended to be used by drivers which init/exit section does nothing but register/unregister the rpmsg driver. By using this macro it is possible to eliminate a few lines of boilerplate code per rpmsg driver. Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: add THIS_MODULE to rpmsg_driver in rpmsg coreAndrew F. Davis2016-05-061-1/+5
| | | | | | | | | | Add register_rpmsg_driver helper macro that adds THIS_MODULE to rpmsg_driver for the registering driver. We rename and modify the existing register_rpmsg_driver to enable this. Signed-off-by: Andrew F. Davis <afd@ti.com> Acked-by: Suman Anna <s-anna@ti.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* rpmsg: make sure inflight messages don't invoke just-removed callbacksOhad Ben-Cohen2012-07-041-0/+3
| | | | | | | | | | | | | | | | | When inbound messages arrive, rpmsg core looks up their associated endpoint (by destination address) and then invokes their callback. We've made sure that endpoints will never be de-allocated after they were found by rpmsg core, but we also need to protect against the (rare) scenario where the rpmsg driver was just removed, and its callback function isn't available anymore. This is achieved by introducing a callback mutex, which must be taken before the callback is invoked, and, obviously, before it is removed. Cc: stable <stable@vger.kernel.org> Reported-by: Fernando Guzman Lugo <fernando.lugo@ti.com> Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
* rpmsg: avoid premature deallocation of endpointsOhad Ben-Cohen2012-07-041-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | When an inbound message arrives, the rpmsg core looks up its associated endpoint and invokes the registered callback. If a message arrives while its endpoint is being removed (because the rpmsg driver was removed, or a recovery of a remote processor has kicked in) we must ensure atomicity, i.e.: - Either the ept is removed before it is found or - The ept is found but will not be freed until the callback returns This is achieved by maintaining a per-ept reference count, which, when drops to zero, will trigger deallocation of the ept. With this in hand, it is now forbidden to directly deallocate epts once they have been added to the endpoints idr. Cc: stable <stable@vger.kernel.org> Reported-by: Fernando Guzman Lugo <fernando.lugo@ti.com> Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
* rpmsg: add virtio-based remote processor messaging busOhad Ben-Cohen2012-02-081-0/+326
Add a virtio-based inter-processor communication bus, which enables kernel drivers to communicate with entities, running on remote processors, over shared memory using a simple messaging protocol. Every pair of AMP processors share two vrings, which are used to send and receive the messages over shared memory. The header of every message sent on the rpmsg bus contains src and dst addresses, which make it possible to multiplex several rpmsg channels on the same vring. Every rpmsg channel is a device on this bus. When a channel is added, and an appropriate rpmsg driver is found and probed, it is also assigned a local rpmsg address, which is then bound to the driver's callback. When inbound messages carry the local address of a bound driver, its callback is invoked by the bus. This patch provides a kernel interface only; user space interfaces will be later exposed by kernel users of this rpmsg bus. Designed with Brian Swetland <swetland@google.com>. Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com> Acked-by: Rusty Russell <rusty@rustcorp.com.au> (virtio_ids.h) Cc: Brian Swetland <swetland@google.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Tony Lindgren <tony@atomide.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Greg KH <greg@kroah.com> Cc: Stephen Boyd <sboyd@codeaurora.org>