• Oliver O'Halloran's avatar
    powerpc/powernv/pci: Add device to iommu group during dma_dev_setup() · 84d8cc07
    Oliver O'Halloran authored
    Historically adding devices to their respective iommu group has been
    handled by the post-init phb fixup for most devices. This was done
    because:
    
    1) The IOMMU group is tied to the PE (usually) so we can only setup the
       iommu groups after we've done resource allocation since BAR location
       determines the device's PE, and:
    2) The sysfs directory for the pci_dev needs to be available since
       iommu_add_device() wants to add an attribute for the iommu group.
    
    However, since commit 30d87ef8 ("powerpc/pci: Fix
    pcibios_setup_device() ordering") both conditions are met when
    hose->ops->dma_dev_setup() is called so there's no real need to do
    this in the fixup.
    
    Moving the call to iommu_add_device() into pnv_pci_ioda_dma_setup_dev()
    is a nice cleanup since it puts all the per-device IOMMU setup into one
    place. It also results in all (non-nvlink) devices getting their iommu
    group via a common path rather than relying on the bus notifier hack
    in pnv_tce_iommu_bus_notifier() to handle the adding VFs and
    hotplugged devices to their group.
    Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
    Reviewed-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200406030745.24595-5-oohall@gmail.com
    84d8cc07
pci-ioda.c 108 KB