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/daplt/daplt.c
          +++ new/usr/src/uts/common/io/ib/clients/daplt/daplt.c
↓ open down ↓ 8285 lines elided ↑ open up ↑
8286 8286  
8287 8287          if (acct_enabled) {
8288 8288                  if (daplka_max_qp_percent != 0 &&
8289 8289                      max_qps <= hca_p->hca_qp_count) {
8290 8290                          DERR("ibt_alloc_rc_channel: resource limit exceeded "
8291 8291                              "(limit %d, count %d)\n", max_qps,
8292 8292                              hca_p->hca_qp_count);
8293 8293                          return (IBT_INSUFF_RESOURCE);
8294 8294                  }
8295 8295                  DAPLKA_RS_ACCT_INC(ep_rp, 1);
8296      -                atomic_add_32(&hca_p->hca_qp_count, 1);
     8296 +                atomic_inc_32(&hca_p->hca_qp_count);
8297 8297          }
8298 8298          status = ibt_alloc_rc_channel(hca_hdl, flags, args, chan_hdl_p, sizes);
8299 8299  
8300 8300          if (status != IBT_SUCCESS && acct_enabled) {
8301 8301                  DAPLKA_RS_ACCT_DEC(ep_rp, 1);
8302      -                atomic_add_32(&hca_p->hca_qp_count, -1);
     8302 +                atomic_dec_32(&hca_p->hca_qp_count);
8303 8303          }
8304 8304          return (status);
8305 8305  }
8306 8306  
8307 8307  static ibt_status_t
8308 8308  daplka_ibt_free_channel(daplka_ep_resource_t *ep_rp, ibt_channel_hdl_t chan_hdl)
8309 8309  {
8310 8310          daplka_hca_t    *hca_p;
8311 8311          ibt_status_t    status;
8312 8312  
8313 8313          hca_p = ep_rp->ep_hca;
8314 8314  
8315 8315          status = ibt_free_channel(chan_hdl);
8316 8316          if (status != IBT_SUCCESS) {
8317 8317                  return (status);
8318 8318          }
8319 8319          if (DAPLKA_RS_ACCT_CHARGED(ep_rp) > 0) {
8320 8320                  DAPLKA_RS_ACCT_DEC(ep_rp, 1);
8321      -                atomic_add_32(&hca_p->hca_qp_count, -1);
     8321 +                atomic_dec_32(&hca_p->hca_qp_count);
8322 8322          }
8323 8323          return (status);
8324 8324  }
8325 8325  
8326 8326  static ibt_status_t
8327 8327  daplka_ibt_alloc_cq(daplka_evd_resource_t *evd_rp, ibt_hca_hdl_t hca_hdl,
8328 8328      ibt_cq_attr_t *cq_attr, ibt_cq_hdl_t *ibt_cq_p, uint32_t *real_size)
8329 8329  {
8330 8330          daplka_hca_t    *hca_p;
8331 8331          uint32_t        max_cqs;
↓ open down ↓ 6 lines elided ↑ open up ↑
8338 8338  
8339 8339          if (acct_enabled) {
8340 8340                  if (daplka_max_cq_percent != 0 &&
8341 8341                      max_cqs <= hca_p->hca_cq_count) {
8342 8342                          DERR("ibt_alloc_cq: resource limit exceeded "
8343 8343                              "(limit %d, count %d)\n", max_cqs,
8344 8344                              hca_p->hca_cq_count);
8345 8345                          return (IBT_INSUFF_RESOURCE);
8346 8346                  }
8347 8347                  DAPLKA_RS_ACCT_INC(evd_rp, 1);
8348      -                atomic_add_32(&hca_p->hca_cq_count, 1);
     8348 +                atomic_inc_32(&hca_p->hca_cq_count);
8349 8349          }
8350 8350          status = ibt_alloc_cq(hca_hdl, cq_attr, ibt_cq_p, real_size);
8351 8351  
8352 8352          if (status != IBT_SUCCESS && acct_enabled) {
8353 8353                  DAPLKA_RS_ACCT_DEC(evd_rp, 1);
8354      -                atomic_add_32(&hca_p->hca_cq_count, -1);
     8354 +                atomic_dec_32(&hca_p->hca_cq_count);
8355 8355          }
8356 8356          return (status);
8357 8357  }
8358 8358  
8359 8359  static ibt_status_t
8360 8360  daplka_ibt_free_cq(daplka_evd_resource_t *evd_rp, ibt_cq_hdl_t cq_hdl)
8361 8361  {
8362 8362          daplka_hca_t    *hca_p;
8363 8363          ibt_status_t    status;
8364 8364  
8365 8365          hca_p = evd_rp->evd_hca;
8366 8366  
8367 8367          status = ibt_free_cq(cq_hdl);
8368 8368          if (status != IBT_SUCCESS) {
8369 8369                  return (status);
8370 8370          }
8371 8371          if (DAPLKA_RS_ACCT_CHARGED(evd_rp) > 0) {
8372 8372                  DAPLKA_RS_ACCT_DEC(evd_rp, 1);
8373      -                atomic_add_32(&hca_p->hca_cq_count, -1);
     8373 +                atomic_dec_32(&hca_p->hca_cq_count);
8374 8374          }
8375 8375          return (status);
8376 8376  }
8377 8377  
8378 8378  static ibt_status_t
8379 8379  daplka_ibt_alloc_pd(daplka_pd_resource_t *pd_rp, ibt_hca_hdl_t hca_hdl,
8380 8380      ibt_pd_flags_t flags, ibt_pd_hdl_t *pd_hdl_p)
8381 8381  {
8382 8382          daplka_hca_t    *hca_p;
8383 8383          uint32_t        max_pds;
↓ open down ↓ 6 lines elided ↑ open up ↑
8390 8390  
8391 8391          if (acct_enabled) {
8392 8392                  if (daplka_max_pd_percent != 0 &&
8393 8393                      max_pds <= hca_p->hca_pd_count) {
8394 8394                          DERR("ibt_alloc_pd: resource limit exceeded "
8395 8395                              "(limit %d, count %d)\n", max_pds,
8396 8396                              hca_p->hca_pd_count);
8397 8397                          return (IBT_INSUFF_RESOURCE);
8398 8398                  }
8399 8399                  DAPLKA_RS_ACCT_INC(pd_rp, 1);
8400      -                atomic_add_32(&hca_p->hca_pd_count, 1);
     8400 +                atomic_inc_32(&hca_p->hca_pd_count);
8401 8401          }
8402 8402          status = ibt_alloc_pd(hca_hdl, flags, pd_hdl_p);
8403 8403  
8404 8404          if (status != IBT_SUCCESS && acct_enabled) {
8405 8405                  DAPLKA_RS_ACCT_DEC(pd_rp, 1);
8406      -                atomic_add_32(&hca_p->hca_pd_count, -1);
     8406 +                atomic_dec_32(&hca_p->hca_pd_count);
8407 8407          }
8408 8408          return (status);
8409 8409  }
8410 8410  
8411 8411  static ibt_status_t
8412 8412  daplka_ibt_free_pd(daplka_pd_resource_t *pd_rp, ibt_hca_hdl_t hca_hdl,
8413 8413      ibt_pd_hdl_t pd_hdl)
8414 8414  {
8415 8415          daplka_hca_t    *hca_p;
8416 8416          ibt_status_t    status;
8417 8417  
8418 8418          hca_p = pd_rp->pd_hca;
8419 8419  
8420 8420          status = ibt_free_pd(hca_hdl, pd_hdl);
8421 8421          if (status != IBT_SUCCESS) {
8422 8422                  return (status);
8423 8423          }
8424 8424          if (DAPLKA_RS_ACCT_CHARGED(pd_rp) > 0) {
8425 8425                  DAPLKA_RS_ACCT_DEC(pd_rp, 1);
8426      -                atomic_add_32(&hca_p->hca_pd_count, -1);
     8426 +                atomic_dec_32(&hca_p->hca_pd_count);
8427 8427          }
8428 8428          return (status);
8429 8429  }
8430 8430  
8431 8431  static ibt_status_t
8432 8432  daplka_ibt_alloc_mw(daplka_mw_resource_t *mw_rp, ibt_hca_hdl_t hca_hdl,
8433 8433      ibt_pd_hdl_t pd_hdl, ibt_mw_flags_t flags, ibt_mw_hdl_t *mw_hdl_p,
8434 8434      ibt_rkey_t *rkey_p)
8435 8435  {
8436 8436          daplka_hca_t    *hca_p;
↓ open down ↓ 7 lines elided ↑ open up ↑
8444 8444  
8445 8445          if (acct_enabled) {
8446 8446                  if (daplka_max_mw_percent != 0 &&
8447 8447                      max_mws <= hca_p->hca_mw_count) {
8448 8448                          DERR("ibt_alloc_mw: resource limit exceeded "
8449 8449                              "(limit %d, count %d)\n", max_mws,
8450 8450                              hca_p->hca_mw_count);
8451 8451                          return (IBT_INSUFF_RESOURCE);
8452 8452                  }
8453 8453                  DAPLKA_RS_ACCT_INC(mw_rp, 1);
8454      -                atomic_add_32(&hca_p->hca_mw_count, 1);
     8454 +                atomic_inc_32(&hca_p->hca_mw_count);
8455 8455          }
8456 8456          status = ibt_alloc_mw(hca_hdl, pd_hdl, flags, mw_hdl_p, rkey_p);
8457 8457  
8458 8458          if (status != IBT_SUCCESS && acct_enabled) {
8459 8459                  DAPLKA_RS_ACCT_DEC(mw_rp, 1);
8460      -                atomic_add_32(&hca_p->hca_mw_count, -1);
     8460 +                atomic_dec_32(&hca_p->hca_mw_count);
8461 8461          }
8462 8462          return (status);
8463 8463  }
8464 8464  
8465 8465  static ibt_status_t
8466 8466  daplka_ibt_free_mw(daplka_mw_resource_t *mw_rp, ibt_hca_hdl_t hca_hdl,
8467 8467      ibt_mw_hdl_t mw_hdl)
8468 8468  {
8469 8469          daplka_hca_t    *hca_p;
8470 8470          ibt_status_t    status;
8471 8471  
8472 8472          hca_p = mw_rp->mw_hca;
8473 8473  
8474 8474          status = ibt_free_mw(hca_hdl, mw_hdl);
8475 8475          if (status != IBT_SUCCESS) {
8476 8476                  return (status);
8477 8477          }
8478 8478          if (DAPLKA_RS_ACCT_CHARGED(mw_rp) > 0) {
8479 8479                  DAPLKA_RS_ACCT_DEC(mw_rp, 1);
8480      -                atomic_add_32(&hca_p->hca_mw_count, -1);
     8480 +                atomic_dec_32(&hca_p->hca_mw_count);
8481 8481          }
8482 8482          return (status);
8483 8483  }
8484 8484  
8485 8485  static ibt_status_t
8486 8486  daplka_ibt_register_mr(daplka_mr_resource_t *mr_rp, ibt_hca_hdl_t hca_hdl,
8487 8487      ibt_pd_hdl_t pd_hdl, ibt_mr_attr_t *mr_attr, ibt_mr_hdl_t *mr_hdl_p,
8488 8488      ibt_mr_desc_t *mr_desc_p)
8489 8489  {
8490 8490          daplka_hca_t    *hca_p;
↓ open down ↓ 7 lines elided ↑ open up ↑
8498 8498  
8499 8499          if (acct_enabled) {
8500 8500                  if (daplka_max_mr_percent != 0 &&
8501 8501                      max_mrs <= hca_p->hca_mr_count) {
8502 8502                          DERR("ibt_register_mr: resource limit exceeded "
8503 8503                              "(limit %d, count %d)\n", max_mrs,
8504 8504                              hca_p->hca_mr_count);
8505 8505                          return (IBT_INSUFF_RESOURCE);
8506 8506                  }
8507 8507                  DAPLKA_RS_ACCT_INC(mr_rp, 1);
8508      -                atomic_add_32(&hca_p->hca_mr_count, 1);
     8508 +                atomic_inc_32(&hca_p->hca_mr_count);
8509 8509          }
8510 8510          status = ibt_register_mr(hca_hdl, pd_hdl, mr_attr, mr_hdl_p, mr_desc_p);
8511 8511  
8512 8512          if (status != IBT_SUCCESS && acct_enabled) {
8513 8513                  DAPLKA_RS_ACCT_DEC(mr_rp, 1);
8514      -                atomic_add_32(&hca_p->hca_mr_count, -1);
     8514 +                atomic_dec_32(&hca_p->hca_mr_count);
8515 8515          }
8516 8516          return (status);
8517 8517  }
8518 8518  
8519 8519  static ibt_status_t
8520 8520  daplka_ibt_register_shared_mr(daplka_mr_resource_t *mr_rp,
8521 8521      ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, ibt_pd_hdl_t pd_hdl,
8522 8522      ibt_smr_attr_t *smr_attr_p, ibt_mr_hdl_t *mr_hdl_p,
8523 8523      ibt_mr_desc_t *mr_desc_p)
8524 8524  {
↓ open down ↓ 8 lines elided ↑ open up ↑
8533 8533  
8534 8534          if (acct_enabled) {
8535 8535                  if (daplka_max_mr_percent != 0 &&
8536 8536                      max_mrs <= hca_p->hca_mr_count) {
8537 8537                          DERR("ibt_register_shared_mr: resource limit exceeded "
8538 8538                              "(limit %d, count %d)\n", max_mrs,
8539 8539                              hca_p->hca_mr_count);
8540 8540                          return (IBT_INSUFF_RESOURCE);
8541 8541                  }
8542 8542                  DAPLKA_RS_ACCT_INC(mr_rp, 1);
8543      -                atomic_add_32(&hca_p->hca_mr_count, 1);
     8543 +                atomic_inc_32(&hca_p->hca_mr_count);
8544 8544          }
8545 8545          status = ibt_register_shared_mr(hca_hdl, mr_hdl, pd_hdl,
8546 8546              smr_attr_p, mr_hdl_p, mr_desc_p);
8547 8547  
8548 8548          if (status != IBT_SUCCESS && acct_enabled) {
8549 8549                  DAPLKA_RS_ACCT_DEC(mr_rp, 1);
8550      -                atomic_add_32(&hca_p->hca_mr_count, -1);
     8550 +                atomic_dec_32(&hca_p->hca_mr_count);
8551 8551          }
8552 8552          return (status);
8553 8553  }
8554 8554  
8555 8555  static ibt_status_t
8556 8556  daplka_ibt_deregister_mr(daplka_mr_resource_t *mr_rp, ibt_hca_hdl_t hca_hdl,
8557 8557      ibt_mr_hdl_t mr_hdl)
8558 8558  {
8559 8559          daplka_hca_t    *hca_p;
8560 8560          ibt_status_t    status;
8561 8561  
8562 8562          hca_p = mr_rp->mr_hca;
8563 8563  
8564 8564          status = ibt_deregister_mr(hca_hdl, mr_hdl);
8565 8565          if (status != IBT_SUCCESS) {
8566 8566                  return (status);
8567 8567          }
8568 8568          if (DAPLKA_RS_ACCT_CHARGED(mr_rp) > 0) {
8569 8569                  DAPLKA_RS_ACCT_DEC(mr_rp, 1);
8570      -                atomic_add_32(&hca_p->hca_mr_count, -1);
     8570 +                atomic_dec_32(&hca_p->hca_mr_count);
8571 8571          }
8572 8572          return (status);
8573 8573  }
8574 8574  
8575 8575  static ibt_status_t
8576 8576  daplka_ibt_alloc_srq(daplka_srq_resource_t *srq_rp, ibt_hca_hdl_t hca_hdl,
8577 8577      ibt_srq_flags_t flags, ibt_pd_hdl_t pd, ibt_srq_sizes_t *reqsz,
8578 8578      ibt_srq_hdl_t *srq_hdl_p, ibt_srq_sizes_t *realsz)
8579 8579  {
8580 8580          daplka_hca_t    *hca_p;
↓ open down ↓ 7 lines elided ↑ open up ↑
8588 8588  
8589 8589          if (acct_enabled) {
8590 8590                  if (daplka_max_srq_percent != 0 &&
8591 8591                      max_srqs <= hca_p->hca_srq_count) {
8592 8592                          DERR("ibt_alloc_srq: resource limit exceeded "
8593 8593                              "(limit %d, count %d)\n", max_srqs,
8594 8594                              hca_p->hca_srq_count);
8595 8595                          return (IBT_INSUFF_RESOURCE);
8596 8596                  }
8597 8597                  DAPLKA_RS_ACCT_INC(srq_rp, 1);
8598      -                atomic_add_32(&hca_p->hca_srq_count, 1);
     8598 +                atomic_inc_32(&hca_p->hca_srq_count);
8599 8599          }
8600 8600          status = ibt_alloc_srq(hca_hdl, flags, pd, reqsz, srq_hdl_p, realsz);
8601 8601  
8602 8602          if (status != IBT_SUCCESS && acct_enabled) {
8603 8603                  DAPLKA_RS_ACCT_DEC(srq_rp, 1);
8604      -                atomic_add_32(&hca_p->hca_srq_count, -1);
     8604 +                atomic_dec_32(&hca_p->hca_srq_count);
8605 8605          }
8606 8606          return (status);
8607 8607  }
8608 8608  
8609 8609  static ibt_status_t
8610 8610  daplka_ibt_free_srq(daplka_srq_resource_t *srq_rp, ibt_srq_hdl_t srq_hdl)
8611 8611  {
8612 8612          daplka_hca_t    *hca_p;
8613 8613          ibt_status_t    status;
8614 8614  
8615 8615          hca_p = srq_rp->srq_hca;
8616 8616  
8617 8617          D3("ibt_free_srq: %p %p\n", srq_rp, srq_hdl);
8618 8618  
8619 8619          status = ibt_free_srq(srq_hdl);
8620 8620          if (status != IBT_SUCCESS) {
8621 8621                  return (status);
8622 8622          }
8623 8623          if (DAPLKA_RS_ACCT_CHARGED(srq_rp) > 0) {
8624 8624                  DAPLKA_RS_ACCT_DEC(srq_rp, 1);
8625      -                atomic_add_32(&hca_p->hca_srq_count, -1);
     8625 +                atomic_dec_32(&hca_p->hca_srq_count);
8626 8626          }
8627 8627          return (status);
8628 8628  }
8629 8629  
8630 8630  
8631 8631  static int
8632 8632  daplka_common_ioctl(int cmd, minor_t rnum, intptr_t arg, int mode,
8633 8633          cred_t *cred, int *rvalp)
8634 8634  {
8635 8635          int error;
↓ open down ↓ 392 lines elided ↑ open up ↑
9028 9028          daplka_ia_resource_t    *ia_rp;
9029 9029          minor_t                 rnum = getminor(dev);
9030 9030  
9031 9031          /*
9032 9032           * Char only
9033 9033           */
9034 9034          if (otyp != OTYP_CHR) {
9035 9035                  return (EINVAL);
9036 9036          }
9037 9037          D2("daplka_close: closing rnum = %d\n", rnum);
9038      -        atomic_add_32(&daplka_pending_close, 1);
     9038 +        atomic_inc_32(&daplka_pending_close);
9039 9039  
9040 9040          /*
9041 9041           * remove from resource table.
9042 9042           */
9043 9043          ia_rp = (daplka_ia_resource_t *)daplka_resource_remove(rnum);
9044 9044  
9045 9045          /*
9046 9046           * remove the initial reference
9047 9047           */
9048 9048          if (ia_rp != NULL) {
9049 9049                  DAPLKA_RS_UNREF(ia_rp);
9050 9050          }
9051      -        atomic_add_32(&daplka_pending_close, -1);
     9051 +        atomic_dec_32(&daplka_pending_close);
9052 9052          return (DDI_SUCCESS);
9053 9053  }
9054 9054  
9055 9055  
9056 9056  /*
9057 9057   * Resource management routines
9058 9058   *
9059 9059   * We start with no resource array. Each time we run out of slots, we
9060 9060   * reallocate a new larger array and copy the pointer to the new array and
9061 9061   * a new resource blk is allocated and added to the hash table.
↓ open down ↓ 777 lines elided ↑ open up ↑
9839 9839  
9840 9840  /*
9841 9841   * Generates a non-zero 32 bit hash key used for the timer hash table.
9842 9842   */
9843 9843  static uint32_t
9844 9844  daplka_timer_hkey_gen()
9845 9845  {
9846 9846          uint32_t new_hkey;
9847 9847  
9848 9848          do {
9849      -                new_hkey = atomic_add_32_nv(&daplka_timer_hkey, 1);
     9849 +                new_hkey = atomic_inc_32_nv(&daplka_timer_hkey);
9850 9850          } while (new_hkey == 0);
9851 9851  
9852 9852          return (new_hkey);
9853 9853  }
9854 9854  
9855 9855  
9856 9856  /*
9857 9857   * The DAPL KA debug logging routines
9858 9858   */
9859 9859  
↓ open down ↓ 80 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX