[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN9PR11MB527652D88D15437F52FCE8268C889@BN9PR11MB5276.namprd11.prod.outlook.com>
Date: Tue, 28 Mar 2023 07:35:43 +0000
From: "Tian, Kevin" <kevin.tian@...el.com>
To: Jacob Pan <jacob.jun.pan@...ux.intel.com>,
LKML <linux-kernel@...r.kernel.org>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
Jason Gunthorpe <jgg@...dia.com>,
Lu Baolu <baolu.lu@...ux.intel.com>,
Joerg Roedel <joro@...tes.org>,
"dmaengine@...r.kernel.org" <dmaengine@...r.kernel.org>,
"vkoul@...nel.org" <vkoul@...nel.org>
CC: Robin Murphy <robin.murphy@....com>, Will Deacon <will@...nel.org>,
"David Woodhouse" <dwmw2@...radead.org>,
"Raj, Ashok" <ashok.raj@...el.com>,
"Liu, Yi L" <yi.l.liu@...el.com>,
"Yu, Fenghua" <fenghua.yu@...el.com>,
"Jiang, Dave" <dave.jiang@...el.com>,
"Luck, Tony" <tony.luck@...el.com>,
"Zanussi, Tom" <tom.zanussi@...el.com>
Subject: RE: [PATCH v2 3/8] iommu/sva: Support reservation of global SVA
PASIDs
> From: Jacob Pan <jacob.jun.pan@...ux.intel.com>
> Sent: Tuesday, March 28, 2023 7:22 AM
>
> +/**
> + * @brief
> + * Reserve a PASID from the SVA global number space.
> + *
> + * @param min starting range, inclusive
> + * @param max ending range, inclusive
> + * @return The reserved PASID on success or IOMMU_PASID_INVALID on
> failure.
> + */
> +ioasid_t iommu_sva_reserve_pasid(ioasid_t min, ioasid_t max)
> +{
> + int ret;
> +
> + if (!pasid_valid(min) || !pasid_valid(max) ||
> + min == 0 || max < min)
> + return IOMMU_PASID_INVALID;
> +
> + ret = ida_alloc_range(&iommu_global_pasid_ida, min, max,
> GFP_KERNEL);
> + if (ret < 0)
> + return IOMMU_PASID_INVALID;
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(iommu_sva_reserve_pasid);
> +
Look at this function. There is no single word about sva except
in the function name.
sva is just one user of global pasids.
when a driver supports sva it has to always use global pasids even
for non-sva usages like dma pasid.
but this doesn't mean that we should build the API around sva.
it's really about global pasids.
let's just call it clearly as iommu_alloc_global_pasid(min, max).
Then we can define a wrapper iommu_reserve_global_pasid(pasid)
as iommu_alloc_global_pasid(pasid, pasid).
for PASID#0 driver calls iommu_reserve_global_pasid(0).
for dma pasid driver calls iommu_alloc_global_pasid() to get a random
one instead of reserving pasid#1.
this would be future proof when the same driver starts to allocate
more pasids for other usages e..g siov.
Powered by blists - more mailing lists