Skip to content

Commit b321a2f

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu: Make .release_device optional
Many drivers do nothing meaningful for .release_device, and it's neatly abstracted to just two callsites in the core code, so let's make it optional to implement. Signed-off-by: Robin Murphy <robin.murphy@arm.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Link: https://lore.kernel.org/r/bda9d3eb4527eac8f6544a15067e2529cca54a2e.1655822151.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent e63cfb5 commit b321a2f

6 files changed

Lines changed: 4 additions & 23 deletions

File tree

drivers/iommu/fsl_pamu_domain.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,15 +447,10 @@ static struct iommu_device *fsl_pamu_probe_device(struct device *dev)
447447
return &pamu_iommu;
448448
}
449449

450-
static void fsl_pamu_release_device(struct device *dev)
451-
{
452-
}
453-
454450
static const struct iommu_ops fsl_pamu_ops = {
455451
.capable = fsl_pamu_capable,
456452
.domain_alloc = fsl_pamu_domain_alloc,
457453
.probe_device = fsl_pamu_probe_device,
458-
.release_device = fsl_pamu_release_device,
459454
.device_group = fsl_pamu_device_group,
460455
.default_domain_ops = &(const struct iommu_domain_ops) {
461456
.attach_dev = fsl_pamu_attach_device,

drivers/iommu/iommu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list
259259
return 0;
260260

261261
out_release:
262-
ops->release_device(dev);
262+
if (ops->release_device)
263+
ops->release_device(dev);
263264

264265
out_module_put:
265266
module_put(ops->owner);
@@ -337,7 +338,8 @@ void iommu_release_device(struct device *dev)
337338
iommu_device_unlink(dev->iommu->iommu_dev, dev);
338339

339340
ops = dev_iommu_ops(dev);
340-
ops->release_device(dev);
341+
if (ops->release_device)
342+
ops->release_device(dev);
341343

342344
iommu_group_remove_device(dev);
343345
module_put(ops->owner);

drivers/iommu/msm_iommu.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,6 @@ static struct iommu_device *msm_iommu_probe_device(struct device *dev)
394394
return &iommu->iommu;
395395
}
396396

397-
static void msm_iommu_release_device(struct device *dev)
398-
{
399-
}
400-
401397
static int msm_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
402398
{
403399
int ret = 0;
@@ -677,7 +673,6 @@ irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id)
677673
static struct iommu_ops msm_iommu_ops = {
678674
.domain_alloc = msm_iommu_domain_alloc,
679675
.probe_device = msm_iommu_probe_device,
680-
.release_device = msm_iommu_release_device,
681676
.device_group = generic_device_group,
682677
.pgsize_bitmap = MSM_IOMMU_PGSIZES,
683678
.of_xlate = qcom_iommu_of_xlate,

drivers/iommu/sun50i-iommu.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,6 @@ static struct iommu_device *sun50i_iommu_probe_device(struct device *dev)
738738
return &iommu->iommu;
739739
}
740740

741-
static void sun50i_iommu_release_device(struct device *dev) {}
742-
743741
static struct iommu_group *sun50i_iommu_device_group(struct device *dev)
744742
{
745743
struct sun50i_iommu *iommu = sun50i_iommu_from_dev(dev);
@@ -764,7 +762,6 @@ static const struct iommu_ops sun50i_iommu_ops = {
764762
.domain_alloc = sun50i_iommu_domain_alloc,
765763
.of_xlate = sun50i_iommu_of_xlate,
766764
.probe_device = sun50i_iommu_probe_device,
767-
.release_device = sun50i_iommu_release_device,
768765
.default_domain_ops = &(const struct iommu_domain_ops) {
769766
.attach_dev = sun50i_iommu_attach_device,
770767
.detach_dev = sun50i_iommu_detach_device,

drivers/iommu/tegra-gart.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,6 @@ static struct iommu_device *gart_iommu_probe_device(struct device *dev)
246246
return &gart_handle->iommu;
247247
}
248248

249-
static void gart_iommu_release_device(struct device *dev)
250-
{
251-
}
252-
253249
static int gart_iommu_of_xlate(struct device *dev,
254250
struct of_phandle_args *args)
255251
{
@@ -273,7 +269,6 @@ static void gart_iommu_sync(struct iommu_domain *domain,
273269
static const struct iommu_ops gart_iommu_ops = {
274270
.domain_alloc = gart_iommu_domain_alloc,
275271
.probe_device = gart_iommu_probe_device,
276-
.release_device = gart_iommu_release_device,
277272
.device_group = generic_device_group,
278273
.pgsize_bitmap = GART_IOMMU_PGSIZES,
279274
.of_xlate = gart_iommu_of_xlate,

drivers/iommu/tegra-smmu.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,6 @@ static struct iommu_device *tegra_smmu_probe_device(struct device *dev)
864864
return &smmu->iommu;
865865
}
866866

867-
static void tegra_smmu_release_device(struct device *dev) {}
868-
869867
static const struct tegra_smmu_group_soc *
870868
tegra_smmu_find_group(struct tegra_smmu *smmu, unsigned int swgroup)
871869
{
@@ -966,7 +964,6 @@ static int tegra_smmu_of_xlate(struct device *dev,
966964
static const struct iommu_ops tegra_smmu_ops = {
967965
.domain_alloc = tegra_smmu_domain_alloc,
968966
.probe_device = tegra_smmu_probe_device,
969-
.release_device = tegra_smmu_release_device,
970967
.device_group = tegra_smmu_device_group,
971968
.of_xlate = tegra_smmu_of_xlate,
972969
.pgsize_bitmap = SZ_4K,

0 commit comments

Comments
 (0)