Skip to content

Commit

Permalink
AMD IOMMU: set iommu sunc flag after command queuing
Browse files Browse the repository at this point in the history
The iommu->need_sync flag must be set after the command is queued to
avoid race conditions.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Joerg Roedel authored and Ingo Molnar committed Sep 18, 2008
1 parent ba0593b commit ee2fa74
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions arch/x86/kernel/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,19 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
static int iommu_queue_inv_dev_entry(struct amd_iommu *iommu, u16 devid)
{
struct iommu_cmd cmd;
int ret;

BUG_ON(iommu == NULL);

memset(&cmd, 0, sizeof(cmd));
CMD_SET_TYPE(&cmd, CMD_INV_DEV_ENTRY);
cmd.data[0] = devid;

ret = iommu_queue_command(iommu, &cmd);

iommu->need_sync = 1;

return iommu_queue_command(iommu, &cmd);
return ret;
}

/*
Expand All @@ -159,6 +162,7 @@ static int iommu_queue_inv_iommu_pages(struct amd_iommu *iommu,
u64 address, u16 domid, int pde, int s)
{
struct iommu_cmd cmd;
int ret;

memset(&cmd, 0, sizeof(cmd));
address &= PAGE_MASK;
Expand All @@ -171,9 +175,11 @@ static int iommu_queue_inv_iommu_pages(struct amd_iommu *iommu,
if (pde) /* PDE bit - we wan't flush everything not only the PTEs */
cmd.data[2] |= CMD_INV_IOMMU_PAGES_PDE_MASK;

ret = iommu_queue_command(iommu, &cmd);

iommu->need_sync = 1;

return iommu_queue_command(iommu, &cmd);
return ret;
}

/*
Expand Down

0 comments on commit ee2fa74

Please sign in to comment.