Linux IOMMU Development
 help / color / mirror / Atom feed
From: Yi Liu <yi.l.liu@intel.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: <joro@8bytes.org>, <kevin.tian@intel.com>,
	<baolu.lu@linux.intel.com>, <iommu@lists.linux.dev>,
	<jacob.pan@linux.microsoft.com>, <robin.murphy@arm.com>,
	<nicolinc@nvidia.com>, <will@kernel.org>
Subject: Re: [PATCH 1/2] iommu: Store either domain or handle in group->pasid_array
Date: Tue, 21 Jan 2025 15:22:59 +0800	[thread overview]
Message-ID: <049af2c8-dc76-40c4-9e1c-3d4b9743607b@intel.com> (raw)
In-Reply-To: <20250120155535.GK5556@nvidia.com>

On 2025/1/20 23:55, Jason Gunthorpe wrote:
> On Sun, Jan 19, 2025 at 07:08:39PM -0800, Yi Liu wrote:
>> iommu_attach_device_pasid() only stores handle to group->pasid_array
>> when there is a valid handle input. However, it makes the
>> iommu_attach_device_pasid() unable to detect if the pasid has been
>> attached or not. To be complete, let the iommu_attach_device_pasid()
>> store the domain to group->pasid_array if no valid handle.
>>
>> Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
>> Signed-off-by: Yi Liu <yi.l.liu@intel.com>
>> ---
>>   drivers/iommu/iommu.c | 23 +++++++++++++++++------
>>   1 file changed, 17 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
>> index 28ffd836592b..278c4eb8f225 100644
>> --- a/drivers/iommu/iommu.c
>> +++ b/drivers/iommu/iommu.c
>> @@ -45,6 +45,8 @@ static unsigned int iommu_def_domain_type __read_mostly;
>>   static bool iommu_dma_strict __read_mostly = IS_ENABLED(CONFIG_IOMMU_DEFAULT_DMA_STRICT);
>>   static u32 iommu_cmd_line __read_mostly;
>>   
>> +enum { IOMMU_PASID_ARRAY_DOMAIN, IOMMU_PASID_ARRAY_HANDLE };
> 
> Since xarray says:
> 
>   * @tag: Tag value (0, 1 or 3).
> 
> I would initialize those enums and add a small comment

yes.

> /* tags used with xa_tag_pointer() */
> enum { IOMMU_PASID_ARRAY_DOMAIN = 0, IOMMU_PASID_ARRAY_HANDLE = 1 };
> 
>> @@ -3397,10 +3400,14 @@ int iommu_attach_device_pasid(struct iommu_domain *domain,
>>   		}
>>   	}
>>   
>> -	if (handle)
>> +	if (handle) {
>>   		handle->domain = domain;
>> +		xa_entry = xa_tag_pointer(handle, IOMMU_PASID_ARRAY_HANDLE);
>> +	} else {
>> +		xa_entry = xa_tag_pointer(domain, IOMMU_PASID_ARRAY_DOMAIN);
>> +	}
> 
> What about iommu_attach_group_handle() ?
> 
> 	mutex_lock(&group->mutex);
> 	ret = xa_insert(&group->pasid_array, IOMMU_NO_PASID, handle, GFP_KERNEL);
> 	if (ret)
> 
> And iommu_replace_group_handle() ?
> 
> 	curr = xa_store(&group->pasid_array, IOMMU_NO_PASID, handle, GFP_KERNEL);
> 
> I think it should be consistent and it should call xa_tag_poiner() too
> (even though it implicitly always is since the domain is stored in the
> group)??

yes, it needs to be fixed as well. I asked a help from Baolu in prior
email, but I can enlarge this series to cover both RID and PASID path. :)

-- 
Regards,
Yi Liu

  parent reply	other threads:[~2025-01-21  7:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-20  3:08 [PATCH 0/2] Two enhancements to iommu_attach_device_pasid() Yi Liu
2025-01-20  3:08 ` [PATCH 1/2] iommu: Store either domain or handle in group->pasid_array Yi Liu
2025-01-20  5:55   ` Tian, Kevin
2025-01-20 15:55   ` Jason Gunthorpe
2025-01-21  2:02     ` Baolu Lu
2025-01-21  7:22     ` Yi Liu [this message]
2025-01-20  3:08 ` [PATCH 2/2] iommu: Swap the order of setting group->pasid_array and __iommu_set_group_pasid() Yi Liu
2025-01-20  5:58   ` Tian, Kevin
2025-01-20  6:57     ` Yi Liu
2025-01-20 16:13   ` Jason Gunthorpe
2025-01-21  9:27     ` Yi Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=049af2c8-dc76-40c4-9e1c-3d4b9743607b@intel.com \
    --to=yi.l.liu@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jacob.pan@linux.microsoft.com \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox