On 10/21/2025 7:13 AM, Suravee Suthikulpanit wrote:
> This will be reused in a new iommufd.c file for nested translation.
s/iommufd.c/nested.c/ -OR- something like "it will be used in nested translation
support".
Ditto for next few patches.
>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
-Vasant
> ---
> drivers/iommu/amd/amd_iommu.h | 1 +
> drivers/iommu/amd/iommu.c | 8 ++++----
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h
> index 9b4b589a54b5..6ea549816a1f 100644
> --- a/drivers/iommu/amd/amd_iommu.h
> +++ b/drivers/iommu/amd/amd_iommu.h
> @@ -26,6 +26,7 @@ void amd_iommu_set_rlookup_table(struct amd_iommu *iommu, u16 devid);
> void iommu_feature_enable(struct amd_iommu *iommu, u8 bit);
> void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu,
> gfp_t gfp, size_t size);
> +int amd_iommu_pdom_id_alloc(void);
>
> #ifdef CONFIG_AMD_IOMMU_DEBUGFS
> void amd_iommu_debugfs_setup(void);
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index a9b17d31a969..78b3e5485006 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -1818,7 +1818,7 @@ int amd_iommu_complete_ppr(struct device *dev, u32 pasid, int status, int tag)
> *
> ****************************************************************************/
>
> -static int pdom_id_alloc(void)
> +int amd_iommu_pdom_id_alloc(void)
> {
> return ida_alloc_range(&pdom_ids, 1, MAX_DOMAIN_ID - 1, GFP_ATOMIC);
> }
> @@ -1906,7 +1906,7 @@ static int setup_gcr3_table(struct gcr3_tbl_info *gcr3_info,
> return -EBUSY;
>
> /* Allocate per device domain ID */
> - domid = pdom_id_alloc();
> + domid = amd_iommu_pdom_id_alloc();
> if (domid <= 0)
> return -ENOSPC;
> gcr3_info->domid = domid;
> @@ -2489,7 +2489,7 @@ struct protection_domain *protection_domain_alloc(void)
> if (!domain)
> return NULL;
>
> - domid = pdom_id_alloc();
> + domid = amd_iommu_pdom_id_alloc();
> if (domid <= 0) {
> kfree(domain);
> return NULL;
> @@ -2681,7 +2681,7 @@ void amd_iommu_init_identity_domain(void)
> domain->ops = &identity_domain_ops;
> domain->owner = &amd_iommu_ops;
>
> - identity_domain.id = pdom_id_alloc();
> + identity_domain.id = amd_iommu_pdom_id_alloc();
>
> protection_domain_init(&identity_domain);
> }