As generic_single_device_group() requires it. Otherwise it crashes: generic_single_device_group+0x24/0x88 __iommu_probe_device+0xe8/0x444 iommu_probe_device+0x1c/0x54 of_iommu_configure+0x10c/0x200 of_dma_configure_id+0x1e0/0x3b4 platform_dma_configure+0x30/0x78 really_probe+0x70/0x2b4 __driver_probe_device+0x78/0x12c driver_probe_device+0x3c/0x160 __driver_attach+0x9c/0x1ac bus_for_each_dev+0x74/0xd4 driver_attach+0x24/0x30 bus_add_driver+0xe4/0x1e8 driver_register+0x60/0x128 __platform_driver_register+0x28/0x34 hantro_driver_init+0x20/0x1000 [hantro_vpu] do_one_initcall+0x74/0x2f0 do_init_module+0x58/0x1ec load_module+0x1a20/0x1c64 init_module_from_file+0x84/0xc0 idempotent_init_module+0x180/0x250 __arm64_sys_finit_module+0x64/0xa0 invoke_syscall+0x48/0x114 el0_svc_common.constprop.0+0xec/0x10c do_el0_svc+0x38/0xa4 el0_svc+0x40/0xac el0t_64_sync_handler+0xc0/0xc4 el0t_64_sync+0x190/0x194 Fixes: 5dd59857af60 ("iommu: Add generic_single_device_group()") Reported-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx> Closes: https://lore.kernel.org/all/e5e75222-13a9-ee01-0c25-8311b622fe0d@xxxxxxxxxxx/ Tested-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx> Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx> --- drivers/iommu/iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 3ff365c9117850..18162049bd2294 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -366,6 +366,7 @@ static int iommu_init_device(struct device *dev, const struct iommu_ops *ops) ret = PTR_ERR(iommu_dev); goto err_module_put; } + dev->iommu->iommu_dev = iommu_dev; ret = iommu_device_link(iommu_dev, dev); if (ret) @@ -383,7 +384,6 @@ static int iommu_init_device(struct device *dev, const struct iommu_ops *ops) dev->iommu_group = group; mutex_unlock(&dev_iommu_group_lock); - dev->iommu->iommu_dev = iommu_dev; dev->iommu->max_pasids = dev_iommu_get_max_pasids(dev); if (ops->is_attach_deferred) dev->iommu->attach_deferred = ops->is_attach_deferred(dev); @@ -397,6 +397,7 @@ static int iommu_init_device(struct device *dev, const struct iommu_ops *ops) err_module_put: module_put(ops->owner); err_free: + dev->iommu->iommu_dev = NULL; dev_iommu_free(dev); return ret; } -- 2.41.0