Merge branches 'x86/vt-d', 'x86/amd', 'arm/smmu', 'arm/omap', 'generic-dma-ops' and...
[linux-block.git] / drivers / iommu / intel-svm.c
index eceaa7e968ae8dae1c91ee7d3c94c33607b1752d..780de0caafe845cb1b2c031010fcc25402decf31 100644 (file)
@@ -366,6 +366,21 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_
                }
 
                list_add_tail(&svm->list, &global_svm_list);
+       } else {
+               /*
+                * Binding a new device with existing PASID, need to setup
+                * the PASID entry.
+                */
+               spin_lock(&iommu->lock);
+               ret = intel_pasid_setup_first_level(iommu, dev,
+                                               mm ? mm->pgd : init_mm.pgd,
+                                               svm->pasid, FLPT_DEFAULT_DID,
+                                               mm ? 0 : PASID_FLAG_SUPERVISOR_MODE);
+               spin_unlock(&iommu->lock);
+               if (ret) {
+                       kfree(sdev);
+                       goto out;
+               }
        }
        list_add_rcu(&sdev->list, &svm->devs);