From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
mikey@neuling.org, hbabu@us.ibm.com, nicholas.piggin@gmail.com,
linuxppc-dev@ozlabs.org, <linux-kernel@vger.kernel.org>
Subject: [PATCH v3 18/18] powerpc/vas: Add support for user receive window
Date: Tue, 7 Nov 2017 18:23:58 -0800 [thread overview]
Message-ID: <1510107838-15181-19-git-send-email-sukadev@linux.vnet.ibm.com> (raw)
In-Reply-To: <1510107838-15181-1-git-send-email-sukadev@linux.vnet.ibm.com>
Add support for user space receive window (for the Fast thread-wakeup
coprocessor type)
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
Changelog[v3]
- [Nick Piggin] Drop CP_ABORT since set_thread_uses_vas() does
that now (in earlier patch) and add a check for return value.
---
arch/powerpc/platforms/powernv/vas-window.c | 56 +++++++++++++++++++++++++----
1 file changed, 49 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c
index 8275492..2b3eb01 100644
--- a/arch/powerpc/platforms/powernv/vas-window.c
+++ b/arch/powerpc/platforms/powernv/vas-window.c
@@ -16,7 +16,8 @@
#include <linux/log2.h>
#include <linux/rcupdate.h>
#include <linux/cred.h>
-
+#include <asm/switch_to.h>
+#include <asm/ppc-opcode.h>
#include "vas.h"
#include "copy-paste.h"
@@ -598,6 +599,32 @@ static void put_rx_win(struct vas_window *rxwin)
}
/*
+ * Find the user space receive window given the @pswid.
+ * - We must have a valid vasid and it must belong to this instance.
+ * (so both send and receive windows are on the same VAS instance)
+ * - The window must refer to an OPEN, FTW, RECEIVE window.
+ *
+ * NOTE: We access ->windows[] table and assume that vinst->mutex is held.
+ */
+static struct vas_window *get_user_rxwin(struct vas_instance *vinst, u32 pswid)
+{
+ int vasid, winid;
+ struct vas_window *rxwin;
+
+ decode_pswid(pswid, &vasid, &winid);
+
+ if (vinst->vas_id != vasid)
+ return ERR_PTR(-EINVAL);
+
+ rxwin = vinst->windows[winid];
+
+ if (!rxwin || rxwin->tx_win || rxwin->cop != VAS_COP_TYPE_FTW)
+ return ERR_PTR(-EINVAL);
+
+ return rxwin;
+}
+
+/*
* Get the VAS receive window associated with NX engine identified
* by @cop and if applicable, @pswid.
*
@@ -610,10 +637,10 @@ static struct vas_window *get_vinst_rxwin(struct vas_instance *vinst,
mutex_lock(&vinst->mutex);
- if (cop == VAS_COP_TYPE_842 || cop == VAS_COP_TYPE_842_HIPRI)
- rxwin = vinst->rxwin[cop] ?: ERR_PTR(-EINVAL);
+ if (cop == VAS_COP_TYPE_FTW)
+ rxwin = get_user_rxwin(vinst, pswid);
else
- rxwin = ERR_PTR(-EINVAL);
+ rxwin = vinst->rxwin[cop] ?: ERR_PTR(-EINVAL);
if (!IS_ERR(rxwin))
atomic_inc(&rxwin->num_txwins);
@@ -937,10 +964,9 @@ static void init_winctx_for_txwin(struct vas_window *txwin,
winctx->tx_word_mode = txattr->tx_win_ord_mode;
winctx->rsvd_txbuf_count = txattr->rsvd_txbuf_count;
- if (winctx->nx_win) {
+ winctx->intr_disable = true;
+ if (winctx->nx_win)
winctx->data_stamp = true;
- winctx->intr_disable = true;
- }
winctx->lpid = txattr->lpid;
winctx->pidr = txattr->pidr;
@@ -985,6 +1011,14 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop,
if (!tx_win_args_valid(cop, attr))
return ERR_PTR(-EINVAL);
+ /*
+ * If caller did not specify a vasid but specified the PSWID of a
+ * receive window (applicable only to FTW windows), use the vasid
+ * from that receive window.
+ */
+ if (vasid == -1 && attr->pswid)
+ decode_pswid(attr->pswid, &vasid, NULL);
+
vinst = find_vas_instance(vasid);
if (!vinst) {
pr_devel("vasid %d not found!\n", vasid);
@@ -1031,6 +1065,14 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop,
}
}
+ /*
+ * Now that we have a send window, ensure context switch issues
+ * CP_ABORT for this thread.
+ */
+ rc = -EINVAL;
+ if (set_thread_uses_vas() < 0)
+ goto free_window;
+
set_vinst_win(vinst, txwin);
return txwin;
--
2.7.4
prev parent reply other threads:[~2017-11-08 2:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-08 2:23 [PATCH v3 00/18] powerpc/vas: Add support for FTW Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 01/18] powerpc/vas: init missing fields from [rt]xattr Sukadev Bhattiprolu
2017-11-14 11:12 ` [v3,01/18] " Michael Ellerman
2017-11-08 2:23 ` [PATCH v3 02/18] powerpc/vas: Validate window credits Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 03/18] powerpc/vas: Cleanup some debug code Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 04/18] powerpc/vas: Drop poll_window_cast_out() Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 05/18] powerpc/vas: Use helper to unpin/close window Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 06/18] powerpc/vas: Reduce polling interval for busy state Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 07/18] powerpc/vas: Save configured window credits Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 08/18] powerpc/vas: poll for return of " Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 09/18] powerpc/vas: Create cpu to vas id mapping Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 10/18] powerpc/vas, nx-842: Define and use chip_to_vas_id() Sukadev Bhattiprolu
2017-11-20 17:57 ` Josh Boyer
2017-11-22 11:56 ` Michael Ellerman
2017-11-08 2:23 ` [PATCH v3 11/18] powerpc/vas: Export HVWC to debugfs Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 12/18] powerpc: have copy depend on CONFIG_BOOK3S_64 Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 13/18] powerpc: Add support for setting SPRN_TIDR Sukadev Bhattiprolu
2017-11-09 11:53 ` Michael Ellerman
2017-11-08 2:23 ` [PATCH v3 14/18] powerpc: Define set_thread_uses_vas() Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 15/18] powerpc: Emulate paste instruction Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 16/18] powerpc/vas: Define vas_win_paste_addr() Sukadev Bhattiprolu
2017-11-08 2:23 ` [PATCH v3 17/18] powerpc/vas: Define vas_win_id() Sukadev Bhattiprolu
2017-11-08 2:23 ` Sukadev Bhattiprolu [this message]
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=1510107838-15181-19-git-send-email-sukadev@linux.vnet.ibm.com \
--to=sukadev@linux.vnet.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=hbabu@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mikey@neuling.org \
--cc=mpe@ellerman.id.au \
--cc=nicholas.piggin@gmail.com \
/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).