diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2008-09-17 08:19:15 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-09-18 03:25:44 -0400 |
commit | 7e4f88da7bf1887563f70bd5edbbd0479e31dc12 (patch) | |
tree | eacefdd0980b384a89463cca211c042c7faa9b1d /arch/x86/kernel/amd_iommu.c | |
parent | ee2fa7435b6dddf1ca119f298ad0100cf50c0397 (diff) |
AMD IOMMU: protect completion wait loop with iommu lock
The unlocked polling of the ComWaitInt bit in the IOMMU completion wait
path is racy. Protect it with the iommu lock.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/amd_iommu.c')
-rw-r--r-- | arch/x86/kernel/amd_iommu.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index a96d8c049a88..042fdc27bc92 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c | |||
@@ -101,10 +101,10 @@ static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd) | |||
101 | */ | 101 | */ |
102 | static int iommu_completion_wait(struct amd_iommu *iommu) | 102 | static int iommu_completion_wait(struct amd_iommu *iommu) |
103 | { | 103 | { |
104 | int ret, ready = 0; | 104 | int ret = 0, ready = 0; |
105 | unsigned status = 0; | 105 | unsigned status = 0; |
106 | struct iommu_cmd cmd; | 106 | struct iommu_cmd cmd; |
107 | unsigned long i = 0; | 107 | unsigned long flags, i = 0; |
108 | 108 | ||
109 | memset(&cmd, 0, sizeof(cmd)); | 109 | memset(&cmd, 0, sizeof(cmd)); |
110 | cmd.data[0] = CMD_COMPL_WAIT_INT_MASK; | 110 | cmd.data[0] = CMD_COMPL_WAIT_INT_MASK; |
@@ -112,10 +112,12 @@ static int iommu_completion_wait(struct amd_iommu *iommu) | |||
112 | 112 | ||
113 | iommu->need_sync = 0; | 113 | iommu->need_sync = 0; |
114 | 114 | ||
115 | ret = iommu_queue_command(iommu, &cmd); | 115 | spin_lock_irqsave(&iommu->lock, flags); |
116 | |||
117 | ret = __iommu_queue_command(iommu, &cmd); | ||
116 | 118 | ||
117 | if (ret) | 119 | if (ret) |
118 | return ret; | 120 | goto out; |
119 | 121 | ||
120 | while (!ready && (i < EXIT_LOOP_COUNT)) { | 122 | while (!ready && (i < EXIT_LOOP_COUNT)) { |
121 | ++i; | 123 | ++i; |
@@ -130,6 +132,8 @@ static int iommu_completion_wait(struct amd_iommu *iommu) | |||
130 | 132 | ||
131 | if (unlikely((i == EXIT_LOOP_COUNT) && printk_ratelimit())) | 133 | if (unlikely((i == EXIT_LOOP_COUNT) && printk_ratelimit())) |
132 | printk(KERN_WARNING "AMD IOMMU: Completion wait loop failed\n"); | 134 | printk(KERN_WARNING "AMD IOMMU: Completion wait loop failed\n"); |
135 | out: | ||
136 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
133 | 137 | ||
134 | return 0; | 138 | return 0; |
135 | } | 139 | } |