[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7aa8fd9e-e43d-db68-bdb6-fe4f891255ca@linux.intel.com>
Date: Wed, 20 Sep 2023 13:28:41 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: Yi Liu <yi.l.liu@...el.com>, joro@...tes.org,
alex.williamson@...hat.com, jgg@...dia.com, kevin.tian@...el.com,
robin.murphy@....com
Cc: baolu.lu@...ux.intel.com, cohuck@...hat.com, eric.auger@...hat.com,
nicolinc@...dia.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 6/6] iommu/vt-d: Add domain_alloc_user op
On 9/19/23 5:25 PM, Yi Liu wrote:
> This adds the domain_alloc_user op implementation. It supports allocating
> domains to be used as parent under nested translation.
Documentation/process/submitting-patches.rst:
Describe your changes in imperative mood, e.g. "make xyzzy do frotz"
instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy
to do frotz", as if you are giving orders to the codebase to change
its behaviour.
So how about,
Add the domain_alloc_user callback to support allocating domains used as
parent under nested translation.
?
>
> Signed-off-by: Yi Liu <yi.l.liu@...el.com>
> ---
> drivers/iommu/intel/iommu.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 5db283c17e0d..491bcde1ff96 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -4074,6 +4074,25 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type)
> return NULL;
> }
>
> +static struct iommu_domain *
> +intel_iommu_domain_alloc_user(struct device *dev, u32 flags)
> +{
> + struct iommu_domain *domain;
> + struct intel_iommu *iommu;
> +
> + iommu = device_to_iommu(dev, NULL, NULL);
> + if (!iommu)
> + return ERR_PTR(-ENODEV);
> +
> + if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !ecap_nest(iommu->ecap))
> + return ERR_PTR(-EOPNOTSUPP);
> +
> + domain = iommu_domain_alloc(dev->bus);
No need to bounce between core and driver. Just,
intel_iommu_domain_alloc(IOMMU_DOMAIN_UNMANAGED);
and fully initialize it before return.
> + if (!domain)
> + domain = ERR_PTR(-ENOMEM);
> + return domain;
> +}
> +
> static void intel_iommu_domain_free(struct iommu_domain *domain)
> {
> if (domain != &si_domain->domain && domain != &blocking_domain)
> @@ -4807,6 +4826,7 @@ const struct iommu_ops intel_iommu_ops = {
> .capable = intel_iommu_capable,
> .hw_info = intel_iommu_hw_info,
> .domain_alloc = intel_iommu_domain_alloc,
> + .domain_alloc_user = intel_iommu_domain_alloc_user,
> .probe_device = intel_iommu_probe_device,
> .probe_finalize = intel_iommu_probe_finalize,
> .release_device = intel_iommu_release_device,
Best regards,
baolu
Powered by blists - more mailing lists