From e404fe4b8d11db438dd412db60668d02daed7cce Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Tue, 24 Feb 2026 16:12:05 +0800 Subject: [PATCH] rndis.c: move ifup in setconfig to the work queue Move network interface up operation (ifup) to work queue in RNDIS USB device driver to avoid calling netdev_carrier_on API in interrupt context. Signed-off-by: zhanghongyu --- drivers/usbdev/rndis.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/usbdev/rndis.c b/drivers/usbdev/rndis.c index 4b20e5a3855..efefb8fb787 100644 --- a/drivers/usbdev/rndis.c +++ b/drivers/usbdev/rndis.c @@ -2752,6 +2752,22 @@ static void usbclass_resetconfig(FAR struct rndis_dev_s *priv) } } +/**************************************************************************** + * Name: rndis_carrier_on_work + * + * Description: + * Schedule to work queue because netdev_carrier_on API can't be used in + * interrupt context + * + ****************************************************************************/ + +static void rndis_carrier_on_work(FAR void *arg) +{ + FAR struct rndis_dev_s *priv = arg; + + netdev_carrier_on(&priv->netdev); +} + /**************************************************************************** * Name: usbclass_setconfig * @@ -2860,10 +2876,16 @@ static int usbclass_setconfig(FAR struct rndis_dev_s *priv, uint8_t config) /* We are successfully configured */ priv->config = config; - if (priv->netdev.d_ifup(&priv->netdev) == OK) - { - priv->netdev.d_flags |= IFF_UP; - } + + priv->netdev.d_flags |= IFF_UP; + + /* Schedule to work queue because netdev_carrier_on API can't be used in + * interrupt context. Since the current network card is not yet RUNNING, + * it will not be selected to trigger rndis_txavail, so pollwork can be + * reused. + */ + + work_queue(LPWORK, &priv->pollwork, rndis_carrier_on_work, priv, 0); return OK;