Skip to content

Commit d1e281f

Browse files
dhsrivasjoergroedel
authored andcommitted
iommu/amd: Enhance "Completion-wait Time-out" error message
Current IOMMU driver prints "Completion-wait Time-out" error message with insufficient information to further debug the issue. Enhancing the error message as following: 1. Log IOMMU PCI device ID in the error message. 2. With "amd_iommu_dump=1" kernel command line option, dump entire command buffer entries including Head and Tail offset. Dump the entire command buffer only on the first 'Completion-wait Time-out' to avoid dmesg spam. Signed-off-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com> Reviewed-by: Ankit Soni <Ankit.Soni@amd.com> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent a0c7005 commit d1e281f

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

drivers/iommu/amd/amd_iommu_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@
247247
#define CMD_BUFFER_ENTRIES 512
248248
#define MMIO_CMD_SIZE_SHIFT 56
249249
#define MMIO_CMD_SIZE_512 (0x9ULL << MMIO_CMD_SIZE_SHIFT)
250+
#define MMIO_CMD_HEAD_MASK GENMASK_ULL(18, 4) /* Command buffer head ptr field [18:4] */
251+
#define MMIO_CMD_BUFFER_HEAD(x) FIELD_GET(MMIO_CMD_HEAD_MASK, (x))
252+
#define MMIO_CMD_TAIL_MASK GENMASK_ULL(18, 4) /* Command buffer tail ptr field [18:4] */
253+
#define MMIO_CMD_BUFFER_TAIL(x) FIELD_GET(MMIO_CMD_TAIL_MASK, (x))
250254

251255
/* constants for event buffer handling */
252256
#define EVT_BUFFER_SIZE 8192 /* 512 entries */

drivers/iommu/amd/iommu.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,25 @@ irqreturn_t amd_iommu_int_handler(int irq, void *data)
11571157
*
11581158
****************************************************************************/
11591159

1160+
static void dump_command_buffer(struct amd_iommu *iommu)
1161+
{
1162+
struct iommu_cmd *cmd;
1163+
u32 head, tail;
1164+
int i;
1165+
1166+
head = readl(iommu->mmio_base + MMIO_CMD_HEAD_OFFSET);
1167+
tail = readl(iommu->mmio_base + MMIO_CMD_TAIL_OFFSET);
1168+
1169+
pr_err("CMD Buffer head=%llu tail=%llu\n", MMIO_CMD_BUFFER_HEAD(head),
1170+
MMIO_CMD_BUFFER_TAIL(tail));
1171+
1172+
for (i = 0; i < CMD_BUFFER_ENTRIES; i++) {
1173+
cmd = (struct iommu_cmd *)(iommu->cmd_buf + i * sizeof(*cmd));
1174+
pr_err("%3d: %08x %08x %08x %08x\n", i, cmd->data[0], cmd->data[1], cmd->data[2],
1175+
cmd->data[3]);
1176+
}
1177+
}
1178+
11601179
static int wait_on_sem(struct amd_iommu *iommu, u64 data)
11611180
{
11621181
int i = 0;
@@ -1167,7 +1186,14 @@ static int wait_on_sem(struct amd_iommu *iommu, u64 data)
11671186
}
11681187

11691188
if (i == LOOP_TIMEOUT) {
1170-
pr_alert("Completion-Wait loop timed out\n");
1189+
1190+
pr_alert("IOMMU %04x:%02x:%02x.%01x: Completion-Wait loop timed out\n",
1191+
iommu->pci_seg->id, PCI_BUS_NUM(iommu->devid),
1192+
PCI_SLOT(iommu->devid), PCI_FUNC(iommu->devid));
1193+
1194+
if (amd_iommu_dump)
1195+
DO_ONCE_LITE(dump_command_buffer, iommu);
1196+
11711197
return -EIO;
11721198
}
11731199

0 commit comments

Comments
 (0)