Re: [PATCH 1/1] iommu/vt-d: Enable PASID during iommu device probe

From: Baolu Lu
Date: Tue Sep 13 2022 - 05:25:12 EST

On 2022/9/13 16:01, Tian, Kevin wrote:
From: Lu Baolu <>
Sent: Monday, September 12, 2022 10:48 AM

@@ -1401,7 +1403,6 @@ static void iommu_enable_dev_iotlb(struct
device_domain_info *info)

This is not the right name now as dev_iotlb is only related to ATS.

Yes. This name is confusing. Perhaps we can split it into some specific

- intel_iommu_enable_pci_ats()
- intel_iommu_enabel_pci_pri()
- intel_iommu_enable_pci_pasid()

info->pfsid = pci_dev_id(pf_pdev);

/* The PCIe spec, in its wisdom, declares that the behaviour of
the device if you enable PASID support after ATS support is
undefined. So always enable PASID support on devices which
@@ -1414,7 +1415,7 @@ static void iommu_enable_dev_iotlb(struct
device_domain_info *info)
(info->pasid_enabled ? pci_prg_resp_pasid_required(pdev) : 1)
!pci_reset_pri(pdev) && !pci_enable_pri(pdev, PRQ_DEPTH))
info->pri_enabled = 1;
if (info->ats_supported && pci_ats_page_aligned(pdev) &&
!pci_enable_ats(pdev, VTD_PAGE_SHIFT)) {
info->ats_enabled = 1;

iommu_enable_dev_iotlb() is currently called both when the device is probed
and when sva is enabled (which is actually useless). From this angle the commit
msg is inaccurate.

The logic is a bit tricky. iommu_support_dev_iotlb() only returns a
devinfo pointer when ATS is supported on the device. So, you are right
if device supports both ATS and PASID; otherwise PASID will not be

diff --git a/drivers/iommu/intel/Kconfig b/drivers/iommu/intel/Kconfig
index 39a06d245f12..b3f40375f214 100644
--- a/drivers/iommu/intel/Kconfig
+++ b/drivers/iommu/intel/Kconfig
@@ -21,6 +21,8 @@ config INTEL_IOMMU
select IOASID
select IOMMU_DMA
select PCI_ATS
+ select PCI_PRI
+ select PCI_PASID
DMA remapping (DMAR) devices support enables independent
translations for Direct Memory Access (DMA) from devices.
@@ -48,8 +50,6 @@ config INTEL_IOMMU_DEBUGFS
bool "Support for Shared Virtual Memory with Intel IOMMU"
depends on X86_64
- select PCI_PASID
- select PCI_PRI
select IOASID

this is already selected by CONFIG_INTEL_IOMMU

Yes. Should be removed.

select IOMMU_SVA

Best regards,