lkml.org 
[lkml]   [2022]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v10 08/12] iommu/sva: Refactoring iommu_sva_bind/unbind_device()
From
On 2022/7/25 15:50, Tian, Kevin wrote:
>> From: Baolu Lu <baolu.lu@linux.intel.com>
>> Sent: Sunday, July 24, 2022 9:48 PM
>>>
>>> The API is really refcounting the PASID:
>>>
>>>> +struct iommu_sva *iommu_sva_bind_device(struct device *dev,
>>>> + struct mm_struct *mm);
>>>> +void iommu_sva_unbind_device(struct iommu_sva *handle);
>>>
>>> So what you need to do is store that 'iommu_sva' in the group's PASID
>>> xarray.
>>>
>>> The bind logic would be
>>>
>>> sva = xa_load(group->pasid, mm->pasid)
>>> if (sva)
>>> refcount_inc(sva->users)
>>> return sva
>>> sva = kalloc
>>> sva->domain = domain
>>> xa_store(group->pasid, sva);
>>
>> Thanks for the suggestion. It makes a lot of sense to me.
>>
>> Furthermore, I'd like to separate the generic data from the caller-
>> specific things because the group->pasid_array should also be able to
>> serve other usages. Hence, the attach/detach_device_pasid interfaces
>> might be changed like below:
>>
>> /* Collection of per-pasid IOMMU data */
>> struct group_pasid {
>> struct iommu_domain *domain;
>> void *priv;
>> };
>>
>
> Is there any reason why pasid refcnt is sva specific and needs to be
> in a priv field?

I am going to store the iommu_sva data which represents the bind
relationship between device and domain.

Best regards,
baolu

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