[PATCH 1/2] iommu/amd: Use wait_event in put_pasid_state_wait

From: Joerg Roedel
Date: Wed Feb 04 2015 - 09:50:38 EST


Now that I learned about possible spurious wakeups this
place needs fixing too. Replace the self-coded sleep variant
with the generic wait_event() helper.

Signed-off-by: Joerg Roedel <jroedel@xxxxxxx>
---
drivers/iommu/amd_iommu_v2.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index b6398d7..e01bc8f 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -266,14 +266,13 @@ static void put_pasid_state(struct pasid_state *pasid_state)

static void put_pasid_state_wait(struct pasid_state *pasid_state)
{
- DEFINE_WAIT(wait);
+ /* Drop our reference */
+ atomic_dec(&pasid_state->count);

- prepare_to_wait(&pasid_state->wq, &wait, TASK_UNINTERRUPTIBLE);
+ /* Wait for others to drop their references */
+ wait_event(pasid_state->wq, !atomic_read(&pasid_state->count));

- if (!atomic_dec_and_test(&pasid_state->count))
- schedule();
-
- finish_wait(&pasid_state->wq, &wait);
+ /* Get rid of it */
free_pasid_state(pasid_state);
}

--
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/