This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit bf35334f040733a2734b788db3052617a40b0764 Author: Yongrong Wang <[email protected]> AuthorDate: Mon Aug 4 14:08:50 2025 +0800 drivers/rpmsg/rpmsg_virtio: record the tx head index for the dump rpmsg_virtio_dump() printed the rx head index but not the tx one, so a lost tx interrupt could not be told apart from a peer that stopped consuming. Track headtx in the tx notify path and print it next to headrx. Signed-off-by: Yongrong Wang <[email protected]> Signed-off-by: Bowen Wang <[email protected]> --- drivers/rpmsg/rpmsg_virtio.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/rpmsg/rpmsg_virtio.c b/drivers/rpmsg/rpmsg_virtio.c index 962bf38bcec..60dbbbc6b3d 100644 --- a/drivers/rpmsg/rpmsg_virtio.c +++ b/drivers/rpmsg/rpmsg_virtio.c @@ -73,6 +73,7 @@ struct rpmsg_virtio_priv_s pid_t tid; vq_notify notifytx; uint16_t headrx; + uint16_t headtx; #ifdef CONFIG_RPMSG_VIRTIO_PM spinlock_t lock; struct pm_wakelock_s wakelock; @@ -481,8 +482,10 @@ static void rpmsg_virtio_dump(FAR struct rpmsg_s *rpmsg) FAR struct rpmsg_device *rdev = &rvdev->rdev; bool needunlock = false; - metal_log(METAL_LOG_EMERGENCY, "Local: %s Remote: %s Headrx %u\n", - priv->rpmsg.local_cpuname, priv->rpmsg.cpuname, priv->headrx); + metal_log(METAL_LOG_EMERGENCY, + "Local: %s Remote: %s Headrx %u Headtx %u\n", + priv->rpmsg.local_cpuname, priv->rpmsg.cpuname, priv->headrx, + priv->headtx); if (!rvdev->vdev) { @@ -540,6 +543,23 @@ static void rpmsg_virtio_update_rx(FAR struct rpmsg_virtio_priv_s *priv, } } +static void rpmsg_virtio_update_tx(FAR struct rpmsg_virtio_priv_s *priv) +{ + FAR struct rpmsg_virtio_device *rvdev = &priv->rvdev; + FAR struct virtqueue *svq = rvdev->svq; + + if (rpmsg_virtio_get_role(rvdev) == RPMSG_HOST) + { + RPMSG_VIRTIO_INVALIDATE(svq->vq_ring.avail->idx); + priv->headtx = svq->vq_ring.avail->idx; + } + else + { + RPMSG_VIRTIO_INVALIDATE(svq->vq_ring.used->idx); + priv->headtx = svq->vq_ring.used->idx; + } +} + /**************************************************************************** * Name: rpmsg_virtio_rx_callback ****************************************************************************/ @@ -586,6 +606,7 @@ static void rpmsg_virtio_tx_notify(FAR struct virtqueue *vq) * enter to low power mode until all the buffers are returned by peer. */ + rpmsg_virtio_update_tx(priv); rpmsg_virtio_pm_action(priv, true); priv->notifytx(vq); }
