mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 21:34:07 +08:00
rptun: rptun pm and rptun dump support cacheable memory
Should invalidate the memory when the data is located in shared memory and write by remote core. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
+19
-2
@@ -180,9 +180,20 @@ static const struct rpmsg_ops_s g_rptun_rpmsg_ops =
|
||||
static int rptun_buffer_nused(FAR struct rpmsg_virtio_device *rvdev, bool rx)
|
||||
{
|
||||
FAR struct virtqueue *vq = rx ? rvdev->rvq : rvdev->svq;
|
||||
uint16_t nused = vq->vq_ring.avail->idx - vq->vq_ring.used->idx;
|
||||
uint16_t nused;
|
||||
bool is_host = rpmsg_virtio_get_role(rvdev) == RPMSG_HOST;
|
||||
|
||||
if ((rpmsg_virtio_get_role(rvdev) == RPMSG_HOST) ^ rx)
|
||||
if (is_host)
|
||||
{
|
||||
RPTUN_INVALIDATE(vq->vq_ring.used->idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
RPTUN_INVALIDATE(vq->vq_ring.avail->idx);
|
||||
}
|
||||
|
||||
nused = vq->vq_ring.avail->idx - vq->vq_ring.used->idx;
|
||||
if (is_host ^ rx)
|
||||
{
|
||||
return nused;
|
||||
}
|
||||
@@ -269,10 +280,12 @@ static inline void rptun_update_rx(FAR struct rptun_priv_s *priv)
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -527,12 +540,16 @@ static void rptun_dump_buffer(FAR struct rpmsg_virtio_device *rvdev,
|
||||
{
|
||||
if ((rpmsg_virtio_get_role(rvdev) == RPMSG_HOST) ^ rx)
|
||||
{
|
||||
RPTUN_INVALIDATE(vq->vq_ring.used->idx);
|
||||
desc_idx = (vq->vq_ring.used->idx + i) & (vq->vq_nentries - 1);
|
||||
RPTUN_INVALIDATE(vq->vq_ring.avail->ring[desc_idx]);
|
||||
desc_idx = vq->vq_ring.avail->ring[desc_idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
RPTUN_INVALIDATE(vq->vq_ring.avail->idx);
|
||||
desc_idx = (vq->vq_ring.avail->idx + i) & (vq->vq_nentries - 1);
|
||||
RPTUN_INVALIDATE(vq->vq_ring.used->ring[desc_idx].id);
|
||||
desc_idx = vq->vq_ring.used->ring[desc_idx].id;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#ifdef CONFIG_RPTUN
|
||||
|
||||
#include <metal/cache.h>
|
||||
#include <nuttx/rpmsg/rpmsg.h>
|
||||
#include <openamp/remoteproc.h>
|
||||
#include <openamp/rpmsg_virtio.h>
|
||||
@@ -45,6 +46,11 @@
|
||||
#define RPTUNIOC_RESET _RPTUNIOC(102)
|
||||
|
||||
#define RPTUN_NOTIFY_ALL (UINT32_MAX - 0)
|
||||
#ifdef CONFIG_OPENAMP_CACHE
|
||||
# define RPTUN_INVALIDATE(x) metal_cache_invalidate(&x, sizeof(x))
|
||||
#else
|
||||
# define RPTUN_INVALIDATE(x)
|
||||
#endif
|
||||
|
||||
/* Access macros ************************************************************/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user