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

rpmsg: char: Use rpmsg_sendto to specify the message destination address

When the endpoint device is created by the application, a destination
address is specified in the rpmsg_channel_info structure. Since the
rpmsg_endpoint structure does not store the destination address,
this destination address must be specified when sending a message.

Replaces rpmsg_send with rpmsg_sendto to allow to specify the
destination address. This implementation is requested for compatibly with
some rpmsg backends like the virtio backend.

For this, the GLINK an SMD drivers have been updated to support the
rpmsg_sendto, even if the destination address is ignored for these
backends. For these drivers, the rpmsg_send and rpmsg_trysend ops are
preserved to avoid breaking the legacy.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20210311140413.31725-5-arnaud.pouliquen@foss.st.com
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

authored by

Arnaud Pouliquen and committed by
Bjorn Andersson
b4ce7e2e 809328b4

+34 -2
+16
drivers/rpmsg/qcom_smd.c
··· 974 974 return __qcom_smd_send(qsept->qsch, data, len, false); 975 975 } 976 976 977 + static int qcom_smd_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) 978 + { 979 + struct qcom_smd_endpoint *qsept = to_smd_endpoint(ept); 980 + 981 + return __qcom_smd_send(qsept->qsch, data, len, true); 982 + } 983 + 984 + static int qcom_smd_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) 985 + { 986 + struct qcom_smd_endpoint *qsept = to_smd_endpoint(ept); 987 + 988 + return __qcom_smd_send(qsept->qsch, data, len, false); 989 + } 990 + 977 991 static __poll_t qcom_smd_poll(struct rpmsg_endpoint *ept, 978 992 struct file *filp, poll_table *wait) 979 993 { ··· 1052 1038 static const struct rpmsg_endpoint_ops qcom_smd_endpoint_ops = { 1053 1039 .destroy_ept = qcom_smd_destroy_ept, 1054 1040 .send = qcom_smd_send, 1041 + .sendto = qcom_smd_sendto, 1055 1042 .trysend = qcom_smd_trysend, 1043 + .trysendto = qcom_smd_trysendto, 1056 1044 .poll = qcom_smd_poll, 1057 1045 }; 1058 1046
+2 -2
drivers/rpmsg/rpmsg_char.c
··· 239 239 } 240 240 241 241 if (filp->f_flags & O_NONBLOCK) 242 - ret = rpmsg_trysend(eptdev->ept, kbuf, len); 242 + ret = rpmsg_trysendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst); 243 243 else 244 - ret = rpmsg_send(eptdev->ept, kbuf, len); 244 + ret = rpmsg_sendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst); 245 245 246 246 unlock_eptdev: 247 247 mutex_unlock(&eptdev->ept_lock);