On Mon, 30 Jun 2025 19:28:33 -0300 Jason Gunthorpe <jgg@xxxxxxxxxx> wrote: > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index d265de874b14b6..f4584ffacbc03d 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -65,8 +65,16 @@ struct iommu_group { > struct list_head entry; > unsigned int owner_cnt; > void *owner; > + > + /* Used by the device_group() callbacks */ > + u32 bus_data; > }; > > +/* > + * Everything downstream of this group should share it. > + */ > +#define BUS_DATA_PCI_UNISOLATED BIT(0) NON_ISOLATED for consistency w/ enum from the previous patch? ... > +struct iommu_group *pci_device_group(struct device *dev) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + struct iommu_group *group; > + struct pci_dev *real_pdev; > + > + if (WARN_ON(!dev_is_pci(dev))) > + return ERR_PTR(-EINVAL); > + > + /* > + * Arches can supply a completely different PCI device that actually > + * does DMA. > + */ > + real_pdev = pci_real_dma_dev(pdev); > + if (real_pdev != pdev) { > + group = iommu_group_get(&real_pdev->dev); > + if (!group) { > + /* > + * The real_pdev has not had an iommu probed to it. We > + * can't create a new group here because there is no way > + * for pci_device_group(real_pdev) to pick it up. > + */ > + dev_err(dev, > + "PCI device is probing out of order, real device of %s is not probed yet\n", > + pci_name(real_pdev)); > + return ERR_PTR(-EPROBE_DEFER); > + } > + return group; > + } > + > + if (pdev->dev_flags & PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT) > + return iommu_group_alloc(); > + > + /* Anything upstream of this enforcing non-isolated? */ > + group = pci_hierarchy_group(pdev); > if (group) > return group; > > - /* No shared group found, allocate new */ > - return iommu_group_alloc(); > + switch (pci_bus_isolated(pdev->bus)) { > + case PCIE_ISOLATED: > + /* Check multi-function groups and same-bus devfn aliases */ > + group = pci_get_alias_group(pdev); > + if (group) > + return group; > + > + /* No shared group found, allocate new */ > + return iommu_group_alloc(); I'm not following how we'd handle a multi-function root port w/o consistent ACS isolation here. How/where does the resulting group get the UNISOLATED flag set? I think that's necessary for the look-back in pci_hierarchy_group(), right? Thanks, Alex