Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: bcm2835aux: add driver stats to debugfs

To estimate efficiency add statistics on transfer types
(polling and interrupt) used to debugfs.

Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Martin Sperl and committed by
Mark Brown
8048d151 fedd6940

+56
+56
drivers/spi/spi-bcm2835aux.c
··· 21 21 22 22 #include <linux/clk.h> 23 23 #include <linux/completion.h> 24 + #include <linux/debugfs.h> 24 25 #include <linux/delay.h> 25 26 #include <linux/err.h> 26 27 #include <linux/interrupt.h> ··· 105 104 int tx_len; 106 105 int rx_len; 107 106 int pending; 107 + 108 + u64 count_transfer_polling; 109 + u64 count_transfer_irq; 110 + u64 count_transfer_irq_after_poll; 111 + 112 + struct dentry *debugfs_dir; 108 113 }; 114 + 115 + #if defined(CONFIG_DEBUG_FS) 116 + static void bcm2835aux_debugfs_create(struct bcm2835aux_spi *bs, 117 + const char *dname) 118 + { 119 + char name[64]; 120 + struct dentry *dir; 121 + 122 + /* get full name */ 123 + snprintf(name, sizeof(name), "spi-bcm2835aux-%s", dname); 124 + 125 + /* the base directory */ 126 + dir = debugfs_create_dir(name, NULL); 127 + bs->debugfs_dir = dir; 128 + 129 + /* the counters */ 130 + debugfs_create_u64("count_transfer_polling", 0444, dir, 131 + &bs->count_transfer_polling); 132 + debugfs_create_u64("count_transfer_irq", 0444, dir, 133 + &bs->count_transfer_irq); 134 + debugfs_create_u64("count_transfer_irq_after_poll", 0444, dir, 135 + &bs->count_transfer_irq_after_poll); 136 + } 137 + 138 + static void bcm2835aux_debugfs_remove(struct bcm2835aux_spi *bs) 139 + { 140 + debugfs_remove_recursive(bs->debugfs_dir); 141 + bs->debugfs_dir = NULL; 142 + } 143 + #else 144 + static void bcm2835aux_debugfs_create(struct bcm2835aux_spi *bs) 145 + { 146 + } 147 + 148 + static void bcm2835aux_debugfs_remove(struct bcm2835aux_spi *bs) 149 + { 150 + } 151 + #endif /* CONFIG_DEBUG_FS */ 109 152 110 153 static inline u32 bcm2835aux_rd(struct bcm2835aux_spi *bs, unsigned reg) 111 154 { ··· 289 244 { 290 245 struct bcm2835aux_spi *bs = spi_master_get_devdata(master); 291 246 247 + /* update statistics */ 248 + bs->count_transfer_irq++; 249 + 292 250 /* fill in registers and fifos before enabling interrupts */ 293 251 bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); 294 252 bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]); ··· 315 267 struct bcm2835aux_spi *bs = spi_master_get_devdata(master); 316 268 unsigned long timeout; 317 269 270 + /* update statistics */ 271 + bs->count_transfer_polling++; 272 + 318 273 /* configure spi */ 319 274 bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); 320 275 bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]); ··· 338 287 jiffies - timeout, 339 288 bs->tx_len, bs->rx_len); 340 289 /* forward to interrupt handler */ 290 + bs->count_transfer_irq_after_poll++; 341 291 return __bcm2835aux_spi_transfer_one_irq(master, 342 292 spi, tfr); 343 293 } ··· 588 536 goto out_clk_disable; 589 537 } 590 538 539 + bcm2835aux_debugfs_create(bs, dev_name(&pdev->dev)); 540 + 591 541 return 0; 592 542 593 543 out_clk_disable: ··· 603 549 { 604 550 struct spi_master *master = platform_get_drvdata(pdev); 605 551 struct bcm2835aux_spi *bs = spi_master_get_devdata(master); 552 + 553 + bcm2835aux_debugfs_remove(bs); 606 554 607 555 bcm2835aux_spi_reset_hw(bs); 608 556