Message ID | 0-v5-d0a204c678c7+3d16a-iommu_all_defdom_jgg@nvidia.com |
---|---|
Headers | show |
Series | iommu: Make default_domain's mandatory | expand |
On Mon, Jul 24, 2023 at 02:21:50PM -0300, Jason Gunthorpe wrote: > [ It would be good to get this in linux-next, we have some good test > coverage on the ARM side already, thanks! ] > > It has been a long time coming, this series completes the default_domain > transition and makes it so that the core IOMMU code will always have a > non-NULL default_domain for every driver on every > platform. set_platform_dma_ops() turned out to be a bad idea, and so > completely remove it. Joerg, I think we are done with this now, it has been two months since a substantive comment. Can you take it so we have enough time in linux-next? There is a small typo in a commit message, patch 15 should have s/omap_iommu_set_platform_dma/msm_iommu_set_platform_dma/ Let me know if you want me to resend Thanks, Jason
On Mon, Jul 24, 2023 at 02:22:05PM -0300, Jason Gunthorpe wrote: > -void __init iommufd_test_init(void) > +int __init iommufd_test_init(void) > { > + struct platform_device_info pdevinfo = { > + .name = "iommufd_selftest_iommu", > + }; > + int rc; > + > dbgfs_root = > fault_create_debugfs_attr("fail_iommufd", NULL, &fail_iommufd); > - WARN_ON(bus_register(&iommufd_mock_bus_type)); > + > + selftest_iommu_dev = platform_device_register_full(&pdevinfo); > + if (IS_ERR(selftest_iommu_dev)) { > + rc = PTR_ERR(selftest_iommu_dev); > + goto err_dbgfs; > + } > + > + rc = bus_register(&iommufd_mock_bus_type.bus); > + if (rc) > + goto err_platform; > + > + mock_iommu_device.dev = &selftest_iommu_dev->dev; > + rc = iommu_device_register_bus(&mock_iommu_device, &mock_ops, > + &iommufd_mock_bus_type.bus, > + &iommufd_mock_bus_type.nb); > + if (rc) > + goto err_bus; > + return 0; > + > +err_bus: > + bus_unregister(&iommufd_mock_bus_type.bus); > +err_platform: > + platform_device_del(selftest_iommu_dev); > +err_dbgfs: > + debugfs_remove_recursive(dbgfs_root); > + return rc; > } > > void iommufd_test_exit(void) > { > + iommu_device_unregister_bus(&mock_iommu_device, > + &iommufd_mock_bus_type.bus, > + &iommufd_mock_bus_type.nb); > + bus_unregister(&iommufd_mock_bus_type.bus); > + platform_device_del(selftest_iommu_dev); > debugfs_remove_recursive(dbgfs_root); > - bus_unregister(&iommufd_mock_bus_type); > } There is a mistake here that started to become visible after one of the rebases, it needs to call iommu_device_sysfs_add() prior to iommu_device_register_bus() otherwise the iommu core stuff does not fully initialize and weird stuff starts happening. So, it needs this: diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c index 5433c9c545526d..d2b59a1157441c 100644 --- a/drivers/iommu/iommufd/selftest.c +++ b/drivers/iommu/iommufd/selftest.c @@ -987,14 +987,21 @@ int __init iommufd_test_init(void) if (rc) goto err_platform; - mock_iommu_device.dev = &selftest_iommu_dev->dev; + rc = iommu_device_sysfs_add(&mock_iommu_device, + &selftest_iommu_dev->dev, NULL, "%s", + dev_name(&selftest_iommu_dev->dev)); + if (rc) + goto err_bus; + rc = iommu_device_register_bus(&mock_iommu_device, &mock_ops, &iommufd_mock_bus_type.bus, &iommufd_mock_bus_type.nb); if (rc) - goto err_bus; + goto err_sysfs; return 0; +err_sysfs: + iommu_device_sysfs_remove(&mock_iommu_device); err_bus: bus_unregister(&iommufd_mock_bus_type.bus); err_platform: @@ -1006,6 +1013,7 @@ int __init iommufd_test_init(void) void iommufd_test_exit(void) { + iommu_device_sysfs_remove(&mock_iommu_device); iommu_device_unregister_bus(&mock_iommu_device, &iommufd_mock_bus_type.bus, &iommufd_mock_bus_type.nb);