diff options
| author | Philip J Kelleher <pjk1939@linux.vnet.ibm.com> | 2013-06-18 15:52:21 -0400 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2013-06-19 07:52:10 -0400 |
| commit | 36f988e978f81ffa415df4d77bbcd8887917f25c (patch) | |
| tree | 488e28838f38bf646a1c526d7bfe60b07a82fa98 /drivers/block/rsxx | |
| parent | 62302508f2986720ad73494dd8037dff1c4f77d1 (diff) | |
rsxx: Adding in debugfs entries.
Adding debugfs entries to help with debugging and testing and
testing code.
pci_regs:
This entry will spit out all of the data stored on the BAR.
stats:
This entry will display all of the driver stats for each
DMA channel.
cram:
This will allow read/write ability to the CRAM address space
on our adapter's CPU.
Signed-off-by: Philip J Kelleher <pjk1939@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/rsxx')
| -rw-r--r-- | drivers/block/rsxx/core.c | 275 | ||||
| -rw-r--r-- | drivers/block/rsxx/rsxx_priv.h | 3 |
2 files changed, 278 insertions, 0 deletions
diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c index bd763f426774..6e85e21445eb 100644 --- a/drivers/block/rsxx/core.c +++ b/drivers/block/rsxx/core.c | |||
| @@ -31,6 +31,8 @@ | |||
| 31 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
| 32 | #include <linux/bitops.h> | 32 | #include <linux/bitops.h> |
| 33 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
| 34 | #include <linux/debugfs.h> | ||
| 35 | #include <linux/seq_file.h> | ||
| 34 | 36 | ||
| 35 | #include <linux/genhd.h> | 37 | #include <linux/genhd.h> |
| 36 | #include <linux/idr.h> | 38 | #include <linux/idr.h> |
| @@ -58,6 +60,274 @@ MODULE_PARM_DESC(sync_start, "On by Default: Driver load will not complete " | |||
| 58 | static DEFINE_IDA(rsxx_disk_ida); | 60 | static DEFINE_IDA(rsxx_disk_ida); |
| 59 | static DEFINE_SPINLOCK(rsxx_ida_lock); | 61 | static DEFINE_SPINLOCK(rsxx_ida_lock); |
| 60 | 62 | ||
| 63 | /* --------------------Debugfs Setup ------------------- */ | ||
| 64 | |||
| 65 | struct rsxx_cram { | ||
| 66 | u32 f_pos; | ||
| 67 | u32 offset; | ||
| 68 | void *i_private; | ||
| 69 | }; | ||
| 70 | |||
| 71 | static int rsxx_attr_pci_regs_show(struct seq_file *m, void *p) | ||
| 72 | { | ||
| 73 | struct rsxx_cardinfo *card = m->private; | ||
| 74 | |||
| 75 | seq_printf(m, "HWID 0x%08x\n", | ||
| 76 | ioread32(card->regmap + HWID)); | ||
| 77 | seq_printf(m, "SCRATCH 0x%08x\n", | ||
| 78 | ioread32(card->regmap + SCRATCH)); | ||
| 79 | seq_printf(m, "IER 0x%08x\n", | ||
| 80 | ioread32(card->regmap + IER)); | ||
| 81 | seq_printf(m, "IPR 0x%08x\n", | ||
| 82 | ioread32(card->regmap + IPR)); | ||
| 83 | seq_printf(m, "CREG_CMD 0x%08x\n", | ||
| 84 | ioread32(card->regmap + CREG_CMD)); | ||
| 85 | seq_printf(m, "CREG_ADD 0x%08x\n", | ||
| 86 | ioread32(card->regmap + CREG_ADD)); | ||
| 87 | seq_printf(m, "CREG_CNT 0x%08x\n", | ||
| 88 | ioread32(card->regmap + CREG_CNT)); | ||
| 89 | seq_printf(m, "CREG_STAT 0x%08x\n", | ||
| 90 | ioread32(card->regmap + CREG_STAT)); | ||
| 91 | seq_printf(m, "CREG_DATA0 0x%08x\n", | ||
| 92 | ioread32(card->regmap + CREG_DATA0)); | ||
| 93 | seq_printf(m, "CREG_DATA1 0x%08x\n", | ||
| 94 | ioread32(card->regmap + CREG_DATA1)); | ||
| 95 | seq_printf(m, "CREG_DATA2 0x%08x\n", | ||
| 96 | ioread32(card->regmap + CREG_DATA2)); | ||
| 97 | seq_printf(m, "CREG_DATA3 0x%08x\n", | ||
| 98 | ioread32(card->regmap + CREG_DATA3)); | ||
| 99 | seq_printf(m, "CREG_DATA4 0x%08x\n", | ||
| 100 | ioread32(card->regmap + CREG_DATA4)); | ||
| 101 | seq_printf(m, "CREG_DATA5 0x%08x\n", | ||
| 102 | ioread32(card->regmap + CREG_DATA5)); | ||
| 103 | seq_printf(m, "CREG_DATA6 0x%08x\n", | ||
| 104 | ioread32(card->regmap + CREG_DATA6)); | ||
| 105 | seq_printf(m, "CREG_DATA7 0x%08x\n", | ||
| 106 | ioread32(card->regmap + CREG_DATA7)); | ||
| 107 | seq_printf(m, "INTR_COAL 0x%08x\n", | ||
| 108 | ioread32(card->regmap + INTR_COAL)); | ||
| 109 | seq_printf(m, "HW_ERROR 0x%08x\n", | ||
| 110 | ioread32(card->regmap + HW_ERROR)); | ||
| 111 | seq_printf(m, "DEBUG0 0x%08x\n", | ||
| 112 | ioread32(card->regmap + PCI_DEBUG0)); | ||
| 113 | seq_printf(m, "DEBUG1 0x%08x\n", | ||
| 114 | ioread32(card->regmap + PCI_DEBUG1)); | ||
| 115 | seq_printf(m, "DEBUG2 0x%08x\n", | ||
| 116 | ioread32(card->regmap + PCI_DEBUG2)); | ||
| 117 | seq_printf(m, "DEBUG3 0x%08x\n", | ||
| 118 | ioread32(card->regmap + PCI_DEBUG3)); | ||
| 119 | seq_printf(m, "DEBUG4 0x%08x\n", | ||
| 120 | ioread32(card->regmap + PCI_DEBUG4)); | ||
| 121 | seq_printf(m, "DEBUG5 0x%08x\n", | ||
| 122 | ioread32(card->regmap + PCI_DEBUG5)); | ||
| 123 | seq_printf(m, "DEBUG6 0x%08x\n", | ||
| 124 | ioread32(card->regmap + PCI_DEBUG6)); | ||
| 125 | seq_printf(m, "DEBUG7 0x%08x\n", | ||
| 126 | ioread32(card->regmap + PCI_DEBUG7)); | ||
| 127 | seq_printf(m, "RECONFIG 0x%08x\n", | ||
| 128 | ioread32(card->regmap + PCI_RECONFIG)); | ||
| 129 | |||
| 130 | return 0; | ||
| 131 | } | ||
| 132 | |||
| 133 | static int rsxx_attr_stats_show(struct seq_file *m, void *p) | ||
| 134 | { | ||
| 135 | struct rsxx_cardinfo *card = m->private; | ||
| 136 | int i; | ||
| 137 | |||
| 138 | for (i = 0; i < card->n_targets; i++) { | ||
| 139 | seq_printf(m, "Ctrl %d CRC Errors = %d\n", | ||
| 140 | i, card->ctrl[i].stats.crc_errors); | ||
| 141 | seq_printf(m, "Ctrl %d Hard Errors = %d\n", | ||
| 142 | i, card->ctrl[i].stats.hard_errors); | ||
| 143 | seq_printf(m, "Ctrl %d Soft Errors = %d\n", | ||
| 144 | i, card->ctrl[i].stats.soft_errors); | ||
| 145 | seq_printf(m, "Ctrl %d Writes Issued = %d\n", | ||
| 146 | i, card->ctrl[i].stats.writes_issued); | ||
| 147 | seq_printf(m, "Ctrl %d Writes Failed = %d\n", | ||
| 148 | i, card->ctrl[i].stats.writes_failed); | ||
| 149 | seq_printf(m, "Ctrl %d Reads Issued = %d\n", | ||
| 150 | i, card->ctrl[i].stats.reads_issued); | ||
| 151 | seq_printf(m, "Ctrl %d Reads Failed = %d\n", | ||
| 152 | i, card->ctrl[i].stats.reads_failed); | ||
| 153 | seq_printf(m, "Ctrl %d Reads Retried = %d\n", | ||
| 154 | i, card->ctrl[i].stats.reads_retried); | ||
| 155 | seq_printf(m, "Ctrl %d Discards Issued = %d\n", | ||
| 156 | i, card->ctrl[i].stats.discards_issued); | ||
| 157 | seq_printf(m, "Ctrl %d Discards Failed = %d\n", | ||
| 158 | i, card->ctrl[i].stats.discards_failed); | ||
| 159 | seq_printf(m, "Ctrl %d DMA SW Errors = %d\n", | ||
| 160 | i, card->ctrl[i].stats.dma_sw_err); | ||
| 161 | seq_printf(m, "Ctrl %d DMA HW Faults = %d\n", | ||
| 162 | i, card->ctrl[i].stats.dma_hw_fault); | ||
| 163 | seq_printf(m, "Ctrl %d DMAs Cancelled = %d\n", | ||
| 164 | i, card->ctrl[i].stats.dma_cancelled); | ||
| 165 | seq_printf(m, "Ctrl %d SW Queue Depth = %d\n", | ||
| 166 | i, card->ctrl[i].stats.sw_q_depth); | ||
| 167 | seq_printf(m, "Ctrl %d HW Queue Depth = %d\n", | ||
| 168 | i, atomic_read(&card->ctrl[i].stats.hw_q_depth)); | ||
| 169 | } | ||
| 170 | |||
| 171 | return 0; | ||
| 172 | } | ||
| 173 | |||
| 174 | static int rsxx_attr_stats_open(struct inode *inode, struct file *file) | ||
| 175 | { | ||
| 176 | return single_open(file, rsxx_attr_stats_show, inode->i_private); | ||
| 177 | } | ||
| 178 | |||
| 179 | static int rsxx_attr_pci_regs_open(struct inode *inode, struct file *file) | ||
| 180 | { | ||
| 181 | return single_open(file, rsxx_attr_pci_regs_show, inode->i_private); | ||
| 182 | } | ||
| 183 | |||
| 184 | static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf, | ||
| 185 | size_t cnt, loff_t *ppos) | ||
| 186 | { | ||
| 187 | struct rsxx_cram *info = fp->private_data; | ||
| 188 | struct rsxx_cardinfo *card = info->i_private; | ||
| 189 | char *buf; | ||
| 190 | int st; | ||
| 191 | |||
| 192 | buf = kzalloc(sizeof(*buf) * cnt, GFP_KERNEL); | ||
| 193 | if (!buf) | ||
| 194 | return -ENOMEM; | ||
| 195 | |||
| 196 | info->f_pos = (u32)*ppos + info->offset; | ||
| 197 | |||
| 198 | st = rsxx_creg_read(card, CREG_ADD_CRAM + info->f_pos, cnt, buf, 1); | ||
| 199 | if (st) | ||
| 200 | return st; | ||
| 201 | |||
| 202 | st = copy_to_user(ubuf, buf, cnt); | ||
| 203 | if (st) | ||
| 204 | return st; | ||
| 205 | |||
| 206 | info->offset += cnt; | ||
| 207 | |||
| 208 | kfree(buf); | ||
| 209 | |||
| 210 | return cnt; | ||
| 211 | } | ||
| 212 | |||
| 213 | static ssize_t rsxx_cram_write(struct file *fp, const char __user *ubuf, | ||
| 214 | size_t cnt, loff_t *ppos) | ||
| 215 | { | ||
| 216 | struct rsxx_cram *info = fp->private_data; | ||
| 217 | struct rsxx_cardinfo *card = info->i_private; | ||
| 218 | char *buf; | ||
| 219 | int st; | ||
| 220 | |||
| 221 | buf = kzalloc(sizeof(*buf) * cnt, GFP_KERNEL); | ||
| 222 | if (!buf) | ||
| 223 | return -ENOMEM; | ||
| 224 | |||
| 225 | st = copy_from_user(buf, ubuf, cnt); | ||
| 226 | if (st) | ||
| 227 | return st; | ||
| 228 | |||
| 229 | info->f_pos = (u32)*ppos + info->offset; | ||
| 230 | |||
| 231 | st = rsxx_creg_write(card, CREG_ADD_CRAM + info->f_pos, cnt, buf, 1); | ||
| 232 | if (st) | ||
| 233 | return st; | ||
| 234 | |||
| 235 | info->offset += cnt; | ||
| 236 | |||
| 237 | kfree(buf); | ||
| 238 | |||
| 239 | return cnt; | ||
| 240 | } | ||
| 241 | |||
| 242 | static int rsxx_cram_open(struct inode *inode, struct file *file) | ||
| 243 | { | ||
| 244 | struct rsxx_cram *info = kzalloc(sizeof(*info), GFP_KERNEL); | ||
| 245 | if (!info) | ||
| 246 | return -ENOMEM; | ||
| 247 | |||
| 248 | info->i_private = inode->i_private; | ||
| 249 | info->f_pos = file->f_pos; | ||
| 250 | file->private_data = info; | ||
| 251 | |||
| 252 | return 0; | ||
| 253 | } | ||
| 254 | |||
| 255 | static int rsxx_cram_release(struct inode *inode, struct file *file) | ||
| 256 | { | ||
| 257 | struct rsxx_cram *info = file->private_data; | ||
| 258 | |||
| 259 | if (!info) | ||
| 260 | return 0; | ||
| 261 | |||
| 262 | kfree(info); | ||
| 263 | file->private_data = NULL; | ||
| 264 | |||
| 265 | return 0; | ||
| 266 | } | ||
| 267 | |||
| 268 | static const struct file_operations debugfs_cram_fops = { | ||
| 269 | .owner = THIS_MODULE, | ||
| 270 | .open = rsxx_cram_open, | ||
| 271 | .read = rsxx_cram_read, | ||
| 272 | .write = rsxx_cram_write, | ||
| 273 | .release = rsxx_cram_release, | ||
| 274 | }; | ||
| 275 | |||
| 276 | static const struct file_operations debugfs_stats_fops = { | ||
| 277 | .owner = THIS_MODULE, | ||
| 278 | .open = rsxx_attr_stats_open, | ||
| 279 | .read = seq_read, | ||
| 280 | .llseek = seq_lseek, | ||
| 281 | .release = single_release, | ||
| 282 | }; | ||
| 283 | |||
| 284 | static const struct file_operations debugfs_pci_regs_fops = { | ||
| 285 | .owner = THIS_MODULE, | ||
| 286 | .open = rsxx_attr_pci_regs_open, | ||
| 287 | .read = seq_read, | ||
| 288 | .llseek = seq_lseek, | ||
| 289 | .release = single_release, | ||
| 290 | }; | ||
| 291 | |||
| 292 | static void rsxx_debugfs_dev_new(struct rsxx_cardinfo *card) | ||
| 293 | { | ||
| 294 | struct dentry *debugfs_stats; | ||
| 295 | struct dentry *debugfs_pci_regs; | ||
| 296 | struct dentry *debugfs_cram; | ||
| 297 | |||
| 298 | card->debugfs_dir = debugfs_create_dir(card->gendisk->disk_name, NULL); | ||
| 299 | if (IS_ERR_OR_NULL(card->debugfs_dir)) | ||
| 300 | goto failed_debugfs_dir; | ||
| 301 | |||
| 302 | debugfs_stats = debugfs_create_file("stats", S_IRUGO, | ||
| 303 | card->debugfs_dir, card, | ||
| 304 | &debugfs_stats_fops); | ||
| 305 | if (IS_ERR_OR_NULL(debugfs_stats)) | ||
| 306 | goto failed_debugfs_stats; | ||
| 307 | |||
| 308 | debugfs_pci_regs = debugfs_create_file("pci_regs", S_IRUGO, | ||
| 309 | card->debugfs_dir, card, | ||
| 310 | &debugfs_pci_regs_fops); | ||
| 311 | if (IS_ERR_OR_NULL(debugfs_pci_regs)) | ||
| 312 | goto failed_debugfs_pci_regs; | ||
| 313 | |||
| 314 | debugfs_cram = debugfs_create_file("cram", S_IRUGO | S_IWUSR, | ||
| 315 | card->debugfs_dir, card, | ||
| 316 | &debugfs_cram_fops); | ||
| 317 | if (IS_ERR_OR_NULL(debugfs_cram)) | ||
| 318 | goto failed_debugfs_cram; | ||
| 319 | |||
| 320 | return; | ||
| 321 | failed_debugfs_cram: | ||
| 322 | debugfs_remove(debugfs_pci_regs); | ||
| 323 | failed_debugfs_pci_regs: | ||
| 324 | debugfs_remove(debugfs_stats); | ||
| 325 | failed_debugfs_stats: | ||
| 326 | debugfs_remove(card->debugfs_dir); | ||
| 327 | failed_debugfs_dir: | ||
| 328 | card->debugfs_dir = NULL; | ||
| 329 | } | ||
| 330 | |||
| 61 | /*----------------- Interrupt Control & Handling -------------------*/ | 331 | /*----------------- Interrupt Control & Handling -------------------*/ |
| 62 | 332 | ||
| 63 | static void rsxx_mask_interrupts(struct rsxx_cardinfo *card) | 333 | static void rsxx_mask_interrupts(struct rsxx_cardinfo *card) |
| @@ -741,6 +1011,9 @@ static int rsxx_pci_probe(struct pci_dev *dev, | |||
| 741 | 1011 | ||
| 742 | rsxx_attach_dev(card); | 1012 | rsxx_attach_dev(card); |
| 743 | 1013 | ||
| 1014 | /************* Setup Debugfs *************/ | ||
| 1015 | rsxx_debugfs_dev_new(card); | ||
| 1016 | |||
| 744 | return 0; | 1017 | return 0; |
| 745 | 1018 | ||
| 746 | failed_create_dev: | 1019 | failed_create_dev: |
| @@ -818,6 +1091,8 @@ static void rsxx_pci_remove(struct pci_dev *dev) | |||
| 818 | /* Prevent work_structs from re-queuing themselves. */ | 1091 | /* Prevent work_structs from re-queuing themselves. */ |
| 819 | card->halt = 1; | 1092 | card->halt = 1; |
| 820 | 1093 | ||
| 1094 | debugfs_remove_recursive(card->debugfs_dir); | ||
| 1095 | |||
| 821 | free_irq(dev->irq, card); | 1096 | free_irq(dev->irq, card); |
| 822 | 1097 | ||
| 823 | if (!force_legacy) | 1098 | if (!force_legacy) |
diff --git a/drivers/block/rsxx/rsxx_priv.h b/drivers/block/rsxx/rsxx_priv.h index c968a6918b6e..5ad5055a4104 100644 --- a/drivers/block/rsxx/rsxx_priv.h +++ b/drivers/block/rsxx/rsxx_priv.h | |||
| @@ -185,6 +185,8 @@ struct rsxx_cardinfo { | |||
| 185 | 185 | ||
| 186 | int n_targets; | 186 | int n_targets; |
| 187 | struct rsxx_dma_ctrl *ctrl; | 187 | struct rsxx_dma_ctrl *ctrl; |
| 188 | |||
| 189 | struct dentry *debugfs_dir; | ||
| 188 | }; | 190 | }; |
| 189 | 191 | ||
| 190 | enum rsxx_pci_regmap { | 192 | enum rsxx_pci_regmap { |
| @@ -287,6 +289,7 @@ enum rsxx_creg_addr { | |||
| 287 | CREG_ADD_CAPABILITIES = 0x80001050, | 289 | CREG_ADD_CAPABILITIES = 0x80001050, |
| 288 | CREG_ADD_LOG = 0x80002000, | 290 | CREG_ADD_LOG = 0x80002000, |
| 289 | CREG_ADD_NUM_TARGETS = 0x80003000, | 291 | CREG_ADD_NUM_TARGETS = 0x80003000, |
| 292 | CREG_ADD_CRAM = 0xA0000000, | ||
| 290 | CREG_ADD_CONFIG = 0xB0000000, | 293 | CREG_ADD_CONFIG = 0xB0000000, |
| 291 | }; | 294 | }; |
| 292 | 295 | ||
