lkml.org 
[lkml]   [2022]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v10 04/12] iommu: Add attach/detach_dev_pasid iommu interface
From
On 2022/7/25 15:46, Tian, Kevin wrote:
>> From: Baolu Lu <baolu.lu@linux.intel.com>
>> Sent: Sunday, July 24, 2022 5:14 PM
>>
>> On 2022/7/23 22:11, Jason Gunthorpe wrote:
>>>> +void iommu_detach_device_pasid(struct iommu_domain *domain,
>> struct device *dev,
>>>> + ioasid_t pasid)
>>>> +{
>>>> + struct iommu_group *group = iommu_group_get(dev);
>>>> +
>>>> + mutex_lock(&group->mutex);
>>>> + domain->ops->block_dev_pasid(domain, dev, pasid);
>>> I still really this OP, it is nonsense to invoke 'block_dev_pasid' on
>>> a domain, it should be on the iommu ops and it should not take in a
>>> domain parameter. This is why I prefer we write it as
>>>
>>> domain->ops->set_dev_pasid(group->blocking_domain, dev, pasid);
>>>
>>
>> I originally plan to refactor this after both Intel and ARM SMMUv3
>> drivers have real blocking domain supports. After revisiting this, it
>> seems that the only difficulty is how to check whether a domain is a
>> blocking domain. I am going to use below checking code:
>>
>> + /*
>> + * Detach the domain if a blocking domain is set. Check the
>> + * right domain type once the IOMMU driver supports a real
>> + * blocking domain.
>> + */
>> + if (!domain || domain->type == IOMMU_DOMAIN_UNMANAGED) {
>>
>> Does this work for you?
>>
>
> Or you can call __iommu_group_alloc_blocking_domain() in the sva
> path and then just check whether the domain is equal to
> group->blocking_domain here.

Above check is in the IOMMU driver where group->blocking_domain is not
viable. I ever thought about have something like

struct iommu_domain *iommu_group_blocking_domain(struct iommu_group
*group)

to return group->blocking_domain. But it looks redundant.

Best regards,
baolu

\
 
 \ /
  Last update: 2022-07-25 12:12    [W:0.932 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site