[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 12/14] vdpa: use dev_shared in vdpa_iommu
From: |
Eugenio Pérez |
Subject: |
[PATCH v3 12/14] vdpa: use dev_shared in vdpa_iommu |
Date: |
Thu, 21 Dec 2023 12:53:17 +0100 |
The memory listener functions can call these too. Make vdpa_iommu work
with VhostVDPAShared.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
include/hw/virtio/vhost-vdpa.h | 2 +-
hw/virtio/vhost-vdpa.c | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index 705c754776..2abee2164a 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -75,7 +75,7 @@ int vhost_vdpa_dma_unmap(VhostVDPAShared *s, uint32_t asid,
hwaddr iova,
hwaddr size);
typedef struct vdpa_iommu {
- struct vhost_vdpa *dev;
+ VhostVDPAShared *dev_shared;
IOMMUMemoryRegion *iommu_mr;
hwaddr iommu_offset;
IOMMUNotifier n;
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 0ed6550aad..61553ad196 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -199,7 +199,7 @@ static void vhost_vdpa_iommu_map_notify(IOMMUNotifier *n,
IOMMUTLBEntry *iotlb)
struct vdpa_iommu *iommu = container_of(n, struct vdpa_iommu, n);
hwaddr iova = iotlb->iova + iommu->iommu_offset;
- struct vhost_vdpa *v = iommu->dev;
+ VhostVDPAShared *s = iommu->dev_shared;
void *vaddr;
int ret;
Int128 llend;
@@ -212,10 +212,10 @@ static void vhost_vdpa_iommu_map_notify(IOMMUNotifier *n,
IOMMUTLBEntry *iotlb)
RCU_READ_LOCK_GUARD();
/* check if RAM section out of device range */
llend = int128_add(int128_makes64(iotlb->addr_mask), int128_makes64(iova));
- if (int128_gt(llend, int128_make64(v->shared->iova_range.last))) {
+ if (int128_gt(llend, int128_make64(s->iova_range.last))) {
error_report("RAM section out of device range (max=0x%" PRIx64
", end addr=0x%" PRIx64 ")",
- v->shared->iova_range.last, int128_get64(llend));
+ s->iova_range.last, int128_get64(llend));
return;
}
@@ -225,20 +225,20 @@ static void vhost_vdpa_iommu_map_notify(IOMMUNotifier *n,
IOMMUTLBEntry *iotlb)
if (!memory_get_xlat_addr(iotlb, &vaddr, NULL, &read_only, NULL)) {
return;
}
- ret = vhost_vdpa_dma_map(v->shared, VHOST_VDPA_GUEST_PA_ASID, iova,
+ ret = vhost_vdpa_dma_map(s, VHOST_VDPA_GUEST_PA_ASID, iova,
iotlb->addr_mask + 1, vaddr, read_only);
if (ret) {
error_report("vhost_vdpa_dma_map(%p, 0x%" HWADDR_PRIx ", "
"0x%" HWADDR_PRIx ", %p) = %d (%m)",
- v, iova, iotlb->addr_mask + 1, vaddr, ret);
+ s, iova, iotlb->addr_mask + 1, vaddr, ret);
}
} else {
- ret = vhost_vdpa_dma_unmap(v->shared, VHOST_VDPA_GUEST_PA_ASID, iova,
+ ret = vhost_vdpa_dma_unmap(s, VHOST_VDPA_GUEST_PA_ASID, iova,
iotlb->addr_mask + 1);
if (ret) {
error_report("vhost_vdpa_dma_unmap(%p, 0x%" HWADDR_PRIx ", "
"0x%" HWADDR_PRIx ") = %d (%m)",
- v, iova, iotlb->addr_mask + 1, ret);
+ s, iova, iotlb->addr_mask + 1, ret);
}
}
}
@@ -270,7 +270,7 @@ static void vhost_vdpa_iommu_region_add(MemoryListener
*listener,
iommu_idx);
iommu->iommu_offset = section->offset_within_address_space -
section->offset_within_region;
- iommu->dev = v;
+ iommu->dev_shared = v->shared;
ret = memory_region_register_iommu_notifier(section->mr, &iommu->n, NULL);
if (ret) {
--
2.39.3
- [PATCH v3 03/14] vdpa: move iova_range to vhost_vdpa_shared, (continued)
- [PATCH v3 03/14] vdpa: move iova_range to vhost_vdpa_shared, Eugenio Pérez, 2023/12/21
- [PATCH v3 02/14] vdpa: move iova tree to the shared struct, Eugenio Pérez, 2023/12/21
- [PATCH v3 05/14] vdpa: use vdpa shared for tracing, Eugenio Pérez, 2023/12/21
- [PATCH v3 06/14] vdpa: move file descriptor to vhost_vdpa_shared, Eugenio Pérez, 2023/12/21
- [PATCH v3 07/14] vdpa: move iotlb_batch_begin_sent to vhost_vdpa_shared, Eugenio Pérez, 2023/12/21
- [PATCH v3 04/14] vdpa: move shadow_data to vhost_vdpa_shared, Eugenio Pérez, 2023/12/21
- [PATCH v3 10/14] vdpa: move iommu_list to vhost_vdpa_shared, Eugenio Pérez, 2023/12/21
- [PATCH v3 11/14] vdpa: use VhostVDPAShared in vdpa_dma_map and unmap, Eugenio Pérez, 2023/12/21
- [PATCH v3 08/14] vdpa: move backend_cap to vhost_vdpa_shared, Eugenio Pérez, 2023/12/21
- [PATCH v3 09/14] vdpa: remove msg type of vhost_vdpa, Eugenio Pérez, 2023/12/21
- [PATCH v3 12/14] vdpa: use dev_shared in vdpa_iommu,
Eugenio Pérez <=
- [PATCH v3 13/14] vdpa: factor out vhost_vdpa_last_dev, Eugenio Pérez, 2023/12/21
- [PATCH v3 14/14] vdpa: move memory listener to vhost_vdpa_shared, Eugenio Pérez, 2023/12/21