From: Jason Gunthorpe <jgg@nvidia.com>
To: Sairaj Kodilkar <sarunkod@amd.com>
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
joro@8bytes.org, suravee.suthikulpanit@amd.com,
vasant.hegde@amd.com, ashish.kalra@amd.com, robin.murphy@arm.com,
will@kernel.org
Subject: Re: [PATCH 2/2] amd/iommu: Make protection domain ID functions non-static
Date: Wed, 19 Nov 2025 09:47:03 -0400 [thread overview]
Message-ID: <20251119134703.GA135560@nvidia.com> (raw)
In-Reply-To: <20251114104442.23296-3-sarunkod@amd.com>
On Fri, Nov 14, 2025 at 04:14:42PM +0530, Sairaj Kodilkar wrote:
> So that both iommu.c and init.c can utilize them. Also define a new
> function 'pdom_id_destroy()' to destroy 'pdom_ids' instead of directly
> calling ida functions.
>
> Signed-off-by: Sairaj Kodilkar <sarunkod@amd.com>
> ---
> drivers/iommu/amd/amd_iommu.h | 5 +++++
> drivers/iommu/amd/init.c | 7 ++-----
> drivers/iommu/amd/iommu.c | 27 ++++++++++++++++++---------
> 3 files changed, 25 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h
> index 25044d28f28a..6335b577f80d 100644
> --- a/drivers/iommu/amd/amd_iommu.h
> +++ b/drivers/iommu/amd/amd_iommu.h
> @@ -173,6 +173,11 @@ static inline struct protection_domain *to_pdomain(struct iommu_domain *dom)
> bool translation_pre_enabled(struct amd_iommu *iommu);
> int __init add_special_device(u8 type, u8 id, u32 *devid, bool cmd_line);
>
> +int amd_iommu_pdom_id_alloc(void);
> +int amd_iommu_pdom_id_reserve(int id);
> +void amd_iommu_pdom_id_free(int id);
> +void amd_iommu_pdom_id_destroy(void);
Domain IDs are not signed integers. Use u32.
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 48bca4dc8eb6..4d57e820b824 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -1785,17 +1785,26 @@ int amd_iommu_complete_ppr(struct device *dev, u32 pasid, int status, int tag)
> * contain.
> *
> ****************************************************************************/
> -
> -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);
> }
>
> -static void pdom_id_free(int id)
> +int amd_iommu_pdom_id_reserve(int id)
> +{
> + return ida_alloc_range(&pdom_ids, id, id, GFP_ATOMIC);
> +}
The GFP should probably be passed in as a function argument
Jason
prev parent reply other threads:[~2025-11-19 13:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 10:44 [PATCH 0/2] amd/iommu: Preserve domain ids inside the kdump kernel Sairaj Kodilkar
2025-11-14 10:44 ` [PATCH 1/2] " Sairaj Kodilkar
2025-11-17 5:21 ` Ankit Soni
2025-11-19 10:50 ` Vasant Hegde
2025-11-19 13:43 ` Jason Gunthorpe
2025-11-20 5:02 ` Sairaj Kodilkar
2025-11-20 12:56 ` Jason Gunthorpe
2025-11-21 5:21 ` Sairaj Kodilkar
2025-11-20 6:22 ` Vasant Hegde
2025-11-20 6:56 ` Vasant Hegde
2025-11-14 10:44 ` [PATCH 2/2] amd/iommu: Make protection domain ID functions non-static Sairaj Kodilkar
2025-11-19 10:47 ` Vasant Hegde
2025-11-19 13:47 ` Jason Gunthorpe [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251119134703.GA135560@nvidia.com \
--to=jgg@nvidia.com \
--cc=ashish.kalra@amd.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=sarunkod@amd.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@amd.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox