rptun: change lock to recursive lock
[ap] [ 6] [<0x2c351a18>] arm_switchcontext+0xc/0x10 [ap] [ 6] [<0x2c321b36>] sem_wait+0x5a/0xbc [ap] [ 6] [<0x2c333d68>] rptun_ns_bind+0x2c/0x128 [ap] [ 6] [<0x2c5f863c>] rpmsg_virtio_ns_callback+0x9c/0x140 [ap] [ 6] [<0x2c5f84a6>] rpmsg_virtio_rx_callback+0xba/0x1b4 [ap] [ 6] [<0x2c5f7b38>] rproc_virtio_notified+0x44/0x5c [ap] [ 6] [<0x2c5f7504>] remoteproc_get_notification+0x1c/0x2c [ap] [ 6] [<0x2c33432c>] rptun_wait_tx+0x11c/0x160 [ap] [ 6] [<0x2c5f8734>] rpmsg_virtio_get_tx_payload_buffer+0x54/0x100 [ap] [ 6] [<0x2c5f87f2>] rpmsg_virtio_send_offchannel_raw+0x12/0x6c [ap] [ 6] [<0x2c321b4c>] sem_wait+0x70/0xbc [ap] [ 6] [<0x2c5f8166>] rpmsg_create_ept+0x102/0x1a4 [ap] [ 6] [<0x2c5eafcc>] rpmsgfs_device_created+0x44/0x5c [ap] [ 6] [<0x2c33407c>] rptun_dev_start.isra.0+0x218/0x3ac [ap] [ 6] [<0x2c3343f4>] rptun_thread+0x84/0x164 [ap] [ 6] [<0x2c323762>] nxtask_start+0x3a/0x60 Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
8a3683fb9f
commit
5dcc905f27
@ -54,9 +54,6 @@
|
||||
# define ALIGN_UP(s, a) (((s) + (a) - 1) & ~((a) - 1))
|
||||
#endif
|
||||
|
||||
#define rptun_lock() nxrmutex_lock(&g_rptunlock)
|
||||
#define rptun_unlock() nxrmutex_unlock(&g_rptunlock)
|
||||
|
||||
#define RPTUNIOC_NONE 0
|
||||
|
||||
/****************************************************************************
|
||||
@ -71,7 +68,7 @@ struct rptun_priv_s
|
||||
struct rpmsg_virtio_shm_pool tx_shpool;
|
||||
struct rpmsg_virtio_shm_pool rx_shpool;
|
||||
struct metal_list bind;
|
||||
mutex_t lock;
|
||||
rmutex_t lock;
|
||||
struct metal_list node;
|
||||
sem_t sem;
|
||||
unsigned long cmd;
|
||||
@ -199,8 +196,8 @@ static struct image_store_ops g_rptun_storeops =
|
||||
static METAL_DECLARE_LIST(g_rptun_cb);
|
||||
static METAL_DECLARE_LIST(g_rptun_priv);
|
||||
|
||||
static mutex_t g_rptun_lockcb = NXMUTEX_INITIALIZER;
|
||||
static mutex_t g_rptun_lockpriv = NXMUTEX_INITIALIZER;
|
||||
static rmutex_t g_rptun_lockcb = NXRMUTEX_INITIALIZER;
|
||||
static rmutex_t g_rptun_lockpriv = NXRMUTEX_INITIALIZER;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -483,7 +480,7 @@ static void rptun_ns_bind(FAR struct rpmsg_device *rdev,
|
||||
FAR struct rptun_bind_s *bind;
|
||||
FAR struct metal_list *node;
|
||||
|
||||
nxmutex_lock(&g_rptun_lockcb);
|
||||
nxrmutex_lock(&g_rptun_lockcb);
|
||||
|
||||
metal_list_for_each(&g_rptun_cb, node)
|
||||
{
|
||||
@ -495,7 +492,7 @@ static void rptun_ns_bind(FAR struct rpmsg_device *rdev,
|
||||
rpmsg_bind_cb_t ns_bind = cb->ns_bind;
|
||||
FAR void *cb_priv = cb->priv;
|
||||
|
||||
nxmutex_unlock(&g_rptun_lockcb);
|
||||
nxrmutex_unlock(&g_rptun_lockcb);
|
||||
|
||||
DEBUGASSERT(ns_bind != NULL);
|
||||
ns_bind(rdev, cb_priv, name, dest);
|
||||
@ -504,7 +501,7 @@ static void rptun_ns_bind(FAR struct rpmsg_device *rdev,
|
||||
}
|
||||
}
|
||||
|
||||
nxmutex_unlock(&g_rptun_lockcb);
|
||||
nxrmutex_unlock(&g_rptun_lockcb);
|
||||
|
||||
bind = kmm_malloc(sizeof(struct rptun_bind_s));
|
||||
if (bind == NULL)
|
||||
@ -515,9 +512,9 @@ static void rptun_ns_bind(FAR struct rpmsg_device *rdev,
|
||||
bind->dest = dest;
|
||||
strlcpy(bind->name, name, RPMSG_NAME_SIZE);
|
||||
|
||||
nxmutex_lock(&priv->lock);
|
||||
nxrmutex_lock(&priv->lock);
|
||||
metal_list_add_tail(&priv->bind, &bind->node);
|
||||
nxmutex_unlock(&priv->lock);
|
||||
nxrmutex_unlock(&priv->lock);
|
||||
}
|
||||
|
||||
static void rptun_ns_unbind(FAR struct rpmsg_device *rdev,
|
||||
@ -526,7 +523,7 @@ static void rptun_ns_unbind(FAR struct rpmsg_device *rdev,
|
||||
FAR struct rptun_priv_s *priv = rptun_get_priv_by_rdev(rdev);
|
||||
FAR struct metal_list *node;
|
||||
|
||||
nxmutex_lock(&priv->lock);
|
||||
nxrmutex_lock(&priv->lock);
|
||||
|
||||
metal_list_for_each(&priv->bind, node)
|
||||
{
|
||||
@ -542,7 +539,7 @@ static void rptun_ns_unbind(FAR struct rpmsg_device *rdev,
|
||||
}
|
||||
}
|
||||
|
||||
nxmutex_unlock(&priv->lock);
|
||||
nxrmutex_unlock(&priv->lock);
|
||||
}
|
||||
|
||||
static int rptun_dev_start(FAR struct remoteproc *rproc)
|
||||
@ -706,7 +703,7 @@ static int rptun_dev_start(FAR struct remoteproc *rproc)
|
||||
|
||||
/* Broadcast device_created to all registers */
|
||||
|
||||
nxmutex_lock(&g_rptun_lockcb);
|
||||
nxrmutex_lock(&g_rptun_lockcb);
|
||||
|
||||
metal_list_for_each(&g_rptun_cb, node)
|
||||
{
|
||||
@ -717,13 +714,13 @@ static int rptun_dev_start(FAR struct remoteproc *rproc)
|
||||
}
|
||||
}
|
||||
|
||||
nxmutex_unlock(&g_rptun_lockcb);
|
||||
nxrmutex_unlock(&g_rptun_lockcb);
|
||||
|
||||
/* Add priv to list */
|
||||
|
||||
nxmutex_lock(&g_rptun_lockpriv);
|
||||
nxrmutex_lock(&g_rptun_lockpriv);
|
||||
metal_list_add_tail(&g_rptun_priv, &priv->node);
|
||||
nxmutex_unlock(&g_rptun_lockpriv);
|
||||
nxrmutex_unlock(&g_rptun_lockpriv);
|
||||
|
||||
virtqueue_enable_cb(priv->rvdev.svq);
|
||||
|
||||
@ -749,13 +746,13 @@ static int rptun_dev_stop(FAR struct remoteproc *rproc)
|
||||
|
||||
/* Remove priv from list */
|
||||
|
||||
nxmutex_lock(&g_rptun_lockpriv);
|
||||
nxrmutex_lock(&g_rptun_lockpriv);
|
||||
metal_list_del(&priv->node);
|
||||
nxmutex_unlock(&g_rptun_lockpriv);
|
||||
nxrmutex_unlock(&g_rptun_lockpriv);
|
||||
|
||||
/* Broadcast device_destroy to all registers */
|
||||
|
||||
nxmutex_lock(&g_rptun_lockcb);
|
||||
nxrmutex_lock(&g_rptun_lockcb);
|
||||
|
||||
metal_list_for_each(&g_rptun_cb, node)
|
||||
{
|
||||
@ -766,7 +763,7 @@ static int rptun_dev_stop(FAR struct remoteproc *rproc)
|
||||
}
|
||||
}
|
||||
|
||||
nxmutex_unlock(&g_rptun_lockcb);
|
||||
nxrmutex_unlock(&g_rptun_lockcb);
|
||||
|
||||
/* Remote proc stop and shutdown */
|
||||
|
||||
@ -1046,7 +1043,7 @@ int rpmsg_register_callback(FAR void *priv_,
|
||||
cb->ns_match = ns_match;
|
||||
cb->ns_bind = ns_bind;
|
||||
|
||||
nxmutex_lock(&g_rptun_lockpriv);
|
||||
nxrmutex_lock(&g_rptun_lockpriv);
|
||||
|
||||
metal_list_for_each(&g_rptun_priv, node)
|
||||
{
|
||||
@ -1065,7 +1062,7 @@ int rpmsg_register_callback(FAR void *priv_,
|
||||
|
||||
DEBUGASSERT(ns_match != NULL);
|
||||
again:
|
||||
nxmutex_lock(&priv->lock);
|
||||
nxrmutex_lock(&priv->lock);
|
||||
|
||||
metal_list_for_each(&priv->bind, bnode)
|
||||
{
|
||||
@ -1075,7 +1072,7 @@ again:
|
||||
if (ns_match(&priv->rvdev.rdev, priv_, bind->name, bind->dest))
|
||||
{
|
||||
metal_list_del(bnode);
|
||||
nxmutex_unlock(&priv->lock);
|
||||
nxrmutex_unlock(&priv->lock);
|
||||
|
||||
ns_bind(&priv->rvdev.rdev, priv_, bind->name, bind->dest);
|
||||
kmm_free(bind);
|
||||
@ -1083,14 +1080,14 @@ again:
|
||||
}
|
||||
}
|
||||
|
||||
nxmutex_unlock(&priv->lock);
|
||||
nxrmutex_unlock(&priv->lock);
|
||||
}
|
||||
|
||||
nxmutex_unlock(&g_rptun_lockpriv);
|
||||
nxrmutex_unlock(&g_rptun_lockpriv);
|
||||
|
||||
nxmutex_lock(&g_rptun_lockcb);
|
||||
nxrmutex_lock(&g_rptun_lockcb);
|
||||
metal_list_add_tail(&g_rptun_cb, &cb->node);
|
||||
nxmutex_unlock(&g_rptun_lockcb);
|
||||
nxrmutex_unlock(&g_rptun_lockcb);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1104,7 +1101,7 @@ void rpmsg_unregister_callback(FAR void *priv_,
|
||||
FAR struct metal_list *node;
|
||||
FAR struct metal_list *pnode;
|
||||
|
||||
nxmutex_lock(&g_rptun_lockcb);
|
||||
nxrmutex_lock(&g_rptun_lockcb);
|
||||
|
||||
metal_list_for_each(&g_rptun_cb, node)
|
||||
{
|
||||
@ -1124,11 +1121,11 @@ void rpmsg_unregister_callback(FAR void *priv_,
|
||||
}
|
||||
}
|
||||
|
||||
nxmutex_unlock(&g_rptun_lockcb);
|
||||
nxrmutex_unlock(&g_rptun_lockcb);
|
||||
|
||||
if (device_destroy)
|
||||
{
|
||||
nxmutex_lock(&g_rptun_lockpriv);
|
||||
nxrmutex_lock(&g_rptun_lockpriv);
|
||||
|
||||
metal_list_for_each(&g_rptun_priv, pnode)
|
||||
{
|
||||
@ -1139,7 +1136,7 @@ void rpmsg_unregister_callback(FAR void *priv_,
|
||||
device_destroy(&priv->rvdev.rdev, priv_);
|
||||
}
|
||||
|
||||
nxmutex_unlock(&g_rptun_lockpriv);
|
||||
nxrmutex_unlock(&g_rptun_lockpriv);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1171,7 +1168,7 @@ int rptun_initialize(FAR struct rptun_dev_s *dev)
|
||||
|
||||
remoteproc_init(&priv->rproc, &g_rptun_ops, priv);
|
||||
metal_list_init(&priv->bind);
|
||||
nxmutex_init(&priv->lock);
|
||||
nxrmutex_init(&priv->lock);
|
||||
|
||||
snprintf(name, sizeof(name), "/dev/rptun/%s", RPTUN_GET_CPUNAME(dev));
|
||||
ret = register_driver(name, &g_rptun_devops, 0222, priv);
|
||||
@ -1219,7 +1216,7 @@ int rptun_initialize(FAR struct rptun_dev_s *dev)
|
||||
return OK;
|
||||
|
||||
err_driver:
|
||||
nxmutex_destroy(&priv->lock);
|
||||
nxrmutex_destroy(&priv->lock);
|
||||
kmm_free(priv);
|
||||
|
||||
err_mem:
|
||||
|
Loading…
Reference in New Issue
Block a user