From ff399054c12a07bdb3852f77a349ee4e3f919ecb Mon Sep 17 00:00:00 2001 From: wangyongrong Date: Thu, 16 May 2024 15:32:01 +0800 Subject: [PATCH] rptun/rpmsg_virtio: fix addrenv/raddrenv num error Buf fix, simple_addrenv assume the last addrenv in addrenv array be zero value Signed-off-by: wangyongrong --- arch/sim/src/sim/sim_rpmsg_virtio.c | 10 +++++----- arch/sim/src/sim/sim_rptun.c | 2 +- drivers/rpmsg/rpmsg_virtio_ivshmem.c | 10 +++++----- drivers/rptun/rptun_ivshmem.c | 22 +++++++++++----------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/arch/sim/src/sim/sim_rpmsg_virtio.c b/arch/sim/src/sim/sim_rpmsg_virtio.c index 38100e8a73..e06c6f11fc 100644 --- a/arch/sim/src/sim/sim_rpmsg_virtio.c +++ b/arch/sim/src/sim/sim_rpmsg_virtio.c @@ -63,7 +63,7 @@ struct sim_rpmsg_virtio_dev_s int master; uint32_t seq; struct sim_rpmsg_virtio_shmem_s *shmem; - struct simple_addrenv_s addrenv; + struct simple_addrenv_s addrenv[2]; char cpuname[RPMSG_NAME_SIZE + 1]; char shmemname[RPMSG_NAME_SIZE + 1]; @@ -127,11 +127,11 @@ sim_rpmsg_virtio_get_resource(struct rpmsg_virtio_s *dev) usleep(1000); } - priv->addrenv.va = (uintptr_t)priv->shmem; - priv->addrenv.pa = priv->shmem->base; - priv->addrenv.size = sizeof(*priv->shmem); + priv->addrenv[0].va = (uintptr_t)priv->shmem; + priv->addrenv[0].pa = priv->shmem->base; + priv->addrenv[0].size = sizeof(*priv->shmem); - simple_addrenv_initialize(&priv->addrenv); + simple_addrenv_initialize(&priv->addrenv[0]); } return rsc; diff --git a/arch/sim/src/sim/sim_rptun.c b/arch/sim/src/sim/sim_rptun.c index 8c014b417d..fa55d282dc 100644 --- a/arch/sim/src/sim/sim_rptun.c +++ b/arch/sim/src/sim/sim_rptun.c @@ -170,7 +170,7 @@ sim_rptun_get_resource(struct rptun_dev_s *dev) priv->addrenv[0].pa = priv->shmem->base; priv->addrenv[0].size = sizeof(*priv->shmem); - simple_addrenv_initialize(priv->addrenv); + simple_addrenv_initialize(&priv->addrenv[0]); } return &priv->shmem->rsc; diff --git a/drivers/rpmsg/rpmsg_virtio_ivshmem.c b/drivers/rpmsg/rpmsg_virtio_ivshmem.c index ee8f7825d8..17595fc838 100644 --- a/drivers/rpmsg/rpmsg_virtio_ivshmem.c +++ b/drivers/rpmsg/rpmsg_virtio_ivshmem.c @@ -69,7 +69,7 @@ struct rpmsg_virtio_ivshmem_dev_s uint32_t seq; FAR struct rpmsg_virtio_ivshmem_mem_s *shmem; size_t shmem_size; - struct simple_addrenv_s addrenv; + struct simple_addrenv_s addrenv[2]; int master; char cpuname[RPMSG_NAME_SIZE + 1]; FAR struct pci_device_s *ivshmem; @@ -162,11 +162,11 @@ rpmsg_virtio_ivshmem_get_resource(FAR struct rpmsg_virtio_s *dev) usleep(1000); } - priv->addrenv.va = (uint64_t)(uintptr_t)priv->shmem; - priv->addrenv.pa = priv->shmem->basem; - priv->addrenv.size = priv->shmem_size; + priv->addrenv[0].va = (uint64_t)(uintptr_t)priv->shmem; + priv->addrenv[0].pa = priv->shmem->basem; + priv->addrenv[0].size = priv->shmem_size; - simple_addrenv_initialize(&priv->addrenv); + simple_addrenv_initialize(&priv->addrenv[0]); priv->shmem->basem = 0; } diff --git a/drivers/rptun/rptun_ivshmem.c b/drivers/rptun/rptun_ivshmem.c index db7ff20da0..ae4838d65b 100644 --- a/drivers/rptun/rptun_ivshmem.c +++ b/drivers/rptun/rptun_ivshmem.c @@ -70,8 +70,8 @@ struct rptun_ivshmem_dev_s uint32_t seq; FAR struct rptun_ivshmem_mem_s *shmem; size_t shmem_size; - struct simple_addrenv_s addrenv; - struct rptun_addrenv_s raddrenv; + struct simple_addrenv_s addrenv[2]; + struct rptun_addrenv_s raddrenv[2]; bool master; char cpuname[RPMSG_NAME_SIZE + 1]; FAR struct ivshmem_device_s *ivdev; @@ -137,7 +137,7 @@ rptun_ivshmem_get_addrenv(FAR struct rptun_dev_s *dev) { FAR struct rptun_ivshmem_dev_s *priv = (FAR struct rptun_ivshmem_dev_s *)dev; - return &priv->raddrenv; + return &priv->raddrenv[0]; } static FAR struct rptun_rsc_s * @@ -146,12 +146,12 @@ rptun_ivshmem_get_resource(FAR struct rptun_dev_s *dev) FAR struct rptun_ivshmem_dev_s *priv = (FAR struct rptun_ivshmem_dev_s *)dev; - priv->raddrenv.da = 0; - priv->raddrenv.size = priv->shmem_size; + priv->raddrenv[0].da = 0; + priv->raddrenv[0].size = priv->shmem_size; if (priv->master) { - priv->raddrenv.pa = (uintptr_t)priv->shmem; + priv->raddrenv[0].pa = (uintptr_t)priv->shmem; /* Wait untils salve is ready */ @@ -204,13 +204,13 @@ rptun_ivshmem_get_resource(FAR struct rptun_dev_s *dev) usleep(1000); } - priv->raddrenv.pa = (uintptr_t)priv->shmem->basem; + priv->raddrenv[0].pa = (uintptr_t)priv->shmem->basem; - priv->addrenv.va = (uint64_t)(uintptr_t)priv->shmem; - priv->addrenv.pa = priv->shmem->basem; - priv->addrenv.size = priv->shmem_size; + priv->addrenv[0].va = (uint64_t)(uintptr_t)priv->shmem; + priv->addrenv[0].pa = priv->shmem->basem; + priv->addrenv[0].size = priv->shmem_size; - simple_addrenv_initialize(&priv->addrenv); + simple_addrenv_initialize(&priv->addrenv[0]); } return &priv->shmem->rsc;