Skip to content

Commit 6c8e6bb

Browse files
Sukadev Bhattiprolumpe
authored andcommitted
powerpc/vas: Add support for user receive window
Add support for user space receive window (for the Fast thread-wakeup coprocessor type) Signed-off-by: Sukadev Bhattiprolu <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 61f3cca commit 6c8e6bb

File tree

1 file changed

+49
-7
lines changed

1 file changed

+49
-7
lines changed

arch/powerpc/platforms/powernv/vas-window.c

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#include <linux/log2.h>
1717
#include <linux/rcupdate.h>
1818
#include <linux/cred.h>
19-
19+
#include <asm/switch_to.h>
20+
#include <asm/ppc-opcode.h>
2021
#include "vas.h"
2122
#include "copy-paste.h"
2223

@@ -597,6 +598,32 @@ static void put_rx_win(struct vas_window *rxwin)
597598
atomic_dec(&rxwin->num_txwins);
598599
}
599600

601+
/*
602+
* Find the user space receive window given the @pswid.
603+
* - We must have a valid vasid and it must belong to this instance.
604+
* (so both send and receive windows are on the same VAS instance)
605+
* - The window must refer to an OPEN, FTW, RECEIVE window.
606+
*
607+
* NOTE: We access ->windows[] table and assume that vinst->mutex is held.
608+
*/
609+
static struct vas_window *get_user_rxwin(struct vas_instance *vinst, u32 pswid)
610+
{
611+
int vasid, winid;
612+
struct vas_window *rxwin;
613+
614+
decode_pswid(pswid, &vasid, &winid);
615+
616+
if (vinst->vas_id != vasid)
617+
return ERR_PTR(-EINVAL);
618+
619+
rxwin = vinst->windows[winid];
620+
621+
if (!rxwin || rxwin->tx_win || rxwin->cop != VAS_COP_TYPE_FTW)
622+
return ERR_PTR(-EINVAL);
623+
624+
return rxwin;
625+
}
626+
600627
/*
601628
* Get the VAS receive window associated with NX engine identified
602629
* by @cop and if applicable, @pswid.
@@ -610,10 +637,10 @@ static struct vas_window *get_vinst_rxwin(struct vas_instance *vinst,
610637

611638
mutex_lock(&vinst->mutex);
612639

613-
if (cop == VAS_COP_TYPE_842 || cop == VAS_COP_TYPE_842_HIPRI)
614-
rxwin = vinst->rxwin[cop] ?: ERR_PTR(-EINVAL);
640+
if (cop == VAS_COP_TYPE_FTW)
641+
rxwin = get_user_rxwin(vinst, pswid);
615642
else
616-
rxwin = ERR_PTR(-EINVAL);
643+
rxwin = vinst->rxwin[cop] ?: ERR_PTR(-EINVAL);
617644

618645
if (!IS_ERR(rxwin))
619646
atomic_inc(&rxwin->num_txwins);
@@ -937,10 +964,9 @@ static void init_winctx_for_txwin(struct vas_window *txwin,
937964
winctx->tx_word_mode = txattr->tx_win_ord_mode;
938965
winctx->rsvd_txbuf_count = txattr->rsvd_txbuf_count;
939966

940-
if (winctx->nx_win) {
967+
winctx->intr_disable = true;
968+
if (winctx->nx_win)
941969
winctx->data_stamp = true;
942-
winctx->intr_disable = true;
943-
}
944970

945971
winctx->lpid = txattr->lpid;
946972
winctx->pidr = txattr->pidr;
@@ -985,6 +1011,14 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop,
9851011
if (!tx_win_args_valid(cop, attr))
9861012
return ERR_PTR(-EINVAL);
9871013

1014+
/*
1015+
* If caller did not specify a vasid but specified the PSWID of a
1016+
* receive window (applicable only to FTW windows), use the vasid
1017+
* from that receive window.
1018+
*/
1019+
if (vasid == -1 && attr->pswid)
1020+
decode_pswid(attr->pswid, &vasid, NULL);
1021+
9881022
vinst = find_vas_instance(vasid);
9891023
if (!vinst) {
9901024
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,
10311065
}
10321066
}
10331067

1068+
/*
1069+
* Now that we have a send window, ensure context switch issues
1070+
* CP_ABORT for this thread.
1071+
*/
1072+
rc = -EINVAL;
1073+
if (set_thread_uses_vas() < 0)
1074+
goto free_window;
1075+
10341076
set_vinst_win(vinst, txwin);
10351077

10361078
return txwin;

0 commit comments

Comments
 (0)