[RFC,08/13] powerpc/vas: Print CRB and FIFO values
diff mbox series

Message ID 1571464701.24387.34.camel@hbabu-laptop
State New
Headers show
Series
  • powerpc/vas: Page fault handling for user space NX requests
Related show

Commit Message

Haren Myneni Oct. 19, 2019, 5:58 a.m. UTC
Dump FIFO values if could not find send window and print CRB for
debugging.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Haren Myneni <haren@us.ibm.com>
---
 arch/powerpc/platforms/powernv/vas-fault.c | 40 ++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

Patch
diff mbox series

diff --git a/arch/powerpc/platforms/powernv/vas-fault.c b/arch/powerpc/platforms/powernv/vas-fault.c
index 7aacce9..1ce85b5 100644
--- a/arch/powerpc/platforms/powernv/vas-fault.c
+++ b/arch/powerpc/platforms/powernv/vas-fault.c
@@ -39,6 +39,27 @@  void vas_wakeup_fault_handler(int virq, void *arg)
 	wake_up(&vinst->fault_wq);
 }
 
+static void dump_crb(struct coprocessor_request_block *crb)
+{
+	struct data_descriptor_entry *dde;
+	struct nx_fault_stamp *nx;
+
+	dde = &crb->source;
+	pr_devel("SrcDDE: addr 0x%llx, len %d, count %d, idx %d, flags %d\n",
+		be64_to_cpu(dde->address), be32_to_cpu(dde->length),
+		dde->count, dde->index, dde->flags);
+
+	dde = &crb->target;
+	pr_devel("TgtDDE: addr 0x%llx, len %d, count %d, idx %d, flags %d\n",
+		be64_to_cpu(dde->address), be32_to_cpu(dde->length),
+		dde->count, dde->index, dde->flags);
+
+	nx = &crb->stamp.nx;
+	pr_devel("NX Stamp: PSWID 0x%x, FSA 0x%llx, flags 0x%x, FS 0x%x\n",
+		be32_to_cpu(nx->pswid), crb_nx_fault_addr(crb),
+		nx->flags, be32_to_cpu(nx->fault_status));
+}
+
 /*
  * Check if the fault occurred in the CSB itself. Return true if so, false
  */
@@ -153,6 +174,23 @@  static void update_csb(int pid, struct coprocessor_request_block *crb)
 	notify_process(pid, crb_nx_fault_addr(crb));
 }
 
+static void dump_fifo(struct vas_instance *vinst)
+{
+	int i;
+	unsigned long *fifo = vinst->fault_fifo;
+
+	pr_err("Fault fifo size %d, max crbs %d, crb size %lu\n",
+			vinst->fault_fifo_size,
+			vinst->fault_fifo_size / CRB_SIZE,
+			sizeof(struct coprocessor_request_block));
+
+	pr_err("Fault FIFO Dump:\n");
+	for (i = 0; i < 64; i+=4, fifo+=4) {
+		pr_err("[%.3d, %p]: 0x%.16lx 0x%.16lx 0x%.16lx 0x%.16lx\n",
+			i, fifo, *fifo, *(fifo+1), *(fifo+2), *(fifo+3));
+	}
+}
+
 /*
  * Process CRBs that we receive on the fault window.
  */
@@ -210,6 +248,7 @@  static void process_fault_crbs(struct vas_instance *vinst)
 				vinst->fault_fifo, fifo, vinst->fault_crbs,
 				atomic_read(&vinst->pending_fault));
 
+		dump_crb(crb);
 		window = vas_pswid_to_window(vinst, crb_nx_pswid(crb));
 
 		if (IS_ERR(window)) {
@@ -219,6 +258,7 @@  static void process_fault_crbs(struct vas_instance *vinst)
 			 * even clean it up (return credit).
 			 * But we should not get here.
 			 */
+			dump_fifo(vinst);
 			pr_err("VAS[%d] fault_fifo %p, fifo %p, pswid 0x%x, "
 				"fault_crbs %d, pending %d bad CRB?\n",
 				vinst->vas_id,