2 * SPU local store allocation routines
4 * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/kernel.h>
25 #include <linux/slab.h>
26 #include <linux/vmalloc.h>
29 #include <asm/spu_csa.h>
34 int spu_alloc_lscsa(struct spu_state
*csa
)
36 struct spu_lscsa
*lscsa
;
39 lscsa
= vzalloc(sizeof(struct spu_lscsa
));
44 /* Set LS pages reserved to allow for user-space mapping. */
45 for (p
= lscsa
->ls
; p
< lscsa
->ls
+ LS_SIZE
; p
+= PAGE_SIZE
)
46 SetPageReserved(vmalloc_to_page(p
));
51 void spu_free_lscsa(struct spu_state
*csa
)
53 /* Clear reserved bit before vfree. */
56 if (csa
->lscsa
== NULL
)
59 for (p
= csa
->lscsa
->ls
; p
< csa
->lscsa
->ls
+ LS_SIZE
; p
+= PAGE_SIZE
)
60 ClearPageReserved(vmalloc_to_page(p
));