From patchwork Wed Dec 19 15:56:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 154274 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5092463ljp; Wed, 19 Dec 2018 07:56:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/WIAlRq36veZAptCXM1Vk8xsQAjXq/KpsCPrFMwjOwxLEVjE2mOsrldMWnUzxqm8Smm1DCp X-Received: by 2002:a17:902:2aaa:: with SMTP id j39mr21290777plb.335.1545234969340; Wed, 19 Dec 2018 07:56:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545234969; cv=none; d=google.com; s=arc-20160816; b=eDsUH97gvH1UJd/Jd7dsS+sxQyScInAQVHzjft6vVAXi2APAchGHVNtczZK5wHjrT/ OK/mCb+dh8SFSLftL+OeFOctdLv9l9Nn1+SmFyWzQ0Po4b5YDe7bH6obt/hp61Ojmb3b REtDHTvpjrR+rpWnWRWycKw2PsmL5mg/uCTjydYUFUoNpi9idqfGiOet+bRxmPGoLQLY uf4fHnrhwsrgR8I5WlhWmOXPZcfVtrIBREMk4bNq1lE8Mb3D5QInITdHfpNssk8TsQ6z 0R8yfJ09hkFOAHxEC3mpNZZKTlgkpG6wJY9TiSJnL7e4GDXmMWIkxxl0ObmLQMkWS4NV rDrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=xOdHBpyzdEUsaN48DPTNqBBYOIqf23n7nGgq/sro3JU=; b=RKnucbcxDUKH0ff70tdfHVfZDf1Y7KZykdGLJ1Fe98s/YFB59eqFG3wuNutc+xdvCj LGgrWv4jutbAfn2mn6DZ4k6brpEo9s8mdvM/dWzg8g9kJ7w1jVcLKJNTneUF6KwZC0b3 KgUv0LZx6hTMrtzsQ2LAfMxgU/TnDsIPKS0+0i8wpCd1RTIvQqKHTyGe5m9UfPp3O0NS GK1FFmUamePJbj4waHpMU4Aah+9ZqpvWScAiF5Ufc9r2rjd7Q/WN/5LvboQtY2JCFtZL jvZIrSYU4htHRWr2fvyZIXVarAfnPy28nJdLu0YHWrRAPv7k43r62e/3AQi6/rSurz9r R7Zw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v141si17900747pfc.260.2018.12.19.07.56.09; Wed, 19 Dec 2018 07:56:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730459AbeLSP4H (ORCPT + 31 others); Wed, 19 Dec 2018 10:56:07 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:16165 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730425AbeLSP4A (ORCPT ); Wed, 19 Dec 2018 10:56:00 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 361BF1A9E0C6B; Wed, 19 Dec 2018 23:55:51 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Wed, 19 Dec 2018 23:55:45 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , John Garry Subject: [PATCH 6/8] scsi: hisi_sas: Add debugfs CQ file and add file operations Date: Wed, 19 Dec 2018 23:56:44 +0800 Message-ID: <1545235006-151716-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1545235006-151716-1-git-send-email-john.garry@huawei.com> References: <1545235006-151716-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing This patch create debugfs file for CQ and add file operations. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 70 +++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index fbd9b4a..ce0a9dc 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2630,12 +2630,68 @@ static int hisi_sas_debugfs_port_open(struct inode *inode, struct file *filp) .owner = THIS_MODULE, }; +static int hisi_sas_show_row_32(struct seq_file *s, int index, + int sz, u32 *ptr) +{ + int i; + + /* completion header size not fixed per HW version */ + seq_printf(s, "index %04d:\n\t", index); + for (i = 1; i <= sz / 4; i++, ptr++) { + if (!(i % 4)) + seq_puts(s, "\n\t"); + } + seq_puts(s, "\n"); + + return 0; +} + +static int hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr) +{ + struct hisi_sas_cq *cq = cq_ptr; + struct hisi_hba *hisi_hba = cq->hisi_hba; + void *complete_queue = hisi_hba->debugfs_complete_hdr[cq->id]; + void *complete_hdr = complete_queue + + (hisi_hba->hw->complete_hdr_size * slot); + + return hisi_sas_show_row_32(s, slot, + hisi_hba->hw->complete_hdr_size, + complete_hdr); +} + +static int hisi_sas_debugfs_cq_show(struct seq_file *s, void *p) +{ + struct hisi_sas_cq *cq = s->private; + int slot, ret; + + for (slot = 0; slot < HISI_SAS_QUEUE_SLOTS; slot++) { + ret = hisi_sas_cq_show_slot(s, slot, cq); + if (ret) + return ret; + } + return 0; +} + +static int hisi_sas_debugfs_cq_open(struct inode *inode, struct file *filp) +{ + return single_open(filp, hisi_sas_debugfs_cq_show, inode->i_private); +} + +static const struct file_operations hisi_sas_debugfs_cq_fops = { + .open = hisi_sas_debugfs_cq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, +}; + static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) { struct dentry *dump_dentry; struct dentry *dentry; char name[256]; int p; + int c; /* Create dump dir inside device dir */ dump_dentry = debugfs_create_dir("dump", hisi_hba->debugfs_dir); @@ -2661,6 +2717,20 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) goto fail; } + /* Create CQ dir and files */ + dentry = debugfs_create_dir("cq", dump_dentry); + if (!dentry) + goto fail; + + for (c = 0; c < hisi_hba->queue_count; c++) { + snprintf(name, 256, "%d", c); + + if (!debugfs_create_file(name, 0400, dentry, + &hisi_hba->cq[c], + &hisi_sas_debugfs_cq_fops)) + goto fail; + } + return; fail: debugfs_remove_recursive(hisi_hba->debugfs_dir);