Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/sunddi.c
          +++ new/usr/src/uts/common/os/sunddi.c
↓ open down ↓ 8084 lines elided ↑ open up ↑
8085 8085           * The i_ddi_umem_unlock for this cookie may or may not have been
8086 8086           * called already.  It is the responsibility of the caller of
8087 8087           * umem_lockmemory to handle the case of the cleanup routine
8088 8088           * being called after a ddi_umem_unlock for the cookie
8089 8089           * was called.
8090 8090           */
8091 8091  
8092 8092          (*cp->callbacks.cbo_umem_lock_cleanup)((ddi_umem_cookie_t)cp);
8093 8093  
8094 8094          /* remove the cookie if reference goes to zero */
8095      -        if (atomic_add_long_nv((ulong_t *)(&(cp->cook_refcnt)), -1) == 0) {
     8095 +        if (atomic_dec_ulong_nv((ulong_t *)(&(cp->cook_refcnt))) == 0) {
8096 8096                  kmem_free(cp, sizeof (struct ddi_umem_cookie));
8097 8097          }
8098 8098  }
8099 8099  
8100 8100  /*
8101 8101   * The following two Consolidation Private routines provide generic
8102 8102   * interfaces to increase/decrease the amount of device-locked memory.
8103 8103   *
8104 8104   * To keep project_rele and project_hold consistent, i_ddi_decr_locked_memory()
8105 8105   * must be called every time i_ddi_incr_locked_memory() is called.
↓ open down ↓ 374 lines elided ↑ open up ↑
8480 8480          } else {
8481 8481                  /*
8482 8482                   * umem_undo_lock may happen if as_delete_callback returned
8483 8483                   * AS_CALLBACK_DELETE_DEFERRED.  In that case, decrement the
8484 8484                   * reference count, atomically, and return the cookie
8485 8485                   * memory if the reference count goes to zero.  The only
8486 8486                   * other value for rc is AS_CALLBACK_NOTFOUND.  In that
8487 8487                   * case, just return the cookie memory.
8488 8488                   */
8489 8489                  if ((rc != AS_CALLBACK_DELETE_DEFERRED) ||
8490      -                    (atomic_add_long_nv((ulong_t *)(&(p->cook_refcnt)), -1)
     8490 +                    (atomic_dec_ulong_nv((ulong_t *)(&(p->cook_refcnt)))
8491 8491                      == 0)) {
8492 8492                          kmem_free(p, sizeof (struct ddi_umem_cookie));
8493 8493                  }
8494 8494          }
8495 8495  }
8496 8496  
8497 8497  /*
8498 8498   * i_ddi_umem_unlock_thread - deferred ddi_umem_unlock list handler.
8499 8499   *
8500 8500   * Call i_ddi_umem_unlock for entries in the ddi_umem_unlock list
↓ open down ↓ 1524 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX