Commit 6b456264 authored by Zhangfei Gao's avatar Zhangfei Gao Committed by Kunkun Jiang
Browse files

iommufd: enable SVA when IOPF enabled

virt inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IB4WDJ
CVE: NA

--------------------------------

On smmuv3, SVA is only enabled once enable SVA, so enable
SVA as well when enable IOPF as quick solution.

In drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c,
iommu_dev_enable_feature(IOMMU_DEV_FEAT_SVA) will real call
iopf_queue_add_device,
while iommu_dev_enable_feature(IOPF)  only set flag.

arm_smmu_dev_enable_feature
case IOMMU_DEV_FEAT_SVA:
arm_smmu_master_enable_sva(master)
iopf_queue_add_device(master->smmu->evtq.iopf, dev);

By the way, Jason is doing a new patchset to handle this
https://patchwork.kernel.org/project/linux-acpi/cover/0-v4-9e99b76f3518+3a8-smmuv3_nesting_jgg@nvidia.com/



Signed-off-by: default avatarZhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: default avatarKunkun Jiang <jiangkunkun@huawei.com>
parent d6b8d85d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -45,6 +45,11 @@ static int iommufd_fault_iopf_enable(struct iommufd_device *idev)
	ret = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_IOPF);
	if (ret)
		--idev->iopf_enabled;

	ret = iommu_dev_enable_feature(idev->dev, IOMMU_DEV_FEAT_SVA);
	if (ret)
		return ret;

	mutex_unlock(&idev->iopf_lock);

	return ret;
@@ -53,6 +58,7 @@ static int iommufd_fault_iopf_enable(struct iommufd_device *idev)
static void iommufd_fault_iopf_disable(struct iommufd_device *idev)
{
	mutex_lock(&idev->iopf_lock);
	iommu_dev_disable_feature(idev->dev, IOMMU_DEV_FEAT_SVA);
	if (!WARN_ON(idev->iopf_enabled == 0)) {
		if (--idev->iopf_enabled == 0)
			iommu_dev_disable_feature(idev->dev, IOMMU_DEV_FEAT_IOPF);