Commit 1aa7d6a5 authored by Robert Tivy's avatar Robert Tivy Committed by Ohad Ben-Cohen

rpmsg: process _all_ pending messages in rpmsg_recv_done

Change virtqueue callback function rpmsg_recv_done() to process all
available messages instead of just one message.
Signed-off-by: default avatarRobert Tivy <rtivy@ti.com>
[split _recv function instead of adding indentation]
Signed-off-by: default avatarOhad Ben-Cohen <ohad@wizery.com>
parent f6161aa1
...@@ -776,23 +776,13 @@ int rpmsg_send_offchannel_raw(struct rpmsg_channel *rpdev, u32 src, u32 dst, ...@@ -776,23 +776,13 @@ int rpmsg_send_offchannel_raw(struct rpmsg_channel *rpdev, u32 src, u32 dst,
} }
EXPORT_SYMBOL(rpmsg_send_offchannel_raw); EXPORT_SYMBOL(rpmsg_send_offchannel_raw);
/* called when an rx buffer is used, and it's time to digest a message */ static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev,
static void rpmsg_recv_done(struct virtqueue *rvq) struct rpmsg_hdr *msg, unsigned int len)
{ {
struct rpmsg_hdr *msg;
unsigned int len;
struct rpmsg_endpoint *ept; struct rpmsg_endpoint *ept;
struct scatterlist sg; struct scatterlist sg;
struct virtproc_info *vrp = rvq->vdev->priv;
struct device *dev = &rvq->vdev->dev;
int err; int err;
msg = virtqueue_get_buf(rvq, &len);
if (!msg) {
dev_err(dev, "uhm, incoming signal, but no used buffer ?\n");
return;
}
dev_dbg(dev, "From: 0x%x, To: 0x%x, Len: %d, Flags: %d, Reserved: %d\n", dev_dbg(dev, "From: 0x%x, To: 0x%x, Len: %d, Flags: %d, Reserved: %d\n",
msg->src, msg->dst, msg->len, msg->src, msg->dst, msg->len,
msg->flags, msg->reserved); msg->flags, msg->reserved);
...@@ -806,7 +796,7 @@ static void rpmsg_recv_done(struct virtqueue *rvq) ...@@ -806,7 +796,7 @@ static void rpmsg_recv_done(struct virtqueue *rvq)
if (len > RPMSG_BUF_SIZE || if (len > RPMSG_BUF_SIZE ||
msg->len > (len - sizeof(struct rpmsg_hdr))) { msg->len > (len - sizeof(struct rpmsg_hdr))) {
dev_warn(dev, "inbound msg too big: (%d, %d)\n", len, msg->len); dev_warn(dev, "inbound msg too big: (%d, %d)\n", len, msg->len);
return; return -EINVAL;
} }
/* use the dst addr to fetch the callback of the appropriate user */ /* use the dst addr to fetch the callback of the appropriate user */
...@@ -842,11 +832,42 @@ static void rpmsg_recv_done(struct virtqueue *rvq) ...@@ -842,11 +832,42 @@ static void rpmsg_recv_done(struct virtqueue *rvq)
err = virtqueue_add_buf(vrp->rvq, &sg, 0, 1, msg, GFP_KERNEL); err = virtqueue_add_buf(vrp->rvq, &sg, 0, 1, msg, GFP_KERNEL);
if (err < 0) { if (err < 0) {
dev_err(dev, "failed to add a virtqueue buffer: %d\n", err); dev_err(dev, "failed to add a virtqueue buffer: %d\n", err);
return err;
}
return 0;
}
/* called when an rx buffer is used, and it's time to digest a message */
static void rpmsg_recv_done(struct virtqueue *rvq)
{
struct virtproc_info *vrp = rvq->vdev->priv;
struct device *dev = &rvq->vdev->dev;
struct rpmsg_hdr *msg;
unsigned int len, msgs_received = 0;
int err;
msg = virtqueue_get_buf(rvq, &len);
if (!msg) {
dev_err(dev, "uhm, incoming signal, but no used buffer ?\n");
return; return;
} }
while (msg) {
err = rpmsg_recv_single(vrp, dev, msg, len);
if (err)
break;
msgs_received++;
msg = virtqueue_get_buf(rvq, &len);
};
dev_dbg(dev, "Received %u messages\n", msgs_received);
/* tell the remote processor we added another available rx buffer */ /* tell the remote processor we added another available rx buffer */
virtqueue_kick(vrp->rvq); if (msgs_received)
virtqueue_kick(vrp->rvq);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment