diff options
author | Joerg Roedel <jroedel@suse.de> | 2015-10-21 17:51:36 -0400 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2015-10-21 18:00:48 -0400 |
commit | 46c6b2bc88a729366605d0dedb6a35b8cf7cc4f0 (patch) | |
tree | 7584041357cf881e24998c49a14353cf32ed14d8 | |
parent | 876945dbf6497c7539ef958fee7ade970fbbe17a (diff) |
iommu: Revive device_group iommu-ops call-back
That call-back is currently unused, change it into a
call-back function for finding the right IOMMU group for a
device.
This is a first step to remove the hard-coded PCI dependency
in the iommu-group code.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r-- | drivers/iommu/iommu.c | 9 | ||||
-rw-r--r-- | include/linux/iommu.h | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 049df495c274..563746383973 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c | |||
@@ -814,6 +814,7 @@ static struct iommu_group *iommu_group_get_for_pci_dev(struct pci_dev *pdev) | |||
814 | */ | 814 | */ |
815 | struct iommu_group *iommu_group_get_for_dev(struct device *dev) | 815 | struct iommu_group *iommu_group_get_for_dev(struct device *dev) |
816 | { | 816 | { |
817 | const struct iommu_ops *ops = dev->bus->iommu_ops; | ||
817 | struct iommu_group *group; | 818 | struct iommu_group *group; |
818 | int ret; | 819 | int ret; |
819 | 820 | ||
@@ -821,10 +822,12 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev) | |||
821 | if (group) | 822 | if (group) |
822 | return group; | 823 | return group; |
823 | 824 | ||
824 | if (!dev_is_pci(dev)) | 825 | group = ERR_PTR(-EINVAL); |
825 | return ERR_PTR(-EINVAL); | ||
826 | 826 | ||
827 | group = iommu_group_get_for_pci_dev(to_pci_dev(dev)); | 827 | if (ops && ops->device_group) |
828 | group = ops->device_group(dev); | ||
829 | else if (dev_is_pci(dev)) | ||
830 | group = iommu_group_get_for_pci_dev(to_pci_dev(dev)); | ||
828 | 831 | ||
829 | if (IS_ERR(group)) | 832 | if (IS_ERR(group)) |
830 | return group; | 833 | return group; |
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index f174506a5343..a1e6e8914c17 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h | |||
@@ -168,7 +168,7 @@ struct iommu_ops { | |||
168 | phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova); | 168 | phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova); |
169 | int (*add_device)(struct device *dev); | 169 | int (*add_device)(struct device *dev); |
170 | void (*remove_device)(struct device *dev); | 170 | void (*remove_device)(struct device *dev); |
171 | int (*device_group)(struct device *dev, unsigned int *groupid); | 171 | struct iommu_group *(*device_group)(struct device *dev); |
172 | int (*domain_get_attr)(struct iommu_domain *domain, | 172 | int (*domain_get_attr)(struct iommu_domain *domain, |
173 | enum iommu_attr attr, void *data); | 173 | enum iommu_attr attr, void *data); |
174 | int (*domain_set_attr)(struct iommu_domain *domain, | 174 | int (*domain_set_attr)(struct iommu_domain *domain, |