If vhost device's IOMMU feature is disabled, IOTLB mempool allocation
is unnecessary.
Reported-by: Peng He <hepeng.0320@bytedance.com>
Signed-off-by: Junjie Wan <wanjunjie@bytedance.com>
Reviewed-by: Zhihong Wang <wangzhihong.wzh@bytedance.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
vhost_free_async_mem(vq);
}
rte_free(vq->batch_copy_elems);
- rte_mempool_free(vq->iotlb_pool);
+ if (vq->iotlb_pool)
+ rte_mempool_free(vq->iotlb_pool);
rte_free(vq->log_cache);
rte_free(vq);
}
vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;
vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD;
vq->notif_enable = VIRTIO_UNINITIALIZED_NOTIF;
-
- vhost_user_iotlb_init(dev, vring_idx);
}
static void
return RTE_VHOST_MSG_RESULT_ERR;
}
+ if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) {
+ if (vhost_user_iotlb_init(dev, msg->payload.state.index))
+ return RTE_VHOST_MSG_RESULT_ERR;
+ }
return RTE_VHOST_MSG_RESULT_OK;
}
dev->virtqueue[index] = vq;
vhost_devices[dev->vid] = dev;
- if (old_vq != vq)
+ if (old_vq != vq && (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)))
vhost_user_iotlb_init(dev, index);
return dev;