aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu/amd_iommu.c
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2011-10-21 15:56:24 -0400
committerJoerg Roedel <joerg.roedel@amd.com>2011-11-15 06:22:31 -0500
commitbcb71abe7d4c5a0d0368c67da0a7def4fc73497a (patch)
tree3a043f872b234cb5c47cec1c01b4bbb69539fa0f /drivers/iommu/amd_iommu.c
parent8fbdce659549d93dfb257ec4eabacf63a188e506 (diff)
iommu: Add option to group multi-function devices
The option iommu=group_mf indicates the that the iommu driver should expose all functions of a multi-function PCI device as the same iommu_device_group. This is useful for disallowing individual functions being exposed as independent devices to userspace as there are often hidden dependencies. Virtual functions are not affected by this option. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'drivers/iommu/amd_iommu.c')
-rw-r--r--drivers/iommu/amd_iommu.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 1d82b631d09c..6f7553684c1e 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2776,11 +2776,19 @@ static int amd_iommu_domain_has_cap(struct iommu_domain *domain,
2776static int amd_iommu_device_group(struct device *dev, unsigned int *groupid) 2776static int amd_iommu_device_group(struct device *dev, unsigned int *groupid)
2777{ 2777{
2778 struct iommu_dev_data *dev_data = dev->archdata.iommu; 2778 struct iommu_dev_data *dev_data = dev->archdata.iommu;
2779 struct pci_dev *pdev = to_pci_dev(dev);
2780 u16 devid;
2779 2781
2780 if (!dev_data) 2782 if (!dev_data)
2781 return -ENODEV; 2783 return -ENODEV;
2782 2784
2783 *groupid = amd_iommu_alias_table[dev_data->devid]; 2785 if (pdev->is_virtfn || !iommu_group_mf)
2786 devid = dev_data->devid;
2787 else
2788 devid = calc_devid(pdev->bus->number,
2789 PCI_DEVFN(PCI_SLOT(pdev->devfn), 0));
2790
2791 *groupid = amd_iommu_alias_table[devid];
2784 2792
2785 return 0; 2793 return 0;
2786} 2794}