[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 28/40] vdpa: support iotlb_batch_asid
From: |
Si-Wei Liu |
Subject: |
[PATCH 28/40] vdpa: support iotlb_batch_asid |
Date: |
Thu, 7 Dec 2023 09:39:41 -0800 |
Then it's possible to specify ASID when calling the DMA
batching API. If the ASID to work on doesn't align with
the ASID for ongoing transaction, the API will fail the
request and return negative, and the transaction will
remain intact as if no failed request ever had occured.
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
---
hw/virtio/vhost-vdpa.c | 25 +++++++++++++++++++------
include/hw/virtio/vhost-vdpa.h | 1 +
net/vhost-vdpa.c | 1 +
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index d3f5721..b7896a8 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -189,15 +189,25 @@ static bool vhost_vdpa_map_batch_begin(VhostVDPAShared
*s, uint32_t asid)
static int vhost_vdpa_dma_batch_begin_once(VhostVDPAShared *s, uint32_t asid)
{
- if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH)) ||
- s->iotlb_batch_begin_sent) {
+ if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) {
return 0;
}
- if (vhost_vdpa_map_batch_begin(s, asid)) {
- s->iotlb_batch_begin_sent = true;
+ if (s->iotlb_batch_begin_sent && s->iotlb_batch_asid != asid) {
+ return -1;
+ }
+
+ if (s->iotlb_batch_begin_sent) {
+ return 0;
}
+ if (!vhost_vdpa_map_batch_begin(s, asid)) {
+ return 0;
+ }
+
+ s->iotlb_batch_begin_sent = true;
+ s->iotlb_batch_asid = asid;
+
return 0;
}
@@ -237,10 +247,13 @@ static int vhost_vdpa_dma_batch_end_once(VhostVDPAShared
*s, uint32_t asid)
return 0;
}
- if (vhost_vdpa_dma_batch_end(s, asid)) {
- s->iotlb_batch_begin_sent = false;
+ if (!vhost_vdpa_dma_batch_end(s, asid)) {
+ return 0;
}
+ s->iotlb_batch_begin_sent = false;
+ s->iotlb_batch_asid = -1;
+
return 0;
}
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index 0fe0f60..219316f 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -61,6 +61,7 @@ typedef struct vhost_vdpa_shared {
bool map_thread_enabled;
bool iotlb_batch_begin_sent;
+ uint32_t iotlb_batch_asid;
/*
* The memory listener has been registered, so DMA maps have been sent to
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index e9b96ed..bc72345 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -1933,6 +1933,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState
*peer,
s->vhost_vdpa.shared->device_fd = vdpa_device_fd;
s->vhost_vdpa.shared->iova_range = iova_range;
s->vhost_vdpa.shared->shadow_data = svq;
+ s->vhost_vdpa.shared->iotlb_batch_asid = -1;
s->vhost_vdpa.shared->refcnt++;
} else if (!is_datapath) {
s->cvq_cmd_out_buffer = mmap(NULL, vhost_vdpa_net_cvq_cmd_page_len(),
--
1.8.3.1
- [PATCH 25/40] vdpa: add asid to dma_batch_once API, (continued)
- [PATCH 25/40] vdpa: add asid to dma_batch_once API, Si-Wei Liu, 2023/12/07
- [PATCH 19/40] vdpa: should avoid map flushing with persistent iotlb, Si-Wei Liu, 2023/12/07
- [PATCH 21/40] vdpa: vhost_vdpa_dma_batch_end_once rename, Si-Wei Liu, 2023/12/07
- [PATCH 16/40] vdpa: indicate SVQ switching via flag, Si-Wei Liu, 2023/12/07
- [PATCH 24/40] vdpa: factor out vhost_vdpa_dma_batch_end, Si-Wei Liu, 2023/12/07
- [PATCH 26/40] vdpa: return int for dma_batch_once API, Si-Wei Liu, 2023/12/07
- [PATCH 27/40] vdpa: add asid to all dma_batch call sites, Si-Wei Liu, 2023/12/07
- [PATCH 20/40] vdpa: avoid mapping flush across reset, Si-Wei Liu, 2023/12/07
- [PATCH 23/40] vdpa: vhost_vdpa_dma_batch_begin_once rename, Si-Wei Liu, 2023/12/07
- [PATCH 28/40] vdpa: support iotlb_batch_asid,
Si-Wei Liu <=
- [PATCH 30/40] vdpa: batch map/unmap op per svq pair basis, Si-Wei Liu, 2023/12/07
- [PATCH 29/40] vdpa: expose API vhost_vdpa_dma_batch_once, Si-Wei Liu, 2023/12/07
- [PATCH 31/40] vdpa: batch map and unmap around cvq svq start/stop, Si-Wei Liu, 2023/12/07
- [PATCH 32/40] vdpa: factor out vhost_vdpa_net_get_nc_vdpa, Si-Wei Liu, 2023/12/07
- [PATCH 34/40] vdpa: fix network breakage after cancelling migration, Si-Wei Liu, 2023/12/07
- [PATCH 35/40] vdpa: add vhost_vdpa_set_address_space_id trace, Si-Wei Liu, 2023/12/07
- [PATCH 33/40] vdpa: batch multiple dma_unmap to a single call for vm stop, Si-Wei Liu, 2023/12/07