Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * IBM Accelerator Family 'GenWQE'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * (C) Copyright IBM Corp. 2013
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Author: Frank Haverkamp <haver@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Author: Joerg-Stephan Vogt <jsvogt@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Author: Michael Jung <mijung@gmx.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Author: Michael Ruettger <michael@ibmra.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * Debugfs interfaces for the GenWQE card. Help to debug potential
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * problems. Dump internal chip state for debugging and failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * determination.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include "card_base.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include "card_ddcb.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static void dbg_uidn_show(struct seq_file *s, struct genwqe_reg *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 			  int entries)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	u32 v_hi, v_lo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	for (i = 0; i < entries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		v_hi = (regs[i].val >> 32) & 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		v_lo = (regs[i].val)       & 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		seq_printf(s, "  0x%08x 0x%08x 0x%08x 0x%08x EXT_ERR_REC\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			   regs[i].addr, regs[i].idx, v_hi, v_lo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static int curr_dbg_uidn_show(struct seq_file *s, void *unused, int uid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct genwqe_dev *cd = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	int entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	struct genwqe_reg *regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	entries = genwqe_ffdc_buff_size(cd, uid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	if (entries < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	if (entries == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	regs = kcalloc(entries, sizeof(*regs), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	if (regs == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	genwqe_stop_traps(cd); /* halt the traps while dumping data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	genwqe_ffdc_buff_read(cd, uid, regs, entries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	genwqe_start_traps(cd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	dbg_uidn_show(s, regs, entries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	kfree(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) static int curr_dbg_uid0_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	return curr_dbg_uidn_show(s, unused, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) DEFINE_SHOW_ATTRIBUTE(curr_dbg_uid0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) static int curr_dbg_uid1_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	return curr_dbg_uidn_show(s, unused, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) DEFINE_SHOW_ATTRIBUTE(curr_dbg_uid1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) static int curr_dbg_uid2_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return curr_dbg_uidn_show(s, unused, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) DEFINE_SHOW_ATTRIBUTE(curr_dbg_uid2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) static int prev_dbg_uidn_show(struct seq_file *s, void *unused, int uid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	struct genwqe_dev *cd = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	dbg_uidn_show(s, cd->ffdc[uid].regs,  cd->ffdc[uid].entries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static int prev_dbg_uid0_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	return prev_dbg_uidn_show(s, unused, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) DEFINE_SHOW_ATTRIBUTE(prev_dbg_uid0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static int prev_dbg_uid1_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	return prev_dbg_uidn_show(s, unused, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) DEFINE_SHOW_ATTRIBUTE(prev_dbg_uid1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static int prev_dbg_uid2_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	return prev_dbg_uidn_show(s, unused, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) DEFINE_SHOW_ATTRIBUTE(prev_dbg_uid2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static int curr_regs_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	struct genwqe_dev *cd = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	struct genwqe_reg *regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	regs = kcalloc(GENWQE_FFDC_REGS, sizeof(*regs), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (regs == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	genwqe_stop_traps(cd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	genwqe_read_ffdc_regs(cd, regs, GENWQE_FFDC_REGS, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	genwqe_start_traps(cd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	for (i = 0; i < GENWQE_FFDC_REGS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		if (regs[i].addr == 0xffffffff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 			break;  /* invalid entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		if (regs[i].val == 0x0ull)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			continue;  /* do not print 0x0 FIRs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		seq_printf(s, "  0x%08x 0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			   regs[i].addr, regs[i].val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) DEFINE_SHOW_ATTRIBUTE(curr_regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static int prev_regs_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	struct genwqe_dev *cd = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	struct genwqe_reg *regs = cd->ffdc[GENWQE_DBG_REGS].regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	if (regs == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	for (i = 0; i < GENWQE_FFDC_REGS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		if (regs[i].addr == 0xffffffff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 			break;  /* invalid entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		if (regs[i].val == 0x0ull)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 			continue;  /* do not print 0x0 FIRs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		seq_printf(s, "  0x%08x 0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			   regs[i].addr, regs[i].val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) DEFINE_SHOW_ATTRIBUTE(prev_regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static int jtimer_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	struct genwqe_dev *cd = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	unsigned int vf_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	u64 jtimer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	jtimer = genwqe_read_vreg(cd, IO_SLC_VF_APPJOB_TIMEOUT, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	seq_printf(s, "  PF   0x%016llx %d msec\n", jtimer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		   GENWQE_PF_JOBTIMEOUT_MSEC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	for (vf_num = 0; vf_num < cd->num_vfs; vf_num++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		jtimer = genwqe_read_vreg(cd, IO_SLC_VF_APPJOB_TIMEOUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 					  vf_num + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		seq_printf(s, "  VF%-2d 0x%016llx %d msec\n", vf_num, jtimer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			   cd->vf_jobtimeout_msec[vf_num]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) DEFINE_SHOW_ATTRIBUTE(jtimer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static int queue_working_time_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	struct genwqe_dev *cd = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	unsigned int vf_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	u64 t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	t = genwqe_read_vreg(cd, IO_SLC_VF_QUEUE_WTIME, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	seq_printf(s, "  PF   0x%016llx\n", t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	for (vf_num = 0; vf_num < cd->num_vfs; vf_num++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		t = genwqe_read_vreg(cd, IO_SLC_VF_QUEUE_WTIME, vf_num + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		seq_printf(s, "  VF%-2d 0x%016llx\n", vf_num, t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) DEFINE_SHOW_ATTRIBUTE(queue_working_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static int ddcb_info_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	struct genwqe_dev *cd = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	struct ddcb_queue *queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	struct ddcb *pddcb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	queue = &cd->queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	seq_puts(s, "DDCB QUEUE:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	seq_printf(s, "  ddcb_max:            %d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		   "  ddcb_daddr:          %016llx - %016llx\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		   "  ddcb_vaddr:          %p\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		   "  ddcbs_in_flight:     %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		   "  ddcbs_max_in_flight: %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		   "  ddcbs_completed:     %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		   "  return_on_busy:      %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		   "  wait_on_busy:        %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		   "  irqs_processed:      %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		   queue->ddcb_max, (long long)queue->ddcb_daddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		   (long long)queue->ddcb_daddr +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		   (queue->ddcb_max * DDCB_LENGTH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		   queue->ddcb_vaddr, queue->ddcbs_in_flight,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		   queue->ddcbs_max_in_flight, queue->ddcbs_completed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		   queue->return_on_busy, queue->wait_on_busy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		   cd->irqs_processed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	/* Hardware State */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	seq_printf(s, "  0x%08x 0x%016llx IO_QUEUE_CONFIG\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		   "  0x%08x 0x%016llx IO_QUEUE_STATUS\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		   "  0x%08x 0x%016llx IO_QUEUE_SEGMENT\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		   "  0x%08x 0x%016llx IO_QUEUE_INITSQN\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		   "  0x%08x 0x%016llx IO_QUEUE_WRAP\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		   "  0x%08x 0x%016llx IO_QUEUE_OFFSET\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		   "  0x%08x 0x%016llx IO_QUEUE_WTIME\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		   "  0x%08x 0x%016llx IO_QUEUE_ERRCNTS\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		   "  0x%08x 0x%016llx IO_QUEUE_LRW\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		   queue->IO_QUEUE_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		   __genwqe_readq(cd, queue->IO_QUEUE_CONFIG),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		   queue->IO_QUEUE_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		   __genwqe_readq(cd, queue->IO_QUEUE_STATUS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		   queue->IO_QUEUE_SEGMENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		   __genwqe_readq(cd, queue->IO_QUEUE_SEGMENT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		   queue->IO_QUEUE_INITSQN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		   __genwqe_readq(cd, queue->IO_QUEUE_INITSQN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		   queue->IO_QUEUE_WRAP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		   __genwqe_readq(cd, queue->IO_QUEUE_WRAP),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		   queue->IO_QUEUE_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		   __genwqe_readq(cd, queue->IO_QUEUE_OFFSET),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		   queue->IO_QUEUE_WTIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		   __genwqe_readq(cd, queue->IO_QUEUE_WTIME),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		   queue->IO_QUEUE_ERRCNTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		   __genwqe_readq(cd, queue->IO_QUEUE_ERRCNTS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		   queue->IO_QUEUE_LRW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		   __genwqe_readq(cd, queue->IO_QUEUE_LRW));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	seq_printf(s, "DDCB list (ddcb_act=%d/ddcb_next=%d):\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		   queue->ddcb_act, queue->ddcb_next);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	pddcb = queue->ddcb_vaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	for (i = 0; i < queue->ddcb_max; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		seq_printf(s, "  %-3d: RETC=%03x SEQ=%04x HSI/SHI=%02x/%02x ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 			   i, be16_to_cpu(pddcb->retc_16),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 			   be16_to_cpu(pddcb->seqnum_16),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			   pddcb->hsi, pddcb->shi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		seq_printf(s, "PRIV=%06llx CMD=%02x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			   be64_to_cpu(pddcb->priv_64), pddcb->cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		pddcb++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) DEFINE_SHOW_ATTRIBUTE(ddcb_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) static int info_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	struct genwqe_dev *cd = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	u64 app_id, slu_id, bitstream = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	struct pci_dev *pci_dev = cd->pci_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	slu_id = __genwqe_readq(cd, IO_SLU_UNITCFG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	app_id = __genwqe_readq(cd, IO_APP_UNITCFG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	if (genwqe_is_privileged(cd))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		bitstream = __genwqe_readq(cd, IO_SLU_BITSTREAM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	seq_printf(s, "%s driver version: %s\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		   "    Device Name/Type: %s %s CardIdx: %d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		   "    SLU/APP Config  : 0x%016llx/0x%016llx\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		   "    Build Date      : %u/%x/%u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		   "    Base Clock      : %u MHz\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		   "    Arch/SVN Release: %u/%llx\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		   "    Bitstream       : %llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		   GENWQE_DEVNAME, DRV_VERSION, dev_name(&pci_dev->dev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		   genwqe_is_privileged(cd) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		   "Physical" : "Virtual or no SR-IOV",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		   cd->card_idx, slu_id, app_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		   (u16)((slu_id >> 12) & 0x0fLLU),	   /* month */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		   (u16)((slu_id >>  4) & 0xffLLU),	   /* day */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		   (u16)((slu_id >> 16) & 0x0fLLU) + 2010, /* year */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 		   genwqe_base_clock_frequency(cd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		   (u16)((slu_id >> 32) & 0xffLLU), slu_id >> 40,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		   bitstream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) DEFINE_SHOW_ATTRIBUTE(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) void genwqe_init_debugfs(struct genwqe_dev *cd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	struct dentry *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	char card_name[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	char name[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	sprintf(card_name, "%s%d_card", GENWQE_DEVNAME, cd->card_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	root = debugfs_create_dir(card_name, cd->debugfs_genwqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	/* non privileged interfaces are done here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	debugfs_create_file("ddcb_info", S_IRUGO, root, cd, &ddcb_info_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	debugfs_create_file("info", S_IRUGO, root, cd, &info_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	debugfs_create_x64("err_inject", 0666, root, &cd->err_inject);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	debugfs_create_u32("ddcb_software_timeout", 0666, root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 			   &cd->ddcb_software_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	debugfs_create_u32("kill_timeout", 0666, root, &cd->kill_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	/* privileged interfaces follow here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	if (!genwqe_is_privileged(cd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		cd->debugfs_root = root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	debugfs_create_file("curr_regs", S_IRUGO, root, cd, &curr_regs_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	debugfs_create_file("curr_dbg_uid0", S_IRUGO, root, cd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 			    &curr_dbg_uid0_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	debugfs_create_file("curr_dbg_uid1", S_IRUGO, root, cd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 			    &curr_dbg_uid1_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	debugfs_create_file("curr_dbg_uid2", S_IRUGO, root, cd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 			    &curr_dbg_uid2_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	debugfs_create_file("prev_regs", S_IRUGO, root, cd, &prev_regs_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	debugfs_create_file("prev_dbg_uid0", S_IRUGO, root, cd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 			    &prev_dbg_uid0_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	debugfs_create_file("prev_dbg_uid1", S_IRUGO, root, cd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 			    &prev_dbg_uid1_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	debugfs_create_file("prev_dbg_uid2", S_IRUGO, root, cd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 			    &prev_dbg_uid2_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	for (i = 0; i <  GENWQE_MAX_VFS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		sprintf(name, "vf%u_jobtimeout_msec", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		debugfs_create_u32(name, 0666, root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 				   &cd->vf_jobtimeout_msec[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	debugfs_create_file("jobtimer", S_IRUGO, root, cd, &jtimer_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	debugfs_create_file("queue_working_time", S_IRUGO, root, cd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			    &queue_working_time_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	debugfs_create_u32("skip_recovery", 0666, root, &cd->skip_recovery);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	debugfs_create_u32("use_platform_recovery", 0666, root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 			   &cd->use_platform_recovery);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	cd->debugfs_root = root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) void genqwe_exit_debugfs(struct genwqe_dev *cd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	debugfs_remove_recursive(cd->debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }