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

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

This patch create debugfs file for DQ 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
148e379f 971afae7

+52
+52
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 2685 2685 .owner = THIS_MODULE, 2686 2686 }; 2687 2687 2688 + static int hisi_sas_dq_show_slot(struct seq_file *s, int slot, void *dq_ptr) 2689 + { 2690 + struct hisi_sas_dq *dq = dq_ptr; 2691 + struct hisi_hba *hisi_hba = dq->hisi_hba; 2692 + void *cmd_queue = hisi_hba->debugfs_cmd_hdr[dq->id]; 2693 + void *cmd_hdr = cmd_queue + 2694 + hisi_hba->hw->complete_hdr_size * slot; 2695 + 2696 + return hisi_sas_show_row_32(s, slot, sizeof(struct hisi_sas_cmd_hdr), 2697 + cmd_hdr); 2698 + } 2699 + 2700 + static int hisi_sas_debugfs_dq_show(struct seq_file *s, void *p) 2701 + { 2702 + int slot, ret; 2703 + 2704 + for (slot = 0; slot < HISI_SAS_QUEUE_SLOTS; slot++) { 2705 + ret = hisi_sas_dq_show_slot(s, slot, s->private); 2706 + if (ret) 2707 + return ret; 2708 + } 2709 + return 0; 2710 + } 2711 + 2712 + static int hisi_sas_debugfs_dq_open(struct inode *inode, struct file *filp) 2713 + { 2714 + return single_open(filp, hisi_sas_debugfs_dq_show, inode->i_private); 2715 + } 2716 + 2717 + static const struct file_operations hisi_sas_debugfs_dq_fops = { 2718 + .open = hisi_sas_debugfs_dq_open, 2719 + .read = seq_read, 2720 + .llseek = seq_lseek, 2721 + .release = single_release, 2722 + .owner = THIS_MODULE, 2723 + }; 2724 + 2688 2725 static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) 2689 2726 { 2690 2727 struct dentry *dump_dentry; ··· 2729 2692 char name[256]; 2730 2693 int p; 2731 2694 int c; 2695 + int d; 2732 2696 2733 2697 /* Create dump dir inside device dir */ 2734 2698 dump_dentry = debugfs_create_dir("dump", hisi_hba->debugfs_dir); ··· 2766 2728 if (!debugfs_create_file(name, 0400, dentry, 2767 2729 &hisi_hba->cq[c], 2768 2730 &hisi_sas_debugfs_cq_fops)) 2731 + goto fail; 2732 + } 2733 + 2734 + /* Create DQ dir and files */ 2735 + dentry = debugfs_create_dir("dq", dump_dentry); 2736 + if (!dentry) 2737 + goto fail; 2738 + 2739 + for (d = 0; d < hisi_hba->queue_count; d++) { 2740 + snprintf(name, 256, "%d", d); 2741 + 2742 + if (!debugfs_create_file(name, 0400, dentry, 2743 + &hisi_hba->dq[d], 2744 + &hisi_sas_debugfs_dq_fops)) 2769 2745 goto fail; 2770 2746 } 2771 2747