aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorOhad Ben-Cohen <ohad@wizery.com>2012-06-06 03:09:25 -0400
committerOhad Ben-Cohen <ohad@wizery.com>2012-07-04 04:51:42 -0400
commit5a081caa0414b9bbb82c17ffab9d6fe66edbb72f (patch)
treede3c3d2044db5843e836690732a4f688985e35af /include
parent6887a4131da3adaab011613776d865f4bcfb5678 (diff)
rpmsg: avoid premature deallocation of endpoints
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>
Diffstat (limited to 'include')
-rw-r--r--include/linux/rpmsg.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h
index a8e50e44203c..195f373590b8 100644
--- a/include/linux/rpmsg.h
+++ b/include/linux/rpmsg.h
@@ -38,6 +38,7 @@
38#include <linux/types.h> 38#include <linux/types.h>
39#include <linux/device.h> 39#include <linux/device.h>
40#include <linux/mod_devicetable.h> 40#include <linux/mod_devicetable.h>
41#include <linux/kref.h>
41 42
42/* The feature bitmap for virtio rpmsg */ 43/* The feature bitmap for virtio rpmsg */
43#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */ 44#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
@@ -120,6 +121,7 @@ typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, u32);
120/** 121/**
121 * struct rpmsg_endpoint - binds a local rpmsg address to its user 122 * struct rpmsg_endpoint - binds a local rpmsg address to its user
122 * @rpdev: rpmsg channel device 123 * @rpdev: rpmsg channel device
124 * @refcount: when this drops to zero, the ept is deallocated
123 * @cb: rx callback handler 125 * @cb: rx callback handler
124 * @addr: local rpmsg address 126 * @addr: local rpmsg address
125 * @priv: private data for the driver's use 127 * @priv: private data for the driver's use
@@ -140,6 +142,7 @@ typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, u32);
140 */ 142 */
141struct rpmsg_endpoint { 143struct rpmsg_endpoint {
142 struct rpmsg_channel *rpdev; 144 struct rpmsg_channel *rpdev;
145 struct kref refcount;
143 rpmsg_rx_cb_t cb; 146 rpmsg_rx_cb_t cb;
144 u32 addr; 147 u32 addr;
145 void *priv; 148 void *priv;