Commit be428cdc authored by Changpeng Liu's avatar Changpeng Liu Committed by Tomasz Zawadzki
Browse files

vhost: enable `RTE_VHOST_USER_ASYNC_COPY` flag based on IOMMU



DPDK vhost-user library will try to register external VM memory when
flag `RTE_VHOST_USER_ASYNC_COPY` is set and `vfio` module loaded, but SPDK
always registers the external memory region to kernel vfio container when
IOMMU is enabled, the same memory region will be registered to vfio
twice for this case, here we only set this flag based on IOMMU, then
DPDK will not register this memory region, and it can cover both vfio and
uio bindings.

Fix issue #3061.

Change-Id: I4e71ee4b33ca8140a3f194d0e350809d5c6ca88b
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19783


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@gmail.com>
Community-CI: Mellanox Build Bot
parent 0bbe3cb0
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1590,6 +1590,7 @@ vhost_register_unix_socket(const char *path, const char *ctrl_name,
{
	struct stat file_stat;
	uint64_t features = 0;
	uint64_t flags = 0;

	/* Register vhost driver to handle vhost messages. */
	if (stat(path, &file_stat) != -1) {
@@ -1607,9 +1608,10 @@ vhost_register_unix_socket(const char *path, const char *ctrl_name,
	}

#if RTE_VERSION < RTE_VERSION_NUM(20, 8, 0, 0)
	if (rte_vhost_driver_register(path, 0) != 0) {
	if (rte_vhost_driver_register(path, flags) != 0) {
#else
	if (rte_vhost_driver_register(path, RTE_VHOST_USER_ASYNC_COPY) != 0) {
	flags = spdk_iommu_is_enabled() ? 0 : RTE_VHOST_USER_ASYNC_COPY;
	if (rte_vhost_driver_register(path, flags) != 0) {
#endif
		SPDK_ERRLOG("Could not register controller %s with vhost library\n", ctrl_name);
		SPDK_ERRLOG("Check if domain socket %s already exists\n", path);
+1 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ DEFINE_STUB(rte_vhost_get_vring_base_from_inflight, int,
	    (int vid, uint16_t queue_id, uint16_t *last_avail_idx, uint16_t *last_used_idx), 0);
DEFINE_STUB(rte_vhost_extern_callback_register, int,
	    (int vid, struct rte_vhost_user_extern_ops const *const ops, void *ctx), 0);
DEFINE_STUB(spdk_iommu_is_enabled, bool, (void), 0);

/* rte_vhost_user.c shutdowns vhost_user sessions in a separate pthread */
DECLARE_WRAPPER(pthread_create, int, (pthread_t *thread, const pthread_attr_t *attr,