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 Use atomic_cas_uint() and atomic_store_rel...



details:   https://anonhg.NetBSD.org/src/rev/d7557613d4be
branches:  trunk
changeset: 937249:d7557613d4be
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Aug 13 08:38:50 2020 +0000

description:
Use atomic_cas_uint() and atomic_store_relaxed(). Advised by thorpej@.
Tested by me. OK'd by knakahara.

diffstat:

 sys/dev/pci/ixgbe/ixgbe.c |  26 +++++++++++---------------
 sys/dev/pci/ixgbe/ixv.c   |  20 ++++++++------------
 2 files changed, 19 insertions(+), 27 deletions(-)

diffs (168 lines):

diff -r 282e2d8fcde8 -r d7557613d4be sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 13 07:19:59 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 13 08:38:50 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.233 2020/06/25 07:53:01 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.234 2020/08/13 08:38:50 msaitoh Exp $ */
 
 /******************************************************************************
 
@@ -1512,11 +1512,9 @@
 ixgbe_schedule_admin_tasklet(struct adapter *adapter)
 {
        if (adapter->schedule_wqs_ok) {
-               if (!adapter->admin_pending) {
-                       atomic_or_uint(&adapter->admin_pending, 1);
+               if (atomic_cas_uint(&adapter->admin_pending, 0, 1) == 0)
                        workqueue_enqueue(adapter->admin_wq,
                            &adapter->admin_wc, NULL);
-               }
        }
 }
 
@@ -4063,7 +4061,7 @@
        ixgbe_enable_rx_dma(hw, rxctrl);
 
        callout_reset(&adapter->timer, hz, ixgbe_local_timer, adapter);
-       atomic_and_uint(&adapter->timer_pending, ~1);
+       atomic_store_relaxed(&adapter->timer_pending, 0);
        if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE)
                callout_reset(&adapter->recovery_mode_timer, hz,
                    ixgbe_recovery_mode_timer, adapter);
@@ -4446,11 +4444,9 @@
        struct adapter *adapter = arg;
 
        if (adapter->schedule_wqs_ok) {
-               if (!adapter->timer_pending) {
-                       atomic_or_uint(&adapter->timer_pending, 1);
+               if (atomic_cas_uint(&adapter->timer_pending, 0, 1) == 0)
                        workqueue_enqueue(adapter->timer_wq,
                            &adapter->timer_wc, NULL);
-               }
        }
 }
 
@@ -4549,7 +4545,7 @@
 #endif
 
 out:
-       atomic_and_uint(&adapter->timer_pending, ~1);
+       atomic_store_relaxed(&adapter->timer_pending, 0);
        IXGBE_CORE_UNLOCK(adapter);
        callout_reset(&adapter->timer, hz, ixgbe_local_timer, adapter);
        return;
@@ -4570,8 +4566,8 @@
 {
        struct adapter *adapter = arg;
 
-       if (!adapter->recovery_mode_timer_pending) {
-               atomic_or_uint(&adapter->recovery_mode_timer_pending, 1);
+       if (atomic_cas_uint(&adapter->recovery_mode_timer_pending, 0, 1) == 0)
+       {
                workqueue_enqueue(adapter->recovery_mode_timer_wq,
                    &adapter->recovery_mode_timer_wc, NULL);
        }
@@ -4595,7 +4591,7 @@
        } else
                atomic_cas_uint(&adapter->recovery_mode, 1, 0);
 
-       atomic_and_uint(&adapter->recovery_mode_timer_pending, ~1);
+       atomic_store_relaxed(&adapter->recovery_mode_timer_pending, 0);
        callout_reset(&adapter->recovery_mode_timer, hz,
            ixgbe_recovery_mode_timer, adapter);
        IXGBE_CORE_UNLOCK(adapter);
@@ -4808,7 +4804,7 @@
                }
 #endif
        }
-       atomic_and_uint(&adapter->admin_pending, ~1);
+       atomic_store_relaxed(&adapter->admin_pending, 0);
        if ((adapter->feat_en & IXGBE_FEATURE_MSIX) != 0) {
                /* Re-enable other interrupts */
                IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER);
