aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2008-12-02 14:54:37 -0500
committerJoerg Roedel <joerg.roedel@amd.com>2009-01-03 08:11:54 -0500
commit237b6f33291394c337ae84e2d3782d5605803af2 (patch)
tree774b6ad48b008c707ac9087eeac25a84b3472c8e
parent8d201968e15f56ae2837b0d0b64d3fff098857b0 (diff)
AMD IOMMU: move invalidation command building to a separate function
Impact: refactoring of iommu_queue_inv_iommu_pages Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
-rw-r--r--arch/x86/kernel/amd_iommu.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 2280ef86651f..fee16fbf2f33 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -286,6 +286,21 @@ static int iommu_queue_inv_dev_entry(struct amd_iommu *iommu, u16 devid)
286 return ret; 286 return ret;
287} 287}
288 288
289static void __iommu_build_inv_iommu_pages(struct iommu_cmd *cmd, u64 address,
290 u16 domid, int pde, int s)
291{
292 memset(cmd, 0, sizeof(*cmd));
293 address &= PAGE_MASK;
294 CMD_SET_TYPE(cmd, CMD_INV_IOMMU_PAGES);
295 cmd->data[1] |= domid;
296 cmd->data[2] = lower_32_bits(address);
297 cmd->data[3] = upper_32_bits(address);
298 if (s) /* size bit - we flush more than one 4kb page */
299 cmd->data[2] |= CMD_INV_IOMMU_PAGES_SIZE_MASK;
300 if (pde) /* PDE bit - we wan't flush everything not only the PTEs */
301 cmd->data[2] |= CMD_INV_IOMMU_PAGES_PDE_MASK;
302}
303
289/* 304/*
290 * Generic command send function for invalidaing TLB entries 305 * Generic command send function for invalidaing TLB entries
291 */ 306 */
@@ -295,16 +310,7 @@ static int iommu_queue_inv_iommu_pages(struct amd_iommu *iommu,
295 struct iommu_cmd cmd; 310 struct iommu_cmd cmd;
296 int ret; 311 int ret;
297 312
298 memset(&cmd, 0, sizeof(cmd)); 313 __iommu_build_inv_iommu_pages(&cmd, address, domid, pde, s);
299 address &= PAGE_MASK;
300 CMD_SET_TYPE(&cmd, CMD_INV_IOMMU_PAGES);
301 cmd.data[1] |= domid;
302 cmd.data[2] = lower_32_bits(address);
303 cmd.data[3] = upper_32_bits(address);
304 if (s) /* size bit - we flush more than one 4kb page */
305 cmd.data[2] |= CMD_INV_IOMMU_PAGES_SIZE_MASK;
306 if (pde) /* PDE bit - we wan't flush everything not only the PTEs */
307 cmd.data[2] |= CMD_INV_IOMMU_PAGES_PDE_MASK;
308 314
309 ret = iommu_queue_command(iommu, &cmd); 315 ret = iommu_queue_command(iommu, &cmd);
310 316