mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
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>
This commit is contained in:
parent
5a2ab03439
commit
cd38049e48
1 changed files with 4 additions and 22 deletions
|
@ -515,35 +515,17 @@ int init_winctx_regs(struct vas_window *window, struct vas_winctx *winctx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEFINE_SPINLOCK(vas_ida_lock);
|
|
||||||
|
|
||||||
static void vas_release_window_id(struct ida *ida, int winid)
|
static void vas_release_window_id(struct ida *ida, int winid)
|
||||||
{
|
{
|
||||||
spin_lock(&vas_ida_lock);
|
ida_free(ida, winid);
|
||||||
ida_remove(ida, winid);
|
|
||||||
spin_unlock(&vas_ida_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vas_assign_window_id(struct ida *ida)
|
static int vas_assign_window_id(struct ida *ida)
|
||||||
{
|
{
|
||||||
int rc, winid;
|
int winid = ida_alloc_max(ida, VAS_WINDOWS_PER_CHIP - 1, GFP_KERNEL);
|
||||||
|
|
||||||
do {
|
if (winid == -ENOSPC) {
|
||||||
rc = ida_pre_get(ida, GFP_KERNEL);
|
pr_err("Too many (%d) open windows\n", VAS_WINDOWS_PER_CHIP);
|
||||||
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;
|
|
||||||
|
|
||||||
if (winid > VAS_WINDOWS_PER_CHIP) {
|
|
||||||
pr_err("Too many (%d) open windows\n", winid);
|
|
||||||
vas_release_window_id(ida, winid);
|
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue