Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci/ixgbe Fix checking return value of atomic_cas_ui...



details:   https://anonhg.NetBSD.org/src/rev/93c9620dea56
branches:  trunk
changeset: 937225:93c9620dea56
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Aug 12 09:13:46 2020 +0000

description:
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.

diffstat:

 sys/dev/pci/ixgbe/if_bypass.c |  18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diffs (71 lines):

diff -r 7f1f8e20c570 -r 93c9620dea56 sys/dev/pci/ixgbe/if_bypass.c
--- a/sys/dev/pci/ixgbe/if_bypass.c     Wed Aug 12 08:57:03 2020 +0000
+++ b/sys/dev/pci/ixgbe/if_bypass.c     Wed Aug 12 09:13:46 2020 +0000
@@ -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 @@
 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 @@
 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 @@
 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 @@
                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 @@
 
        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 */



Home | Main Index | Thread Index | Old Index