mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 05:42:05 +08:00
sim: add global work queue to replace HPWORK
rpmsg work in hpwork are waiting for remote buffer, remote get buffer and callback, but callback also in hpwork, deadlock occurs here. now we move periodic work to global work queue instead of hpwork to fix deadlock. Signed-off-by: guanyi3 <guanyi3@xiaomi.com>
This commit is contained in:
@@ -1132,14 +1132,14 @@ fail:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sim_audio_work_handler(FAR void *arg)
|
||||
static void sim_audio_work(FAR void *arg)
|
||||
{
|
||||
struct sim_audio_s *priv = (struct sim_audio_s *)arg;
|
||||
|
||||
sim_audio_process(priv);
|
||||
|
||||
work_queue_next(HPWORK, &priv->work, sim_audio_work_handler, priv,
|
||||
SIM_AUDIO_PERIOD);
|
||||
work_queue_next_wq(g_work_queue, &priv->work, sim_audio_work, priv,
|
||||
SIM_AUDIO_PERIOD);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1169,8 +1169,8 @@ struct audio_lowerhalf_s *sim_audio_initialize(bool playback, bool offload)
|
||||
}
|
||||
|
||||
memset(&priv->work, 0, sizeof(struct work_s));
|
||||
work_queue(HPWORK, &priv->work, sim_audio_work_handler, priv,
|
||||
SIM_AUDIO_PERIOD);
|
||||
work_queue_wq(g_work_queue, &priv->work, sim_audio_work, priv,
|
||||
SIM_AUDIO_PERIOD);
|
||||
|
||||
/* Setting default config */
|
||||
|
||||
|
||||
@@ -59,6 +59,12 @@ static struct work_s g_x11event_work; /* Watchdog for event loop */
|
||||
static struct work_s g_x11update_work; /* Watchdog for update loop */
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
struct kwork_wqueue_s *g_work_queue;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
@@ -92,8 +98,8 @@ static void sim_init_cmdline(void)
|
||||
static void sim_x11event_work(void *arg)
|
||||
{
|
||||
sim_x11events();
|
||||
work_queue_next(HPWORK, &g_x11event_work, sim_x11event_work,
|
||||
NULL, SIM_X11EVENT_PERIOD);
|
||||
work_queue_next_wq(g_work_queue, &g_x11event_work, sim_x11event_work,
|
||||
NULL, SIM_X11EVENT_PERIOD);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -109,8 +115,8 @@ static void sim_x11event_work(void *arg)
|
||||
static void sim_x11update_work(void *arg)
|
||||
{
|
||||
sim_x11loop();
|
||||
work_queue_next(HPWORK, &g_x11update_work, sim_x11update_work,
|
||||
NULL, SIM_X11UPDATE_PERIOD);
|
||||
work_queue_next_wq(g_work_queue, &g_x11update_work, sim_x11update_work,
|
||||
NULL, SIM_X11UPDATE_PERIOD);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -246,6 +252,10 @@ void up_initialize(void)
|
||||
host_init_cwd();
|
||||
#endif
|
||||
|
||||
g_work_queue = work_queue_create("sim_loop_wq",
|
||||
CONFIG_SCHED_HPWORKPRIORITY, NULL,
|
||||
CONFIG_SCHED_HPWORKSTACKSIZE, 1u);
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
/* Initialize the power management subsystem. This MCU-specific function
|
||||
* must be called *very* early in the initialization sequence *before* any
|
||||
@@ -318,12 +328,12 @@ void up_initialize(void)
|
||||
|
||||
#if defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK) || \
|
||||
defined(CONFIG_SIM_BUTTONS)
|
||||
work_queue(HPWORK, &g_x11event_work, sim_x11event_work,
|
||||
NULL, SIM_X11EVENT_PERIOD);
|
||||
work_queue_wq(g_work_queue, &g_x11event_work, sim_x11event_work,
|
||||
NULL, SIM_X11EVENT_PERIOD);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SIM_X11FB
|
||||
work_queue(HPWORK, &g_x11update_work, sim_x11update_work,
|
||||
NULL, SIM_X11UPDATE_PERIOD);
|
||||
work_queue_wq(g_work_queue, &g_x11update_work, sim_x11update_work,
|
||||
NULL, SIM_X11UPDATE_PERIOD);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -198,6 +198,7 @@ struct i2c_master_s;
|
||||
|
||||
extern int g_argc;
|
||||
extern char **g_argv;
|
||||
extern struct kwork_wqueue_s *g_work_queue;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
|
||||
@@ -278,8 +278,8 @@ static void sim_netdev_work(void *arg)
|
||||
netdev_lower_rxready(dev);
|
||||
}
|
||||
|
||||
work_queue_next(HPWORK, &priv->work, sim_netdev_work, arg,
|
||||
SIM_NETDEV_PERIOD);
|
||||
work_queue_next_wq(g_work_queue, &priv->work, sim_netdev_work, arg,
|
||||
SIM_NETDEV_PERIOD);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -330,9 +330,9 @@ int sim_netdriver_init(void)
|
||||
|
||||
netdev_lower_register(dev, devidx < CONFIG_SIM_WIFIDEV_NUMBER ?
|
||||
NET_LL_IEEE80211 : NET_LL_ETHERNET);
|
||||
work_queue(HPWORK, &g_sim_dev[devidx].work,
|
||||
sim_netdev_work, &g_sim_dev[devidx],
|
||||
SIM_NETDEV_PERIOD);
|
||||
work_queue_wq(g_work_queue, &g_sim_dev[devidx].work,
|
||||
sim_netdev_work, &g_sim_dev[devidx],
|
||||
SIM_NETDEV_PERIOD);
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
@@ -189,8 +189,8 @@ static void sim_rpmsg_virtio_work(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
work_queue_next(HPWORK, &dev->work, sim_rpmsg_virtio_work, dev,
|
||||
SIM_RPMSG_VIRTIO_WORK_DELAY);
|
||||
work_queue_next_wq(g_work_queue, &dev->work, sim_rpmsg_virtio_work, dev,
|
||||
SIM_RPMSG_VIRTIO_WORK_DELAY);
|
||||
}
|
||||
|
||||
static int sim_rpmsg_virtio_notify(struct rpmsg_virtio_lite_s *dev,
|
||||
@@ -252,6 +252,6 @@ int sim_rpmsg_virtio_init(const char *shmemname, const char *cpuname,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return work_queue(HPWORK, &priv->work, sim_rpmsg_virtio_work, priv,
|
||||
SIM_RPMSG_VIRTIO_WORK_DELAY);
|
||||
return work_queue_wq(g_work_queue, &priv->work, sim_rpmsg_virtio_work,
|
||||
priv, 0);
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ static void sim_rptun_check_reset(struct sim_rptun_dev_s *priv)
|
||||
}
|
||||
}
|
||||
|
||||
static void sim_rptun_work(wdparm_t arg)
|
||||
static void sim_rptun_work(void *arg)
|
||||
{
|
||||
struct sim_rptun_dev_s *dev = (struct sim_rptun_dev_s *)arg;
|
||||
|
||||
@@ -358,8 +358,8 @@ static void sim_rptun_work(wdparm_t arg)
|
||||
}
|
||||
}
|
||||
|
||||
work_queue_next(HPWORK, &dev->work, sim_rptun_work, dev,
|
||||
SIM_RPTUN_WORK_DELAY);
|
||||
work_queue_next_wq(g_work_queue, &dev->work, sim_rptun_work, dev,
|
||||
SIM_RPTUN_WORK_DELAY);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -406,6 +406,5 @@ int sim_rptun_init(const char *shmemname, const char *cpuname, int master)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return work_queue(HPWORK, &dev->work, sim_rptun_work, dev,
|
||||
SIM_RPTUN_WORK_DELAY);
|
||||
return work_queue_wq(g_work_queue, &dev->work, sim_rptun_work, dev, 0);
|
||||
}
|
||||
|
||||
@@ -1080,8 +1080,8 @@ static void sim_usbdev_work(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
work_queue_next(HPWORK, &priv->work, sim_usbdev_work, priv,
|
||||
SIM_USB_PERIOD);
|
||||
work_queue_next_wq(g_work_queue, &priv->work, sim_usbdev_work, priv,
|
||||
SIM_USB_PERIOD);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1139,7 +1139,8 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
|
||||
#endif
|
||||
}
|
||||
|
||||
work_queue(HPWORK, &priv->work, sim_usbdev_work, priv, SIM_USB_PERIOD);
|
||||
work_queue_wq(g_work_queue, &priv->work, sim_usbdev_work, priv,
|
||||
SIM_USB_PERIOD);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -710,7 +710,7 @@ static void sim_usbhost_rqcomplete(struct sim_usbhost_s *drvr)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_usbhost_interrupt
|
||||
* Name: sim_usbhost_work
|
||||
****************************************************************************/
|
||||
|
||||
static void sim_usbhost_work(void *arg)
|
||||
@@ -779,8 +779,8 @@ static void sim_usbhost_work(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
work_queue_next(HPWORK, &priv->work, sim_usbhost_work, priv,
|
||||
SIM_USBHOST_PERIOD);
|
||||
work_queue_next_wq(g_work_queue, &priv->work, sim_usbhost_work, priv,
|
||||
SIM_USBHOST_PERIOD);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -853,7 +853,8 @@ int sim_usbhost_initialize(void)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
work_queue(HPWORK, &priv->work, sim_usbhost_work, priv, SIM_USBHOST_PERIOD);
|
||||
work_queue_wq(g_work_queue, &priv->work, sim_usbhost_work, priv,
|
||||
SIM_USBHOST_PERIOD);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,9 @@
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/net/usrsock.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
|
||||
#include "sim_internal.h"
|
||||
#include "sim_hostusrsock.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -395,8 +397,8 @@ static const usrsock_handler_t g_usrsock_handler[] =
|
||||
|
||||
static void sim_usrsock_work(void *arg)
|
||||
{
|
||||
work_queue(HPWORK, &g_usrsock.work, (void *)sim_usrsock_work,
|
||||
NULL, SIM_USRSOCK_PERIOD);
|
||||
work_queue_next_wq(g_work_queue, &g_usrsock.work, sim_usrsock_work,
|
||||
NULL, SIM_USRSOCK_PERIOD);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -410,8 +412,8 @@ int usrsock_event_callback(int16_t usockid, uint16_t events)
|
||||
|
||||
void usrsock_register(void)
|
||||
{
|
||||
work_queue(HPWORK, &g_usrsock.work, (void *)sim_usrsock_work,
|
||||
NULL, SIM_USRSOCK_PERIOD);
|
||||
work_queue_wq(g_work_queue, &g_usrsock.work, sim_usrsock_work,
|
||||
NULL, SIM_USRSOCK_PERIOD);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user