summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2018-06-18 09:34:34 -0400
committerMatthew Wilcox <willy@infradead.org>2018-08-21 23:54:19 -0400
commitcd38049e48f0d6ae151339b8882c3510a6ca6eb5 (patch)
tree6b92818f431ea6ff2a184f43821cb280ae0d21a5 /arch
parent5a2ab034396c063ceed167076424cf37d17cdc01 (diff)
downloadlinux-cd38049e48f0d6ae151339b8882c3510a6ca6eb5.tar.gz
linux-cd38049e48f0d6ae151339b8882c3510a6ca6eb5.tar.bz2
linux-cd38049e48f0d6ae151339b8882c3510a6ca6eb5.zip
ppc: Convert vas ID allocation to new IDA API
Removes a custom spinlock and simplifies the code. Also fix an error where we could allocate one ID too many. Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/platforms/powernv/vas-window.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c
index ff9f48812331..e59e0e60e5b5 100644
--- a/arch/powerpc/platforms/powernv/vas-window.c
+++ b/arch/powerpc/platforms/powernv/vas-window.c
@@ -515,35 +515,17 @@ int init_winctx_regs(struct vas_window *window, struct vas_winctx *winctx)
return 0;
}
-static DEFINE_SPINLOCK(vas_ida_lock);
-
static void vas_release_window_id(struct ida *ida, int winid)
{
- spin_lock(&vas_ida_lock);
- ida_remove(ida, winid);
- spin_unlock(&vas_ida_lock);
+ ida_free(ida, winid);
}
static int vas_assign_window_id(struct ida *ida)
{
- int rc, winid;
-
- do {
- rc = ida_pre_get(ida, GFP_KERNEL);
- if (!rc)
- return -EAGAIN;
-
- spin_lock(&vas_ida_lock);
- rc = ida_get_new(ida, &winid);
- spin_unlock(&vas_ida_lock);
- } while (rc == -EAGAIN);
-
- if (rc)
- return rc;
+ int winid = ida_alloc_max(ida, VAS_WINDOWS_PER_CHIP - 1, GFP_KERNEL);
- if (winid > VAS_WINDOWS_PER_CHIP) {
- pr_err("Too many (%d) open windows\n", winid);
- vas_release_window_id(ida, winid);
+ if (winid == -ENOSPC) {
+ pr_err("Too many (%d) open windows\n", VAS_WINDOWS_PER_CHIP);
return -EAGAIN;
}