From: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
To: <joro@8bytes.org>, <suravee.suthikulpanit@amd.com>,
<vasant.hegde@amd.com>, <will@kernel.org>, <robin.murphy@arm.com>,
<iommu@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Cc: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
Subject: [PATCH] iommu/amd: Enhance "Command buffer timeout" error message
Date: Sun, 18 Oct 2026 18:11:13 +0530 [thread overview]
Message-ID: <20261018124113.910-1-dheerajkumar.srivastava@amd.com> (raw)
Current IOMMU driver prints "Command buffer timeout" error message with
insufficient information to further debug the issue.
Enhance the error message as follows:
1. Log the IOMMU PCI device ID in the error message.
2. With the "amd_iommu_dump=1" kernel command line option, dump the
entire command buffer entries, including the Head and Tail offsets.
Consolidate the timeout logging and the command buffer dump into a
single helper and use DO_ONCE_LITE() to dump the command buffer only
once to avoid dmesg spam. While at it, apply the same reporting to the
completion-wait timeout path as well.
Signed-off-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
---
drivers/iommu/amd/iommu.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 893cd2be11a2..e75b3f6123e6 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -1228,6 +1228,16 @@ static void dump_command_buffer(struct amd_iommu *iommu)
}
}
+static void report_command_buffer_timeout(struct amd_iommu *iommu, const char *reason)
+{
+ pr_err_ratelimited("IOMMU %04x:%02x:%02x.%01x: %s\n",
+ iommu->pci_seg->id, PCI_BUS_NUM(iommu->devid),
+ PCI_SLOT(iommu->devid), PCI_FUNC(iommu->devid), reason);
+
+ if (amd_iommu_dump)
+ DO_ONCE_LITE(dump_command_buffer, iommu);
+}
+
static int wait_on_sem(struct amd_iommu *iommu, u64 data)
{
int i = 0;
@@ -1243,14 +1253,7 @@ static int wait_on_sem(struct amd_iommu *iommu, u64 data)
}
if (i == LOOP_TIMEOUT) {
-
- pr_alert("IOMMU %04x:%02x:%02x.%01x: Completion-Wait loop timed out\n",
- iommu->pci_seg->id, PCI_BUS_NUM(iommu->devid),
- PCI_SLOT(iommu->devid), PCI_FUNC(iommu->devid));
-
- if (amd_iommu_dump)
- DO_ONCE_LITE(dump_command_buffer, iommu);
-
+ report_command_buffer_timeout(iommu, "Completion-Wait loop timed out");
return -EIO;
}
@@ -1422,7 +1425,7 @@ static int __iommu_queue_command_sync(struct amd_iommu *iommu,
/* Skip udelay() the first time around */
if (count++) {
if (count == LOOP_TIMEOUT) {
- pr_err("Command buffer timeout\n");
+ report_command_buffer_timeout(iommu, "Command buffer timeout");
return -EIO;
}
--
2.25.1
reply other threads:[~2026-10-18 12:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261018124113.910-1-dheerajkumar.srivastava@amd.com \
--to=dheerajkumar.srivastava@amd.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.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
all inboxes | Powered by JetHome®