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>
This commit is contained in:
Deepak Kumar Singh 2020-08-11 00:01:18 +05:30
commit 4831a6abdd

View file

@ -211,6 +211,7 @@ struct glink_channel {
struct mutex intent_req_lock;
bool intent_req_result;
bool channel_ready;
atomic_t intent_req_comp;
wait_queue_head_t intent_req_event;
@ -876,7 +877,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);
@ -1401,6 +1402,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) {