mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Enhance "Command buffer timeout" error message
@ 2026-10-18 12:41 Dheeraj Kumar Srivastava
  0 siblings, 0 replies; only message in thread
From: Dheeraj Kumar Srivastava @ 2026-10-18 12:41 UTC (permalink / raw)
  To: joro, suravee.suthikulpanit, vasant.hegde, will, robin.murphy,
	iommu, linux-kernel
  Cc: Dheeraj Kumar Srivastava

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-18 12:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-18 12:41 [PATCH] iommu/amd: Enhance "Command buffer timeout" error message Dheeraj Kumar Srivastava

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®