|
@@ -274,11 +274,9 @@ static void intel_mm_release(struct mmu_notifier *mn, struct mm_struct *mm)
|
|
|
* page) so that we end up taking a fault that the hardware really
|
|
|
* *has* to handle gracefully without affecting other processes.
|
|
|
*/
|
|
|
- svm->iommu->pasid_table[svm->pasid].val = 0;
|
|
|
- wmb();
|
|
|
-
|
|
|
rcu_read_lock();
|
|
|
list_for_each_entry_rcu(sdev, &svm->devs, list) {
|
|
|
+ intel_pasid_clear_entry(sdev->dev, svm->pasid);
|
|
|
intel_flush_pasid_dev(svm, sdev, svm->pasid);
|
|
|
intel_flush_svm_range_dev(svm, sdev, 0, -1, 0, !svm->mm);
|
|
|
}
|
|
@@ -299,6 +297,7 @@ static LIST_HEAD(global_svm_list);
|
|
|
int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ops *ops)
|
|
|
{
|
|
|
struct intel_iommu *iommu = intel_svm_device_to_iommu(dev);
|
|
|
+ struct pasid_entry *entry;
|
|
|
struct intel_svm_dev *sdev;
|
|
|
struct intel_svm *svm = NULL;
|
|
|
struct mm_struct *mm = NULL;
|
|
@@ -306,7 +305,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_
|
|
|
int pasid_max;
|
|
|
int ret;
|
|
|
|
|
|
- if (!iommu || !iommu->pasid_table)
|
|
|
+ if (!iommu)
|
|
|
return -EINVAL;
|
|
|
|
|
|
if (dev_is_pci(dev)) {
|
|
@@ -384,8 +383,8 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_
|
|
|
}
|
|
|
svm->iommu = iommu;
|
|
|
|
|
|
- if (pasid_max > iommu->pasid_max)
|
|
|
- pasid_max = iommu->pasid_max;
|
|
|
+ if (pasid_max > intel_pasid_max_id)
|
|
|
+ pasid_max = intel_pasid_max_id;
|
|
|
|
|
|
/* Do not use PASID 0 in caching mode (virtualised IOMMU) */
|
|
|
ret = intel_pasid_alloc_id(svm,
|
|
@@ -418,7 +417,8 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_
|
|
|
if (cpu_feature_enabled(X86_FEATURE_LA57))
|
|
|
pasid_entry_val |= PASID_ENTRY_FLPM_5LP;
|
|
|
|
|
|
- iommu->pasid_table[svm->pasid].val = pasid_entry_val;
|
|
|
+ entry = intel_pasid_get_entry(dev, svm->pasid);
|
|
|
+ entry->val = pasid_entry_val;
|
|
|
|
|
|
wmb();
|
|
|
|
|
@@ -453,7 +453,7 @@ int intel_svm_unbind_mm(struct device *dev, int pasid)
|
|
|
|
|
|
mutex_lock(&pasid_mutex);
|
|
|
iommu = intel_svm_device_to_iommu(dev);
|
|
|
- if (!iommu || !iommu->pasid_table)
|
|
|
+ if (!iommu)
|
|
|
goto out;
|
|
|
|
|
|
svm = intel_pasid_lookup_id(pasid);
|
|
@@ -476,11 +476,9 @@ int intel_svm_unbind_mm(struct device *dev, int pasid)
|
|
|
intel_flush_pasid_dev(svm, sdev, svm->pasid);
|
|
|
intel_flush_svm_range_dev(svm, sdev, 0, -1, 0, !svm->mm);
|
|
|
kfree_rcu(sdev, rcu);
|
|
|
+ intel_pasid_clear_entry(dev, svm->pasid);
|
|
|
|
|
|
if (list_empty(&svm->devs)) {
|
|
|
- svm->iommu->pasid_table[svm->pasid].val = 0;
|
|
|
- wmb();
|
|
|
-
|
|
|
intel_pasid_free_id(svm->pasid);
|
|
|
if (svm->mm)
|
|
|
mmu_notifier_unregister(&svm->notifier, svm->mm);
|
|
@@ -513,7 +511,7 @@ int intel_svm_is_pasid_valid(struct device *dev, int pasid)
|
|
|
|
|
|
mutex_lock(&pasid_mutex);
|
|
|
iommu = intel_svm_device_to_iommu(dev);
|
|
|
- if (!iommu || !iommu->pasid_table)
|
|
|
+ if (!iommu)
|
|
|
goto out;
|
|
|
|
|
|
svm = intel_pasid_lookup_id(pasid);
|