summaryrefslogtreecommitdiff
path: root/arch/powerpc/mm/mmu_context_book3s64.c
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2017-03-29 14:10:45 +0300
committerMichael Ellerman <mpe@ellerman.id.au>2017-03-31 15:09:58 +0300
commitc1ff840d21208aff8cea18c0ae052c536d74f53e (patch)
tree9dc711039f36e5ec0304ed48176d41ab89265b44 /arch/powerpc/mm/mmu_context_book3s64.c
parenta336f2f5b05c3c02876a365b8f17b3d10920dbd5 (diff)
downloadlinux-c1ff840d21208aff8cea18c0ae052c536d74f53e.tar.xz
powerpc/mm/hash: Pull hash constants into hash__alloc_context_id()
The min and max context id values used in alloc_context_id() are currently the right values for use on hash, and happen to also be safe for use on radix. But we need to change that in a subsequent patch, so make the min/max ids parameters and pull the hash values into hsah__alloc_context_id(). Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/mm/mmu_context_book3s64.c')
-rw-r--r--arch/powerpc/mm/mmu_context_book3s64.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/arch/powerpc/mm/mmu_context_book3s64.c b/arch/powerpc/mm/mmu_context_book3s64.c
index 650a498b1de9..981c3b02e46a 100644
--- a/arch/powerpc/mm/mmu_context_book3s64.c
+++ b/arch/powerpc/mm/mmu_context_book3s64.c
@@ -30,17 +30,16 @@
static DEFINE_SPINLOCK(mmu_context_lock);
static DEFINE_IDA(mmu_context_ida);
-static int __init_new_context(void)
+static int alloc_context_id(int min_id, int max_id)
{
- int index;
- int err;
+ int index, err;
again:
if (!ida_pre_get(&mmu_context_ida, GFP_KERNEL))
return -ENOMEM;
spin_lock(&mmu_context_lock);
- err = ida_get_new_above(&mmu_context_ida, 1, &index);
+ err = ida_get_new_above(&mmu_context_ida, min_id, &index);
spin_unlock(&mmu_context_lock);
if (err == -EAGAIN)
@@ -48,7 +47,7 @@ again:
else if (err)
return err;
- if (index > MAX_USER_CONTEXT) {
+ if (index > max_id) {
spin_lock(&mmu_context_lock);
ida_remove(&mmu_context_ida, index);
spin_unlock(&mmu_context_lock);
@@ -60,7 +59,7 @@ again:
int hash__alloc_context_id(void)
{
- return __init_new_context();
+ return alloc_context_id(1, MAX_USER_CONTEXT);
}
EXPORT_SYMBOL_GPL(hash__alloc_context_id);
@@ -80,7 +79,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
{
int index;
- index = __init_new_context();
+ index = hash__alloc_context_id();
if (index < 0)
return index;