mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
driver/usbdev: fix cdcacm wr container missing issue
in cdcacm_sndpacket, If `if (priv->wrcontainer)` is true, then `priv->wrcontainer` is set to NULL. If an interrupt occurs before `priv->wrcontainer` is reassigned after being NULL, `priv->wrcontainer` will be reassigned once during the interrupt, and `nwrq--` will be called, but no data will be sent at this time. Only when data is sent by calling `txint` will `priv->wrcontainer` be reassigned and `nwrq--` called again. This causes the issue. Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
This commit is contained in:
@@ -464,15 +464,12 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
|||||||
spin_unlock_irqrestore_nopreempt(&priv->lock, flags);
|
spin_unlock_irqrestore_nopreempt(&priv->lock, flags);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = spin_lock_irqsave(&priv->lock);
|
|
||||||
priv->wrcontainer = NULL;
|
|
||||||
spin_unlock_irqrestore(&priv->lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flags = spin_lock_irqsave_nopreempt(&priv->lock);
|
||||||
|
priv->wrcontainer = NULL;
|
||||||
if (!sq_empty(&priv->txfree))
|
if (!sq_empty(&priv->txfree))
|
||||||
{
|
{
|
||||||
flags = spin_lock_irqsave_nopreempt(&priv->lock);
|
|
||||||
priv->wrcontainer = (FAR struct cdcacm_wrreq_s *)
|
priv->wrcontainer = (FAR struct cdcacm_wrreq_s *)
|
||||||
sq_remfirst(&priv->txfree);
|
sq_remfirst(&priv->txfree);
|
||||||
dev->xmit.buffer = (FAR char *)priv->wrcontainer->req->buf;
|
dev->xmit.buffer = (FAR char *)priv->wrcontainer->req->buf;
|
||||||
@@ -480,8 +477,9 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
|||||||
dev->xmit.head = 0;
|
dev->xmit.head = 0;
|
||||||
dev->xmit.tail = 0;
|
dev->xmit.tail = 0;
|
||||||
uart_datasent(dev);
|
uart_datasent(dev);
|
||||||
spin_unlock_irqrestore_nopreempt(&priv->lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spin_unlock_irqrestore_nopreempt(&priv->lock, flags);
|
||||||
#else
|
#else
|
||||||
if (!sq_empty(&priv->txfree))
|
if (!sq_empty(&priv->txfree))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user