diff options
| author | Matthew Wilcox <willy@infradead.org> | 2018-06-18 09:34:34 -0400 |
|---|---|---|
| committer | Matthew Wilcox <willy@infradead.org> | 2018-08-21 23:54:19 -0400 |
| commit | cd38049e48f0d6ae151339b8882c3510a6ca6eb5 (patch) | |
| tree | 6b92818f431ea6ff2a184f43821cb280ae0d21a5 | |
| parent | 5a2ab034396c063ceed167076424cf37d17cdc01 (diff) | |
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>
| -rw-r--r-- | arch/powerpc/platforms/powernv/vas-window.c | 26 |
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) | |||
| 515 | return 0; | 515 | return 0; |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | static DEFINE_SPINLOCK(vas_ida_lock); | ||
| 519 | |||
| 520 | static void vas_release_window_id(struct ida *ida, int winid) | 518 | static void vas_release_window_id(struct ida *ida, int winid) |
| 521 | { | 519 | { |
| 522 | spin_lock(&vas_ida_lock); | 520 | ida_free(ida, winid); |
| 523 | ida_remove(ida, winid); | ||
| 524 | spin_unlock(&vas_ida_lock); | ||
| 525 | } | 521 | } |
| 526 | 522 | ||
| 527 | static int vas_assign_window_id(struct ida *ida) | 523 | static int vas_assign_window_id(struct ida *ida) |
| 528 | { | 524 | { |
| 529 | int rc, winid; | 525 | int winid = ida_alloc_max(ida, VAS_WINDOWS_PER_CHIP - 1, GFP_KERNEL); |
| 530 | |||
| 531 | do { | ||
| 532 | rc = ida_pre_get(ida, GFP_KERNEL); | ||
| 533 | if (!rc) | ||
| 534 | return -EAGAIN; | ||
| 535 | |||
| 536 | spin_lock(&vas_ida_lock); | ||
| 537 | rc = ida_get_new(ida, &winid); | ||
| 538 | spin_unlock(&vas_ida_lock); | ||
| 539 | } while (rc == -EAGAIN); | ||
| 540 | |||
| 541 | if (rc) | ||
| 542 | return rc; | ||
| 543 | 526 | ||
| 544 | if (winid > VAS_WINDOWS_PER_CHIP) { | 527 | if (winid == -ENOSPC) { |
| 545 | pr_err("Too many (%d) open windows\n", winid); | 528 | pr_err("Too many (%d) open windows\n", VAS_WINDOWS_PER_CHIP); |
| 546 | vas_release_window_id(ida, winid); | ||
| 547 | return -EAGAIN; | 529 | return -EAGAIN; |
| 548 | } | 530 | } |
| 549 | 531 | ||
