Skip to contentSkip to conversation

iommu/amd: Use wait_event in put_pasid_state_wait

PATCH Superseded Joerg Roedel 3 participants 5 messages Feb 4, 2015 – Feb 5, 2015 IOMMU

lore
Share & tools
lore

Joerg Roedel

author maintainer
#0 lore raw

PATCH 1/1 iommu/amd: Use wait_event in put_pasid_state_wait

From: Joerg Roedel <[email protected]>

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.

---
 drivers/iommu/amd_iommu_v2.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/iommu/amd_iommu_v2.c +1 -8
index b6398d7..5cc1409 100644
@@ -266,14 +266,7 @@ static void put_pasid_state(struct pasid_state *pasid_state)
 
 static void put_pasid_state_wait(struct pasid_state *pasid_state)
 {
-	DEFINE_WAIT(wait);
-
-	prepare_to_wait(&pasid_state->wq, &wait, TASK_UNINTERRUPTIBLE);
-
-	if (!atomic_dec_and_test(&pasid_state->count))
-		schedule();
-
-	finish_wait(&pasid_state->wq, &wait);
+	wait_event(pasid_state->wq, !atomic_read(&pasid_state->count));
 	free_pasid_state(pasid_state);
 }
 
Signature · 1 line
1.8.4.5
#1 lore raw
Quoted 20 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

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.

---
 drivers/iommu/amd_iommu_v2.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/iommu/amd_iommu_v2.c +0 -1
index b6398d7..5cc1409 100644
@@ -266,14 +266,7 @@ static void put_pasid_state(struct pasid_state *pasid_state)
 
 static void put_pasid_state_wait(struct pasid_state *pasid_state)
 {
-	DEFINE_WAIT(wait);

drivers/iommu/amd_iommu_v2.c static void put_pasid_state(struct pasid_state *pasid_state) · line 271

Quoted 10 lines
drivers/iommu/amd_iommu_v2.c +1 -7
-
-	prepare_to_wait(&pasid_state->wq, &wait, TASK_UNINTERRUPTIBLE);
-
-	if (!atomic_dec_and_test(&pasid_state->count))
-		schedule();
-
-	finish_wait(&pasid_state->wq, &wait);
+	wait_event(pasid_state->wq, !atomic_read(&pasid_state->count));
 	free_pasid_state(pasid_state);
 }

You just lost your atomic_dec.

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>

author maintainer
#2 lore raw
Quoted 18 lines · Peter Zijlstra
Quoted 17 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

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.

---
 drivers/iommu/amd_iommu_v2.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/iommu/amd_iommu_v2.c +0 -0
index b6398d7..5cc1409 100644
@@ -266,14 +266,7 @@ static void put_pasid_state(struct pasid_state *pasid_state)
 
Quoted 15 lines

drivers/iommu/amd_iommu_v2.c static void put_pasid_state(struct pasid_state *pasid_state) · line 271

Quoted 13 lines
drivers/iommu/amd_iommu_v2.c +1 -8
 static void put_pasid_state_wait(struct pasid_state *pasid_state)
 {
-	DEFINE_WAIT(wait);
-
-	prepare_to_wait(&pasid_state->wq, &wait, TASK_UNINTERRUPTIBLE);
-
-	if (!atomic_dec_and_test(&pasid_state->count))
-		schedule();
-
-	finish_wait(&pasid_state->wq, &wait);
+	wait_event(pasid_state->wq, !atomic_read(&pasid_state->count));
 	free_pasid_state(pasid_state);
 }

You just lost your atomic_dec.

Right, thanks.

author maintainer
#3 lore raw

PATCH v2 1/1 iommu/amd: Use wait_event in put_pasid_state_wait

In reply to Peter Zijlstra
Quoted 1 line · Peter Zijlstra

You just lost your atomic_dec.

So this should be the correct version then.

Quoted 1 line

From 2a52250e542d8964c8285a37b71fe838a44c05c4 Mon Sep 17 00:00:00 2001

From: Joerg Roedel <[email protected]>
Date: Wed, 4 Feb 2015 15:50:38 +0100
Subject: [PATCH 1/2] iommu/amd: Use wait_event in put_pasid_state_wait

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.

---
 drivers/iommu/amd_iommu_v2.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iommu/amd_iommu_v2.c +5 -6
index b6398d7..e01bc8f 100644
@@ -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);
 }
 
Signature · 1 line
1.8.4.5
Tested-by on v2 1/1
#4 lore raw
Quoted 7 lines · Joerg Roedel

So this should be the correct version then.

From 2a52250e542d8964c8285a37b71fe838a44c05c4 Mon Sep 17 00:00:00 2001
From: Joerg Roedel<[email protected]>
Date: Wed, 4 Feb 2015 15:50:38 +0100
Subject: [PATCH 1/2] iommu/amd: Use wait_event in put_pasid_state_wait

Quoted 5 lines

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.

Oded

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>