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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/sun4u/sunfire/io/ac_test.c
          +++ new/usr/src/uts/sun4u/sunfire/io/ac_test.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   27  #include <sys/types.h>
  30   28  #include <sys/conf.h>
  31   29  #include <sys/ddi.h>
  32   30  #include <sys/sunddi.h>
  33   31  #include <sys/ddi_impldefs.h>
  34   32  #include <sys/obpdefs.h>
  35   33  #include <sys/cmn_err.h>
  36   34  #include <sys/errno.h>
  37   35  #include <sys/kmem.h>
  38   36  #include <sys/vmem.h>
↓ open down ↓ 146 lines elided ↑ open up ↑
 185  183           * create a test buffer
 186  184           */
 187  185          test = kmem_zalloc(sizeof (struct test_info), KM_SLEEP);
 188  186          test->va = vmem_alloc(heap_arena, PAGESIZE, VM_SLEEP);
 189  187  
 190  188          /* fill in all the test info details now */
 191  189          test->mem_info = mem_info;
 192  190          test->board = softsp->board;
 193  191          test->bank = pkt->bank;
 194  192          test->bufp = kmem_alloc(TEST_PAGESIZE, KM_SLEEP);
 195      -        test->info.handle = atomic_add_32_nv(&mem_test_sequence_id, 1);
      193 +        test->info.handle = atomic_inc_32_nv(&mem_test_sequence_id);
 196  194          (void) drv_getparm(PPID, (ulong_t *)(&(test->info.tester_pid)));
 197  195          test->info.prev_condition = mem_info->condition;
 198  196          test->info.page_size = TEST_PAGESIZE;
 199  197          /* If Blackbird ever gets a variable line size, this will change. */
 200  198          test->info.line_size = cpunodes[CPU->cpu_id].ecache_linesize;
 201  199          decode = (pkt->bank == Bank0) ?
 202  200              *softsp->ac_memdecode0 : *softsp->ac_memdecode1;
 203  201          test->info.afar_base = GRP_REALBASE(decode);
 204  202          test->info.bank_size = GRP_UK2SPAN(decode);
 205  203  
↓ open down ↓ 191 lines elided ↑ open up ↑
 397  395                  if (test->info.handle == t_read.handle)
 398  396                          break;
 399  397          }
 400  398          if (test == NULL) {
 401  399                  mutex_exit(&test_mutex);
 402  400                  AC_ERR_SET(pkt, AC_ERR_MEM_TEST);
 403  401                  return (EINVAL);
 404  402          }
 405  403  
 406  404          /* bump the busy bit */
 407      -        atomic_add_32(&test->in_test, 1);
      405 +        atomic_inc_32(&test->in_test);
 408  406          mutex_exit(&test_mutex);
 409  407  
 410  408          /* verify the remaining parameters */
 411  409          if ((t_read.address.page_num >=
 412  410              test->info.bank_size / test->info.page_size) ||
 413  411              (t_read.address.line_count == 0) ||
 414  412              (t_read.address.line_count >
 415  413              test->info.page_size / test->info.line_size) ||
 416  414              (t_read.address.line_offset >=
 417  415              test->info.page_size / test->info.line_size) ||
↓ open down ↓ 73 lines elided ↑ open up ↑
 491  489  
 492  490          /*
 493  491           * Then, return the page to the user (always)
 494  492           */
 495  493          if (ddi_copyout(dst_va, (caddr_t)(t_read.page_buf) + page_offset,
 496  494              t_read.address.line_count * test->info.line_size, flag) != 0) {
 497  495                  retval = EFAULT;
 498  496          }
 499  497  
 500  498  read_done:
 501      -        atomic_add_32(&test->in_test, -1);
      499 +        atomic_dec_32(&test->in_test);
 502  500          return (retval);
 503  501  }
 504  502  
 505  503  int
 506  504  ac_mem_test_write(ac_cfga_pkt_t *pkt, int flag)
 507  505  {
 508  506          struct test_info *test;
 509  507          uint_t page_offset;
 510  508          uint64_t page_pa;
 511  509          uint_t pstate_save;
↓ open down ↓ 31 lines elided ↑ open up ↑
 543  541          for (test = test_base; test != NULL; test = test->next) {
 544  542                  if (test->info.handle == t_write.handle)
 545  543                          break;
 546  544          }
 547  545          if (test == NULL) {
 548  546                  mutex_exit(&test_mutex);
 549  547                  return (EINVAL);
 550  548          }
 551  549  
 552  550          /* bump the busy bit */
 553      -        atomic_add_32(&test->in_test, 1);
      551 +        atomic_inc_32(&test->in_test);
 554  552          mutex_exit(&test_mutex);
 555  553  
 556  554          /* verify the remaining parameters */
 557  555          if ((t_write.address.page_num >=
 558  556              test->info.bank_size / test->info.page_size) ||
 559  557              (t_write.address.line_count == 0) ||
 560  558              (t_write.address.line_count >
 561  559              test->info.page_size / test->info.line_size) ||
 562  560              (t_write.address.line_offset >=
 563  561              test->info.page_size / test->info.line_size) ||
↓ open down ↓ 31 lines elided ↑ open up ↑
 595  593  
 596  594          enable_vec_intr(pstate_save);
 597  595  
 598  596          /* tear down translation (who needs an mmu) */
 599  597          ac_unmap(test->va);
 600  598  
 601  599          /* we're back! */
 602  600          kpreempt_enable();
 603  601  
 604  602  write_done:
 605      -        atomic_add_32(&test->in_test, -1);
      603 +        atomic_dec_32(&test->in_test);
 606  604          return (retval);
 607  605  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX