All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/vt-d: Fix bind svm with multiple devices
@ 2019-05-08 19:22 ` Jacob Pan
  0 siblings, 0 replies; 6+ messages in thread
From: Jacob Pan @ 2019-05-08 19:22 UTC (permalink / raw)
  To: LKML, iommu, Joerg Roedel, David Woodhouse; +Cc: Raj Ashok, Lu Baolu, Jacob Pan

If multiple devices try to bind to the same mm/PASID, we need to
set up first level PASID entries for all the devices. The current
code does not consider this case which results in failed DMA for
devices after the first bind.

Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Reported-by: Mike Campin <mike.campin@intel.com>
---
 drivers/iommu/intel-svm.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
index 3a4b09a..f3d59d1 100644
--- a/drivers/iommu/intel-svm.c
+++ b/drivers/iommu/intel-svm.c
@@ -357,6 +357,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);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] iommu/vt-d: Fix bind svm with multiple devices
@ 2019-05-08 19:22 ` Jacob Pan
  0 siblings, 0 replies; 6+ messages in thread
From: Jacob Pan @ 2019-05-08 19:22 UTC (permalink / raw)
  To: LKML, iommu, Joerg Roedel, David Woodhouse; +Cc: Raj Ashok

If multiple devices try to bind to the same mm/PASID, we need to
set up first level PASID entries for all the devices. The current
code does not consider this case which results in failed DMA for
devices after the first bind.

Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Reported-by: Mike Campin <mike.campin@intel.com>
---
 drivers/iommu/intel-svm.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
index 3a4b09a..f3d59d1 100644
--- a/drivers/iommu/intel-svm.c
+++ b/drivers/iommu/intel-svm.c
@@ -357,6 +357,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);
 
-- 
2.7.4

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] iommu/vt-d: Fix bind svm with multiple devices
  2019-05-08 19:22 ` Jacob Pan
@ 2019-05-20 15:33   ` Jacob Pan
  -1 siblings, 0 replies; 6+ messages in thread
From: Jacob Pan @ 2019-05-20 15:33 UTC (permalink / raw)
  To: LKML, iommu, Joerg Roedel, David Woodhouse
  Cc: Raj Ashok, Lu Baolu, jacob.jun.pan

Hi Joerg & David,

Any feedback on this one? Thanks.

On Wed,  8 May 2019 12:22:46 -0700
Jacob Pan <jacob.jun.pan@linux.intel.com> wrote:

> If multiple devices try to bind to the same mm/PASID, we need to
> set up first level PASID entries for all the devices. The current
> code does not consider this case which results in failed DMA for
> devices after the first bind.
> 
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Reported-by: Mike Campin <mike.campin@intel.com>
> ---
>  drivers/iommu/intel-svm.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
> index 3a4b09a..f3d59d1 100644
> --- a/drivers/iommu/intel-svm.c
> +++ b/drivers/iommu/intel-svm.c
> @@ -357,6 +357,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);
>  

[Jacob Pan]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iommu/vt-d: Fix bind svm with multiple devices
@ 2019-05-20 15:33   ` Jacob Pan
  0 siblings, 0 replies; 6+ messages in thread
From: Jacob Pan @ 2019-05-20 15:33 UTC (permalink / raw)
  To: LKML, iommu, Joerg Roedel, David Woodhouse; +Cc: Raj Ashok

Hi Joerg & David,

Any feedback on this one? Thanks.

On Wed,  8 May 2019 12:22:46 -0700
Jacob Pan <jacob.jun.pan@linux.intel.com> wrote:

> If multiple devices try to bind to the same mm/PASID, we need to
> set up first level PASID entries for all the devices. The current
> code does not consider this case which results in failed DMA for
> devices after the first bind.
> 
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Reported-by: Mike Campin <mike.campin@intel.com>
> ---
>  drivers/iommu/intel-svm.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
> index 3a4b09a..f3d59d1 100644
> --- a/drivers/iommu/intel-svm.c
> +++ b/drivers/iommu/intel-svm.c
> @@ -357,6 +357,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);
>  

[Jacob Pan]
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iommu/vt-d: Fix bind svm with multiple devices
  2019-05-08 19:22 ` Jacob Pan
@ 2019-05-27  9:55   ` Joerg Roedel
  -1 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2019-05-27  9:55 UTC (permalink / raw)
  To: Jacob Pan; +Cc: LKML, iommu, David Woodhouse, Raj Ashok, Lu Baolu

On Wed, May 08, 2019 at 12:22:46PM -0700, Jacob Pan wrote:
> If multiple devices try to bind to the same mm/PASID, we need to
> set up first level PASID entries for all the devices. The current
> code does not consider this case which results in failed DMA for
> devices after the first bind.
> 
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Reported-by: Mike Campin <mike.campin@intel.com>
> ---
>  drivers/iommu/intel-svm.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)

Applied for v5.3, thanks.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iommu/vt-d: Fix bind svm with multiple devices
@ 2019-05-27  9:55   ` Joerg Roedel
  0 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2019-05-27  9:55 UTC (permalink / raw)
  To: Jacob Pan; +Cc: iommu, David Woodhouse, LKML, Raj Ashok

On Wed, May 08, 2019 at 12:22:46PM -0700, Jacob Pan wrote:
> If multiple devices try to bind to the same mm/PASID, we need to
> set up first level PASID entries for all the devices. The current
> code does not consider this case which results in failed DMA for
> devices after the first bind.
> 
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Reported-by: Mike Campin <mike.campin@intel.com>
> ---
>  drivers/iommu/intel-svm.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)

Applied for v5.3, thanks.

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-05-27  9:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-08 19:22 [PATCH] iommu/vt-d: Fix bind svm with multiple devices Jacob Pan
2019-05-08 19:22 ` Jacob Pan
2019-05-20 15:33 ` Jacob Pan
2019-05-20 15:33   ` Jacob Pan
2019-05-27  9:55 ` Joerg Roedel
2019-05-27  9:55   ` Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.