summaryrefslogtreecommitdiff
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
committerHiroshi DOYU <hdoyu@nvidia.com>2012-01-23 11:11:38 +0200
commit207e42f7c160d4ba3e93385fb0ccfe8d6b798069 (patch)
tree68a9d6aeb094cf5640781f82d467cd7c5d2bc2e5 /drivers/iommu/amd_iommu.c
parentfeba22d51d38598182191c36bdf9fc2f2ebbe481 (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 e9c6233045eb..c106106f3f12 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2791,11 +2791,19 @@ static int amd_iommu_domain_has_cap(struct iommu_domain *domain,
static int amd_iommu_device_group(struct device *dev, unsigned int *groupid)
{
struct iommu_dev_data *dev_data = dev->archdata.iommu;
+ struct pci_dev *pdev = to_pci_dev(dev);
+ u16 devid;
if (!dev_data)
return -ENODEV;
- *groupid = amd_iommu_alias_table[dev_data->devid];
+ if (pdev->is_virtfn || !iommu_group_mf)
+ devid = dev_data->devid;
+ else
+ devid = calc_devid(pdev->bus->number,
+ PCI_DEVFN(PCI_SLOT(pdev->devfn), 0));
+
+ *groupid = amd_iommu_alias_table[devid];
return 0;
}