From patchwork Thu Oct 24 14:08:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177517 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2249647ill; Thu, 24 Oct 2019 07:13:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyH3777EbpPrutikuBlZhLy1WovDSXYAiqK6QPDKtDxQ9IxsIgSfzQZlscAGRUrkWIwY3lA X-Received: by 2002:a17:906:7c57:: with SMTP id g23mr38055836ejp.116.1571926401642; Thu, 24 Oct 2019 07:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571926401; cv=none; d=google.com; s=arc-20160816; b=pyrMmuB8uE9PQuDBezLZU8YihuxDZETCj+uK4+PGuLi6qMwLYQ6XICcv20vdgcvEt1 GzTYXLB7IFO/QdXxZOWF8e+pXrlx3dT2VP4IOMejU+H09EwPe2cIvATrzUz4AI+y9CiS 3XS3hO92t122HQa7iaya0luRYW9+sw4TjlJuZK07PtEwLWgC8bkEOwuL/8C5aRcofj8b HGg6Xbul4hIx72B7NOVA5cyhIBMeS2MwjnwRMKFHLIWEzpBzEoguR5XUq+C0iYPFQKYX 6626eN/3kQGa6fq5TqznwBngjNd0xisgkQFzrf4FXoRKsZfG++PRQd+tAqgy66xkA1I/ G2lw== 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=rUCy0US1o8lGrV47tXlj9moDifDnqM31y9Roq/EJg2o=; b=GdcmYNMaAsviLo5otO+x4ru4bw9DKBskJFu0gkd/27w+mn62NjxZsxrvyAYh2leqGn kyraXi3G9w1mmCpJqPM9JOYRmZmKuMO8QgueUh/I2MQZX2SKtCpIyY9VvlcrVa6HJtNm KLTUhX7VImhsK4MUl2KuAQNmA9jQIieX6iqwNGhYkfezq5x8kHS9Xwp/WAnr+HIjK2dL YKWNHHKTfuzQ4nJkEwOdETyIZOrqi+lgF+0RwEcXYq+he/i6cAa+S/0+W8LGiCmYwdpQ iGM43wRhy8rTbs/XVXfGlJMOQPSbX441+DLZoleeTzU8aYIvvyOeqAGd8xKPtsaI6X4U 11dg== 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 v15si1667367edc.148.2019.10.24.07.13.21; Thu, 24 Oct 2019 07:13:21 -0700 (PDT) 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 S2502681AbfJXONS (ORCPT + 26 others); Thu, 24 Oct 2019 10:13:18 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5155 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389916AbfJXOLg (ORCPT ); Thu, 24 Oct 2019 10:11:36 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 44DD4B3BD7F8C7BC19CC; Thu, 24 Oct 2019 22:11:30 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Thu, 24 Oct 2019 22:11:24 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH v2 02/18] scsi: hisi_sas: Set the BIST init value before enabling BIST Date: Thu, 24 Oct 2019 22:08:09 +0800 Message-ID: <1571926105-74636-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571926105-74636-1-git-send-email-john.garry@huawei.com> References: <1571926105-74636-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen If set the BIST init value after enabling BIST, there may be still some few error bits. According to the process, need to set the BIST init value before enabling BIST. Fixes: 97b151e75861 ("scsi: hisi_sas: Add BIST support for phy loopback") Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index cb8d087762db..cc594937fa8d 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3022,11 +3022,6 @@ static int debugfs_set_bist_v3_hw(struct hisi_hba *hisi_hba, bool enable) hisi_sas_phy_write32(hisi_hba, phy_id, SAS_PHY_BIST_CTRL, reg_val); - mdelay(100); - reg_val |= (CFG_RX_BIST_EN_MSK | CFG_TX_BIST_EN_MSK); - hisi_sas_phy_write32(hisi_hba, phy_id, - SAS_PHY_BIST_CTRL, reg_val); - /* set the bist init value */ hisi_sas_phy_write32(hisi_hba, phy_id, SAS_PHY_BIST_CODE, @@ -3035,6 +3030,11 @@ static int debugfs_set_bist_v3_hw(struct hisi_hba *hisi_hba, bool enable) SAS_PHY_BIST_CODE1, SAS_PHY_BIST_CODE1_INIT); + mdelay(100); + reg_val |= (CFG_RX_BIST_EN_MSK | CFG_TX_BIST_EN_MSK); + hisi_sas_phy_write32(hisi_hba, phy_id, + SAS_PHY_BIST_CTRL, reg_val); + /* clear error bit */ mdelay(100); hisi_sas_phy_read32(hisi_hba, phy_id, SAS_BIST_ERR_CNT); From patchwork Thu Oct 24 14:08:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177509 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2248091ill; Thu, 24 Oct 2019 07:12:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxDwN41EphPmj/eka++yFglFGaOBtJ3F298XUTo/gs+Oew4uGG8Ki1o74gnn5zo45qgyY2 X-Received: by 2002:a17:906:181b:: with SMTP id v27mr39221541eje.117.1571926334968; Thu, 24 Oct 2019 07:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571926334; cv=none; d=google.com; s=arc-20160816; b=s7KKPezG+Nj86AZY65UtbWQlEanJsFw9gO3XR6N+4srmdrXT0oNeW+DF4+4EnKSO4q PwohfkQVk7B29I9Ijj7vFWMGGymhW8ihTeQWHZl6vL0YVG6eL1wX0NfK1bcV6d3UygNn pnyWZ0nZO1wSxSRALaRvA4i1lL+4ACyPnaoWUr7atiiAVBZi9+1KL1UdoFZkPFgM+OuS vbNrVQhy84WvKbD9i8lguQkQxBtkBQzGxvgdWqhIVOxD3IcquRcF+P7RvcfHJh4G4Ryj NxKPOx9PqCCwT5X02/g9vnOUAT27Fx+mRbyXAED9Yf71zOCsLdQEBFLVep/7070k9g/5 QnJw== 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=wAwQCV736AbNkqgaujYtXWqMcPhJSrU6720BsJg8DvA=; b=fSRHGvamy0OowLiHxtaUYL8OsMzOCBXOacmcnXPWz0NL76MYpsEybm8LcKzy/NDS5g wPikhIeow2FtpL4MkGx/8AE2SuADL8JrwhUMvECik7XKp1ig5dvW1aPO3IhHxiae24UO B3GwHDvaUMcYy1P97eyTLOyiV7EoP1ys8/ic6U2E481Y4UnKpIxoB234yHldneCfxbUk tQJZHNMNnWNEV2Etkk7sXall5Tegy3uS3TWuFoTWqRsS5XgSYwkjwM7e8f7tTcFfKy4O rg6dargE/ORYLmHqAoe5K6O5t27kHGqoa+Nhs1NTu8xuy+0OB88Qz/BKTVAnSkH6DSsR lJBw== 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 f1si14829944eje.338.2019.10.24.07.12.14; Thu, 24 Oct 2019 07:12:14 -0700 (PDT) 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 S2502729AbfJXOMM (ORCPT + 26 others); Thu, 24 Oct 2019 10:12:12 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5167 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2502668AbfJXOL6 (ORCPT ); Thu, 24 Oct 2019 10:11:58 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 82294410C9B617EB410C; Thu, 24 Oct 2019 22:11:35 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Thu, 24 Oct 2019 22:11:25 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH v2 06/18] scsi: hisi_sas: Add debugfs file structure for CQ Date: Thu, 24 Oct 2019 22:08:13 +0800 Message-ID: <1571926105-74636-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571926105-74636-1-git-send-email-john.garry@huawei.com> References: <1571926105-74636-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] 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 Create a file structure which was used to save the memory address and CQ pointer for CQ at debugfs. This structure is bound to the corresponding debugfs file, it can help callback function of debugfs file to get what it need. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 7 ++++++- drivers/scsi/hisi_sas/hisi_sas_main.c | 29 +++++++++++++++------------ 2 files changed, 22 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 7069dae4cec9..5b0f08286af7 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -323,6 +323,11 @@ struct hisi_sas_hw { const struct hisi_sas_debugfs_reg *debugfs_reg_port; }; +struct hisi_sas_debugfs_cq { + struct hisi_sas_cq *cq; + void *complete_hdr; +}; + struct hisi_hba { /* This must be the first element, used by SHOST_TO_SAS_HA */ struct sas_ha_struct *p; @@ -406,7 +411,7 @@ struct hisi_hba { /* Put Global AXI and RAS Register into register array */ u32 *debugfs_regs[DEBUGFS_REGS_NUM]; u32 *debugfs_port_reg[HISI_SAS_MAX_PHYS]; - void *debugfs_complete_hdr[HISI_SAS_MAX_QUEUES]; + struct hisi_sas_debugfs_cq debugfs_cq[HISI_SAS_MAX_QUEUES]; struct hisi_sas_cmd_hdr *debugfs_cmd_hdr[HISI_SAS_MAX_QUEUES]; struct hisi_sas_iost *debugfs_iost; struct hisi_sas_itct *debugfs_itct; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index a0d04e4e13e2..5c1005f77131 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2700,7 +2700,7 @@ static void hisi_sas_debugfs_snapshot_cq_reg(struct hisi_hba *hisi_hba) int i; for (i = 0; i < hisi_hba->queue_count; i++) - memcpy(hisi_hba->debugfs_complete_hdr[i], + memcpy(hisi_hba->debugfs_cq[i].complete_hdr, hisi_hba->complete_hdr[i], HISI_SAS_QUEUE_SLOTS * queue_entry_size); } @@ -2985,13 +2985,13 @@ static void hisi_sas_show_row_32(struct seq_file *s, int index, seq_puts(s, "\n"); } -static void hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr) +static void hisi_sas_cq_show_slot(struct seq_file *s, int slot, + struct hisi_sas_debugfs_cq *debugfs_cq) { - struct hisi_sas_cq *cq = cq_ptr; + struct hisi_sas_cq *cq = debugfs_cq->cq; struct hisi_hba *hisi_hba = cq->hisi_hba; - void *complete_queue = hisi_hba->debugfs_complete_hdr[cq->id]; - __le32 *complete_hdr = complete_queue + - (hisi_hba->hw->complete_hdr_size * slot); + __le32 *complete_hdr = debugfs_cq->complete_hdr + + (hisi_hba->hw->complete_hdr_size * slot); hisi_sas_show_row_32(s, slot, hisi_hba->hw->complete_hdr_size, @@ -3000,11 +3000,11 @@ static void hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr) static int hisi_sas_debugfs_cq_show(struct seq_file *s, void *p) { - struct hisi_sas_cq *cq = s->private; + struct hisi_sas_debugfs_cq *debugfs_cq = s->private; int slot; for (slot = 0; slot < HISI_SAS_QUEUE_SLOTS; slot++) { - hisi_sas_cq_show_slot(s, slot, cq); + hisi_sas_cq_show_slot(s, slot, debugfs_cq); } return 0; } @@ -3227,7 +3227,8 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) for (c = 0; c < hisi_hba->queue_count; c++) { snprintf(name, 256, "%d", c); - debugfs_create_file(name, 0400, dentry, &hisi_hba->cq[c], + debugfs_create_file(name, 0400, dentry, + &hisi_hba->debugfs_cq[c], &hisi_sas_debugfs_cq_fops); } @@ -3714,7 +3715,7 @@ static void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba) devm_kfree(dev, hisi_hba->debugfs_cmd_hdr[i]); for (i = 0; i < hisi_hba->queue_count; i++) - devm_kfree(dev, hisi_hba->debugfs_complete_hdr[i]); + devm_kfree(dev, hisi_hba->debugfs_cq[i].complete_hdr); for (i = 0; i < DEBUGFS_REGS_NUM; i++) devm_kfree(dev, hisi_hba->debugfs_regs[i]); @@ -3762,11 +3763,13 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) sz = hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; for (c = 0; c < hisi_hba->queue_count; c++) { - hisi_hba->debugfs_complete_hdr[c] = - devm_kmalloc(dev, sz, GFP_KERNEL); + struct hisi_sas_debugfs_cq *cq = + &hisi_hba->debugfs_cq[c]; - if (!hisi_hba->debugfs_complete_hdr[c]) + cq->complete_hdr = devm_kmalloc(dev, sz, GFP_KERNEL); + if (!cq->complete_hdr) goto fail; + cq->cq = &hisi_hba->cq[c]; } sz = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS; From patchwork Thu Oct 24 14:08:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177512 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2248911ill; Thu, 24 Oct 2019 07:12:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKdJYKpjtmpDD6VEb7D5vvObhQS6oMc0lxBh7tGGlxkuXi5uhmqQJXTsaAt/xYjAjvL4bh X-Received: by 2002:aa7:cb58:: with SMTP id w24mr43566324edt.158.1571926371410; Thu, 24 Oct 2019 07:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571926371; cv=none; d=google.com; s=arc-20160816; b=w9l0H4L5ermZGCYJhPZhUVsAJOru+NPSZku9UW0GDvF+xfBbU0cr8a5bHNWGW0uJvT vO/qPtlTDS1QW9WrJ+vuExl13v3z89IzNv8MeGST6pmEuYi+wMumBB02RclsHJbIi4ab 8m5M2zhF5gwTRZPs4dPBJb5Sdg1t5zlGrAxDoimVV18d3uLE+bVeFgLnCYifhl6lscq1 v2FpPEyk7VpbgwDOdFA9ScztuyL8MqzJGpnGP9RG/UToqeUUbb9zxjwuZQajONeDQftT 9P5M+ePTLCH/8LDQ9Sf2J3RGkypX56NAddw4W+2yvEeZNideAe+giB1H65FqoDq++8c8 3BaQ== 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=L6QRSdlUgQiWpPsEA1fWH3ajeN3mW+cTYKj+6m8zCKg=; b=W4AEiAD2sVIcMST6z7cL7X6tPoWmqygZKto3k1sMRAJK2gqYNq68TnP86dOV6khW16 TmjaR8dip6F1VIQGFHOlCl99qs/AvZzXbkk6mBZBF4aydEK+aectrYF31Ybrxv+124eB pxXakQ5yK+6bZmEXG4HQr1Zt+kdGzXv2b75VTZ8+3+tBx6ht8+WlR+ufCp81oFJ3Q9d+ UkyXsUqVruKHS9s8ZckkytgKYBEYEWyxghuaOaqjKQ2ki0mzthV3/4lKZQc0rxB5lwzZ KVVyIHLD0ZTDdH9BWXDdNUHRNerq4HJv9U1NTpX1ryWGwTyDoI7rFRTPFWG0N3LD67px sQNg== 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 b53si10588448edb.419.2019.10.24.07.12.51; Thu, 24 Oct 2019 07:12:51 -0700 (PDT) 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 S2502625AbfJXOLr (ORCPT + 26 others); Thu, 24 Oct 2019 10:11:47 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5163 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390869AbfJXOLj (ORCPT ); Thu, 24 Oct 2019 10:11:39 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 665D01499C9B7F39CFD2; Thu, 24 Oct 2019 22:11:35 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Thu, 24 Oct 2019 22:11:25 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH v2 08/18] scsi: hisi_sas: Add debugfs file structure for registers Date: Thu, 24 Oct 2019 22:08:15 +0800 Message-ID: <1571926105-74636-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571926105-74636-1-git-send-email-john.garry@huawei.com> References: <1571926105-74636-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] 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 Create a file structure which was used to save the memory address and hisi_hba pointer for REGS at debugfs. This structure is bound to the corresponding debugfs file, it can help callback function of debugfs file to get what it need. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 7 ++- drivers/scsi/hisi_sas/hisi_sas_main.c | 62 +++++++++++++-------------- 2 files changed, 35 insertions(+), 34 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 91c10be3dfb7..1c01e0e76a0e 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -333,6 +333,11 @@ struct hisi_sas_debugfs_dq { struct hisi_sas_cmd_hdr *hdr; }; +struct hisi_sas_debugfs_regs { + struct hisi_hba *hisi_hba; + u32 *data; +}; + struct hisi_hba { /* This must be the first element, used by SHOST_TO_SAS_HA */ struct sas_ha_struct *p; @@ -414,7 +419,7 @@ struct hisi_hba { /* debugfs memories */ /* Put Global AXI and RAS Register into register array */ - u32 *debugfs_regs[DEBUGFS_REGS_NUM]; + struct hisi_sas_debugfs_regs debugfs_regs[DEBUGFS_REGS_NUM]; u32 *debugfs_port_reg[HISI_SAS_MAX_PHYS]; struct hisi_sas_debugfs_cq debugfs_cq[HISI_SAS_MAX_QUEUES]; struct hisi_sas_debugfs_dq debugfs_dq[HISI_SAS_MAX_QUEUES]; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 647a14983696..92cf9b514a70 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2743,7 +2743,7 @@ static void hisi_sas_debugfs_snapshot_port_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_global_reg(struct hisi_hba *hisi_hba) { - u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_GLOBAL]; + u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_GLOBAL].data; const struct hisi_sas_hw *hw = hisi_hba->hw; const struct hisi_sas_debugfs_reg *global = hw->debugfs_reg_array[DEBUGFS_GLOBAL]; @@ -2755,7 +2755,7 @@ static void hisi_sas_debugfs_snapshot_global_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_axi_reg(struct hisi_hba *hisi_hba) { - u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_AXI]; + u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_AXI].data; const struct hisi_sas_hw *hw = hisi_hba->hw; const struct hisi_sas_debugfs_reg *axi = hw->debugfs_reg_array[DEBUGFS_AXI]; @@ -2768,7 +2768,7 @@ static void hisi_sas_debugfs_snapshot_axi_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_ras_reg(struct hisi_hba *hisi_hba) { - u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_RAS]; + u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_RAS].data; const struct hisi_sas_hw *hw = hisi_hba->hw; const struct hisi_sas_debugfs_reg *ras = hw->debugfs_reg_array[DEBUGFS_RAS]; @@ -2852,11 +2852,12 @@ static void hisi_sas_debugfs_print_reg(u32 *regs_val, const void *ptr, static int hisi_sas_debugfs_global_show(struct seq_file *s, void *p) { - struct hisi_hba *hisi_hba = s->private; + struct hisi_sas_debugfs_regs *global = s->private; + struct hisi_hba *hisi_hba = global->hisi_hba; const struct hisi_sas_hw *hw = hisi_hba->hw; const void *reg_global = hw->debugfs_reg_array[DEBUGFS_GLOBAL]; - hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_GLOBAL], + hisi_sas_debugfs_print_reg(global->data, reg_global, s); return 0; @@ -2878,11 +2879,12 @@ static const struct file_operations hisi_sas_debugfs_global_fops = { static int hisi_sas_debugfs_axi_show(struct seq_file *s, void *p) { - struct hisi_hba *hisi_hba = s->private; + struct hisi_sas_debugfs_regs *axi = s->private; + struct hisi_hba *hisi_hba = axi->hisi_hba; const struct hisi_sas_hw *hw = hisi_hba->hw; const void *reg_axi = hw->debugfs_reg_array[DEBUGFS_AXI]; - hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_AXI], + hisi_sas_debugfs_print_reg(axi->data, reg_axi, s); return 0; @@ -2904,11 +2906,12 @@ static const struct file_operations hisi_sas_debugfs_axi_fops = { static int hisi_sas_debugfs_ras_show(struct seq_file *s, void *p) { - struct hisi_hba *hisi_hba = s->private; + struct hisi_sas_debugfs_regs *ras = s->private; + struct hisi_hba *hisi_hba = ras->hisi_hba; const struct hisi_sas_hw *hw = hisi_hba->hw; const void *reg_ras = hw->debugfs_reg_array[DEBUGFS_RAS]; - hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_RAS], + hisi_sas_debugfs_print_reg(ras->data, reg_ras, s); return 0; @@ -3209,7 +3212,8 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) debugfs_create_u64("timestamp", 0400, dump_dentry, debugfs_timestamp); - debugfs_create_file("global", 0400, dump_dentry, hisi_hba, + debugfs_create_file("global", 0400, dump_dentry, + &hisi_hba->debugfs_regs[DEBUGFS_GLOBAL], &hisi_sas_debugfs_global_fops); /* Create port dir and files */ @@ -3253,10 +3257,12 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) debugfs_create_file("itct_cache", 0400, dump_dentry, hisi_hba, &hisi_sas_debugfs_itct_cache_fops); - debugfs_create_file("axi", 0400, dump_dentry, hisi_hba, + debugfs_create_file("axi", 0400, dump_dentry, + &hisi_hba->debugfs_regs[DEBUGFS_AXI], &hisi_sas_debugfs_axi_fops); - debugfs_create_file("ras", 0400, dump_dentry, hisi_hba, + debugfs_create_file("ras", 0400, dump_dentry, + &hisi_hba->debugfs_regs[DEBUGFS_RAS], &hisi_sas_debugfs_ras_fops); return; @@ -3718,7 +3724,7 @@ static void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba) devm_kfree(dev, hisi_hba->debugfs_cq[i].complete_hdr); for (i = 0; i < DEBUGFS_REGS_NUM; i++) - devm_kfree(dev, hisi_hba->debugfs_regs[i]); + devm_kfree(dev, hisi_hba->debugfs_regs[i].data); for (i = 0; i < hisi_hba->n_phy; i++) devm_kfree(dev, hisi_hba->debugfs_port_reg[i]); @@ -3728,15 +3734,19 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) { const struct hisi_sas_hw *hw = hisi_hba->hw; struct device *dev = hisi_hba->dev; - int p, c, d; + int p, c, d, r; size_t sz; - sz = hw->debugfs_reg_array[DEBUGFS_GLOBAL]->count * 4; - hisi_hba->debugfs_regs[DEBUGFS_GLOBAL] = - devm_kmalloc(dev, sz, GFP_KERNEL); + for (r = 0; r < DEBUGFS_REGS_NUM; r++) { + struct hisi_sas_debugfs_regs *regs = + &hisi_hba->debugfs_regs[r]; - if (!hisi_hba->debugfs_regs[DEBUGFS_GLOBAL]) - goto fail; + sz = hw->debugfs_reg_array[r]->count * 4; + regs->data = devm_kmalloc(dev, sz, GFP_KERNEL); + if (!regs->data) + goto fail; + regs->hisi_hba = hisi_hba; + } sz = hw->debugfs_reg_port->count * 4; for (p = 0; p < hisi_hba->n_phy; p++) { @@ -3747,20 +3757,6 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) goto fail; } - sz = hw->debugfs_reg_array[DEBUGFS_AXI]->count * 4; - hisi_hba->debugfs_regs[DEBUGFS_AXI] = - devm_kmalloc(dev, sz, GFP_KERNEL); - - if (!hisi_hba->debugfs_regs[DEBUGFS_AXI]) - goto fail; - - sz = hw->debugfs_reg_array[DEBUGFS_RAS]->count * 4; - hisi_hba->debugfs_regs[DEBUGFS_RAS] = - devm_kmalloc(dev, sz, GFP_KERNEL); - - if (!hisi_hba->debugfs_regs[DEBUGFS_RAS]) - goto fail; - sz = hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; for (c = 0; c < hisi_hba->queue_count; c++) { struct hisi_sas_debugfs_cq *cq = From patchwork Thu Oct 24 14:08:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177508 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2248067ill; Thu, 24 Oct 2019 07:12:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqydjFtoFvcI94Cjs1ac0ZuwTJ4E/FRTIoepAMwPtlsPcukFLkmLXqbEo0IGFjpKEott3JGZ X-Received: by 2002:a05:6402:21c7:: with SMTP id bi7mr43891014edb.205.1571926334149; Thu, 24 Oct 2019 07:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571926334; cv=none; d=google.com; s=arc-20160816; b=m6fWTHfk0AhIWWCSAfvLqkc2qiTM4IzFMeGJLasz4VbCnQrcQuFxSO8R7gBj+Tg86m IPZhL8tnHVfVJqN72A7NSC7K5wPgGa3NiRm5yAPJeex0A7+2qz8sgqkABgLO8zFM8E2K m/vwMwY1UQa+shqmqeeiIlJGE78kqM6DLo4+xUsYkIUQgWhkO1zfSpF5549IpJmhJDHb pwx37g2r43Ij+46SnYgTBiddbiY3pDjlGDhZmsw/7MT230SQ8/FV9Fvw770r4ImrwLYX 2RhZtk3ATTye+YLxO3q1HyQVvJctb6R0A49DP3JHaA6jG4SftIgeUI0e4MelilJVoIGM eXOA== 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=kg6HHprnIV74Qrd8uf+anUKQ7pnAdXs4thJwJc6fJxY=; b=iuNfH7wkt8xrKiQkrUfO/V06kfki4J2l1nGIvWUNNCXb5g9mrA8jJEO3x9euRqCCfi s5LcFWNEG5DJqbKo7cCNPaJMC7h3W1E2nraNSNcv5T7LXV8cRQPq4Pko7zWjBaAZSs0s dU0jOoA7DguTTfSq+c3GQnv+hyFY9IhjjrXpPt591z/UkV7DLncBrI9uqwEmSOU4L7ez g9CUYqc0qsGVwJqKmWyH+wWmF1dy8OvTX7Yyx1quOXx4kAQNr3eQNb+9Rajd1QJvXBYy wOaWkhbMBmY/QPBn3hpBJLjKkYHuHfNZcKMMRLF4I4q4yEsiDcJ/+O91yJ2QPzqe3ybq iFQw== 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 f1si14829944eje.338.2019.10.24.07.12.13; Thu, 24 Oct 2019 07:12:14 -0700 (PDT) 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 S2502718AbfJXOMF (ORCPT + 26 others); Thu, 24 Oct 2019 10:12:05 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5166 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2502667AbfJXOL6 (ORCPT ); Thu, 24 Oct 2019 10:11:58 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 7C9226AC344EAB312033; Thu, 24 Oct 2019 22:11:35 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Thu, 24 Oct 2019 22:11:26 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH v2 09/18] scsi: hisi_sas: Add debugfs file structure for port Date: Thu, 24 Oct 2019 22:08:16 +0800 Message-ID: <1571926105-74636-10-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571926105-74636-1-git-send-email-john.garry@huawei.com> References: <1571926105-74636-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] 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 Create a file structure which was used to save the memory address and phy pointer for port at debugfs. This structure is bound to the corresponding debugfs file, it can help callback function of debugfs file to get what it need. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 7 ++++++- drivers/scsi/hisi_sas/hisi_sas_main.c | 21 ++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 1c01e0e76a0e..af5f836e5807 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -338,6 +338,11 @@ struct hisi_sas_debugfs_regs { u32 *data; }; +struct hisi_sas_debugfs_port { + struct hisi_sas_phy *phy; + u32 *data; +}; + struct hisi_hba { /* This must be the first element, used by SHOST_TO_SAS_HA */ struct sas_ha_struct *p; @@ -420,7 +425,7 @@ struct hisi_hba { /* debugfs memories */ /* Put Global AXI and RAS Register into register array */ struct hisi_sas_debugfs_regs debugfs_regs[DEBUGFS_REGS_NUM]; - u32 *debugfs_port_reg[HISI_SAS_MAX_PHYS]; + struct hisi_sas_debugfs_port debugfs_port_reg[HISI_SAS_MAX_PHYS]; struct hisi_sas_debugfs_cq debugfs_cq[HISI_SAS_MAX_QUEUES]; struct hisi_sas_debugfs_dq debugfs_dq[HISI_SAS_MAX_QUEUES]; struct hisi_sas_iost *debugfs_iost; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 92cf9b514a70..e28aa3d517da 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2732,7 +2732,7 @@ static void hisi_sas_debugfs_snapshot_port_reg(struct hisi_hba *hisi_hba) u32 *databuf; for (phy_cnt = 0; phy_cnt < hisi_hba->n_phy; phy_cnt++) { - databuf = (u32 *)hisi_hba->debugfs_port_reg[phy_cnt]; + databuf = hisi_hba->debugfs_port_reg[phy_cnt].data; for (i = 0; i < port->count; i++, databuf++) { offset = port->base_off + 4 * i; *databuf = port->read_port_reg(hisi_hba, phy_cnt, @@ -2933,13 +2933,13 @@ static const struct file_operations hisi_sas_debugfs_ras_fops = { static int hisi_sas_debugfs_port_show(struct seq_file *s, void *p) { - struct hisi_sas_phy *phy = s->private; + struct hisi_sas_debugfs_port *port = s->private; + struct hisi_sas_phy *phy = port->phy; struct hisi_hba *hisi_hba = phy->hisi_hba; const struct hisi_sas_hw *hw = hisi_hba->hw; const struct hisi_sas_debugfs_reg *reg_port = hw->debugfs_reg_port; - u32 *databuf = hisi_hba->debugfs_port_reg[phy->sas_phy.id]; - hisi_sas_debugfs_print_reg(databuf, reg_port, s); + hisi_sas_debugfs_print_reg(port->data, reg_port, s); return 0; } @@ -3221,7 +3221,8 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) for (p = 0; p < hisi_hba->n_phy; p++) { snprintf(name, 256, "%d", p); - debugfs_create_file(name, 0400, dentry, &hisi_hba->phy[p], + debugfs_create_file(name, 0400, dentry, + &hisi_hba->debugfs_port_reg[p], &hisi_sas_debugfs_port_fops); } @@ -3727,7 +3728,7 @@ static void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba) devm_kfree(dev, hisi_hba->debugfs_regs[i].data); for (i = 0; i < hisi_hba->n_phy; i++) - devm_kfree(dev, hisi_hba->debugfs_port_reg[i]); + devm_kfree(dev, hisi_hba->debugfs_port_reg[i].data); } static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) @@ -3750,11 +3751,13 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) sz = hw->debugfs_reg_port->count * 4; for (p = 0; p < hisi_hba->n_phy; p++) { - hisi_hba->debugfs_port_reg[p] = - devm_kmalloc(dev, sz, GFP_KERNEL); + struct hisi_sas_debugfs_port *port = + &hisi_hba->debugfs_port_reg[p]; - if (!hisi_hba->debugfs_port_reg[p]) + port->data = devm_kmalloc(dev, sz, GFP_KERNEL); + if (!port->data) goto fail; + port->phy = &hisi_hba->phy[p]; } sz = hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; From patchwork Thu Oct 24 14:08:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177515 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2249361ill; Thu, 24 Oct 2019 07:13:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwF9oy68wVezt9L7JdfswKsApDgjnQ0TK4HAlvKjTjn5kA+g/r+Zq5yLbHNy+5eU0dNlkoS X-Received: by 2002:a05:6402:1255:: with SMTP id l21mr30419240edw.41.1571926390180; Thu, 24 Oct 2019 07:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571926390; cv=none; d=google.com; s=arc-20160816; b=lyitu7RGec/Ztp2YFz5ZlnigGyJmkDJ/C0P7cncR6Do4g+MjthnLbn/ePtlNTgSKqa u2keWzpoz84Cv7Ko+K2vJPMGsZvWAb8PDJuXIczsMvKyvklrARMYDmr3RwyjI1kR/WuY fqgerZO0ljw1RMBnv9CgswxDf7PJcWukvGn+B4MXrfBjjUQs1iTlenU+QKdiyxWoVySp 6uvUcfW5AEjbkwDcSEi+qjsodSgf0plhakaBe6/HrWyUCgc6BmilGkltrmm1gJaWX9RC KNM9aLud8Uan3zTiLE3viYOSsDRP06++hKfeixJfEvVdq4lEW0ib+u89u/JKI45UKr/k lk+A== 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=YV0r69tKm7ReTEhDeGNCeS6AQJO+bz/YkWBe/LvCAlE=; b=d3JqrEd9NKaP4QY4tQ+8LFqfpmi309UUFoHTtkCqjRXz5yYX62Eiw6tHmuDm/aLuN6 dVC2UXBD1V1EIyw38fWBju7CRc5kWmzzOT37iGBV9nOG1a+CgURaWt2cBMHCCH3v9hob oQ1G2Nj9VPoUcNW8nHEX5z8Vwa2U27yIMZLhT3uCkzG084fGdiR+q1L/u3Vx06JJqPPV s6Fq36jqMZviKwaA9xjLu8BnMlsLF3EP+uFD8S8Jj0cwFgo0ds4qYjH8TkRJpAZWUp61 BlL7spHSad1xPVKtzNU5RA0uJMwf9rbXLDoGEkYEsVs9lesutaQ3DpNeKRyl5tgGjXGv UF8A== 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 q17si11416150edc.6.2019.10.24.07.13.09; Thu, 24 Oct 2019 07:13:10 -0700 (PDT) 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 S2502593AbfJXOLn (ORCPT + 26 others); Thu, 24 Oct 2019 10:11:43 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5160 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2393687AbfJXOLl (ORCPT ); Thu, 24 Oct 2019 10:11:41 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 5B33FF7F16871DCC4F29; Thu, 24 Oct 2019 22:11:35 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Thu, 24 Oct 2019 22:11:26 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH v2 11/18] scsi: hisi_sas: Add debugfs file structure for ITCT Date: Thu, 24 Oct 2019 22:08:18 +0800 Message-ID: <1571926105-74636-12-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571926105-74636-1-git-send-email-john.garry@huawei.com> References: <1571926105-74636-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] 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 Create a file structure which was used to save the memory address for ITCT at debugfs. This structure is bound to the corresponding debugfs file, it can help callback function of debugfs file to get what it need. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 6 +++++- drivers/scsi/hisi_sas/hisi_sas_main.c | 23 ++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index c4bcaa5aff8a..f42f1b34f843 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -347,6 +347,10 @@ struct hisi_sas_debugfs_iost { struct hisi_sas_iost *iost; }; +struct hisi_sas_debugfs_itct { + struct hisi_sas_itct *itct; +}; + struct hisi_hba { /* This must be the first element, used by SHOST_TO_SAS_HA */ struct sas_ha_struct *p; @@ -433,7 +437,7 @@ struct hisi_hba { struct hisi_sas_debugfs_cq debugfs_cq[HISI_SAS_MAX_QUEUES]; struct hisi_sas_debugfs_dq debugfs_dq[HISI_SAS_MAX_QUEUES]; struct hisi_sas_debugfs_iost debugfs_iost; - struct hisi_sas_itct *debugfs_itct; + struct hisi_sas_debugfs_itct debugfs_itct; u64 *debugfs_iost_cache; u64 debugfs_timestamp; u64 *debugfs_itct_cache; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 55191056f37f..a35d3a76ac11 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1573,7 +1573,7 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba) struct Scsi_Host *shost = hisi_hba->shost; int rc; - if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct) + if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct.itct) queue_work(hisi_hba->wq, &hisi_hba->debugfs_work); if (!hisi_hba->hw->soft_reset) @@ -2065,7 +2065,7 @@ _hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba, /* Internal abort timed out */ if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { - if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct) + if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct.itct) queue_work(hisi_hba->wq, &hisi_hba->debugfs_work); if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { @@ -2782,7 +2782,7 @@ static void hisi_sas_debugfs_snapshot_ras_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_itct_reg(struct hisi_hba *hisi_hba) { void *cachebuf = hisi_hba->debugfs_itct_cache; - void *databuf = hisi_hba->debugfs_itct; + void *databuf = hisi_hba->debugfs_itct.itct; struct hisi_sas_itct *itct; int i; @@ -3129,13 +3129,13 @@ static const struct file_operations hisi_sas_debugfs_iost_cache_fops = { static int hisi_sas_debugfs_itct_show(struct seq_file *s, void *p) { int i; - struct hisi_hba *hisi_hba = s->private; - struct hisi_sas_itct *debugfs_itct = hisi_hba->debugfs_itct; + struct hisi_sas_debugfs_itct *debugfs_itct = s->private; + struct hisi_sas_itct *itct = debugfs_itct->itct; - for (i = 0; i < HISI_SAS_MAX_ITCT_ENTRIES; i++, debugfs_itct++) { - __le64 *itct = &debugfs_itct->qw0; + for (i = 0; i < HISI_SAS_MAX_ITCT_ENTRIES; i++, itct++) { + __le64 *data = &itct->qw0; - hisi_sas_show_row_64(s, i, sizeof(*debugfs_itct), itct); + hisi_sas_show_row_64(s, i, sizeof(*itct), data); } return 0; @@ -3253,7 +3253,8 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) debugfs_create_file("iost_cache", 0400, dump_dentry, hisi_hba, &hisi_sas_debugfs_iost_cache_fops); - debugfs_create_file("itct", 0400, dump_dentry, hisi_hba, + debugfs_create_file("itct", 0400, dump_dentry, + &hisi_hba->debugfs_itct, &hisi_sas_debugfs_itct_fops); debugfs_create_file("itct_cache", 0400, dump_dentry, hisi_hba, @@ -3806,8 +3807,8 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) /* New memory allocation must be locate before itct */ sz = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_itct); - hisi_hba->debugfs_itct = devm_kmalloc(dev, sz, GFP_KERNEL); - if (!hisi_hba->debugfs_itct) + hisi_hba->debugfs_itct.itct = devm_kmalloc(dev, sz, GFP_KERNEL); + if (!hisi_hba->debugfs_itct.itct) goto fail; return 0; From patchwork Thu Oct 24 14:08:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177506 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2247649ill; Thu, 24 Oct 2019 07:11:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtUXgQQ9nIUAwIwTdf2FFkt9nqtE1xa0Tc4eEFswxVgb58dUbsm9TIR6qPzA5L7WZ+zPcr X-Received: by 2002:a50:9930:: with SMTP id k45mr14514973edb.134.1571926317821; Thu, 24 Oct 2019 07:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571926317; cv=none; d=google.com; s=arc-20160816; b=aIWvkPtp/h/vjXgmfVMlBW8IMDEyiCmYSzuMo4+CW/4Y3dgRe4o+dCvj7oraem8Ser EnJ7r5WnJwOPxoLYnNCjyX97pplyZbTVwMfgLayWQT2/WBW7lL1yTFtJ6WwwwKKL/9D+ rSnzKck5OYhxTwQ7z7dVYC6gluNHlaq4hQioD5WQgSuQZ8EapfBIviXZRkWV4wnfh99Q IoO3/0DOTfKg0encIU6IlssuqNynLgX1ZZI1CYLHpWt9iRj2vt4R49qEc7tDwrzMz7GO 7xaE6/ZADVekDgm4WBY8SAZJNiHdVO6d9VOdY+Ai1m5ihAEsQMkUgLH+6eghJZrpgPN0 I0vA== 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=oae9ng6uOw77in3fXlQperKvk029cA2UvT8QaZLP3r0=; b=orokUZr+rzt+b3nogtV88eJRlU57tWhm/r7Pi1DWJbJGE1p6lDnH1aOQjtyC4RkAig kKJvuMlbH32AeqxXSIEIn9OX9gdv0tsVaA/B6isVwRIhc0ZdjY++F7om3zEnhVn2OntT lGKLzVEdLHNmVpPN2uC/9H4PJGxesJMwgrjjMoJyKSaFnjEwkr0sorl1L4Fmq+RqyG/N cG3vjOvIGy9T63iV8tyRxd5k1uSaHJP8WPlbimrIZWtD67Eyqw3KPHopyIaph8FJTxFC loiSXj8WQ4VRXcuO7APTiOSFRbOykkzLz6iFyPqxqIdfcFlH6nws7rX1G6/B6YJ+3GnN cmKg== 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 ha5si652079ejb.329.2019.10.24.07.11.57; Thu, 24 Oct 2019 07:11:57 -0700 (PDT) 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 S2502660AbfJXOLw (ORCPT + 26 others); Thu, 24 Oct 2019 10:11:52 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5168 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2502311AbfJXOLn (ORCPT ); Thu, 24 Oct 2019 10:11:43 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 87A609AA9AABC151AA19; Thu, 24 Oct 2019 22:11:35 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Thu, 24 Oct 2019 22:11:27 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH v2 12/18] scsi: hisi_sas: Add debugfs file structure for IOST cache Date: Thu, 24 Oct 2019 22:08:19 +0800 Message-ID: <1571926105-74636-13-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571926105-74636-1-git-send-email-john.garry@huawei.com> References: <1571926105-74636-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] 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 Create a file structure which was used to save the memory address for IOST cache at debugfs. This structure is bound to the corresponding debugfs file, it can help callback function of debugfs file to get what it need. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 6 +++++- drivers/scsi/hisi_sas/hisi_sas_main.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index f42f1b34f843..4e32d1b77d16 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -351,6 +351,10 @@ struct hisi_sas_debugfs_itct { struct hisi_sas_itct *itct; }; +struct hisi_sas_debugfs_iost_cache { + struct hisi_sas_iost_itct_cache *cache; +}; + struct hisi_hba { /* This must be the first element, used by SHOST_TO_SAS_HA */ struct sas_ha_struct *p; @@ -438,8 +442,8 @@ struct hisi_hba { struct hisi_sas_debugfs_dq debugfs_dq[HISI_SAS_MAX_QUEUES]; struct hisi_sas_debugfs_iost debugfs_iost; struct hisi_sas_debugfs_itct debugfs_itct; - u64 *debugfs_iost_cache; u64 debugfs_timestamp; + struct hisi_sas_debugfs_iost_cache debugfs_iost_cache; u64 *debugfs_itct_cache; struct dentry *debugfs_dir; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index a35d3a76ac11..499a733f9a5a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2800,7 +2800,7 @@ static void hisi_sas_debugfs_snapshot_itct_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_iost_reg(struct hisi_hba *hisi_hba) { int max_command_entries = HISI_SAS_MAX_COMMANDS; - void *cachebuf = hisi_hba->debugfs_iost_cache; + void *cachebuf = hisi_hba->debugfs_iost_cache.cache; void *databuf = hisi_hba->debugfs_iost.iost; struct hisi_sas_iost *iost; int i; @@ -3088,9 +3088,8 @@ static const struct file_operations hisi_sas_debugfs_iost_fops = { static int hisi_sas_debugfs_iost_cache_show(struct seq_file *s, void *p) { - struct hisi_hba *hisi_hba = s->private; - struct hisi_sas_iost_itct_cache *iost_cache = - (struct hisi_sas_iost_itct_cache *)hisi_hba->debugfs_iost_cache; + struct hisi_sas_debugfs_iost_cache *debugfs_iost_cache = s->private; + struct hisi_sas_iost_itct_cache *iost_cache = debugfs_iost_cache->cache; u32 cache_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ * 4; int i, tab_idx; __le64 *iost; @@ -3250,7 +3249,8 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) &hisi_hba->debugfs_iost, &hisi_sas_debugfs_iost_fops); - debugfs_create_file("iost_cache", 0400, dump_dentry, hisi_hba, + debugfs_create_file("iost_cache", 0400, dump_dentry, + &hisi_hba->debugfs_iost_cache, &hisi_sas_debugfs_iost_cache_fops); debugfs_create_file("itct", 0400, dump_dentry, @@ -3716,7 +3716,7 @@ static void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba) struct device *dev = hisi_hba->dev; int i; - devm_kfree(dev, hisi_hba->debugfs_iost_cache); + devm_kfree(dev, hisi_hba->debugfs_iost_cache.cache); devm_kfree(dev, hisi_hba->debugfs_itct_cache); devm_kfree(dev, hisi_hba->debugfs_iost.iost); @@ -3793,8 +3793,8 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) sz = HISI_SAS_IOST_ITCT_CACHE_NUM * sizeof(struct hisi_sas_iost_itct_cache); - hisi_hba->debugfs_iost_cache = devm_kmalloc(dev, sz, GFP_KERNEL); - if (!hisi_hba->debugfs_iost_cache) + hisi_hba->debugfs_iost_cache.cache = devm_kmalloc(dev, sz, GFP_KERNEL); + if (!hisi_hba->debugfs_iost_cache.cache) goto fail; sz = HISI_SAS_IOST_ITCT_CACHE_NUM * From patchwork Thu Oct 24 14:08:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177513 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2249199ill; Thu, 24 Oct 2019 07:13:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWJC7k6vyflT/Sl1jiJ6fq7+Z7MeoQqqW4KBwCrhtHty036NrnJ7EJ4aeyHG6y6h37Xsr4 X-Received: by 2002:a17:906:1d59:: with SMTP id o25mr3106454ejh.115.1571926383309; Thu, 24 Oct 2019 07:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571926383; cv=none; d=google.com; s=arc-20160816; b=IEzAQTUXWUMS0csMpOsrhURRt6SQKQV+FK4Sup8Igcb8vlHBcJv6OOi9KQUk7AXcpC V5qUl/jx0JQcPVB4L0J+iEelnsDnOztggCM2+vL7hgym5HR0WeiK9JJlW+JIby2vv2jK D+188b6MpXWALPB5gx1bNNIfONInnDrgD9XHj3KUIx4RA/pF8alnBJo/upDbUuV/RKDY kSOFQqXAy7qew9gsf+euF3pijPxPz97vCH78JOJgTt6/GpWgmQLT9u04rT/wTr27iG+Z FUNsMb5vsydTCiSvcJZ/oCMqCnx+5A/4SgVbz1KEFLCn8HaXYHoKn5Kjg7AkABMaCPVG G8WQ== 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=eRxKZHpBE5G6cJqnFaoAeqNP+tWxjCa25EPzM8k3J80=; b=MTcJHdm1oZV5m3OXEGUkRWQqYN6Z7FBVpGBArGy/zT30br7Ld4wdSRr8MOWhcioBbM Ng2aoUKSjcYqQk+MbaHSO0I+IcPu8Ai40zHcbs7qc2kLbqyNxxIW97aZT+2r3mgBZ9uB G0DmjsUyVSuzX3FFWllIluqL9KioKvFQHUOf4C5UOb+kNNjf9mpyjeoOS/c6s8ofgL2z 2QfQmtgCWICXWBSiftc0C84NR++f3mIFs0eai6cAFS42WQUM8ty+P2qJmCsoWGr846ST KzFyhyqptU2FqUraR4341vlpFlYSzAKPncWqavGLmu7Izx4Vym0jqVCrN7NaUfbkm8Kn mO+w== 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 c13si702273edk.4.2019.10.24.07.13.03; Thu, 24 Oct 2019 07:13:03 -0700 (PDT) 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 S2502608AbfJXOLp (ORCPT + 26 others); Thu, 24 Oct 2019 10:11:45 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5164 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2391351AbfJXOLk (ORCPT ); Thu, 24 Oct 2019 10:11:40 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 75F7ACC1A99828294657; Thu, 24 Oct 2019 22:11:35 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Thu, 24 Oct 2019 22:11:27 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH v2 13/18] scsi: hisi_sas: Add debugfs file structure for ITCT cache Date: Thu, 24 Oct 2019 22:08:20 +0800 Message-ID: <1571926105-74636-14-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571926105-74636-1-git-send-email-john.garry@huawei.com> References: <1571926105-74636-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] 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 Create a file structure which was used to save the memory address for ITCT cache at debugfs. This structure is bound to the corresponding debugfs file, it can help callback function of debugfs file to get what it need. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 6 +++++- drivers/scsi/hisi_sas/hisi_sas_main.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 4e32d1b77d16..a608b2bef0b4 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -355,6 +355,10 @@ struct hisi_sas_debugfs_iost_cache { struct hisi_sas_iost_itct_cache *cache; }; +struct hisi_sas_debugfs_itct_cache { + struct hisi_sas_iost_itct_cache *cache; +}; + struct hisi_hba { /* This must be the first element, used by SHOST_TO_SAS_HA */ struct sas_ha_struct *p; @@ -444,7 +448,7 @@ struct hisi_hba { struct hisi_sas_debugfs_itct debugfs_itct; u64 debugfs_timestamp; struct hisi_sas_debugfs_iost_cache debugfs_iost_cache; - u64 *debugfs_itct_cache; + struct hisi_sas_debugfs_itct_cache debugfs_itct_cache; struct dentry *debugfs_dir; struct dentry *debugfs_dump_dentry; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 499a733f9a5a..5014a7a21aa4 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2781,7 +2781,7 @@ static void hisi_sas_debugfs_snapshot_ras_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_itct_reg(struct hisi_hba *hisi_hba) { - void *cachebuf = hisi_hba->debugfs_itct_cache; + void *cachebuf = hisi_hba->debugfs_itct_cache.cache; void *databuf = hisi_hba->debugfs_itct.itct; struct hisi_sas_itct *itct; int i; @@ -3155,9 +3155,8 @@ static const struct file_operations hisi_sas_debugfs_itct_fops = { static int hisi_sas_debugfs_itct_cache_show(struct seq_file *s, void *p) { - struct hisi_hba *hisi_hba = s->private; - struct hisi_sas_iost_itct_cache *itct_cache = - (struct hisi_sas_iost_itct_cache *)hisi_hba->debugfs_itct_cache; + struct hisi_sas_debugfs_itct_cache *debugfs_itct_cache = s->private; + struct hisi_sas_iost_itct_cache *itct_cache = debugfs_itct_cache->cache; u32 cache_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ * 4; int i, tab_idx; __le64 *itct; @@ -3257,7 +3256,8 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) &hisi_hba->debugfs_itct, &hisi_sas_debugfs_itct_fops); - debugfs_create_file("itct_cache", 0400, dump_dentry, hisi_hba, + debugfs_create_file("itct_cache", 0400, dump_dentry, + &hisi_hba->debugfs_itct_cache, &hisi_sas_debugfs_itct_cache_fops); debugfs_create_file("axi", 0400, dump_dentry, @@ -3717,7 +3717,7 @@ static void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba) int i; devm_kfree(dev, hisi_hba->debugfs_iost_cache.cache); - devm_kfree(dev, hisi_hba->debugfs_itct_cache); + devm_kfree(dev, hisi_hba->debugfs_itct_cache.cache); devm_kfree(dev, hisi_hba->debugfs_iost.iost); for (i = 0; i < hisi_hba->queue_count; i++) @@ -3800,8 +3800,8 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) sz = HISI_SAS_IOST_ITCT_CACHE_NUM * sizeof(struct hisi_sas_iost_itct_cache); - hisi_hba->debugfs_itct_cache = devm_kmalloc(dev, sz, GFP_KERNEL); - if (!hisi_hba->debugfs_itct_cache) + hisi_hba->debugfs_itct_cache.cache = devm_kmalloc(dev, sz, GFP_KERNEL); + if (!hisi_hba->debugfs_itct_cache.cache) goto fail; /* New memory allocation must be locate before itct */ From patchwork Thu Oct 24 14:08:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177505 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2247499ill; Thu, 24 Oct 2019 07:11:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbL20wSMbTPjSUzSoM5tTvk9lnZbQGdjuBznd8QL7ZAmOVwEVf9iDnGHT5365eMwu/reJD X-Received: by 2002:a17:906:3488:: with SMTP id g8mr37626948ejb.162.1571926311409; Thu, 24 Oct 2019 07:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571926311; cv=none; d=google.com; s=arc-20160816; b=i9v2cqT6xcCNBhPmSE/y4yqxtctBvvoXAdz5mToOrsgw/NV4VclWUCgJhGPyvBHfet gR1fMjqgBihMUAw4rFlDhdmklzJa+zNML7ob/bh0cH1aro6jTpsbioQT7ff7JYAG7+ZD GR6CLnsTA6Xw1mOKnQJgv4Qfz0AT5LgsyUsplXWGd06KxHLQBFbGaGg83iU8e8IT8hV2 12uUjRLYDzrV0ccKy7LVwga2zonuWQbHVjV/fznKmDTMhNNHvr4sAOJ4S4A5W1gjVgYF +6A6NFWvrtnJlpZ13T0GlOAmryLjjv6ZjvrbcWUbEHk8z+EG0tHgJgIzpABxWmf9PRgn fRCQ== 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=AbruiQlIq/coRJya0uzBZCTZyat5bRkf5vytwWCjYb8=; b=Tz8rUq72mFT0nfnTVkNrKwlJ3wLukmxoKNctK2Ieq2Vw372guy8wANUtth5ImoOO1P bTyCOugB4f8wI42Mbn1I5DHLne1fRYgrJLWDbgfTeoYDTmPOwNtud5pLg4m9NmetB7IH gE1qClnE+alIEdlhV284hOufNRja62/n1i6LeiGADyQI95azrfeX8ydOwhM5e4A3mU2n zX1pwOsAPPo1mYJzyC4lkdiCaqow/DUGDZrMCA2kf8jPOY8xVrC9dsCpmyd3a4Tep6eF VksW5h8rMoE++xrLpayFvm5D4vgQSG8mqIlGb2eebIrWQo5FYtZmnVQVkaOFH1cNdLmw CEMQ== 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 p16si15198398ejj.360.2019.10.24.07.11.51; Thu, 24 Oct 2019 07:11:51 -0700 (PDT) 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 S2502646AbfJXOLt (ORCPT + 26 others); Thu, 24 Oct 2019 10:11:49 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5161 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2391409AbfJXOLn (ORCPT ); Thu, 24 Oct 2019 10:11:43 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 60E745363B7315A47AA4; Thu, 24 Oct 2019 22:11:35 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Thu, 24 Oct 2019 22:11:29 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH v2 18/18] scsi: hisi_sas: Record the phy down event in debugfs Date: Thu, 24 Oct 2019 22:08:25 +0800 Message-ID: <1571926105-74636-19-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571926105-74636-1-git-send-email-john.garry@huawei.com> References: <1571926105-74636-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] 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 The number of phy down reflects the quality of the link between SAS controller and disk. In order to allow the user to confirm the link quality of the system, we record the number of phy down for each phy. The user can check the current phy down count by reading the debugfs file corresponding to the specific phy, or clear the phy down count by writing 0 to the debugfs file. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 1 + drivers/scsi/hisi_sas/hisi_sas_main.c | 63 ++++++++++++++++++++++++++ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 + 3 files changed, 66 insertions(+) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 72823222e08f..233c73e01246 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -169,6 +169,7 @@ struct hisi_sas_phy { enum sas_linkrate minimum_linkrate; enum sas_linkrate maximum_linkrate; int enable; + atomic_t down_cnt; }; struct hisi_sas_port { diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 669ad7463615..18c95b33592b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -3705,6 +3705,52 @@ static const struct file_operations hisi_sas_debugfs_bist_enable_ops = { .owner = THIS_MODULE, }; +static ssize_t hisi_sas_debugfs_phy_down_cnt_write(struct file *filp, + const char __user *buf, + size_t count, loff_t *ppos) +{ + struct seq_file *s = filp->private_data; + struct hisi_sas_phy *phy = s->private; + unsigned int set_val; + int res; + + res = kstrtouint_from_user(buf, count, 0, &set_val); + if (res) + return res; + + if (set_val > 0) + return -EINVAL; + + atomic_set(&phy->down_cnt, 0); + + return count; +} + +static int hisi_sas_debugfs_phy_down_cnt_show(struct seq_file *s, void *p) +{ + struct hisi_sas_phy *phy = s->private; + + seq_printf(s, "%d\n", atomic_read(&phy->down_cnt)); + + return 0; +} + +static int hisi_sas_debugfs_phy_down_cnt_open(struct inode *inode, + struct file *filp) +{ + return single_open(filp, hisi_sas_debugfs_phy_down_cnt_show, + inode->i_private); +} + +static const struct file_operations hisi_sas_debugfs_phy_down_cnt_ops = { + .open = hisi_sas_debugfs_phy_down_cnt_open, + .read = seq_read, + .write = hisi_sas_debugfs_phy_down_cnt_write, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, +}; + void hisi_sas_debugfs_work_handler(struct work_struct *work) { struct hisi_hba *hisi_hba = @@ -3839,6 +3885,21 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba, int dump_index) return -ENOMEM; } +static void hisi_sas_debugfs_phy_down_cnt_init(struct hisi_hba *hisi_hba) +{ + struct dentry *dir = debugfs_create_dir("phy_down_cnt", + hisi_hba->debugfs_dir); + char name[16]; + int phy_no; + + for (phy_no = 0; phy_no < hisi_hba->n_phy; phy_no++) { + snprintf(name, 16, "%d", phy_no); + debugfs_create_file(name, 0600, dir, + &hisi_hba->phy[phy_no], + &hisi_sas_debugfs_phy_down_cnt_ops); + } +} + static void hisi_sas_debugfs_bist_init(struct hisi_hba *hisi_hba) { hisi_hba->debugfs_bist_dentry = @@ -3885,6 +3946,8 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) hisi_hba->debugfs_dump_dentry = debugfs_create_dir("dump", hisi_hba->debugfs_dir); + hisi_sas_debugfs_phy_down_cnt_init(hisi_hba); + for (i = 0; i < hisi_sas_debugfs_dump_count; i++) { if (hisi_sas_debugfs_alloc(hisi_hba, i)) { debugfs_remove_recursive(hisi_hba->debugfs_dir); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index e4da309009c0..2ae7070db41a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1549,6 +1549,8 @@ static irqreturn_t phy_down_v3_hw(int phy_no, struct hisi_hba *hisi_hba) u32 phy_state, sl_ctrl, txid_auto; struct device *dev = hisi_hba->dev; + atomic_inc(&phy->down_cnt); + del_timer(&phy->timer); hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 1);