Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rpmsg: core: Add signal API support

Some transports like Glink support the state notifications between
clients using flow control signals similar to serial protocol signals.
Local glink client drivers can send and receive flow control status
to glink clients running on remote processors.

Add APIs to support sending and receiving of flow control status by
rpmsg clients.

Signed-off-by: Deepak Kumar Singh <quic_deesin@quicinc.com>
Signed-off-by: Sarannya S <quic_sarannya@quicinc.com>
Acked-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Link: https://lore.kernel.org/r/1688679698-31274-2-git-send-email-quic_sarannya@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Deepak Kumar Singh and committed by
Bjorn Andersson
8ce49c2a 06c2afb8

+38
+21
drivers/rpmsg/rpmsg_core.c
··· 331 331 EXPORT_SYMBOL(rpmsg_trysend_offchannel); 332 332 333 333 /** 334 + * rpmsg_set_flow_control() - request remote to pause/resume transmission 335 + * @ept: the rpmsg endpoint 336 + * @pause: pause transmission 337 + * @dst: destination address of the endpoint 338 + * 339 + * Return: 0 on success and an appropriate error value on failure. 340 + */ 341 + int rpmsg_set_flow_control(struct rpmsg_endpoint *ept, bool pause, u32 dst) 342 + { 343 + if (WARN_ON(!ept)) 344 + return -EINVAL; 345 + if (!ept->ops->set_flow_control) 346 + return -EOPNOTSUPP; 347 + 348 + return ept->ops->set_flow_control(ept, pause, dst); 349 + } 350 + EXPORT_SYMBOL_GPL(rpmsg_set_flow_control); 351 + 352 + /** 334 353 * rpmsg_get_mtu() - get maximum transmission buffer size for sending message. 335 354 * @ept: the rpmsg endpoint 336 355 * ··· 558 539 559 540 rpdev->ept = ept; 560 541 rpdev->src = ept->addr; 542 + 543 + ept->flow_cb = rpdrv->flowcontrol; 561 544 } 562 545 563 546 err = rpdrv->probe(rpdev);
+2
drivers/rpmsg/rpmsg_internal.h
··· 55 55 * @trysendto: see @rpmsg_trysendto(), optional 56 56 * @trysend_offchannel: see @rpmsg_trysend_offchannel(), optional 57 57 * @poll: see @rpmsg_poll(), optional 58 + * @set_flow_control: see @rpmsg_set_flow_control(), optional 58 59 * @get_mtu: see @rpmsg_get_mtu(), optional 59 60 * 60 61 * Indirection table for the operations that a rpmsg backend should implement. ··· 76 75 void *data, int len); 77 76 __poll_t (*poll)(struct rpmsg_endpoint *ept, struct file *filp, 78 77 poll_table *wait); 78 + int (*set_flow_control)(struct rpmsg_endpoint *ept, bool pause, u32 dst); 79 79 ssize_t (*get_mtu)(struct rpmsg_endpoint *ept); 80 80 }; 81 81
+15
include/linux/rpmsg.h
··· 64 64 }; 65 65 66 66 typedef int (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32); 67 + typedef int (*rpmsg_flowcontrol_cb_t)(struct rpmsg_device *, void *, bool); 67 68 68 69 /** 69 70 * struct rpmsg_endpoint - binds a local rpmsg address to its user 70 71 * @rpdev: rpmsg channel device 71 72 * @refcount: when this drops to zero, the ept is deallocated 72 73 * @cb: rx callback handler 74 + * @flow_cb: remote flow control callback handler 73 75 * @cb_lock: must be taken before accessing/changing @cb 74 76 * @addr: local rpmsg address 75 77 * @priv: private data for the driver's use ··· 94 92 struct rpmsg_device *rpdev; 95 93 struct kref refcount; 96 94 rpmsg_rx_cb_t cb; 95 + rpmsg_flowcontrol_cb_t flow_cb; 97 96 struct mutex cb_lock; 98 97 u32 addr; 99 98 void *priv; ··· 109 106 * @probe: invoked when a matching rpmsg channel (i.e. device) is found 110 107 * @remove: invoked when the rpmsg channel is removed 111 108 * @callback: invoked when an inbound message is received on the channel 109 + * @flowcontrol: invoked when remote side flow control request is received 112 110 */ 113 111 struct rpmsg_driver { 114 112 struct device_driver drv; ··· 117 113 int (*probe)(struct rpmsg_device *dev); 118 114 void (*remove)(struct rpmsg_device *dev); 119 115 int (*callback)(struct rpmsg_device *, void *, int, void *, u32); 116 + int (*flowcontrol)(struct rpmsg_device *, void *, bool); 120 117 }; 121 118 122 119 static inline u16 rpmsg16_to_cpu(struct rpmsg_device *rpdev, __rpmsg16 val) ··· 196 191 poll_table *wait); 197 192 198 193 ssize_t rpmsg_get_mtu(struct rpmsg_endpoint *ept); 194 + 195 + int rpmsg_set_flow_control(struct rpmsg_endpoint *ept, bool pause, u32 dst); 199 196 200 197 #else 201 198 ··· 316 309 } 317 310 318 311 static inline ssize_t rpmsg_get_mtu(struct rpmsg_endpoint *ept) 312 + { 313 + /* This shouldn't be possible */ 314 + WARN_ON(1); 315 + 316 + return -ENXIO; 317 + } 318 + 319 + static inline int rpmsg_set_flow_control(struct rpmsg_endpoint *ept, bool pause, u32 dst) 319 320 { 320 321 /* This shouldn't be possible */ 321 322 WARN_ON(1);