From b5ebb8c06db4e541630313c8ae6d280a7a2f91cf Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Sat, 3 Aug 2024 18:27:44 +0800 Subject: [PATCH] drivers/rptun/rptun.c: move headrx out of CONFIG_RPTUN_PM headrx is very convient to check weather current core miss interrupt by comparing the headrx with the rx vring avail.idx for slave side or rx vring used.idx for master side. So move headrx out of the CONFIG_RPTUN_PM range. Signed-off-by: Bowen Wang --- drivers/rptun/rptun.c | 54 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c index 78e3d339f22..a9bd1b3ed53 100644 --- a/drivers/rptun/rptun.c +++ b/drivers/rptun/rptun.c @@ -70,9 +70,9 @@ struct rptun_priv_s sem_t semtx; sem_t semrx; pid_t tid; + uint16_t headrx; #ifdef CONFIG_RPTUN_PM struct pm_wakelock_s wakelock; - uint16_t headrx; struct wdog_s wdog; #endif }; @@ -268,28 +268,6 @@ static inline void rptun_pm_action(FAR struct rptun_priv_s *priv, leave_critical_section(flags); } -static inline void rptun_update_rx(FAR struct rptun_priv_s *priv) -{ - FAR struct rpmsg_virtio_device *rvdev = &priv->rvdev; - FAR struct virtqueue *rvq = rvdev->rvq; - - if (priv->rproc.state != RPROC_RUNNING) - { - return; - } - - if (rpmsg_virtio_get_role(rvdev) == RPMSG_HOST) - { - RPTUN_INVALIDATE(rvq->vq_ring.used->idx); - priv->headrx = rvq->vq_ring.used->idx; - } - else - { - RPTUN_INVALIDATE(rvq->vq_ring.avail->idx); - priv->headrx = rvq->vq_ring.avail->idx; - } -} - static inline bool rptun_available_rx(FAR struct rptun_priv_s *priv) { FAR struct rpmsg_virtio_device *rvdev = &priv->rvdev; @@ -312,10 +290,31 @@ static inline bool rptun_available_rx(FAR struct rptun_priv_s *priv) #else # define rptun_pm_action(priv, stay) -# define rptun_update_rx(priv) # define rptun_available_rx(priv) true #endif +static inline void rptun_update_rx(FAR struct rptun_priv_s *priv) +{ + FAR struct rpmsg_virtio_device *rvdev = &priv->rvdev; + FAR struct virtqueue *rvq = rvdev->rvq; + + if (priv->rproc.state != RPROC_RUNNING) + { + return; + } + + if (rpmsg_virtio_get_role(rvdev) == RPMSG_HOST) + { + RPTUN_INVALIDATE(rvq->vq_ring.used->idx); + priv->headrx = rvq->vq_ring.used->idx; + } + else + { + RPTUN_INVALIDATE(rvq->vq_ring.avail->idx); + priv->headrx = rvq->vq_ring.avail->idx; + } +} + static void rptun_start_worker(FAR void *arg) { FAR struct rptun_priv_s *priv = arg; @@ -665,6 +664,9 @@ static void rptun_dump(FAR struct rpmsg_s *rpmsg) FAR struct metal_list *node; bool needlock = true; + metal_log(METAL_LOG_EMERGENCY, "Remote: %s headrx %d\n", + RPTUN_GET_CPUNAME(priv->dev), priv->headrx); + if (!rvdev->vdev) { return; @@ -708,10 +710,6 @@ static void rptun_dump(FAR struct rpmsg_s *rpmsg) { metal_mutex_release(&rdev->lock); } - -#ifdef CONFIG_RPTUN_PM - metal_log(METAL_LOG_EMERGENCY, "rptun headrx %d\n", priv->headrx); -#endif } static FAR const char *rptun_get_local_cpuname(FAR struct rpmsg_s *rpmsg)