diff mbox series

[v3,5/7] iommu/vt-d: Make the blocked domain support PASID

Message ID 20241104132033.14027-6-yi.l.liu@intel.com (mailing list archive)
State New
Headers show
Series Support attaching PASID to the blocked_domain | expand

Commit Message

Yi Liu Nov. 4, 2024, 1:20 p.m. UTC
The blocked domain can be extended to park PASID of a device to be the
DMA blocking state. By this the remove_dev_pasid() op is dropped.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
---
 drivers/iommu/intel/iommu.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Baolu Lu Nov. 5, 2024, 3:46 a.m. UTC | #1
On 11/4/24 21:20, Yi Liu wrote:
> @@ -4291,15 +4296,18 @@ void domain_remove_dev_pasid(struct iommu_domain *domain,
>   	kfree(dev_pasid);
>   }
>   
> -static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
> -					 struct iommu_domain *domain)
> +static int blocking_domain_set_dev_pasid(struct iommu_domain *domain,
> +					 struct device *dev, ioasid_t pasid,
> +					 struct iommu_domain *old)
>   {
>   	struct device_domain_info *info = dev_iommu_priv_get(dev);
>   	struct intel_iommu *iommu = info->iommu;
>   
>   	intel_pasid_tear_down_entry(iommu, dev, pasid, false);
>   	intel_drain_pasid_prq(dev, pasid);
> -	domain_remove_dev_pasid(domain, dev, pasid);
> +	domain_remove_dev_pasid(old, dev, pasid);
> +
> +	return 0;
>   }
>   
>   struct dev_pasid_info *
> @@ -4664,7 +4672,6 @@ const struct iommu_ops intel_iommu_ops = {
>   	.dev_disable_feat	= intel_iommu_dev_disable_feat,
>   	.is_attach_deferred	= intel_iommu_is_attach_deferred,
>   	.def_domain_type	= device_def_domain_type,
> -	.remove_dev_pasid	= intel_iommu_remove_dev_pasid,

This will cause iommu_attach_device_pasid() to fail due to the check and
failure condition introduced in patch 1/7.

--
baolu
Yi Liu Nov. 5, 2024, 5:11 a.m. UTC | #2
On 2024/11/5 11:46, Baolu Lu wrote:
> On 11/4/24 21:20, Yi Liu wrote:
>> @@ -4291,15 +4296,18 @@ void domain_remove_dev_pasid(struct iommu_domain 
>> *domain,
>>       kfree(dev_pasid);
>>   }
>> -static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t 
>> pasid,
>> -                     struct iommu_domain *domain)
>> +static int blocking_domain_set_dev_pasid(struct iommu_domain *domain,
>> +                     struct device *dev, ioasid_t pasid,
>> +                     struct iommu_domain *old)
>>   {
>>       struct device_domain_info *info = dev_iommu_priv_get(dev);
>>       struct intel_iommu *iommu = info->iommu;
>>       intel_pasid_tear_down_entry(iommu, dev, pasid, false);
>>       intel_drain_pasid_prq(dev, pasid);
>> -    domain_remove_dev_pasid(domain, dev, pasid);
>> +    domain_remove_dev_pasid(old, dev, pasid);
>> +
>> +    return 0;
>>   }
>>   struct dev_pasid_info *
>> @@ -4664,7 +4672,6 @@ const struct iommu_ops intel_iommu_ops = {
>>       .dev_disable_feat    = intel_iommu_dev_disable_feat,
>>       .is_attach_deferred    = intel_iommu_is_attach_deferred,
>>       .def_domain_type    = device_def_domain_type,
>> -    .remove_dev_pasid    = intel_iommu_remove_dev_pasid,
> 
> This will cause iommu_attach_device_pasid() to fail due to the check and
> failure condition introduced in patch 1/7.

the check introduced in patch 1 were enhanced in patch 3. So removing
remove_dev_pasid op does not fail as intel iommu driver provides
blocked domain which has the set_dev_pasid op.
Baolu Lu Nov. 5, 2024, 5:45 a.m. UTC | #3
On 11/5/24 13:11, Yi Liu wrote:
> On 2024/11/5 11:46, Baolu Lu wrote:
>> On 11/4/24 21:20, Yi Liu wrote:
>>> @@ -4291,15 +4296,18 @@ void domain_remove_dev_pasid(struct 
>>> iommu_domain *domain,
>>>       kfree(dev_pasid);
>>>   }
>>> -static void intel_iommu_remove_dev_pasid(struct device *dev, 
>>> ioasid_t pasid,
>>> -                     struct iommu_domain *domain)
>>> +static int blocking_domain_set_dev_pasid(struct iommu_domain *domain,
>>> +                     struct device *dev, ioasid_t pasid,
>>> +                     struct iommu_domain *old)
>>>   {
>>>       struct device_domain_info *info = dev_iommu_priv_get(dev);
>>>       struct intel_iommu *iommu = info->iommu;
>>>       intel_pasid_tear_down_entry(iommu, dev, pasid, false);
>>>       intel_drain_pasid_prq(dev, pasid);
>>> -    domain_remove_dev_pasid(domain, dev, pasid);
>>> +    domain_remove_dev_pasid(old, dev, pasid);
>>> +
>>> +    return 0;
>>>   }
>>>   struct dev_pasid_info *
>>> @@ -4664,7 +4672,6 @@ const struct iommu_ops intel_iommu_ops = {
>>>       .dev_disable_feat    = intel_iommu_dev_disable_feat,
>>>       .is_attach_deferred    = intel_iommu_is_attach_deferred,
>>>       .def_domain_type    = device_def_domain_type,
>>> -    .remove_dev_pasid    = intel_iommu_remove_dev_pasid,
>>
>> This will cause iommu_attach_device_pasid() to fail due to the check and
>> failure condition introduced in patch 1/7.
> 
> the check introduced in patch 1 were enhanced in patch 3. So removing
> remove_dev_pasid op does not fail as intel iommu driver provides
> blocked domain which has the set_dev_pasid op.
> 

Okay, I see. Thanks!
Jason Gunthorpe Nov. 5, 2024, 3:43 p.m. UTC | #4
On Mon, Nov 04, 2024 at 05:20:31AM -0800, Yi Liu wrote:
> The blocked domain can be extended to park PASID of a device to be the
> DMA blocking state. By this the remove_dev_pasid() op is dropped.
> 
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
> Signed-off-by: Yi Liu <yi.l.liu@intel.com>
> ---
>  drivers/iommu/intel/iommu.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason
diff mbox series

Patch

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 7f1ca3c342a3..a1341078b962 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -3414,10 +3414,15 @@  static int blocking_domain_attach_dev(struct iommu_domain *domain,
 	return 0;
 }
 
+static int blocking_domain_set_dev_pasid(struct iommu_domain *domain,
+					 struct device *dev, ioasid_t pasid,
+					 struct iommu_domain *old);
+
 static struct iommu_domain blocking_domain = {
 	.type = IOMMU_DOMAIN_BLOCKED,
 	.ops = &(const struct iommu_domain_ops) {
 		.attach_dev	= blocking_domain_attach_dev,
+		.set_dev_pasid	= blocking_domain_set_dev_pasid,
 	}
 };
 
@@ -4291,15 +4296,18 @@  void domain_remove_dev_pasid(struct iommu_domain *domain,
 	kfree(dev_pasid);
 }
 
-static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
-					 struct iommu_domain *domain)
+static int blocking_domain_set_dev_pasid(struct iommu_domain *domain,
+					 struct device *dev, ioasid_t pasid,
+					 struct iommu_domain *old)
 {
 	struct device_domain_info *info = dev_iommu_priv_get(dev);
 	struct intel_iommu *iommu = info->iommu;
 
 	intel_pasid_tear_down_entry(iommu, dev, pasid, false);
 	intel_drain_pasid_prq(dev, pasid);
-	domain_remove_dev_pasid(domain, dev, pasid);
+	domain_remove_dev_pasid(old, dev, pasid);
+
+	return 0;
 }
 
 struct dev_pasid_info *
@@ -4664,7 +4672,6 @@  const struct iommu_ops intel_iommu_ops = {
 	.dev_disable_feat	= intel_iommu_dev_disable_feat,
 	.is_attach_deferred	= intel_iommu_is_attach_deferred,
 	.def_domain_type	= device_def_domain_type,
-	.remove_dev_pasid	= intel_iommu_remove_dev_pasid,
 	.pgsize_bitmap		= SZ_4K,
 #ifdef CONFIG_INTEL_IOMMU_SVM
 	.page_response		= intel_svm_page_response,