rpmsg: glink: check channel state before serving intent

Receive callback can be registered even before rpmsg driver probe is
complete. Assuming callback register as channel ready and allowing
remote host to send data is incorrect. In such case for any rx packet
callback may return prematurely thereby dropping the rx packet.

Adding a flag to store channel state when it is ready. Check this flag
before allocating rx intent and allowing data communication to proceed.
It will ensure that client driver is able to receive data correctly,
without any rx packet getting dropped.

CRs-Fixed: 2747216
Change-Id: Ib153cfe5689f31d7417622bf6177e9535fda628a
Signed-off-by: Deepak Kumar Singh <deesin@codeaurora.org>
Signed-off-by: Sarannya S <sarannya@codeaurora.org>
This commit is contained in:
Deepak Kumar Singh 2020-08-11 00:01:18 +05:30 committed by Chris Lew
parent 0484a3f755
commit db10576a4e

View File

@ -187,6 +187,7 @@ struct glink_channel {
struct mutex intent_req_lock;
bool intent_req_result;
struct completion intent_req_comp;
bool channel_ready;
};
#define to_glink_channel(_ept) container_of(_ept, struct glink_channel, ept)
@ -822,7 +823,7 @@ static void qcom_glink_handle_intent_req(struct qcom_glink *glink,
ept = &channel->ept;
intent = qcom_glink_alloc_intent(glink, channel, size, false);
if (intent && ept->cb)
if (intent && channel->channel_ready)
qcom_glink_advertise_intent(glink, channel, intent);
qcom_glink_send_intent_req_ack(glink, channel, !!intent);
@ -1262,6 +1263,8 @@ static int qcom_glink_announce_create(struct rpmsg_device *rpdev)
if (glink->intentless || !completion_done(&channel->open_ack))
return 0;
channel->channel_ready = true;
/*Serve any pending intent request*/
spin_lock_irqsave(&channel->intent_lock, flags);
idr_for_each_entry(&channel->liids, tmp, iid) {