Message ID | 7-v2-406f7ac07936+6a-iommufd_hwpt_jgg@nvidia.com |
---|---|
State | Superseded |
Headers | show |
Series | Revise the hwpt lifetime model | expand |
> From: Jason Gunthorpe <jgg@nvidia.com> > Sent: Thursday, February 23, 2023 5:03 AM > > This can now be covered since we have a full struct device. > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > --- > tools/testing/selftests/iommu/iommufd.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/iommu/iommufd.c > b/tools/testing/selftests/iommu/iommufd.c > index 0c4bbd4079a425..69cb79d6a0711d 100644 > --- a/tools/testing/selftests/iommu/iommufd.c > +++ b/tools/testing/selftests/iommu/iommufd.c > @@ -187,6 +187,7 @@ FIXTURE(iommufd_ioas) > int fd; > uint32_t ioas_id; > uint32_t domain_id; > + uint32_t hwpt_id; > uint64_t base_iova; > }; > > @@ -212,7 +213,7 @@ FIXTURE_SETUP(iommufd_ioas) > } > > for (i = 0; i != variant->mock_domains; i++) { > - test_cmd_mock_domain(self->ioas_id, NULL, &self- > >domain_id); > + test_cmd_mock_domain(self->ioas_id, &self->domain_id, > &self->hwpt_id); I didn't get how this works. self->domain_id now means device_id but other references still take it as a domain, e.g.: TEST_F(iommufd_ioas, ioas_destroy) { if (self->domain_id) { /* IOAS cannot be freed while a domain is on it */ EXPECT_ERRNO(EBUSY, _test_ioctl_destroy(self->fd, self->ioas_id)); } else { /* Can allocate and manually free an IOAS table */ test_ioctl_destroy(self->ioas_id); } }
On Fri, Feb 24, 2023 at 07:02:06AM +0000, Tian, Kevin wrote: > > From: Jason Gunthorpe <jgg@nvidia.com> > > Sent: Thursday, February 23, 2023 5:03 AM > > > > This can now be covered since we have a full struct device. > > > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > > --- > > tools/testing/selftests/iommu/iommufd.c | 13 ++++++++++++- > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/tools/testing/selftests/iommu/iommufd.c > > b/tools/testing/selftests/iommu/iommufd.c > > index 0c4bbd4079a425..69cb79d6a0711d 100644 > > --- a/tools/testing/selftests/iommu/iommufd.c > > +++ b/tools/testing/selftests/iommu/iommufd.c > > @@ -187,6 +187,7 @@ FIXTURE(iommufd_ioas) > > int fd; > > uint32_t ioas_id; > > uint32_t domain_id; > > + uint32_t hwpt_id; > > uint64_t base_iova; > > }; > > > > @@ -212,7 +213,7 @@ FIXTURE_SETUP(iommufd_ioas) > > } > > > > for (i = 0; i != variant->mock_domains; i++) { > > - test_cmd_mock_domain(self->ioas_id, NULL, &self- > > >domain_id); > > + test_cmd_mock_domain(self->ioas_id, &self->domain_id, > > &self->hwpt_id); > > I didn't get how this works. self->domain_id now means device_id but > other references still take it as a domain, e.g. The names are just wrong, Nicolin pointed this out and I had a later patch to fix it, but lets move it earlier to this series. Thanks, Jason
diff --git a/tools/testing/selftests/iommu/iommufd.c b/tools/testing/selftests/iommu/iommufd.c index 0c4bbd4079a425..69cb79d6a0711d 100644 --- a/tools/testing/selftests/iommu/iommufd.c +++ b/tools/testing/selftests/iommu/iommufd.c @@ -187,6 +187,7 @@ FIXTURE(iommufd_ioas) int fd; uint32_t ioas_id; uint32_t domain_id; + uint32_t hwpt_id; uint64_t base_iova; }; @@ -212,7 +213,7 @@ FIXTURE_SETUP(iommufd_ioas) } for (i = 0; i != variant->mock_domains; i++) { - test_cmd_mock_domain(self->ioas_id, NULL, &self->domain_id); + test_cmd_mock_domain(self->ioas_id, &self->domain_id, &self->hwpt_id); self->base_iova = MOCK_APERTURE_START; } } @@ -259,6 +260,16 @@ TEST_F(iommufd_ioas, ioas_destroy) } } +TEST_F(iommufd_ioas, hwpt_attach) +{ + /* Create a device attached directly to a hwpt */ + if (self->domain_id) { + test_cmd_mock_domain(self->hwpt_id, NULL, NULL); + } else { + test_err_mock_domain(ENOENT, self->hwpt_id, NULL, NULL); + } +} + TEST_F(iommufd_ioas, ioas_area_destroy) { /* Adding an area does not change ability to destroy */
This can now be covered since we have a full struct device. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- tools/testing/selftests/iommu/iommufd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)