@@ -4829,9 +4825,9 @@
        IXGBE_CORE_UNLOCK(adapter);
 
        workqueue_wait(adapter->admin_wq, &adapter->admin_wc);
-       atomic_and_uint(&adapter->admin_pending, ~1);
+       atomic_store_relaxed(&adapter->admin_pending, 0);
        workqueue_wait(adapter->timer_wq, &adapter->timer_wc);
-       atomic_and_uint(&adapter->timer_pending, ~1);
+       atomic_store_relaxed(&adapter->timer_pending, 0);
 }
 
 /************************************************************************
diff -r 282e2d8fcde8 -r d7557613d4be sys/dev/pci/ixgbe/ixv.c
--- a/sys/dev/pci/ixgbe/ixv.c   Thu Aug 13 07:19:59 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixv.c   Thu Aug 13 08:38:50 2020 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.151 2020/06/25 07:53:02 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.152 2020/08/13 08:38:50 msaitoh Exp $*/
 
 /******************************************************************************
 
@@ -787,7 +787,7 @@
 
        /* Start watchdog */
        callout_reset(&adapter->timer, hz, ixv_local_timer, adapter);
-       atomic_and_uint(&adapter->timer_pending, ~1);
+       atomic_store_relaxed(&adapter->timer_pending, 0);
 
        /* OK to schedule workqueues. */
        adapter->schedule_wqs_ok = true;
@@ -1063,11 +1063,9 @@
 ixv_schedule_admin_tasklet(struct adapter *adapter)
 {
        if (adapter->schedule_wqs_ok) {
-               if (!adapter->admin_pending) {
-                       atomic_or_uint(&adapter->admin_pending, 1);
+               if (atomic_cas_uint(&adapter->admin_pending, 0, 1) == 0)
                        workqueue_enqueue(adapter->admin_wq,
                            &adapter->admin_wc, NULL);
-               }
        }
 }
 
@@ -1252,11 +1250,9 @@
        struct adapter *adapter = arg;
 
        if (adapter->schedule_wqs_ok) {
-               if (!adapter->timer_pending) {
-                       atomic_or_uint(&adapter->timer_pending, 1);
+               if (atomic_cas_uint(&adapter->timer_pending, 0, 1) == 0)
                        workqueue_enqueue(adapter->timer_wq,
                            &adapter->timer_wc, NULL);
-               }
        }
 }
 
@@ -1348,7 +1344,7 @@
        }
 #endif
 
-       atomic_and_uint(&adapter->timer_pending, ~1);
+       atomic_store_relaxed(&adapter->timer_pending, 0);
        IXGBE_CORE_UNLOCK(adapter);
        callout_reset(&adapter->timer, hz, ixv_local_timer, adapter);
 
@@ -1443,9 +1439,9 @@
        IXGBE_CORE_UNLOCK(adapter);
 
        workqueue_wait(adapter->admin_wq, &adapter->admin_wc);
-       atomic_and_uint(&adapter->admin_pending, ~1);
+       atomic_store_relaxed(&adapter->admin_pending, 0);
        workqueue_wait(adapter->timer_wq, &adapter->timer_wc);
-       atomic_and_uint(&adapter->timer_pending, ~1);
+       atomic_store_relaxed(&adapter->timer_pending, 0);
 }
 
 static void
@@ -3492,7 +3488,7 @@
        ixv_update_link_status(adapter);
 
        adapter->task_requests = 0;
-       atomic_and_uint(&adapter->admin_pending, ~1);
+       atomic_store_relaxed(&adapter->admin_pending, 0);
 
        /* Re-enable interrupts */
        IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, (1 << adapter->vector));



Home | Main Index | Thread Index | Old Index