Skip to content

Commit

Permalink
iommu/amd: Make sure iommu->need_sync contains correct value
Browse files Browse the repository at this point in the history
The value is only set to true but never set back to false,
which causes to many completion-wait commands to be sent to
hardware. Fix it with this patch.

Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
  • Loading branch information
Joerg Roedel committed Sep 2, 2011
1 parent c6a389f commit f1ca151
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/iommu/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,9 @@ static void build_inv_all(struct iommu_cmd *cmd)
* Writes the command to the IOMMUs command buffer and informs the
* hardware about the new command.
*/
static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
static int iommu_queue_command_sync(struct amd_iommu *iommu,
struct iommu_cmd *cmd,
bool sync)
{
u32 left, tail, head, next_tail;
unsigned long flags;
Expand Down Expand Up @@ -639,13 +641,18 @@ static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
copy_cmd_to_buffer(iommu, cmd, tail);

/* We need to sync now to make sure all commands are processed */
iommu->need_sync = true;
iommu->need_sync = sync;

spin_unlock_irqrestore(&iommu->lock, flags);

return 0;
}

static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
{
return iommu_queue_command_sync(iommu, cmd, true);
}

/*
* This function queues a completion wait command into the command
* buffer of an IOMMU
Expand All @@ -661,7 +668,7 @@ static int iommu_completion_wait(struct amd_iommu *iommu)

build_completion_wait(&cmd, (u64)&sem);

ret = iommu_queue_command(iommu, &cmd);
ret = iommu_queue_command_sync(iommu, &cmd, false);
if (ret)
return ret;

Expand Down

0 comments on commit f1ca151

Please sign in to comment.