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:
yangsong8
2025-11-04 19:28:56 +08:00
committed by Xiang Xiao
parent 10180ab4eb
commit 04fbce9d40
+4 -6
View File
@@ -464,15 +464,12 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
spin_unlock_irqrestore_nopreempt(&priv->lock, flags);
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))
{
flags = spin_lock_irqsave_nopreempt(&priv->lock);
priv->wrcontainer = (FAR struct cdcacm_wrreq_s *)
sq_remfirst(&priv->txfree);
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.tail = 0;
uart_datasent(dev);
spin_unlock_irqrestore_nopreempt(&priv->lock, flags);
}
spin_unlock_irqrestore_nopreempt(&priv->lock, flags);
#else
if (!sq_empty(&priv->txfree))
{