drivers/rpmsg: fix the race condtion about rpmsg_device_created
xxx_rpmsg_device_created may be called repeatedly. rptun thread app thread rptun_dev_start xxx_rpmsg_init ... rpmsg_register_callback priv->...= rpmsg_ns_unbind; priv->..= rptun_notify_wait; if (ns_unbind_cb) (switch app thread) device_created() xxx_rpmsg_device_created metal_list_add_tail(g_cb); ... rpmsg_device_created(); cb->device_created xxx_rpmsg_device_created; Signed-off-by: yintao <yintao@xiaomi.com>
This commit is contained in:
parent
00b6495419
commit
38af7001b6
@ -229,7 +229,7 @@ int rpmsg_register_callback(FAR void *priv,
|
||||
FAR struct rpmsg_s *rpmsg =
|
||||
metal_container_of(node, struct rpmsg_s, node);
|
||||
|
||||
if (rpmsg->rdev->ns_unbind_cb == NULL)
|
||||
if (!rpmsg->init)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -307,7 +307,7 @@ void rpmsg_unregister_callback(FAR void *priv,
|
||||
FAR struct rpmsg_s *rpmsg =
|
||||
metal_container_of(pnode, struct rpmsg_s, node);
|
||||
|
||||
if (rpmsg->rdev->ns_unbind_cb)
|
||||
if (rpmsg->init)
|
||||
{
|
||||
device_destroy(rpmsg->rdev, priv);
|
||||
}
|
||||
@ -397,6 +397,7 @@ void rpmsg_device_created(FAR struct rpmsg_s *rpmsg)
|
||||
}
|
||||
}
|
||||
|
||||
rpmsg->init = true;
|
||||
nxrmutex_unlock(&g_rpmsg_lock);
|
||||
|
||||
#ifdef CONFIG_RPMSG_PING
|
||||
|
@ -47,6 +47,7 @@
|
||||
|
||||
struct rpmsg_s
|
||||
{
|
||||
bool init;
|
||||
struct metal_list bind;
|
||||
rmutex_t lock;
|
||||
struct metal_list node;
|
||||
|
Loading…
Reference in New Issue
Block a user