Commit e56ebe27 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull iommufd updates from Jason Gunthorpe:
 "Two minor fixes:

   - Make the selftest work again on x86 platforms with iommus enabled

   - Fix a compiler warning in the userspace kselftest"

* tag 'for-linus-iommufd' of git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd:
  iommufd: Register iommufd mock devices with fwspec
  iommu/selftest: prevent use of uninitialized variable
parents 8a44189f 2a918911
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ void iommu_device_unregister_bus(struct iommu_device *iommu,
				 const struct bus_type *bus,
				 struct notifier_block *nb);

int iommu_mock_device_add(struct device *dev, struct iommu_device *iommu);

struct iommu_attach_handle *iommu_attach_handle_get(struct iommu_group *group,
						    ioasid_t pasid,
						    unsigned int type);
+26 −0
Original line number Diff line number Diff line
@@ -304,6 +304,7 @@ void iommu_device_unregister_bus(struct iommu_device *iommu,
				 struct notifier_block *nb)
{
	bus_unregister_notifier(bus, nb);
	fwnode_remove_software_node(iommu->fwnode);
	iommu_device_unregister(iommu);
}
EXPORT_SYMBOL_GPL(iommu_device_unregister_bus);
@@ -326,6 +327,12 @@ int iommu_device_register_bus(struct iommu_device *iommu,
	if (err)
		return err;

	iommu->fwnode = fwnode_create_software_node(NULL, NULL);
	if (IS_ERR(iommu->fwnode)) {
		bus_unregister_notifier(bus, nb);
		return PTR_ERR(iommu->fwnode);
	}

	spin_lock(&iommu_device_lock);
	list_add_tail(&iommu->list, &iommu_device_list);
	spin_unlock(&iommu_device_lock);
@@ -335,9 +342,28 @@ int iommu_device_register_bus(struct iommu_device *iommu,
		iommu_device_unregister_bus(iommu, bus, nb);
		return err;
	}
	WRITE_ONCE(iommu->ready, true);
	return 0;
}
EXPORT_SYMBOL_GPL(iommu_device_register_bus);

int iommu_mock_device_add(struct device *dev, struct iommu_device *iommu)
{
	int rc;

	mutex_lock(&iommu_probe_device_lock);
	rc = iommu_fwspec_init(dev, iommu->fwnode);
	mutex_unlock(&iommu_probe_device_lock);

	if (rc)
		return rc;

	rc = device_add(dev);
	if (rc)
		iommu_fwspec_free(dev);
	return rc;
}
EXPORT_SYMBOL_GPL(iommu_mock_device_add);
#endif

static struct dev_iommu *dev_iommu_get(struct device *dev)
+1 −1
Original line number Diff line number Diff line
@@ -1126,7 +1126,7 @@ static struct mock_dev *mock_dev_create(unsigned long dev_flags)
		goto err_put;
	}

	rc = device_add(&mdev->dev);
	rc = iommu_mock_device_add(&mdev->dev, &mock_iommu.iommu_dev);
	if (rc)
		goto err_put;
	return mdev;
+3 −5
Original line number Diff line number Diff line
@@ -1042,15 +1042,13 @@ static int _test_cmd_trigger_vevents(int fd, __u32 dev_id, __u32 nvevents)
			.dev_id = dev_id,
		},
	};
	int ret;

	while (nvevents--) {
		ret = ioctl(fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_TRIGGER_VEVENT),
			    &trigger_vevent_cmd);
		if (ret < 0)
		if (!ioctl(fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_TRIGGER_VEVENT),
			    &trigger_vevent_cmd))
			return -1;
	}
	return ret;
	return 0;
}

#define test_cmd_trigger_vevents(dev_id, nvevents) \