From: Matthew Wilcox <willy@infradead.org>
To: linux-kernel@vger.kernel.org
Cc: Matthew Wilcox <willy@infradead.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 15/26] ppc: Convert vas ID allocation to new IDA API
Date: Thu, 21 Jun 2018 14:28:24 -0700 [thread overview]
Message-ID: <20180621212835.5636-16-willy@infradead.org> (raw)
In-Reply-To: <20180621212835.5636-1-willy@infradead.org>
Removes a custom spinlock and simplifies the code.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
---
arch/powerpc/platforms/powernv/vas-window.c | 26 ++++-----------------
1 file 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..2a5e68a2664d 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, VAX_WINDOWS_PER_CHIP, 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", VAX_WINDOWS_PER_CHIP);
return -EAGAIN;
}
--
2.17.1
next prev parent reply other threads:[~2018-06-21 21:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180621212835.5636-1-willy@infradead.org>
2018-06-21 21:28 ` [PATCH 13/26] ppc: Convert mmu context allocation to new IDA API Matthew Wilcox
2018-06-22 2:15 ` Nicholas Piggin
2018-06-22 4:38 ` Matthew Wilcox
2018-06-22 4:53 ` Nicholas Piggin
2018-06-22 5:47 ` Aneesh Kumar K.V
2018-06-22 5:47 ` Aneesh Kumar K.V
2018-06-21 21:28 ` Matthew Wilcox [this message]
2018-07-05 12:17 ` [PATCH 15/26] ppc: Convert vas ID " Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180621212835.5636-16-willy@infradead.org \
--to=willy@infradead.org \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).