[POWERPC] Remove get_property and device_is_compatible
[linux-2.6-block.git] / arch / powerpc / mm / mmu_context_64.c
CommitLineData
14cf11af
PM
1/*
2 * MMU context allocation for 64-bit kernels.
3 *
4 * Copyright (C) 2004 Anton Blanchard, IBM Corp. <anton@samba.org>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
14cf11af
PM
13#include <linux/sched.h>
14#include <linux/kernel.h>
15#include <linux/errno.h>
16#include <linux/string.h>
17#include <linux/types.h>
18#include <linux/mm.h>
19#include <linux/spinlock.h>
20#include <linux/idr.h>
21
22#include <asm/mmu_context.h>
23
24static DEFINE_SPINLOCK(mmu_context_lock);
25static DEFINE_IDR(mmu_context_idr);
26
27int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
28{
29 int index;
30 int err;
31
32again:
33 if (!idr_pre_get(&mmu_context_idr, GFP_KERNEL))
34 return -ENOMEM;
35
36 spin_lock(&mmu_context_lock);
37 err = idr_get_new_above(&mmu_context_idr, NULL, 1, &index);
38 spin_unlock(&mmu_context_lock);
39
40 if (err == -EAGAIN)
41 goto again;
42 else if (err)
43 return err;
44
45 if (index > MAX_CONTEXT) {
f86c9747 46 spin_lock(&mmu_context_lock);
14cf11af 47 idr_remove(&mmu_context_idr, index);
f86c9747 48 spin_unlock(&mmu_context_lock);
14cf11af
PM
49 return -ENOMEM;
50 }
51
d0f13e3c
BH
52#ifdef CONFIG_PPC_MM_SLICES
53 /* The old code would re-promote on fork, we don't do that
54 * when using slices as it could cause problem promoting slices
55 * that have been forced down to 4K
56 */
9dfe5c53 57 if (mm->context.id == 0)
d0f13e3c
BH
58 slice_set_user_psize(mm, mmu_virtual_psize);
59#else
bf72aeba
PM
60 mm->context.user_psize = mmu_virtual_psize;
61 mm->context.sllp = SLB_VSID_USER |
62 mmu_psize_defs[mmu_virtual_psize].sllp;
d0f13e3c 63#endif
9dfe5c53 64 mm->context.id = index;
14cf11af
PM
65
66 return 0;
67}
68
69void destroy_context(struct mm_struct *mm)
70{
71 spin_lock(&mmu_context_lock);
72 idr_remove(&mmu_context_idr, mm->context.id);
73 spin_unlock(&mmu_context_lock);
74
75 mm->context.id = NO_CONTEXT;
76}