Re: [PATCH v2 06/10] iommu/rockchip: Convert to generic_single_device_group()

Jason Gunthorpe
2023-08-09T13:51:29Z

On Wed, Aug 09, 2023 at 03:19:34PM +0200, Marek Szyprowski wrote:
> Hi Jason,
>
> On 31.07.2023 19:50, Jason Gunthorpe wrote:
> > Use the new helper.
> >
> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> > ---
> > drivers/iommu/rockchip-iommu.c | 22 ++--------------------
> > 1 file changed, 2 insertions(+), 20 deletions(-)
>
> After applying your recent fixes from "[PATCH 0/3] Fix device_lock
> deadlock on two probe() paths" thread I've decided to run more tests on
> all boards I have. This way I found that this patch breaks booting of
> Odroid-M1 board, which is ARM64 system based on Rockchip RK3568
> (arch/arm64/boot/dts/rockchip/rk3568-odroid-m1.dts). Here is the log:

Is this why?

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 8842f4975ec4a8..8677d3ace47bbe 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;
}

Thanks,
Jason