]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
UBUNTU: Ubuntu-4.15.0-96.97
[mirror_ubuntu-bionic-kernel.git] / arch / powerpc / platforms / cell / spufs / lscsa_alloc.c
CommitLineData
f1fa74f4
BH
1/*
2 * SPU local store allocation routines
3 *
4 * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
5 *
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)
9 * any later version.
10 *
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.
15 *
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.
19 */
20
21#undef DEBUG
22
23#include <linux/kernel.h>
24#include <linux/mm.h>
5a0e3ad6 25#include <linux/slab.h>
f1fa74f4
BH
26#include <linux/vmalloc.h>
27
28#include <asm/spu.h>
29#include <asm/spu_csa.h>
30#include <asm/mmu.h>
31
7cd58e43
JK
32#include "spufs.h"
33
f444f1f8 34int spu_alloc_lscsa(struct spu_state *csa)
f1fa74f4
BH
35{
36 struct spu_lscsa *lscsa;
37 unsigned char *p;
38
467d93a7 39 lscsa = vzalloc(sizeof(struct spu_lscsa));
f1fa74f4
BH
40 if (!lscsa)
41 return -ENOMEM;
f1fa74f4
BH
42 csa->lscsa = lscsa;
43
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));
47
48 return 0;
49}
50
f444f1f8 51void spu_free_lscsa(struct spu_state *csa)
f1fa74f4
BH
52{
53 /* Clear reserved bit before vfree. */
54 unsigned char *p;
55
56 if (csa->lscsa == NULL)
57 return;
58
59 for (p = csa->lscsa->ls; p < csa->lscsa->ls + LS_SIZE; p += PAGE_SIZE)
60 ClearPageReserved(vmalloc_to_page(p));
61
62 vfree(csa->lscsa);
63}