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 <wangyongrong@xiaomi.com>
This commit is contained in:
wangyongrong 2024-05-16 15:32:01 +08:00 committed by archer
parent 842486ff52
commit ff399054c1
4 changed files with 22 additions and 22 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;