iommu/amd: Enhance "Completion-wait Time-out" error message
Subsystems (2)
PATCH v3 1/1 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. Also dump the command immediately preceding the COMPLETION_WAIT command to identify what the IOMMU is waiting for.
Signed-off-by Dheeraj Kumar Srivastava <[email protected]>
---
Changes since v2:
-> Fix kernel robot build warnings.
drivers/iommu/amd/amd_iommu_types.h | 2 ++ drivers/iommu/amd/iommu.c | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-)
drivers/iommu/amd/amd_iommu_types.h +2 -0
@@ -247,6 +247,8 @@#define CMD_BUFFER_ENTRIES 512#define MMIO_CMD_SIZE_SHIFT 56#define MMIO_CMD_SIZE_512 (0x9ULL << MMIO_CMD_SIZE_SHIFT) +#define MMIO_CMD_TAIL_MASK GENMASK_ULL(18, 4) +#define MMIO_CMD_BUFFER_TAIL (x) FIELD_GET(MMIO_CMD_TAIL_MASK, (x))/* constants for event buffer handling */ #define EVT_BUFFER_SIZE 8192/* 512 entries */
drivers/iommu/amd/iommu.c +16 -1
@@ -1158,6 +1158,7 @@ irqreturn_t amd_iommu_int_handler(int irq, void *data)static int wait_on_sem (struct amd_iommu *iommu,u64 data) { +struct iommu_cmd *cmd;int i =0 ;while (*iommu->cmd_sem != data && i <LOOP_TIMEOUT ) {
@@ -1166,7 +1167,21 @@ static int wait_on_sem(struct amd_iommu *iommu, u64 data) }if (i ==LOOP_TIMEOUT ) { -pr_alert ("Completion-Wait loop timed out\n" ); +int tail; + + tail =readl (iommu->mmio_base +MMIO_CMD_TAIL_OFFSET ); + +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)); +/* +* On command buffer completion timeout, step back by 2 commands +* to locate the actual command that is causing the issue. +*/ + tail = (MMIO_CMD_BUFFER_TAIL (tail) -2 ) & (CMD_BUFFER_ENTRIES -1 ); + cmd = (struct iommu_cmd *)(iommu->cmd_buf + tail *sizeof (*cmd)); +dump_command (iommu_virt_to_phys (cmd)); +return -EIO ; }
Signature · 1 line
2.25.1