Fix checking return value of atomic_cas_uint().

This change fixes a bug that extra delay() is called only once even if
atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint()
failed.

The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int()
to atomic_cas_uint(). The return value's semantics is different.
This commit is contained in:
msaitoh 2020-08-12 09:13:46 +00:00
parent 97e085086c
commit 38bc295884
1 changed files with 9 additions and 9 deletions

View File

@ -45,9 +45,9 @@
static void
ixgbe_bypass_mutex_enter(struct adapter *adapter)
{
while (atomic_cas_uint(&adapter->bypass.low, 0, 1) == 0)
while (atomic_cas_uint(&adapter->bypass.low, 0, 1) != 0)
usec_delay(3000);
while (atomic_cas_uint(&adapter->bypass.high, 0, 1) == 0)
while (atomic_cas_uint(&adapter->bypass.high, 0, 1) != 0)
usec_delay(3000);
return;
} /* ixgbe_bypass_mutex_enter */
@ -58,9 +58,9 @@ ixgbe_bypass_mutex_enter(struct adapter *adapter)
static void
ixgbe_bypass_mutex_clear(struct adapter *adapter)
{
while (atomic_cas_uint(&adapter->bypass.high, 1, 0) == 0)
while (atomic_cas_uint(&adapter->bypass.high, 1, 0) != 1)
usec_delay(6000);
while (atomic_cas_uint(&adapter->bypass.low, 1, 0) == 0)
while (atomic_cas_uint(&adapter->bypass.low, 1, 0) != 1)
usec_delay(6000);
return;
} /* ixgbe_bypass_mutex_clear */
@ -73,7 +73,7 @@ ixgbe_bypass_mutex_clear(struct adapter *adapter)
static void
ixgbe_bypass_wd_mutex_enter(struct adapter *adapter)
{
while (atomic_cas_uint(&adapter->bypass.high, 0, 1) == 0)
while (atomic_cas_uint(&adapter->bypass.high, 0, 1) != 0)
usec_delay(3000);
return;
} /* ixgbe_bypass_wd_mutex_enter */
@ -84,7 +84,7 @@ ixgbe_bypass_wd_mutex_enter(struct adapter *adapter)
static void
ixgbe_bypass_wd_mutex_clear(struct adapter *adapter)
{
while (atomic_cas_uint(&adapter->bypass.high, 1, 0) == 0)
while (atomic_cas_uint(&adapter->bypass.high, 1, 0) != 1)
usec_delay(6000);
return;
} /* ixgbe_bypass_wd_mutex_clear */
@ -585,7 +585,7 @@ ixgbe_bp_log(SYSCTLFN_ARGS)
return (error);
/* Keep the log display single-threaded */
while (atomic_cas_uint(&adapter->bypass.log, 0, 1) == 0)
while (atomic_cas_uint(&adapter->bypass.log, 0, 1) != 0)
usec_delay(3000);
ixgbe_bypass_mutex_enter(adapter);
@ -713,14 +713,14 @@ ixgbe_bp_log(SYSCTLFN_ARGS)
status = 0; /* reset */
/* Another log command can now run */
while (atomic_cas_uint(&adapter->bypass.log, 1, 0) == 0)
while (atomic_cas_uint(&adapter->bypass.log, 1, 0) != 1)
usec_delay(3000);
return (error);
unlock_err:
ixgbe_bypass_mutex_clear(adapter);
status = 0; /* reset */
while (atomic_cas_uint(&adapter->bypass.log, 1, 0) == 0)
while (atomic_cas_uint(&adapter->bypass.log, 1, 0) != 1)
usec_delay(3000);
return (EINVAL);
} /* ixgbe_bp_log */