Path: blob/master/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
26498 views
// SPDX-License-Identifier: GPL-2.0-or-later1/*2* SPU local store allocation routines3*4* Copyright 2007 Benjamin Herrenschmidt, IBM Corp.5*/67#undef DEBUG89#include <linux/kernel.h>10#include <linux/mm.h>11#include <linux/slab.h>12#include <linux/vmalloc.h>1314#include <asm/spu.h>15#include <asm/spu_csa.h>16#include <asm/mmu.h>1718#include "spufs.h"1920int spu_alloc_lscsa(struct spu_state *csa)21{22struct spu_lscsa *lscsa;23unsigned char *p;2425lscsa = vzalloc(sizeof(*lscsa));26if (!lscsa)27return -ENOMEM;28csa->lscsa = lscsa;2930/* Set LS pages reserved to allow for user-space mapping. */31for (p = lscsa->ls; p < lscsa->ls + LS_SIZE; p += PAGE_SIZE)32SetPageReserved(vmalloc_to_page(p));3334return 0;35}3637void spu_free_lscsa(struct spu_state *csa)38{39/* Clear reserved bit before vfree. */40unsigned char *p;4142if (csa->lscsa == NULL)43return;4445for (p = csa->lscsa->ls; p < csa->lscsa->ls + LS_SIZE; p += PAGE_SIZE)46ClearPageReserved(vmalloc_to_page(p));4748vfree(csa->lscsa);49}505152