Re: [PATCH v2 7/8] iommu: Retire bus ops

From: Jason Gunthorpe
Date: Mon Jan 30 2023 - 09:25:30 EST


On Sat, Jan 28, 2023 at 08:55:09PM +0800, kernel test robot wrote:

> >> drivers/iommu/iommufd/selftest.c:276:39: error: field designator 'iommu_ops' does not refer to any field in type 'struct bus_type'
> static struct bus_type mock_bus = { .iommu_ops = &mock_ops };

So this shortcut isn't going to work..

Probably something like this is the simplest thing:

diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
index cfb5fe9a5e0ee8..27bab42b1ff841 100644
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -274,6 +274,8 @@ static int iommufd_test_mock_domain(struct iommufd_ucmd *ucmd,
struct iommu_test_cmd *cmd)
{
static struct bus_type mock_bus = { .iommu_ops = &mock_ops };
+ static struct iommu_device mock_iommu = { .ops = &mock_ops };
+ static struct dev_iommu mock_dev_iommu = { .iommu_dev = &mock_iommu };
struct iommufd_hw_pagetable *hwpt;
struct selftest_obj *sobj;
struct iommufd_ioas *ioas;
@@ -291,6 +293,7 @@ static int iommufd_test_mock_domain(struct iommufd_ucmd *ucmd,
sobj->idev.ictx = ucmd->ictx;
sobj->type = TYPE_IDEV;
sobj->idev.mock_dev.bus = &mock_bus;
+ sobj->idev.mock_dev.iommu = &mock_dev_iommu;

hwpt = iommufd_device_selftest_attach(ucmd->ictx, ioas,
&sobj->idev.mock_dev);

And then delete mock_bus at this patch

Jason