Print this page
5042 stop using deprecated atomic functions


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #pragma ident   "%Z%%M% %I%     %E% SMI"
  27 
  28 #include <sys/types.h>
  29 #include <sys/systm.h>
  30 #include <sys/archsystm.h>
  31 #include <sys/machsystm.h>
  32 #include <sys/t_lock.h>
  33 #include <sys/vmem.h>
  34 #include <sys/mman.h>
  35 #include <sys/vm.h>
  36 #include <sys/cpu.h>
  37 #include <sys/cmn_err.h>
  38 #include <sys/cpuvar.h>
  39 #include <sys/atomic.h>
  40 #include <vm/as.h>
  41 #include <vm/hat.h>
  42 #include <vm/as.h>
  43 #include <vm/page.h>
  44 #include <vm/seg.h>
  45 #include <vm/seg_kmem.h>
  46 #include <vm/seg_kpm.h>
  47 #include <vm/hat_sfmmu.h>


 144 caddr_t
 145 ppmapin(page_t *pp, uint_t vprot, caddr_t hint)
 146 {
 147         int nset;
 148         caddr_t va;
 149 
 150 #ifdef PPDEBUG
 151         pp_allocs++;
 152 #endif /* PPDEBUG */
 153 
 154         /*
 155          * For sun4v caches are physical caches, we can pick any address
 156          * we want.
 157          */
 158         for (nset = 0; nset < nsets; nset++) {
 159                 va = ppmap_vaddrs[nset];
 160                 if (va != NULL) {
 161 #ifdef PPDEBUG
 162                         align_hits++;
 163 #endif /* PPDEBUG */
 164                         if (casptr(&ppmap_vaddrs[nset], va, NULL) == va) {

 165                                 hat_memload(kas.a_hat, va, pp,
 166                                     vprot | HAT_NOSYNC,
 167                                     HAT_LOAD_LOCK);
 168                                 return (va);
 169                         }
 170                 }
 171         }
 172 
 173 #ifdef PPDEBUG
 174         ppalloc_noslot++;
 175 #endif /* PPDEBUG */
 176 
 177         /*
 178          * No free slots; get a random one from the kernel heap area.
 179          */
 180         va = vmem_alloc(heap_arena, PAGESIZE, VM_SLEEP);
 181 
 182         hat_memload(kas.a_hat, va, pp, vprot | HAT_NOSYNC, HAT_LOAD_LOCK);
 183 
 184         return (va);




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 


  26 #include <sys/types.h>
  27 #include <sys/systm.h>
  28 #include <sys/archsystm.h>
  29 #include <sys/machsystm.h>
  30 #include <sys/t_lock.h>
  31 #include <sys/vmem.h>
  32 #include <sys/mman.h>
  33 #include <sys/vm.h>
  34 #include <sys/cpu.h>
  35 #include <sys/cmn_err.h>
  36 #include <sys/cpuvar.h>
  37 #include <sys/atomic.h>
  38 #include <vm/as.h>
  39 #include <vm/hat.h>
  40 #include <vm/as.h>
  41 #include <vm/page.h>
  42 #include <vm/seg.h>
  43 #include <vm/seg_kmem.h>
  44 #include <vm/seg_kpm.h>
  45 #include <vm/hat_sfmmu.h>


 142 caddr_t
 143 ppmapin(page_t *pp, uint_t vprot, caddr_t hint)
 144 {
 145         int nset;
 146         caddr_t va;
 147 
 148 #ifdef PPDEBUG
 149         pp_allocs++;
 150 #endif /* PPDEBUG */
 151 
 152         /*
 153          * For sun4v caches are physical caches, we can pick any address
 154          * we want.
 155          */
 156         for (nset = 0; nset < nsets; nset++) {
 157                 va = ppmap_vaddrs[nset];
 158                 if (va != NULL) {
 159 #ifdef PPDEBUG
 160                         align_hits++;
 161 #endif /* PPDEBUG */
 162                         if (atomic_cas_ptr(&ppmap_vaddrs[nset], va, NULL) ==
 163                             va) {
 164                                 hat_memload(kas.a_hat, va, pp,
 165                                     vprot | HAT_NOSYNC,
 166                                     HAT_LOAD_LOCK);
 167                                 return (va);
 168                         }
 169                 }
 170         }
 171 
 172 #ifdef PPDEBUG
 173         ppalloc_noslot++;
 174 #endif /* PPDEBUG */
 175 
 176         /*
 177          * No free slots; get a random one from the kernel heap area.
 178          */
 179         va = vmem_alloc(heap_arena, PAGESIZE, VM_SLEEP);
 180 
 181         hat_memload(kas.a_hat, va, pp, vprot | HAT_NOSYNC, HAT_LOAD_LOCK);
 182 
 183         return (va);