[PATCH] vbs: fix virtio_vq_index_get func handling of multi VQ concurrent request.


ong.hock.yu@...
 

Under multiple VQ use case, it is possible to have
concurrent requests. Added support to return multiple vq index from all vcpu.

Signed-off-by: Ong Hock Yu <ong.hock.yu@...>
---
drivers/vbs/vbs.c | 13 +++++++------
drivers/vbs/vbs_rng.c | 2 +-
include/linux/vbs/vbs.h | 3 ++-
3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/vbs/vbs.c b/drivers/vbs/vbs.c
index f644599..c6f55f2 100644
--- a/drivers/vbs/vbs.c
+++ b/drivers/vbs/vbs.c
@@ -145,9 +145,10 @@ long virtio_dev_deregister(struct virtio_dev_info *dev)
return 0;
}

-int virtio_vq_index_get(struct virtio_dev_info *dev, int req_cnt)
+int virtio_vqs_index_get(struct virtio_dev_info *dev, int req_cnt,
+ int *vqs_index, int max_vqs_index)
{
- int val = -1;
+ int idx = 0;
struct vhm_request *req;
int i;

@@ -159,7 +160,7 @@ int virtio_vq_index_get(struct virtio_dev_info *dev, int req_cnt)
return -EINVAL;
}

- for (i = 0; i < dev->_ctx.max_vcpu; i++) {
+ for (i = 0; i < dev->_ctx.max_vcpu && idx < max_vqs_index; i++) {
req = &dev->_ctx.req_buf[i];
if (req->valid && req->processed == REQ_STATE_PROCESSING &&
req->client == dev->_ctx.vhm_client_id) {
@@ -176,16 +177,16 @@ int virtio_vq_index_get(struct virtio_dev_info *dev, int req_cnt)
pr_debug("%s: write request! type %d\n",
__func__, req->type);
if (dev->io_range_type == PIO_RANGE)
- val = req->reqs.pio_request.value;
+ vqs_index[idx++] = req->reqs.pio_request.value;
else
- val = req->reqs.mmio_request.value;
+ vqs_index[idx++] = req->reqs.mmio_request.value;
}
req->processed = REQ_STATE_SUCCESS;
acrn_ioreq_complete_request(dev->_ctx.vhm_client_id, i);
}
}

- return val;
+ return idx;
}

static long virtio_vqs_info_set(struct virtio_dev_info *dev,
diff --git a/drivers/vbs/vbs_rng.c b/drivers/vbs/vbs_rng.c
index 88f6108..d5f78e9 100644
--- a/drivers/vbs/vbs_rng.c
+++ b/drivers/vbs/vbs_rng.c
@@ -268,7 +268,7 @@ static int handle_kick(int client_id, int req_cnt)
return -EINVAL;
}

- val = virtio_vq_index_get(&rng->dev, req_cnt);
+ virtio_vqs_index_get(&rng->dev, req_cnt, &val, 1);

if (val >= 0)
handle_vq_kick(rng, val);
diff --git a/include/linux/vbs/vbs.h b/include/linux/vbs/vbs.h
index e4ecba0..a3d4e51 100644
--- a/include/linux/vbs/vbs.h
+++ b/include/linux/vbs/vbs.h
@@ -273,6 +273,7 @@ long virtio_dev_deregister(struct virtio_dev_info *dev);
*
* Return: >=0 on virtqueue index, <0 on error
*/
-int virtio_vq_index_get(struct virtio_dev_info *dev, int req_cnt);
+int virtio_vqs_index_get(struct virtio_dev_info *dev, int req_cnt,
+ int *vqs_index, int max_vqs_index);

#endif
--
2.7.4

Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.