Skip to content

Commit 5902ee6

Browse files
michichkuba-moo
authored andcommitted
iavf: simplify mutex_trylock+sleep loops
This pattern appears in two places in the iavf source code: while (!mutex_trylock(...)) usleep_range(...); That's just mutex_lock with extra steps. The pattern is a leftover from when iavf used bit flags instead of mutexes for locking. Commit 5ac49f3 ("iavf: use mutexes for locking of critical sections") replaced test_and_set_bit with !mutex_trylock, preserving the pattern. Simplify it to mutex_lock. Signed-off-by: Michal Schmidt <[email protected]> Reviewed-by: Wojciech Drewek <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Jacob Keller <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 77361cb commit 5902ee6

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/net/ethernet/intel/iavf/iavf_main.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3011,8 +3011,7 @@ static void iavf_reset_task(struct work_struct *work)
30113011
return;
30123012
}
30133013

3014-
while (!mutex_trylock(&adapter->client_lock))
3015-
usleep_range(500, 1000);
3014+
mutex_lock(&adapter->client_lock);
30163015
if (CLIENT_ENABLED(adapter)) {
30173016
adapter->flags &= ~(IAVF_FLAG_CLIENT_NEEDS_OPEN |
30183017
IAVF_FLAG_CLIENT_NEEDS_CLOSE |
@@ -5065,8 +5064,7 @@ static int __maybe_unused iavf_suspend(struct device *dev_d)
50655064

50665065
netif_device_detach(netdev);
50675066

5068-
while (!mutex_trylock(&adapter->crit_lock))
5069-
usleep_range(500, 1000);
5067+
mutex_lock(&adapter->crit_lock);
50705068

50715069
if (netif_running(netdev)) {
50725070
rtnl_lock();

0 commit comments

Comments
 (0)