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>
This commit is contained in:
parent
e0c04a47d6
commit
4e226b0bdf
2 changed files with 7 additions and 4 deletions
|
@ -817,6 +817,7 @@ static struct iommu_group *iommu_group_get_for_pci_dev(struct pci_dev *pdev)
|
|||
*/
|
||||
struct iommu_group *iommu_group_get_for_dev(struct device *dev)
|
||||
{
|
||||
const struct iommu_ops *ops = dev->bus->iommu_ops;
|
||||
struct iommu_group *group;
|
||||
int ret;
|
||||
|
||||
|
@ -824,10 +825,12 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev)
|
|||
if (group)
|
||||
return group;
|
||||
|
||||
if (!dev_is_pci(dev))
|
||||
return ERR_PTR(-EINVAL);
|
||||
group = ERR_PTR(-EINVAL);
|
||||
|
||||
group = iommu_group_get_for_pci_dev(to_pci_dev(dev));
|
||||
if (ops && ops->device_group)
|
||||
group = ops->device_group(dev);
|
||||
else if (dev_is_pci(dev))
|
||||
group = iommu_group_get_for_pci_dev(to_pci_dev(dev));
|
||||
|
||||
if (IS_ERR(group))
|
||||
return group;
|
||||
|
|
|
@ -191,7 +191,7 @@ struct iommu_ops {
|
|||
dma_addr_t iova);
|
||||
int (*add_device)(struct device *dev);
|
||||
void (*remove_device)(struct device *dev);
|
||||
int (*device_group)(struct device *dev, unsigned int *groupid);
|
||||
struct iommu_group *(*device_group)(struct device *dev);
|
||||
int (*domain_get_attr)(struct iommu_domain *domain,
|
||||
enum iommu_attr attr, void *data);
|
||||
int (*domain_set_attr)(struct iommu_domain *domain,
|
||||
|
|
Loading…
Add table
Reference in a new issue