Skip to content

Commit c7c182d

Browse files
Arun Kumar Neelakantamandersson
authored andcommitted
rpmsg: glink: Remove the rpmsg dev in close_ack
Un-register and register of rpmsg driver is sending invalid open_ack on closed channel. To avoid sending invalid open_ack case unregister the rpmsg device after receiving the local_close_ack from remote side. Signed-off-by: Deepak Kumar Singh <[email protected]> Signed-off-by: Arun Kumar Neelakantam <[email protected]> [bjorn: s/strlcpy/strscpy/] Signed-off-by: Bjorn Andersson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8956927 commit c7c182d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/rpmsg/qcom_glink_native.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,7 @@ static void qcom_glink_rx_close(struct qcom_glink *glink, unsigned int rcid)
15241524

15251525
rpmsg_unregister_device(glink->dev, &chinfo);
15261526
}
1527+
channel->rpdev = NULL;
15271528

15281529
qcom_glink_send_close_ack(glink, channel->rcid);
15291530

@@ -1537,6 +1538,7 @@ static void qcom_glink_rx_close(struct qcom_glink *glink, unsigned int rcid)
15371538

15381539
static void qcom_glink_rx_close_ack(struct qcom_glink *glink, unsigned int lcid)
15391540
{
1541+
struct rpmsg_channel_info chinfo;
15401542
struct glink_channel *channel;
15411543
unsigned long flags;
15421544

@@ -1551,6 +1553,16 @@ static void qcom_glink_rx_close_ack(struct qcom_glink *glink, unsigned int lcid)
15511553
channel->lcid = 0;
15521554
spin_unlock_irqrestore(&glink->idr_lock, flags);
15531555

1556+
/* Decouple the potential rpdev from the channel */
1557+
if (channel->rpdev) {
1558+
strscpy(chinfo.name, channel->name, sizeof(chinfo.name));
1559+
chinfo.src = RPMSG_ADDR_ANY;
1560+
chinfo.dst = RPMSG_ADDR_ANY;
1561+
1562+
rpmsg_unregister_device(glink->dev, &chinfo);
1563+
}
1564+
channel->rpdev = NULL;
1565+
15541566
kref_put(&channel->refcount, qcom_glink_channel_release);
15551567
}
15561568

0 commit comments

Comments
 (0)