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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/ib/clients/ibd/ibd_cm.c
          +++ new/usr/src/uts/common/io/ib/clients/ibd/ibd_cm.c
↓ open down ↓ 1228 lines elided ↑ open up ↑
1229 1229   */
1230 1230  static int
1231 1231  ibd_rc_post_srq(ibd_state_t *state, ibd_rwqe_t *rwqe)
1232 1232  {
1233 1233          /*
1234 1234           * Here we should add dl_cnt before post recv, because
1235 1235           * we would have to make sure dl_cnt is updated before
1236 1236           * the corresponding ibd_rc_process_rx() is called.
1237 1237           */
1238 1238          ASSERT(state->rc_srq_rwqe_list.dl_cnt < state->rc_srq_size);
1239      -        atomic_add_32(&state->rc_srq_rwqe_list.dl_cnt, 1);
     1239 +        atomic_inc_32(&state->rc_srq_rwqe_list.dl_cnt);
1240 1240          if (ibt_post_srq(state->rc_srq_hdl, &rwqe->w_rwr, 1, NULL) !=
1241 1241              IBT_SUCCESS) {
1242 1242                  atomic_dec_32(&state->rc_srq_rwqe_list.dl_cnt);
1243 1243                  DPRINT(40, "ibd_rc_post_srq : ibt_post_srq() failed");
1244 1244                  return (DDI_FAILURE);
1245 1245          }
1246 1246  
1247 1247          return (DDI_SUCCESS);
1248 1248  }
1249 1249  
↓ open down ↓ 1 lines elided ↑ open up ↑
1251 1251   * Post a rwqe to the hardware and add it to the Rx list.
1252 1252   */
1253 1253  static int
1254 1254  ibd_rc_post_rwqe(ibd_rc_chan_t *chan, ibd_rwqe_t *rwqe)
1255 1255  {
1256 1256          /*
1257 1257           * Here we should add dl_cnt before post recv, because we would
1258 1258           * have to make sure dl_cnt has already updated before
1259 1259           * corresponding ibd_rc_process_rx() is called.
1260 1260           */
1261      -        atomic_add_32(&chan->rx_wqe_list.dl_cnt, 1);
     1261 +        atomic_inc_32(&chan->rx_wqe_list.dl_cnt);
1262 1262          if (ibt_post_recv(chan->chan_hdl, &rwqe->w_rwr, 1, NULL) !=
1263 1263              IBT_SUCCESS) {
1264 1264                  atomic_dec_32(&chan->rx_wqe_list.dl_cnt);
1265 1265                  DPRINT(40, "ibd_rc_post_rwqe : failed in ibt_post_recv()");
1266 1266                  return (DDI_FAILURE);
1267 1267          }
1268 1268          return (DDI_SUCCESS);
1269 1269  }
1270 1270  
1271 1271  static int
↓ open down ↓ 220 lines elided ↑ open up ↑
1492 1492          if ((rxcnt >= state->id_rc_rx_rwqe_thresh) &&
1493 1493              (wc->wc_bytes_xfer > state->id_rc_rx_copy_thresh)) {
1494 1494                  atomic_add_64(&state->rc_rcv_trans_byte, wc->wc_bytes_xfer);
1495 1495                  atomic_inc_64(&state->rc_rcv_trans_pkt);
1496 1496  
1497 1497                  /*
1498 1498                   * Record how many rwqe has been occupied by upper
1499 1499                   * network layer
1500 1500                   */
1501 1501                  if (state->rc_enable_srq) {
1502      -                        atomic_add_32(&state->rc_srq_rwqe_list.
1503      -                            dl_bufs_outstanding, 1);
     1502 +                        atomic_inc_32(
     1503 +                            &state->rc_srq_rwqe_list.dl_bufs_outstanding);
1504 1504                  } else {
1505      -                        atomic_add_32(&chan->rx_wqe_list.
1506      -                            dl_bufs_outstanding, 1);
     1505 +                        atomic_inc_32(&chan->rx_wqe_list.dl_bufs_outstanding);
1507 1506                  }
1508 1507                  mp = rwqe->rwqe_im_mblk;
1509 1508          } else {
1510 1509                  atomic_add_64(&state->rc_rcv_copy_byte, wc->wc_bytes_xfer);
1511 1510                  atomic_inc_64(&state->rc_rcv_copy_pkt);
1512 1511  
1513 1512                  if ((mp = allocb(wc->wc_bytes_xfer + IPOIB_GRH_SIZE,
1514 1513                      BPRI_HI)) == NULL) {        /* no memory */
1515 1514                          DPRINT(40, "ibd_rc_process_rx: allocb() failed");
1516 1515                          state->rc_rcv_alloc_fail++;
↓ open down ↓ 145 lines elided ↑ open up ↑
1662 1661           * Post back to h/w. We could actually have more than
1663 1662           * id_num_rwqe WQEs on the list if there were multiple
1664 1663           * ibd_freemsg_cb() calls outstanding (since the lock is
1665 1664           * not held the entire time). This will start getting
1666 1665           * corrected over subsequent ibd_freemsg_cb() calls.
1667 1666           */
1668 1667          if (ibd_rc_post_rwqe(chan, rwqe) == DDI_FAILURE) {
1669 1668                  ibd_rc_free_rwqe(chan, rwqe);
1670 1669                  return;
1671 1670          }
1672      -        atomic_add_32(&chan->rx_wqe_list.dl_bufs_outstanding, -1);
     1671 +        atomic_dec_32(&chan->rx_wqe_list.dl_bufs_outstanding);
1673 1672  }
1674 1673  
1675 1674  /*
1676 1675   * Common code for interrupt handling as well as for polling
1677 1676   * for all completed wqe's while detaching.
1678 1677   */
1679 1678  static void
1680 1679  ibd_rc_poll_rcq(ibd_rc_chan_t *chan, ibt_cq_hdl_t cq_hdl)
1681 1680  {
1682 1681          ibd_wqe_t *wqe;
↓ open down ↓ 1653 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX