[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231024180049.GV3952@nvidia.com>
Date: Tue, 24 Oct 2023 15:00:49 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Nicolin Chen <nicolinc@...dia.com>
Cc: Yi Liu <yi.l.liu@...el.com>, joro@...tes.org,
alex.williamson@...hat.com, kevin.tian@...el.com,
robin.murphy@....com, baolu.lu@...ux.intel.com, cohuck@...hat.com,
eric.auger@...hat.com, kvm@...r.kernel.org, mjrosato@...ux.ibm.com,
chao.p.peng@...ux.intel.com, yi.y.sun@...ux.intel.com,
peterx@...hat.com, jasowang@...hat.com,
shameerali.kolothum.thodi@...wei.com, lulu@...hat.com,
suravee.suthikulpanit@....com, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
zhenzhong.duan@...el.com, joao.m.martins@...cle.com
Subject: Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object
On Tue, Oct 24, 2023 at 10:50:58AM -0700, Nicolin Chen wrote:
> > The point is for the user_data to always be available, the driver
> > needs to check it if it is passed.
> >
> > This should all be plumbed to allow drivers to also customize their
> > paging domains too.
>
> We don't have a use case of customizing the paging domains.
> And our selftest isn't covering this path. Nor the case is
> supported by the uAPI:
But this is the design, it is why everything is setup like this - we
didn't create a new op to allocate nesting domains, we made a flexible
user allocator.
> 458- * A kernel-managed HWPT will be created with the mappings from the given
> 459- * IOAS via the @pt_id. The @data_type for this allocation must be set to
> 460: * IOMMU_HWPT_DATA_NONE. The HWPT can be allocated as a parent HWPT for a
> 461- * nesting configuration by passing IOMMU_HWPT_ALLOC_NEST_PARENT via @flags.
> 462- *
Yes, that is the reality today. If someone comes to use the more
complete interface they need to fix that comment..
> Also, if we do passing in the data, we'd need to...
> 280-static struct iommu_domain *
> 281-mock_domain_alloc_user(struct device *dev, u32 flags,
> 282- struct iommu_domain *parent,
> 283: const struct iommu_user_data *user_data)
> 284-{
> 285- struct mock_iommu_domain *mock_parent;
> 286- struct iommu_hwpt_selftest user_cfg;
> 287- int rc;
> 288-
> 289: if (!user_data) { /* must be mock_domain */
>
> ...change this to if (!parent)...
Yes, this logic is not ideal. The parent is the request for nesting,
not user_data. user_data is the generic creation parameters, which are
not supported outside nesting
Like this:
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -286,14 +286,12 @@ mock_domain_alloc_user(struct device *dev, u32 flags,
int rc;
/* must be mock_domain */
- if (!user_data) {
+ if (!parent) {
struct mock_dev *mdev = container_of(dev, struct mock_dev, dev);
bool has_dirty_flag = flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING;
bool no_dirty_ops = mdev->flags & MOCK_FLAGS_DEVICE_NO_DIRTY;
- if (parent)
- return ERR_PTR(-EINVAL);
- if (has_dirty_flag && no_dirty_ops)
+ if (user_data || (has_dirty_flag && no_dirty_ops))
return ERR_PTR(-EOPNOTSUPP);
return __mock_domain_alloc_paging(IOMMU_DOMAIN_UNMANAGED,
has_dirty_flag);
Thanks,
Jason
Powered by blists - more mailing lists