Module Name: src Committed By: msaitoh Date: Wed Aug 12 09:13:46 UTC 2020
Modified Files: src/sys/dev/pci/ixgbe: if_bypass.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/ixgbe/if_bypass.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/ixgbe/if_bypass.c diff -u src/sys/dev/pci/ixgbe/if_bypass.c:1.5 src/sys/dev/pci/ixgbe/if_bypass.c:1.6 --- src/sys/dev/pci/ixgbe/if_bypass.c:1.5 Mon Dec 16 02:50:54 2019 +++ src/sys/dev/pci/ixgbe/if_bypass.c Wed Aug 12 09:13:46 2020 @@ -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 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 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 adapt 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 */