Messages in this thread | | | Date | Tue, 28 Mar 2023 13:49:24 +0800 | Subject | Re: [PATCH v2 5/8] iommu/vt-d: Make device pasid attachment explicit | From | Baolu Lu <> |
| |
On 3/28/23 7:21 AM, Jacob Pan wrote: > diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h > index 65b15be72878..b6c26f25d1ba 100644 > --- a/drivers/iommu/intel/iommu.h > +++ b/drivers/iommu/intel/iommu.h > @@ -595,6 +595,7 @@ struct dmar_domain { > > spinlock_t lock; /* Protect device tracking lists */ > struct list_head devices; /* all devices' list */ > + struct list_head dev_pasids; /* all attached pasids */ > > struct dma_pte *pgd; /* virtual address */ > int gaw; /* max guest address width */ > @@ -708,6 +709,7 @@ struct device_domain_info { > u8 ats_supported:1; > u8 ats_enabled:1; > u8 dtlb_extra_inval:1; /* Quirk for devices need extra flush */ > + u8 dev_attached:1; /* Device context activated */ > u8 ats_qdep; > struct device *dev; /* it's NULL for PCIe-to-PCI bridge */ > struct intel_iommu *iommu; /* IOMMU used by this device */ > @@ -715,6 +717,12 @@ struct device_domain_info { > struct pasid_table *pasid_table; /* pasid table */ > }; > > +struct device_pasid_info { > + struct list_head link_domain; /* link to domain siblings */ > + struct device *dev; /* physical device derived from */ > + ioasid_t pasid; /* PASID on physical device */ > +};
The dev_pasids list seems to be duplicate with iommu_group::pasid_array.
The pasid_array is de facto per-device as the PCI subsystem requires ACS to be enabled on the upstream path to the root port.
pci_enable_pasid(): 385 if (!pci_acs_path_enabled(pdev, NULL, PCI_ACS_RR | PCI_ACS_UF)) 386 return -EINVAL;
For such PCI topology, pci_device_group() always assigns an exclusive iommu group (a.k.a. singleton group).
So, how about moving the pasid_array from struct iommu_group to struct dev_iommu? With this refactoring, the individual iommu driver has no need to create their own pasid array or list.
Instead of using iommu_group::mutex, perhaps the pasid_array needs its own lock in struct dev_iommu after moving.
Best regards, baolu
| |