[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d93c8cc9-77a5-4b78-85d2-6b4601f52266@linux.intel.com>
Date: Thu, 20 Feb 2025 15:03:21 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: Jason Gunthorpe <jgg@...pe.ca>
Cc: Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>, Kevin Tian <kevin.tian@...el.com>,
Fenghua Yu <fenghua.yu@...el.com>, Dave Jiang <dave.jiang@...el.com>,
Vinod Koul <vkoul@...nel.org>, Zhangfei Gao <zhangfei.gao@...aro.org>,
Zhou Wang <wangzhou1@...ilicon.com>, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 08/12] iommufd/selftest: Put iopf enablement in domain
attach path
On 2/20/25 09:02, Jason Gunthorpe wrote:
> On Fri, Feb 14, 2025 at 02:11:00PM +0800, Lu Baolu wrote:
>> @@ -197,11 +201,19 @@ static int mock_domain_nop_attach(struct iommu_domain *domain,
>> if (domain->dirty_ops && (mdev->flags & MOCK_FLAGS_DEVICE_NO_DIRTY))
>> return -EINVAL;
>>
>> + return mock_dev_enable_iopf(dev, domain);
>> +}
>
> This isn't going to work for a replace type operation? Maybe like:
>
> if (old_domain->iopf_handler && !domain->iopf_handler)
> return mock_dev_disable_iopf(dev, domain);
> if (old_domain->iopf_handler && domain->iopf_handler)
> return 0;
> return mock_dev_enable_iopf(dev, domain);
>
> ?
The iommufd mock device driver appears not to support replacement. The
replacement operation on this driver is likely handled as follows:
- attach domain_a
- attach blocking_domain
- attach domain_b
The mock_dev_disable_iopf() is called in attach_dev of the blocking
domain.
There seems to be a bug in this patch. The existing domain should be
passed to mock_dev_disable_iopf(). It requires something similar to the
following:
diff --git a/drivers/iommu/iommufd/selftest.c
b/drivers/iommu/iommufd/selftest.c
index a6b12cee7b00..54a6f0851758 100644
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -168,6 +168,7 @@ struct mock_dev {
int id;
u32 cache[MOCK_DEV_CACHE_NUM];
unsigned int iopf_refcount;
+ struct iommu_domain *domain;
};
static inline struct mock_dev *to_mock_dev(struct device *dev)
@@ -197,17 +198,24 @@ static int mock_domain_nop_attach(struct
iommu_domain *domain,
struct device *dev)
{
struct mock_dev *mdev = to_mock_dev(dev);
+ int ret;
if (domain->dirty_ops && (mdev->flags &
MOCK_FLAGS_DEVICE_NO_DIRTY))
return -EINVAL;
- return mock_dev_enable_iopf(dev, domain);
+ ret = mock_dev_enable_iopf(dev, domain);
+ if (ret)
+ return ret;
+
+ mdev->domain = domain;
}
static int mock_domain_blocking_attach(struct iommu_domain *domain,
struct device *dev)
{
- mock_dev_disable_iopf(dev, domain);
+ struct mock_dev *mdev = to_mock_dev(dev);
+
+ mock_dev_disable_iopf(dev, mdev->domain);
return 0;
}
Thanks,
baolu
Powered by blists - more mailing lists