Skip to content

Commit 522af64

Browse files
committed
iommu/s390: Convert to probe/release_device() call-backs
Convert the S390 IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 52dd3ca commit 522af64

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

drivers/iommu/s390-iommu.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,14 @@ static void s390_iommu_detach_device(struct iommu_domain *domain,
166166
}
167167
}
168168

169-
static int s390_iommu_add_device(struct device *dev)
169+
static struct iommu_device *s390_iommu_probe_device(struct device *dev)
170170
{
171-
struct iommu_group *group = iommu_group_get_for_dev(dev);
172171
struct zpci_dev *zdev = to_pci_dev(dev)->sysdata;
173172

174-
if (IS_ERR(group))
175-
return PTR_ERR(group);
176-
177-
iommu_group_put(group);
178-
iommu_device_link(&zdev->iommu_dev, dev);
179-
180-
return 0;
173+
return &zdev->iommu_dev;
181174
}
182175

183-
static void s390_iommu_remove_device(struct device *dev)
176+
static void s390_iommu_release_device(struct device *dev)
184177
{
185178
struct zpci_dev *zdev = to_pci_dev(dev)->sysdata;
186179
struct iommu_domain *domain;
@@ -191,7 +184,7 @@ static void s390_iommu_remove_device(struct device *dev)
191184
* to vfio-pci and completing the VFIO_SET_IOMMU ioctl (which triggers
192185
* the attach_dev), removing the device via
193186
* "echo 1 > /sys/bus/pci/devices/.../remove" won't trigger detach_dev,
194-
* only remove_device will be called via the BUS_NOTIFY_REMOVED_DEVICE
187+
* only release_device will be called via the BUS_NOTIFY_REMOVED_DEVICE
195188
* notifier.
196189
*
197190
* So let's call detach_dev from here if it hasn't been called before.
@@ -201,9 +194,6 @@ static void s390_iommu_remove_device(struct device *dev)
201194
if (domain)
202195
s390_iommu_detach_device(domain, dev);
203196
}
204-
205-
iommu_device_unlink(&zdev->iommu_dev, dev);
206-
iommu_group_remove_device(dev);
207197
}
208198

209199
static int s390_iommu_update_trans(struct s390_domain *s390_domain,
@@ -373,8 +363,8 @@ static const struct iommu_ops s390_iommu_ops = {
373363
.map = s390_iommu_map,
374364
.unmap = s390_iommu_unmap,
375365
.iova_to_phys = s390_iommu_iova_to_phys,
376-
.add_device = s390_iommu_add_device,
377-
.remove_device = s390_iommu_remove_device,
366+
.probe_device = s390_iommu_probe_device,
367+
.release_device = s390_iommu_release_device,
378368
.device_group = generic_device_group,
379369
.pgsize_bitmap = S390_IOMMU_PGSIZES,
380370
};

0 commit comments

Comments
 (0)