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

scsi: hisi_sas: Add debugfs IOST file and add file operations

This patch create debugfs file for IOST and add file operations.

Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Luo Jiaxing and committed by
Martin K. Petersen
1afb4b85 148e379f

+51
+51
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 2630 2630 .owner = THIS_MODULE, 2631 2631 }; 2632 2632 2633 + static int hisi_sas_show_row_64(struct seq_file *s, int index, 2634 + int sz, u64 *ptr) 2635 + { 2636 + int i; 2637 + 2638 + /* completion header size not fixed per HW version */ 2639 + seq_printf(s, "index %04d:\n\t", index); 2640 + for (i = 1; i <= sz / 8; i++, ptr++) { 2641 + seq_printf(s, " 0x%016llx", le64_to_cpu(*ptr)); 2642 + if (!(i % 2)) 2643 + seq_puts(s, "\n\t"); 2644 + } 2645 + 2646 + seq_puts(s, "\n"); 2647 + 2648 + return 0; 2649 + } 2650 + 2633 2651 static int hisi_sas_show_row_32(struct seq_file *s, int index, 2634 2652 int sz, u32 *ptr) 2635 2653 { ··· 2740 2722 .owner = THIS_MODULE, 2741 2723 }; 2742 2724 2725 + static int hisi_sas_debugfs_iost_show(struct seq_file *s, void *p) 2726 + { 2727 + struct hisi_hba *hisi_hba = s->private; 2728 + struct hisi_sas_iost *debugfs_iost = hisi_hba->debugfs_iost; 2729 + int i, ret, max_command_entries = hisi_hba->hw->max_command_entries; 2730 + 2731 + for (i = 0; i < max_command_entries; i++, debugfs_iost++) { 2732 + ret = hisi_sas_show_row_64(s, i, sizeof(*debugfs_iost), 2733 + (u64 *)debugfs_iost); 2734 + if (ret) 2735 + return ret; 2736 + } 2737 + 2738 + return 0; 2739 + } 2740 + 2741 + static int hisi_sas_debugfs_iost_open(struct inode *inode, struct file *filp) 2742 + { 2743 + return single_open(filp, hisi_sas_debugfs_iost_show, inode->i_private); 2744 + } 2745 + 2746 + static const struct file_operations hisi_sas_debugfs_iost_fops = { 2747 + .open = hisi_sas_debugfs_iost_open, 2748 + .read = seq_read, 2749 + .llseek = seq_lseek, 2750 + .release = single_release, 2751 + .owner = THIS_MODULE, 2752 + }; 2753 + 2743 2754 static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) 2744 2755 { 2745 2756 struct dentry *dump_dentry; ··· 2829 2782 &hisi_sas_debugfs_dq_fops)) 2830 2783 goto fail; 2831 2784 } 2785 + 2786 + if (!debugfs_create_file("iost", 0400, dump_dentry, hisi_hba, 2787 + &hisi_sas_debugfs_iost_fops)) 2788 + goto fail; 2832 2789 2833 2790 return; 2834 2791 fail: