1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * SPU local store allocation routines
5 * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
10 #include <linux/kernel.h>
12 #include <linux/slab.h>
13 #include <linux/vmalloc.h>
16 #include <asm/spu_csa.h>
21 int spu_alloc_lscsa(struct spu_state *csa)
23 struct spu_lscsa *lscsa;
26 lscsa = vzalloc(sizeof(*lscsa));
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));
38 void spu_free_lscsa(struct spu_state *csa)
40 /* Clear reserved bit before vfree. */
43 if (csa->lscsa == NULL)
46 for (p = csa->lscsa->ls; p < csa->lscsa->ls + LS_SIZE; p += PAGE_SIZE)
47 ClearPageReserved(vmalloc_to_page(p));