Skip to contentSkip to conversation

powerpc/vas: Setup fault window per VAS instance

PATCH In review Haren Myneni 2 participants 2 messages Nov 27, 2019 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 5/14 powerpc/vas: Setup fault window per VAS instance

Setup fault window for each VAS instance. When NX gets fault on request buffer, write fault CRBs in the corresponding fault FIFO and then sends an interrupt to the OS.

---
 arch/powerpc/platforms/powernv/Makefile     |   2 +-
 arch/powerpc/platforms/powernv/vas-fault.c  | 105 ++++++++++++++++++++++++++++
 arch/powerpc/platforms/powernv/vas-window.c |  13 +++-
 arch/powerpc/platforms/powernv/vas.c        |  12 ++++
 arch/powerpc/platforms/powernv/vas.h        |   6 ++
 5 files changed, 134 insertions(+), 4 deletions(-)
 create mode 100644 arch/powerpc/platforms/powernv/vas-fault.c
arch/powerpc/platforms/powernv/Makefile +1 -1
index a3ac964..74c2246 100644
@@ -17,6 +17,6 @@ obj-$(CONFIG_MEMORY_FAILURE)	+= opal-memory-errors.o
 obj-$(CONFIG_OPAL_PRD)	+= opal-prd.o
 obj-$(CONFIG_PERF_EVENTS) += opal-imc.o
 obj-$(CONFIG_PPC_MEMTRACE)	+= memtrace.o
-obj-$(CONFIG_PPC_VAS)	+= vas.o vas-window.o vas-debug.o
+obj-$(CONFIG_PPC_VAS)	+= vas.o vas-window.o vas-debug.o vas-fault.o
 obj-$(CONFIG_OCXL_BASE)	+= ocxl.o
 obj-$(CONFIG_SCOM_DEBUGFS) += opal-xscom.o
arch/powerpc/platforms/powernv/vas-fault.c new file +105 -0

105 lines not on this page · raw message

arch/powerpc/platforms/powernv/vas-window.c +10 -3
index ad6be91..5f1faeb 100644
@@ -383,7 +383,7 @@ int init_winctx_regs(struct vas_window *window, struct vas_winctx *winctx)
 	init_xlate_regs(window, winctx->user_win);
 
 	val = 0ULL;
-	val = SET_FIELD(VAS_FAULT_TX_WIN, val, 0);
+	val = SET_FIELD(VAS_FAULT_TX_WIN, val, winctx->fault_win_id);
 	write_hvwc_reg(window, VREG(FAULT_TX_WIN), val);
 
 	/* In PowerNV, interrupts go to HV. */
@@ -839,9 +839,10 @@ void vas_init_rx_win_attr(struct vas_rx_win_attr *rxattr, enum vas_cop_type cop)
 		rxattr->fault_win = true;
 		rxattr->notify_disable = true;
 		rxattr->rx_wcred_mode = true;
-		rxattr->tx_wcred_mode = true;
 		rxattr->rx_win_ord_mode = true;
 		rxattr->tx_win_ord_mode = true;
+		rxattr->rej_no_credit = true;
+		rxattr->tc_mode = VAS_THRESH_DISABLED;
 	} else if (cop == VAS_COP_TYPE_FTW) {
 		rxattr->user_win = true;
 		rxattr->intr_disable = true;
@@ -956,6 +957,12 @@ static void init_winctx_for_txwin(struct vas_window *txwin,
 	winctx->lpid = txattr->lpid;
 	winctx->pidr = txattr->pidr;
 	winctx->rx_win_id = txwin->rxwin->winid;
+	/*
+	 * IRQ and fault window setup is successful. Set fault window
+	 * for the send window so that ready to handle faults.
+	 */
+	if (txwin->vinst->virq)
+		winctx->fault_win_id = txwin->vinst->fault_win->winid;
 
 	winctx->dma_type = VAS_DMA_TYPE_INJECT;
 	winctx->tc_mode = txattr->tc_mode;
@@ -964,7 +971,7 @@ static void init_winctx_for_txwin(struct vas_window *txwin,
 	if (txwin->vinst->virq)
 		winctx->irq_port = txwin->vinst->irq_port;
 
-	winctx->pswid = 0;
+	winctx->pswid = txattr->pswid ? txattr->pswid : vas_win_id(txwin);
 }
 
 static bool tx_win_args_valid(enum vas_cop_type cop,
arch/powerpc/platforms/powernv/vas.c +12 -0
index 71bddaa..dd0e06c 100644
@@ -45,6 +45,18 @@ static void vas_irq_fault_handle_setup(struct vas_instance *vinst)
 		pr_err("VAS[%d]: Request IRQ(%d) failed with %d\n",
 				vinst->vas_id, vinst->virq, rc);
 		vinst->virq = 0;
+		return;
+	}
+
+	/*
+	 * Fault window is used only for user space send windows.
+	 * So if vinst->virq is NULL, tx_win_open returns -ENODEV
+	 * for user space.
+	 */
+	rc = vas_setup_fault_window(vinst);
+	if (rc) {
+		free_irq(vinst->virq, vinst);
+		vinst->virq = 0;
 	}
 }
 
arch/powerpc/platforms/powernv/vas.h +6 -0
index bf7d3db..e23fd69 100644
@@ -315,6 +315,10 @@ struct vas_instance {
 
 	u64 irq_port;
 	int virq;
+	int fault_fifo_size;
+	void *fault_fifo;
+	struct vas_window *fault_win; /* Fault window */
+
 	struct mutex mutex;
 	struct vas_window *rxwin[VAS_COP_TYPE_MAX];
 	struct vas_window *windows[VAS_WINDOWS_PER_CHIP];
@@ -408,6 +412,8 @@ struct vas_winctx {
 extern void vas_instance_init_dbgdir(struct vas_instance *vinst);
 extern void vas_window_init_dbgdir(struct vas_window *win);
 extern void vas_window_free_dbgdir(struct vas_window *win);
+extern int vas_setup_fault_window(struct vas_instance *vinst);
+extern int vas_cleanup_fault_window(struct vas_instance *vinst);
 
 static inline void vas_log_write(struct vas_window *win, char *name,
 			void *regptr, u64 val)
Signature · 1 line
1.8.3.1
#1 lore raw

arch/powerpc/platforms/powernv/vas-fault.c line 79

Quoted 5 lines
arch/powerpc/platforms/powernv/vas-fault.c new file +5 -0
+/*
+ * We do not remove VAS instances. The following functions are needed
+ * when VAS hotplug is supported.
+ */
+#if 0

Please don't add dead code to the kernel tree.