[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241017171500.GM3559746@nvidia.com>
Date: Thu, 17 Oct 2024 14:15:00 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Nicolin Chen <nicolinc@...dia.com>
Cc: kevin.tian@...el.com, will@...nel.org, joro@...tes.org,
suravee.suthikulpanit@....com, robin.murphy@....com,
dwmw2@...radead.org, baolu.lu@...ux.intel.com, shuah@...nel.org,
linux-kernel@...r.kernel.org, iommu@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org,
linux-kselftest@...r.kernel.org, eric.auger@...hat.com,
jean-philippe@...aro.org, mdf@...nel.org, mshavit@...gle.com,
shameerali.kolothum.thodi@...wei.com, smostafa@...gle.com,
yi.l.liu@...el.com, aik@....com, patches@...ts.linux.dev
Subject: Re: [PATCH v3 08/11] iommufd/selftest: Add IOMMU_VIOMMU_TYPE_SELFTEST
On Wed, Oct 09, 2024 at 09:38:08AM -0700, Nicolin Chen wrote:
> +static struct iommufd_viommu *
> +mock_viommu_alloc(struct iommu_device *iommu_dev, struct iommu_domain *domain,
> + struct iommufd_ctx *ictx, unsigned int viommu_type)
> +{
> + struct mock_iommu_device *mock_iommu =
> + container_of(iommu_dev, struct mock_iommu_device, iommu_dev);
> + struct mock_viommu *mock_viommu;
> +
> + if (viommu_type != IOMMU_VIOMMU_TYPE_SELFTEST)
> + return ERR_PTR(-EOPNOTSUPP);
What about the default viommu? What happens then?
> + mock_viommu = iommufd_viommu_alloc(ictx, mock_viommu, core,
> + &mock_viommu_ops);
> + if (IS_ERR(mock_viommu))
> + return ERR_CAST(mock_viommu);
> +
> + if (!refcount_inc_not_zero(&mock_iommu->users)) {
It would be a bug if the iommu_dev being passed in was somehow
released while iommufd had hold of it through vfio. So just use
refcount_inc()
Jason
Powered by blists - more mailing lists