public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Jean-Philippe Brucker <jean-philippe@linaro.org>,
	Nicolin Chen <nicolinc@nvidia.com>
Cc: baolu.lu@linux.intel.com, "Liu, Yi L" <yi.l.liu@intel.com>,
	Jacob Pan <jacob.jun.pan@linux.intel.com>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/3] iommu: Make single-device group for PASID explicit
Date: Mon, 21 Aug 2023 13:44:33 +0800	[thread overview]
Message-ID: <51dfc143-aafd-fea2-26fe-e2e9025fcd21@linux.intel.com> (raw)
In-Reply-To: <BN9PR11MB5276E3C3D99C2DFA963805C98C1BA@BN9PR11MB5276.namprd11.prod.outlook.com>

On 2023/8/18 11:56, Tian, Kevin wrote:
>> From: Lu Baolu <baolu.lu@linux.intel.com>
>> Sent: Monday, August 14, 2023 9:18 AM
>>
>> The PASID interfaces have always supported only single-device groups.
>> This was first introduced in commit 26b25a2b98e45 ("iommu: Bind process
>> address spaces to devices"), and has been kept consistent in subsequent
>> commits.
>>
>> However, the core code doesn't explicitly check for this requirement
>> after commit 201007ef707a8 ("PCI: Enable PASID only when ACS RR & UF
>> enabled on upstream path"), which made this requirement implicit.
>>
>> Restore the check to make it explicit that the PASID interfaces only
>> support devices belonging to single-device groups.
>>
>> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>> ---
>>   drivers/iommu/iommu.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
>> index 71b9c41f2a9e..f1eba60e573f 100644
>> --- a/drivers/iommu/iommu.c
>> +++ b/drivers/iommu/iommu.c
>> @@ -3408,6 +3408,11 @@ int iommu_attach_device_pasid(struct
>> iommu_domain *domain,
>>   		return -ENODEV;
>>
>>   	mutex_lock(&group->mutex);
>> +	if (list_count_nodes(&group->devices) != 1) {
>> +		ret = -EINVAL;
>> +		goto out_unlock;
>> +	}
>> +
> 
> I wonder whether we should also block adding new device to this
> group once the single-device has pasid enabled. Otherwise the

This has been guaranteed by pci_enable_pasid():

         if (!pci_acs_path_enabled(pdev, NULL, PCI_ACS_RR | PCI_ACS_UF))
                 return -EINVAL;

> check alone at attach time doesn't mean this group won't be
> expanded to have multiple devices later.

Best regards,
baolu

  reply	other threads:[~2023-08-21  5:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14  1:17 [PATCH v2 0/3] iommu: Make pasid array per device Lu Baolu
2023-08-14  1:17 ` [PATCH v2 1/3] iommu: Make single-device group for PASID explicit Lu Baolu
2023-08-18  3:56   ` Tian, Kevin
2023-08-21  5:44     ` Baolu Lu [this message]
2023-08-21  6:33       ` Tian, Kevin
2023-08-22  6:36         ` Baolu Lu
2023-08-22  8:24           ` Tian, Kevin
2023-08-22 13:51             ` Baolu Lu
2023-08-14  1:17 ` [PATCH v2 2/3] iommu: Consolidate pasid dma ownership check Lu Baolu
2023-08-18  5:43   ` Nicolin Chen
2023-08-21  5:46     ` Baolu Lu
2023-08-14  1:17 ` [PATCH v2 3/3] iommu: Move pasid array from group to device Lu Baolu

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=51dfc143-aafd-fea2-26fe-e2e9025fcd21@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=jean-philippe@linaro.org \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    --cc=yi.l.liu@intel.com \
    /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