Commit ba7a4754 authored by Bjorn Andersson's avatar Bjorn Andersson Committed by Bjorn Andersson

rpmsg: glink: Consolidate TX_DATA and TX_DATA_CONT

Rather than duplicating most of the code for constructing the initial
TX_DATA and subsequent TX_DATA_CONT packets, roll them into a single
loop.
Signed-off-by: default avatarBjorn Andersson <quic_bjorande@quicinc.com>
Reviewed-by: default avatarChris Lew <quic_clew@quicinc.com>
Signed-off-by: default avatarBjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230418163018.785524-3-quic_bjorande@quicinc.com
parent 7a68f9fa
...@@ -1324,7 +1324,7 @@ static int __qcom_glink_send(struct glink_channel *channel, ...@@ -1324,7 +1324,7 @@ static int __qcom_glink_send(struct glink_channel *channel,
int ret; int ret;
unsigned long flags; unsigned long flags;
int chunk_size = len; int chunk_size = len;
int left_size = 0; size_t offset = 0;
if (!glink->intentless) { if (!glink->intentless) {
while (!intent) { while (!intent) {
...@@ -1358,49 +1358,29 @@ static int __qcom_glink_send(struct glink_channel *channel, ...@@ -1358,49 +1358,29 @@ static int __qcom_glink_send(struct glink_channel *channel,
iid = intent->id; iid = intent->id;
} }
if (wait && chunk_size > SZ_8K) { while (offset < len) {
chunk_size = SZ_8K; chunk_size = len - offset;
left_size = len - chunk_size; if (chunk_size > SZ_8K && wait)
}
req.msg.cmd = cpu_to_le16(GLINK_CMD_TX_DATA);
req.msg.param1 = cpu_to_le16(channel->lcid);
req.msg.param2 = cpu_to_le32(iid);
req.chunk_size = cpu_to_le32(chunk_size);
req.left_size = cpu_to_le32(left_size);
ret = qcom_glink_tx(glink, &req, sizeof(req), data, chunk_size, wait);
/* Mark intent available if we failed */
if (ret) {
if (intent)
intent->in_use = false;
return ret;
}
while (left_size > 0) {
data = (void *)((char *)data + chunk_size);
chunk_size = left_size;
if (chunk_size > SZ_8K)
chunk_size = SZ_8K; chunk_size = SZ_8K;
left_size -= chunk_size;
req.msg.cmd = cpu_to_le16(GLINK_CMD_TX_DATA_CONT); req.msg.cmd = cpu_to_le16(offset == 0 ? GLINK_CMD_TX_DATA : GLINK_CMD_TX_DATA_CONT);
req.msg.param1 = cpu_to_le16(channel->lcid); req.msg.param1 = cpu_to_le16(channel->lcid);
req.msg.param2 = cpu_to_le32(iid); req.msg.param2 = cpu_to_le32(iid);
req.chunk_size = cpu_to_le32(chunk_size); req.chunk_size = cpu_to_le32(chunk_size);
req.left_size = cpu_to_le32(left_size); req.left_size = cpu_to_le32(len - offset - chunk_size);
ret = qcom_glink_tx(glink, &req, sizeof(req), data, ret = qcom_glink_tx(glink, &req, sizeof(req), data + offset, chunk_size, wait);
chunk_size, wait);
/* Mark intent available if we failed */
if (ret) { if (ret) {
/* Mark intent available if we failed */
if (intent) if (intent)
intent->in_use = false; intent->in_use = false;
break; return ret;
} }
offset += chunk_size;
} }
return ret;
return 0;
} }
static int qcom_glink_send(struct rpmsg_endpoint *ept, void *data, int len) static int qcom_glink_send(struct rpmsg_endpoint *ept, void *data, int len)
......
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