From: Jason Gunthorpe <jgg@nvidia.com>
To: Vasant Hegde <vasant.hegde@amd.com>
Cc: Sairaj Kodilkar <sarunkod@amd.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
joro@8bytes.org, suravee.suthikulpanit@amd.com,
ashish.kalra@amd.com, robin.murphy@arm.com, will@kernel.org
Subject: Re: [PATCH 1/2] amd/iommu: Preserve domain ids inside the kdump kernel
Date: Wed, 19 Nov 2025 09:43:51 -0400 [thread overview]
Message-ID: <20251119134351.GM120075@nvidia.com> (raw)
In-Reply-To: <78a4598d-5d35-4fd0-a830-a740076aba41@amd.com>
On Wed, Nov 19, 2025 at 04:20:28PM +0530, Vasant Hegde wrote:
> > diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> > index f2991c11867c..9375fba1071c 100644
> > --- a/drivers/iommu/amd/init.c
> > +++ b/drivers/iommu/amd/init.c
> > @@ -1136,9 +1136,13 @@ static void set_dte_bit(struct dev_table_entry *dte, u8 bit)
> > static bool __reuse_device_table(struct amd_iommu *iommu)
> > {
> > struct amd_iommu_pci_seg *pci_seg = iommu->pci_seg;
> > - u32 lo, hi, old_devtb_size;
> > + struct dev_table_entry *old_dev_tbl_entry;
> > + u32 lo, hi, old_devtb_size, devid;
> > phys_addr_t old_devtb_phys;
> > + u16 dom_id;
> > + bool dte_v;
> > u64 entry;
> > + int ret;
> >
> > /* Each IOMMU use separate device table with the same size */
> > lo = readl(iommu->mmio_base + MMIO_DEV_TABLE_OFFSET);
> > @@ -1173,6 +1177,25 @@ static bool __reuse_device_table(struct amd_iommu *iommu)
> > return false;
> > }
> >
> > + for (devid = 0; devid <= pci_seg->last_bdf; devid++) {
> > + old_dev_tbl_entry = &pci_seg->old_dev_tbl_cpy[devid];
> > + dte_v = old_dev_tbl_entry->data[0] & DTE_FLAG_V;
> > + dom_id = old_dev_tbl_entry->data[1] & DEV_DOMID_MASK;
> > +
> > + if (!dte_v || !dom_id)
> > + continue;
> > + /*
> > + * ID reseveration can fail with -ENOSPC when there
> > + * are multiple devices present in the same domain,
> > + * hence check only for -ENOMEM.
> > + */
> > + ret = ida_alloc_range(&pdom_ids, dom_id, dom_id, GFP_ATOMIC);
Is it really an atomic context? Why?
> > + if (ret == -ENOMEM) {
> > + pr_err("Failed to reserve domain ID 0x%x\n", dom_id);
> > + return false;
Please don't print on ENOMEM, there is already a print.
I think you should also keep iterating as other dom_ids may still be
fit in already allocated bitmaps. Though the system is probably toast
if this happens anyhow.
Jason
next prev parent reply other threads:[~2025-11-19 13:44 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 [this message]
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
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=20251119134351.GM120075@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