Skip to content

Commit ba7a475

Browse files
quic-bjorandeandersson
authored andcommitted
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: Bjorn Andersson <quic_bjorande@quicinc.com> Reviewed-by: Chris Lew <quic_clew@quicinc.com> Signed-off-by: Bjorn Andersson <andersson@kernel.org> Link: https://lore.kernel.org/r/20230418163018.785524-3-quic_bjorande@quicinc.com
1 parent 7a68f9f commit ba7a475

1 file changed

Lines changed: 13 additions & 33 deletions

File tree

drivers/rpmsg/qcom_glink_native.c

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ static int __qcom_glink_send(struct glink_channel *channel,
13241324
int ret;
13251325
unsigned long flags;
13261326
int chunk_size = len;
1327-
int left_size = 0;
1327+
size_t offset = 0;
13281328

13291329
if (!glink->intentless) {
13301330
while (!intent) {
@@ -1358,49 +1358,29 @@ static int __qcom_glink_send(struct glink_channel *channel,
13581358
iid = intent->id;
13591359
}
13601360

1361-
if (wait && chunk_size > SZ_8K) {
1362-
chunk_size = SZ_8K;
1363-
left_size = len - chunk_size;
1364-
}
1365-
req.msg.cmd = cpu_to_le16(GLINK_CMD_TX_DATA);
1366-
req.msg.param1 = cpu_to_le16(channel->lcid);
1367-
req.msg.param2 = cpu_to_le32(iid);
1368-
req.chunk_size = cpu_to_le32(chunk_size);
1369-
req.left_size = cpu_to_le32(left_size);
1370-
1371-
ret = qcom_glink_tx(glink, &req, sizeof(req), data, chunk_size, wait);
1372-
1373-
/* Mark intent available if we failed */
1374-
if (ret) {
1375-
if (intent)
1376-
intent->in_use = false;
1377-
return ret;
1378-
}
1379-
1380-
while (left_size > 0) {
1381-
data = (void *)((char *)data + chunk_size);
1382-
chunk_size = left_size;
1383-
if (chunk_size > SZ_8K)
1361+
while (offset < len) {
1362+
chunk_size = len - offset;
1363+
if (chunk_size > SZ_8K && wait)
13841364
chunk_size = SZ_8K;
1385-
left_size -= chunk_size;
13861365

1387-
req.msg.cmd = cpu_to_le16(GLINK_CMD_TX_DATA_CONT);
1366+
req.msg.cmd = cpu_to_le16(offset == 0 ? GLINK_CMD_TX_DATA : GLINK_CMD_TX_DATA_CONT);
13881367
req.msg.param1 = cpu_to_le16(channel->lcid);
13891368
req.msg.param2 = cpu_to_le32(iid);
13901369
req.chunk_size = cpu_to_le32(chunk_size);
1391-
req.left_size = cpu_to_le32(left_size);
1370+
req.left_size = cpu_to_le32(len - offset - chunk_size);
13921371

1393-
ret = qcom_glink_tx(glink, &req, sizeof(req), data,
1394-
chunk_size, wait);
1395-
1396-
/* Mark intent available if we failed */
1372+
ret = qcom_glink_tx(glink, &req, sizeof(req), data + offset, chunk_size, wait);
13971373
if (ret) {
1374+
/* Mark intent available if we failed */
13981375
if (intent)
13991376
intent->in_use = false;
1400-
break;
1377+
return ret;
14011378
}
1379+
1380+
offset += chunk_size;
14021381
}
1403-
return ret;
1382+
1383+
return 0;
14041384
}
14051385

14061386
static int qcom_glink_send(struct rpmsg_endpoint *ept, void *data, int len)

0 commit comments

Comments
 (0)