mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-28 23:24:50 +00:00
x86, AMD IOMMU: add an emergency exit to the completion wait loop
To make the loop waiting for the completion wait command not wait forever this patch adds a limit of cycles that loop. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Cc: iommu@lists.linux-foundation.org Cc: bhavna.sarathy@amd.com Cc: robert.richter@amd.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
9a836de0c9
commit
136f78a19c
1 changed files with 9 additions and 1 deletions
|
@ -32,6 +32,8 @@
|
||||||
#define to_pages(addr, size) \
|
#define to_pages(addr, size) \
|
||||||
(round_up(((addr) & ~PAGE_MASK) + (size), PAGE_SIZE) >> PAGE_SHIFT)
|
(round_up(((addr) & ~PAGE_MASK) + (size), PAGE_SIZE) >> PAGE_SHIFT)
|
||||||
|
|
||||||
|
#define EXIT_LOOP_COUNT 10000000
|
||||||
|
|
||||||
static DEFINE_RWLOCK(amd_iommu_devtable_lock);
|
static DEFINE_RWLOCK(amd_iommu_devtable_lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -106,6 +108,7 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
|
||||||
struct command cmd;
|
struct command cmd;
|
||||||
volatile u64 ready = 0;
|
volatile u64 ready = 0;
|
||||||
unsigned long ready_phys = virt_to_phys(&ready);
|
unsigned long ready_phys = virt_to_phys(&ready);
|
||||||
|
unsigned long i = 0;
|
||||||
|
|
||||||
memset(&cmd, 0, sizeof(cmd));
|
memset(&cmd, 0, sizeof(cmd));
|
||||||
cmd.data[0] = LOW_U32(ready_phys) | CMD_COMPL_WAIT_STORE_MASK;
|
cmd.data[0] = LOW_U32(ready_phys) | CMD_COMPL_WAIT_STORE_MASK;
|
||||||
|
@ -120,8 +123,13 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
while (!ready)
|
while (!ready && (i < EXIT_LOOP_COUNT)) {
|
||||||
|
++i;
|
||||||
cpu_relax();
|
cpu_relax();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely((i == EXIT_LOOP_COUNT) && printk_ratelimit()))
|
||||||
|
printk(KERN_WARNING "AMD IOMMU: Completion wait loop failed\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue