1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * SPU local store allocation routines 4 * 5 * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. 6 */ 7 8 #undef DEBUG 9 10 #include <linux/kernel.h> 11 #include <linux/mm.h> 12 #include <linux/slab.h> 13 #include <linux/vmalloc.h> 14 15 #include <asm/spu.h> 16 #include <asm/spu_csa.h> 17 #include <asm/mmu.h> 18 19 #include "spufs.h" 20 21 int spu_alloc_lscsa(struct spu_state *csa) 22 { 23 struct spu_lscsa *lscsa; 24 unsigned char *p; 25 26 lscsa = vzalloc(sizeof(*lscsa)); 27 if (!lscsa) 28 return -ENOMEM; 29 csa->lscsa = lscsa; 30 31 /* Set LS pages reserved to allow for user-space mapping. */ 32 for (p = lscsa->ls; p < lscsa->ls + LS_SIZE; p += PAGE_SIZE) 33 SetPageReserved(vmalloc_to_page(p)); 34 35 return 0; 36 } 37 38 void spu_free_lscsa(struct spu_state *csa) 39 { 40 /* Clear reserved bit before vfree. */ 41 unsigned char *p; 42 43 if (csa->lscsa == NULL) 44 return; 45 46 for (p = csa->lscsa->ls; p < csa->lscsa->ls + LS_SIZE; p += PAGE_SIZE) 47 ClearPageReserved(vmalloc_to_page(p)); 48 49 vfree(csa->lscsa); 50 } 51
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.