1c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp/** 2c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * IBM Accelerator Family 'GenWQE' 3c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * 4c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * (C) Copyright IBM Corp. 2013 5c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * 6c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * Author: Frank Haverkamp <haver@linux.vnet.ibm.com> 7c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * Author: Joerg-Stephan Vogt <jsvogt@de.ibm.com> 826d8f6f15112b8b0fbff360c360e8c42bf2bc370Frank Haverkamp * Author: Michael Jung <mijung@gmx.net> 9c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * Author: Michael Ruettger <michael@ibmra.de> 10c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * 11c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * This program is free software; you can redistribute it and/or modify 12c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * it under the terms of the GNU General Public License (version 2 only) 13c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * as published by the Free Software Foundation. 14c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * 15c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * This program is distributed in the hope that it will be useful, 16c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * but WITHOUT ANY WARRANTY; without even the implied warranty of 17c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * GNU General Public License for more details. 19c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp */ 20c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 21c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp/* 22c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * Debugfs interfaces for the GenWQE card. Help to debug potential 23c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * problems. Dump internal chip state for debugging and failure 24c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp * determination. 25c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp */ 26c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 27c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp#include <linux/module.h> 28c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp#include <linux/kernel.h> 29c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp#include <linux/debugfs.h> 30c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp#include <linux/seq_file.h> 31c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp#include <linux/uaccess.h> 32c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 33c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp#include "card_base.h" 34c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp#include "card_ddcb.h" 35c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 36c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp#define GENWQE_DEBUGFS_RO(_name, _showfn) \ 37c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp static int genwqe_debugfs_##_name##_open(struct inode *inode, \ 38c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct file *file) \ 39c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp { \ 40c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return single_open(file, _showfn, inode->i_private); \ 41c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } \ 42c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp static const struct file_operations genwqe_##_name##_fops = { \ 43c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp .open = genwqe_debugfs_##_name##_open, \ 44c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp .read = seq_read, \ 45c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp .llseek = seq_lseek, \ 46c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp .release = single_release, \ 47c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 48c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 49c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic void dbg_uidn_show(struct seq_file *s, struct genwqe_reg *regs, 50c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp int entries) 51c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 52c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp unsigned int i; 53c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp u32 v_hi, v_lo; 54c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 55c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp for (i = 0; i < entries; i++) { 56c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp v_hi = (regs[i].val >> 32) & 0xffffffff; 57c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp v_lo = (regs[i].val) & 0xffffffff; 58c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 59c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, " 0x%08x 0x%08x 0x%08x 0x%08x EXT_ERR_REC\n", 60c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp regs[i].addr, regs[i].idx, v_hi, v_lo); 61c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 62c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 63c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 64c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int curr_dbg_uidn_show(struct seq_file *s, void *unused, int uid) 65c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 66c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct genwqe_dev *cd = s->private; 67c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp int entries; 68c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct genwqe_reg *regs; 69c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 70c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp entries = genwqe_ffdc_buff_size(cd, uid); 71c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (entries < 0) 72c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return -EINVAL; 73c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 74c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (entries == 0) 75c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return 0; 76c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 77c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp regs = kcalloc(entries, sizeof(*regs), GFP_KERNEL); 78c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (regs == NULL) 79c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return -ENOMEM; 80c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 81c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp genwqe_stop_traps(cd); /* halt the traps while dumping data */ 82c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp genwqe_ffdc_buff_read(cd, uid, regs, entries); 83c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp genwqe_start_traps(cd); 84c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 85c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp dbg_uidn_show(s, regs, entries); 86c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp kfree(regs); 87c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return 0; 88c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 89c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 90c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_curr_dbg_uid0_show(struct seq_file *s, void *unused) 91c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 92c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return curr_dbg_uidn_show(s, unused, 0); 93c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 94c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 95c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(curr_dbg_uid0, genwqe_curr_dbg_uid0_show); 96c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 97c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_curr_dbg_uid1_show(struct seq_file *s, void *unused) 98c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 99c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return curr_dbg_uidn_show(s, unused, 1); 100c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 101c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 102c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(curr_dbg_uid1, genwqe_curr_dbg_uid1_show); 103c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 104c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_curr_dbg_uid2_show(struct seq_file *s, void *unused) 105c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 106c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return curr_dbg_uidn_show(s, unused, 2); 107c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 108c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 109c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(curr_dbg_uid2, genwqe_curr_dbg_uid2_show); 110c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 111c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int prev_dbg_uidn_show(struct seq_file *s, void *unused, int uid) 112c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 113c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct genwqe_dev *cd = s->private; 114c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 115c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp dbg_uidn_show(s, cd->ffdc[uid].regs, cd->ffdc[uid].entries); 116c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return 0; 117c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 118c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 119c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_prev_dbg_uid0_show(struct seq_file *s, void *unused) 120c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 121c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return prev_dbg_uidn_show(s, unused, 0); 122c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 123c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 124c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(prev_dbg_uid0, genwqe_prev_dbg_uid0_show); 125c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 126c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_prev_dbg_uid1_show(struct seq_file *s, void *unused) 127c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 128c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return prev_dbg_uidn_show(s, unused, 1); 129c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 130c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 131c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(prev_dbg_uid1, genwqe_prev_dbg_uid1_show); 132c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 133c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_prev_dbg_uid2_show(struct seq_file *s, void *unused) 134c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 135c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return prev_dbg_uidn_show(s, unused, 2); 136c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 137c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 138c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(prev_dbg_uid2, genwqe_prev_dbg_uid2_show); 139c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 140c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_curr_regs_show(struct seq_file *s, void *unused) 141c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 142c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct genwqe_dev *cd = s->private; 143c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp unsigned int i; 144c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct genwqe_reg *regs; 145c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 146c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp regs = kcalloc(GENWQE_FFDC_REGS, sizeof(*regs), GFP_KERNEL); 147c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (regs == NULL) 148c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return -ENOMEM; 149c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 150c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp genwqe_stop_traps(cd); 151c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp genwqe_read_ffdc_regs(cd, regs, GENWQE_FFDC_REGS, 1); 152c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp genwqe_start_traps(cd); 153c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 154c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp for (i = 0; i < GENWQE_FFDC_REGS; i++) { 155c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (regs[i].addr == 0xffffffff) 156c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp break; /* invalid entries */ 157c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 158c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (regs[i].val == 0x0ull) 159c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp continue; /* do not print 0x0 FIRs */ 160c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 161c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, " 0x%08x 0x%016llx\n", 162c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp regs[i].addr, regs[i].val); 163c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 164c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return 0; 165c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 166c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 167c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(curr_regs, genwqe_curr_regs_show); 168c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 169c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_prev_regs_show(struct seq_file *s, void *unused) 170c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 171c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct genwqe_dev *cd = s->private; 172c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp unsigned int i; 173c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct genwqe_reg *regs = cd->ffdc[GENWQE_DBG_REGS].regs; 174c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 175c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (regs == NULL) 176c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return -EINVAL; 177c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 178c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp for (i = 0; i < GENWQE_FFDC_REGS; i++) { 179c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (regs[i].addr == 0xffffffff) 180c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp break; /* invalid entries */ 181c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 182c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (regs[i].val == 0x0ull) 183c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp continue; /* do not print 0x0 FIRs */ 184c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 185c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, " 0x%08x 0x%016llx\n", 186c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp regs[i].addr, regs[i].val); 187c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 188c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return 0; 189c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 190c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 191c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(prev_regs, genwqe_prev_regs_show); 192c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 193c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_jtimer_show(struct seq_file *s, void *unused) 194c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 195c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct genwqe_dev *cd = s->private; 196c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp unsigned int vf_num; 197c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp u64 jtimer; 198c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 199c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp jtimer = genwqe_read_vreg(cd, IO_SLC_VF_APPJOB_TIMEOUT, 0); 200c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, " PF 0x%016llx %d msec\n", jtimer, 201c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp genwqe_pf_jobtimeout_msec); 202c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 203c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp for (vf_num = 0; vf_num < cd->num_vfs; vf_num++) { 204c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp jtimer = genwqe_read_vreg(cd, IO_SLC_VF_APPJOB_TIMEOUT, 205c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp vf_num + 1); 206c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, " VF%-2d 0x%016llx %d msec\n", vf_num, jtimer, 207c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp cd->vf_jobtimeout_msec[vf_num]); 208c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 209c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return 0; 210c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 211c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 212c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(jtimer, genwqe_jtimer_show); 213c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 214c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_queue_working_time_show(struct seq_file *s, void *unused) 215c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 216c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct genwqe_dev *cd = s->private; 217c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp unsigned int vf_num; 218c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp u64 t; 219c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 220c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp t = genwqe_read_vreg(cd, IO_SLC_VF_QUEUE_WTIME, 0); 221c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, " PF 0x%016llx\n", t); 222c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 223c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp for (vf_num = 0; vf_num < cd->num_vfs; vf_num++) { 224c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp t = genwqe_read_vreg(cd, IO_SLC_VF_QUEUE_WTIME, vf_num + 1); 225c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, " VF%-2d 0x%016llx\n", vf_num, t); 226c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 227c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return 0; 228c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 229c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 230c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(queue_working_time, genwqe_queue_working_time_show); 231c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 232c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_ddcb_info_show(struct seq_file *s, void *unused) 233c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 234c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct genwqe_dev *cd = s->private; 235c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp unsigned int i; 236c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct ddcb_queue *queue; 237c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct ddcb *pddcb; 238c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 239c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue = &cd->queue; 240c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_puts(s, "DDCB QUEUE:\n"); 241c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, " ddcb_max: %d\n" 242c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " ddcb_daddr: %016llx - %016llx\n" 243c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " ddcb_vaddr: %016llx\n" 244c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " ddcbs_in_flight: %u\n" 245c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " ddcbs_max_in_flight: %u\n" 246c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " ddcbs_completed: %u\n" 2471451f414639465995dfc1f820aa1a64723cbd662Frank Haverkamp " return_on_busy: %u\n" 2481451f414639465995dfc1f820aa1a64723cbd662Frank Haverkamp " wait_on_busy: %u\n" 249c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " irqs_processed: %u\n", 250c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->ddcb_max, (long long)queue->ddcb_daddr, 251c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp (long long)queue->ddcb_daddr + 252c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp (queue->ddcb_max * DDCB_LENGTH), 253c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp (long long)queue->ddcb_vaddr, queue->ddcbs_in_flight, 254c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->ddcbs_max_in_flight, queue->ddcbs_completed, 2551451f414639465995dfc1f820aa1a64723cbd662Frank Haverkamp queue->return_on_busy, queue->wait_on_busy, 2561451f414639465995dfc1f820aa1a64723cbd662Frank Haverkamp cd->irqs_processed); 257c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 258c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp /* Hardware State */ 259c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, " 0x%08x 0x%016llx IO_QUEUE_CONFIG\n" 260c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " 0x%08x 0x%016llx IO_QUEUE_STATUS\n" 261c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " 0x%08x 0x%016llx IO_QUEUE_SEGMENT\n" 262c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " 0x%08x 0x%016llx IO_QUEUE_INITSQN\n" 263c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " 0x%08x 0x%016llx IO_QUEUE_WRAP\n" 264c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " 0x%08x 0x%016llx IO_QUEUE_OFFSET\n" 265c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " 0x%08x 0x%016llx IO_QUEUE_WTIME\n" 266c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " 0x%08x 0x%016llx IO_QUEUE_ERRCNTS\n" 267c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " 0x%08x 0x%016llx IO_QUEUE_LRW\n", 268c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->IO_QUEUE_CONFIG, 269c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp __genwqe_readq(cd, queue->IO_QUEUE_CONFIG), 270c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->IO_QUEUE_STATUS, 271c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp __genwqe_readq(cd, queue->IO_QUEUE_STATUS), 272c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->IO_QUEUE_SEGMENT, 273c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp __genwqe_readq(cd, queue->IO_QUEUE_SEGMENT), 274c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->IO_QUEUE_INITSQN, 275c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp __genwqe_readq(cd, queue->IO_QUEUE_INITSQN), 276c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->IO_QUEUE_WRAP, 277c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp __genwqe_readq(cd, queue->IO_QUEUE_WRAP), 278c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->IO_QUEUE_OFFSET, 279c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp __genwqe_readq(cd, queue->IO_QUEUE_OFFSET), 280c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->IO_QUEUE_WTIME, 281c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp __genwqe_readq(cd, queue->IO_QUEUE_WTIME), 282c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->IO_QUEUE_ERRCNTS, 283c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp __genwqe_readq(cd, queue->IO_QUEUE_ERRCNTS), 284c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->IO_QUEUE_LRW, 285c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp __genwqe_readq(cd, queue->IO_QUEUE_LRW)); 286c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 287c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, "DDCB list (ddcb_act=%d/ddcb_next=%d):\n", 288c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp queue->ddcb_act, queue->ddcb_next); 289c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 290c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp pddcb = queue->ddcb_vaddr; 291c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp for (i = 0; i < queue->ddcb_max; i++) { 292c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, " %-3d: RETC=%03x SEQ=%04x HSI/SHI=%02x/%02x ", 293c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp i, be16_to_cpu(pddcb->retc_16), 294c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp be16_to_cpu(pddcb->seqnum_16), 295c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp pddcb->hsi, pddcb->shi); 296c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, "PRIV=%06llx CMD=%02x\n", 297c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp be64_to_cpu(pddcb->priv_64), pddcb->cmd); 298c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp pddcb++; 299c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 300c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return 0; 301c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 302c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 303c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(ddcb_info, genwqe_ddcb_info_show); 304c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 305c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampstatic int genwqe_info_show(struct seq_file *s, void *unused) 306c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 307c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct genwqe_dev *cd = s->private; 308c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp u16 val16, type; 309c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp u64 app_id, slu_id, bitstream = -1; 310c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct pci_dev *pci_dev = cd->pci_dev; 311c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 312c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp slu_id = __genwqe_readq(cd, IO_SLU_UNITCFG); 313c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp app_id = __genwqe_readq(cd, IO_APP_UNITCFG); 314c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 315c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (genwqe_is_privileged(cd)) 316c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp bitstream = __genwqe_readq(cd, IO_SLU_BITSTREAM); 317c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 318c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp val16 = (u16)(slu_id & 0x0fLLU); 319c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp type = (u16)((slu_id >> 20) & 0xffLLU); 320c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 321c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp seq_printf(s, "%s driver version: %s\n" 322c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " Device Name/Type: %s %s CardIdx: %d\n" 323c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " SLU/APP Config : 0x%016llx/0x%016llx\n" 324c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " Build Date : %u/%x/%u\n" 325c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " Base Clock : %u MHz\n" 326c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " Arch/SVN Release: %u/%llx\n" 327c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp " Bitstream : %llx\n", 32864df2ec5108de3f627761cade7b31e5d583ce448Frank Haverkamp GENWQE_DEVNAME, DRV_VERSION, dev_name(&pci_dev->dev), 329c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp genwqe_is_privileged(cd) ? 330c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp "Physical" : "Virtual or no SR-IOV", 331c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp cd->card_idx, slu_id, app_id, 332c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp (u16)((slu_id >> 12) & 0x0fLLU), /* month */ 333c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp (u16)((slu_id >> 4) & 0xffLLU), /* day */ 334c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp (u16)((slu_id >> 16) & 0x0fLLU) + 2010, /* year */ 335c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp genwqe_base_clock_frequency(cd), 336c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp (u16)((slu_id >> 32) & 0xffLLU), slu_id >> 40, 337c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp bitstream); 338c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 339c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return 0; 340c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 341c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 342c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank HaverkampGENWQE_DEBUGFS_RO(info, genwqe_info_show); 343c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 344c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampint genwqe_init_debugfs(struct genwqe_dev *cd) 345c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 346c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct dentry *root; 347c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp struct dentry *file; 348c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp int ret; 349c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp char card_name[64]; 350c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp char name[64]; 351c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp unsigned int i; 352c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 35332d9dbe37965cb2e7fce47ea836a57cab4ffe5d4Masanari Iida sprintf(card_name, "%s%d_card", GENWQE_DEVNAME, cd->card_idx); 354c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 355c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp root = debugfs_create_dir(card_name, cd->debugfs_genwqe); 356c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!root) { 357c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 358c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err0; 359c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 360c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 361c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp /* non privileged interfaces are done here */ 362c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("ddcb_info", S_IRUGO, root, cd, 363c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_ddcb_info_fops); 364c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 365c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 366c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 367c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 368c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 369c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("info", S_IRUGO, root, cd, 370c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_info_fops); 371c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 372c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 373c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 374c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 375c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 376c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_x64("err_inject", 0666, root, &cd->err_inject); 377c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 378c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 379c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 380c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 381c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 382c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_u32("ddcb_software_timeout", 0666, root, 383c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &cd->ddcb_software_timeout); 384c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 385c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 386c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 387c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 388c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 389c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_u32("kill_timeout", 0666, root, 390c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &cd->kill_timeout); 391c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 392c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 393c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 394c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 395c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 396c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp /* privileged interfaces follow here */ 397c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!genwqe_is_privileged(cd)) { 398c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp cd->debugfs_root = root; 399c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return 0; 400c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 401c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 402c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("curr_regs", S_IRUGO, root, cd, 403c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_curr_regs_fops); 404c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 405c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 406c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 407c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 408c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 409c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("curr_dbg_uid0", S_IRUGO, root, cd, 410c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_curr_dbg_uid0_fops); 411c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 412c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 413c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 414c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 415c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 416c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("curr_dbg_uid1", S_IRUGO, root, cd, 417c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_curr_dbg_uid1_fops); 418c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 419c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 420c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 421c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 422c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 423c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("curr_dbg_uid2", S_IRUGO, root, cd, 424c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_curr_dbg_uid2_fops); 425c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 426c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 427c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 428c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 429c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 430c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("prev_regs", S_IRUGO, root, cd, 431c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_prev_regs_fops); 432c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 433c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 434c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 435c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 436c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 437c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("prev_dbg_uid0", S_IRUGO, root, cd, 438c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_prev_dbg_uid0_fops); 439c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 440c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 441c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 442c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 443c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 444c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("prev_dbg_uid1", S_IRUGO, root, cd, 445c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_prev_dbg_uid1_fops); 446c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 447c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 448c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 449c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 450c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 451c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("prev_dbg_uid2", S_IRUGO, root, cd, 452c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_prev_dbg_uid2_fops); 453c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 454c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 455c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 456c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 457c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 458c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp for (i = 0; i < GENWQE_MAX_VFS; i++) { 45932d9dbe37965cb2e7fce47ea836a57cab4ffe5d4Masanari Iida sprintf(name, "vf%u_jobtimeout_msec", i); 460c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 461c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_u32(name, 0666, root, 462c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &cd->vf_jobtimeout_msec[i]); 463c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 464c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 465c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 466c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 467c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 468c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 469c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("jobtimer", S_IRUGO, root, cd, 470c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_jtimer_fops); 471c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 472c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 473c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 474c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 475c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 476c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_file("queue_working_time", S_IRUGO, root, cd, 477c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &genwqe_queue_working_time_fops); 478c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 479c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 480c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 481c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 482c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 483c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp file = debugfs_create_u32("skip_recovery", 0666, root, 484c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp &cd->skip_recovery); 485c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp if (!file) { 486c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp ret = -ENOMEM; 487c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp goto err1; 488c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp } 489c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 490fb145456fa4f4311f90703aeee058bab3b274bf8Kleber Sacilotto de Souza file = debugfs_create_u32("use_platform_recovery", 0666, root, 491fb145456fa4f4311f90703aeee058bab3b274bf8Kleber Sacilotto de Souza &cd->use_platform_recovery); 492fb145456fa4f4311f90703aeee058bab3b274bf8Kleber Sacilotto de Souza if (!file) { 493fb145456fa4f4311f90703aeee058bab3b274bf8Kleber Sacilotto de Souza ret = -ENOMEM; 494fb145456fa4f4311f90703aeee058bab3b274bf8Kleber Sacilotto de Souza goto err1; 495fb145456fa4f4311f90703aeee058bab3b274bf8Kleber Sacilotto de Souza } 496fb145456fa4f4311f90703aeee058bab3b274bf8Kleber Sacilotto de Souza 497c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp cd->debugfs_root = root; 498c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return 0; 499c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamperr1: 500c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp debugfs_remove_recursive(root); 501c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamperr0: 502c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp return ret; 503c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 504c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp 505c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkampvoid genqwe_exit_debugfs(struct genwqe_dev *cd) 506c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp{ 507c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp debugfs_remove_recursive(cd->debugfs_root); 508c59330cd7c15d550c4edbb8cd49d48e6d65ed47fFrank Haverkamp} 509