From patchwork Mon Oct 21 16:22:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177101 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3635132ill; Mon, 21 Oct 2019 09:25:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHECfbDVBIFPHrW0ALjQF0D3rbRLzCx0ZnPx9hpIElLpVqXsXWFA7J384a7htkrl1iGbmL X-Received: by 2002:a17:906:8488:: with SMTP id m8mr1653720ejx.15.1571675131901; Mon, 21 Oct 2019 09:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571675131; cv=none; d=google.com; s=arc-20160816; b=HEpngxKIpOyUQC7aauE/xOPRQwMYCEKEEgxZ+zD35dprwtNWNVI3ZfSgCidNHm/wm6 B66AdgY2ghudJcEo3OeAVx4YiVDxPRlkAgg0uHAeAj+LjSvAmoevpmMMbTsvMn7uKxUP sRF1JXJrlUHiglroJ5q8gYHhb3FyQoqYUAF+8joYiZDl23yKZ9VZaHFAYLw7k5fxPE5i 5yzGADBuXBxyOagdcQrU4PNWM4jcVY3KxBts9lt3UsvZv3fO0HjkP+JMFVWfpp1EKLJ3 ZOkwWQ+Lqkxuz65GABEhQmxrUjgXUIn+crKrrmzzF3naTYzEuof9fGv7XzXpQm/IT8YD 29uQ== 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=HpxDLPEQaxvmDoIvaik5rVJTO59InNKNGfAx7yLLqYE=; b=LSKcOzPtOiFpnJuJ+SP0PpN9H5Q14vvIClDkLx+sg7qEAUrny0JDtzAY0pI8LahEuT 9DyV5DYWmgPpT8Wix7HYOWeT6PTgteIcDrBSdz4BFO0xzlkVZ1E7YY8j+Ebw4E1tgQ6/ mIo2nEidWoXcvcCIZCk496Hx+aLU/l8TVAr0RmF1iEWvPJJ/p20iLsKtIIUZNAnhgUlZ h3+iet47BI/7lVRrt5BpEhRLv0rPl0V8xuQUcvxqe/OHUM2o3KkxANejW4iPFLeFpoPd LdgatO2Y914aCmmnyQoGfsMj8ue48VloAYLMMAICqZ3nbOzEr1J1lt0D2bV9zRbwfpli WIhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 w43si10892760edd.332.2019.10.21.09.25.31 for ; Mon, 21 Oct 2019 09:25:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728897AbfJUQZ2 (ORCPT ); Mon, 21 Oct 2019 12:25:28 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33120 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728375AbfJUQZ2 (ORCPT ); Mon, 21 Oct 2019 12:25:28 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E182BFD05BB0DD40C6F4; Tue, 22 Oct 2019 00:25:24 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Tue, 22 Oct 2019 00:25:17 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 03/18] scsi: hisi_sas: use wait_for_completion_timeout() when clearing ITCT Date: Tue, 22 Oct 2019 00:22:00 +0800 Message-ID: <1571674935-108326-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571674935-108326-1-git-send-email-john.garry@huawei.com> References: <1571674935-108326-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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Xiang Chen When injecting 2bit ecc errors, it will cause confusion inside SAS controller which needs host reset to recover it. If a device is gone at the same times inject 2bit ecc errors, we may not receive the ITCT interrupt so it will wait for completion in clear_itct_v3_hw() all the time. And host reset will also not occur because it can't require hisi_hba->sem, so the system will be suspended. To solve the issue, use wait_for_completion_timeout() instead of wait_for_completion(), and also don't mark the gone device as SAS_PHY_UNUSED when device gone. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 5 +++-- drivers/scsi/hisi_sas/hisi_sas_main.c | 8 ++++++-- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 6 ++++-- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 13 ++++++++++--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 13 ++++++++++--- 5 files changed, 33 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 720c4d6be939..83232e8472fb 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -84,6 +84,7 @@ #define HISI_SAS_PROT_MASK (HISI_SAS_DIF_PROT_MASK | HISI_SAS_DIX_PROT_MASK) #define HISI_SAS_WAIT_PHYUP_TIMEOUT 20 +#define CLEAR_ITCT_TIMEOUT 20 struct hisi_hba; @@ -296,8 +297,8 @@ struct hisi_sas_hw { void (*phy_set_linkrate)(struct hisi_hba *hisi_hba, int phy_no, struct sas_phy_linkrates *linkrates); enum sas_linkrate (*phy_get_max_linkrate)(void); - void (*clear_itct)(struct hisi_hba *hisi_hba, - struct hisi_sas_device *dev); + int (*clear_itct)(struct hisi_hba *hisi_hba, + struct hisi_sas_device *dev); void (*free_device)(struct hisi_sas_device *sas_dev); int (*get_wideport_bitmap)(struct hisi_hba *hisi_hba, int port_id); void (*dereg_device)(struct hisi_hba *hisi_hba, diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index ceba1016b77f..621eebbeacd6 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1045,6 +1045,7 @@ static void hisi_sas_dev_gone(struct domain_device *device) struct hisi_sas_device *sas_dev = device->lldd_dev; struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); struct device *dev = hisi_hba->dev; + int ret = 0; dev_info(dev, "dev[%d:%x] is gone\n", sas_dev->device_id, sas_dev->dev_type); @@ -1056,13 +1057,16 @@ static void hisi_sas_dev_gone(struct domain_device *device) hisi_sas_dereg_device(hisi_hba, device); - hisi_hba->hw->clear_itct(hisi_hba, sas_dev); + ret = hisi_hba->hw->clear_itct(hisi_hba, sas_dev); device->lldd_dev = NULL; } if (hisi_hba->hw->free_device) hisi_hba->hw->free_device(sas_dev); - sas_dev->dev_type = SAS_PHY_UNUSED; + + /* Don't mark it as SAS_PHY_UNUSED if failed to clear ITCT */ + if (!ret) + sas_dev->dev_type = SAS_PHY_UNUSED; sas_dev->sas_device = NULL; up(&hisi_hba->sem); } diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index b861a0f14c9d..3af53cc42bd6 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -531,8 +531,8 @@ static void setup_itct_v1_hw(struct hisi_hba *hisi_hba, (0xff00ULL << ITCT_HDR_REJ_OPEN_TL_OFF)); } -static void clear_itct_v1_hw(struct hisi_hba *hisi_hba, - struct hisi_sas_device *sas_dev) +static int clear_itct_v1_hw(struct hisi_hba *hisi_hba, + struct hisi_sas_device *sas_dev) { u64 dev_id = sas_dev->device_id; struct hisi_sas_itct *itct = &hisi_hba->itct[dev_id]; @@ -551,6 +551,8 @@ static void clear_itct_v1_hw(struct hisi_hba *hisi_hba, qw0 = le64_to_cpu(itct->qw0); qw0 &= ~ITCT_HDR_VALID_MSK; itct->qw0 = cpu_to_le64(qw0); + + return 0; } static int reset_hw_v1_hw(struct hisi_hba *hisi_hba) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 8e96a257e439..61b1e2693b08 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -974,13 +974,14 @@ static void setup_itct_v2_hw(struct hisi_hba *hisi_hba, (0x1ULL << ITCT_HDR_RTOLT_OFF)); } -static void clear_itct_v2_hw(struct hisi_hba *hisi_hba, - struct hisi_sas_device *sas_dev) +static int clear_itct_v2_hw(struct hisi_hba *hisi_hba, + struct hisi_sas_device *sas_dev) { DECLARE_COMPLETION_ONSTACK(completion); u64 dev_id = sas_dev->device_id; struct hisi_sas_itct *itct = &hisi_hba->itct[dev_id]; u32 reg_val = hisi_sas_read32(hisi_hba, ENT_INT_SRC3); + struct device *dev = hisi_hba->dev; int i; sas_dev->completion = &completion; @@ -990,13 +991,19 @@ static void clear_itct_v2_hw(struct hisi_hba *hisi_hba, hisi_sas_write32(hisi_hba, ENT_INT_SRC3, ENT_INT_SRC3_ITC_INT_MSK); + /* need to set register twice to clear ITCT for v2 hw */ for (i = 0; i < 2; i++) { reg_val = ITCT_CLR_EN_MSK | (dev_id & ITCT_DEV_MSK); hisi_sas_write32(hisi_hba, ITCT_CLR, reg_val); - wait_for_completion(sas_dev->completion); + if (!wait_for_completion_timeout(sas_dev->completion, + CLEAR_ITCT_TIMEOUT * HZ)) { + dev_warn(dev, "failed to clear ITCT\n"); + return -ETIMEDOUT; + } memset(itct, 0, sizeof(struct hisi_sas_itct)); } + return 0; } static void free_device_v2_hw(struct hisi_sas_device *sas_dev) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index cc594937fa8d..19a8cfeb8f6e 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -795,13 +795,14 @@ static void setup_itct_v3_hw(struct hisi_hba *hisi_hba, (0x1ULL << ITCT_HDR_RTOLT_OFF)); } -static void clear_itct_v3_hw(struct hisi_hba *hisi_hba, - struct hisi_sas_device *sas_dev) +static int clear_itct_v3_hw(struct hisi_hba *hisi_hba, + struct hisi_sas_device *sas_dev) { DECLARE_COMPLETION_ONSTACK(completion); u64 dev_id = sas_dev->device_id; struct hisi_sas_itct *itct = &hisi_hba->itct[dev_id]; u32 reg_val = hisi_sas_read32(hisi_hba, ENT_INT_SRC3); + struct device *dev = hisi_hba->dev; sas_dev->completion = &completion; @@ -814,8 +815,14 @@ static void clear_itct_v3_hw(struct hisi_hba *hisi_hba, reg_val = ITCT_CLR_EN_MSK | (dev_id & ITCT_DEV_MSK); hisi_sas_write32(hisi_hba, ITCT_CLR, reg_val); - wait_for_completion(sas_dev->completion); + if (!wait_for_completion_timeout(sas_dev->completion, + CLEAR_ITCT_TIMEOUT * HZ)) { + dev_warn(dev, "failed to clear ITCT\n"); + return -ETIMEDOUT; + } + memset(itct, 0, sizeof(struct hisi_sas_itct)); + return 0; } static void dereg_device_v3_hw(struct hisi_hba *hisi_hba, From patchwork Mon Oct 21 16:22:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177118 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3636558ill; Mon, 21 Oct 2019 09:26:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4skD4+zGxFNsOAQsFnBcbgU2xDxQiQ45J+vy2MOO+axLUy6dJtOosqGUtJnr1Y3Hw/kfy X-Received: by 2002:a17:906:118d:: with SMTP id n13mr2249331eja.229.1571675200694; Mon, 21 Oct 2019 09:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571675200; cv=none; d=google.com; s=arc-20160816; b=s57QwjPaFs1TFepEzGIJ0T+o95UnwP4WmjKRQvJtMZ8jj615KxGobDB9oSAQscYg8w oc+ttifHHMmS2sTFrZJC28zcPkw5g6B3GyRLOnnFug+P5VzGRL2DtlylOis2vN6T+VU9 lymJOEGDPvdbU0UYo58HI3YPElaZdjz5SpwF+m4szqk/9BhLjqDE5Sr/QQHaykew22uz Kk9A6os9HI8uOhLYiivzdnhbkuMRfaoHVMRfAvTYo9d/KYWuRjtggmuCJ2ajfwZETb1J 5r1A9nFy5yKPqCvdoiUidMwWUFodVLOwJXkSeRtvPEGXEd6jOjD3dtsYXqyfWikJpTiX C0lg== 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=G2P3hn8+vmRvhKGGAJmggp/kwH2ayjQf2uQdv6Dq+Mo=; b=uEEld/utliBuy92CGLobgcqGAYSLz3rVBhcK+/SKumhidHe29k9j0SP6zMq7J8EzI0 n36meE7RSnj4Vgqt8L/mSYswzy9bRC7UJCSK2ExjmRkfg0Duvcnx02f3PZBo5X+8RvFa +exvgQBxhH1C/c3DQTN/ZYm2z9QfG86rSCP58+DHDNn5Melz651iEuZZB5JU3dHNyKkM Jm9NtzZfAUW/kwaUX+8tm+BsAufd2lEmznlUOWZF50dJfNrYWF5eCE+yS5LDiKJDpbzY 8wHMnoTqWPcKV6WRLuAkFESZ6y7q0x2jz5T81j/UUwRrutD/Xt8cWgjBJ3DqBe9tDFa4 Bivg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 w32si1309364edc.443.2019.10.21.09.26.40 for ; Mon, 21 Oct 2019 09:26:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727822AbfJUQ0g (ORCPT ); Mon, 21 Oct 2019 12:26:36 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33126 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728292AbfJUQZ1 (ORCPT ); Mon, 21 Oct 2019 12:25:27 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0583C20F66B56A14DC87; Tue, 22 Oct 2019 00:25:25 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Tue, 22 Oct 2019 00:25:18 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 05/18] scsi: hisi_sas: Add timestamp for a debugfs dump Date: Tue, 22 Oct 2019 00:22:02 +0800 Message-ID: <1571674935-108326-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571674935-108326-1-git-send-email-john.garry@huawei.com> References: <1571674935-108326-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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Luo Jiaxing It's useful to know when the dump occurred, so add a timestamp file for this. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 2 ++ drivers/scsi/hisi_sas/hisi_sas_main.c | 7 +++++++ 2 files changed, 9 insertions(+) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 83232e8472fb..7069dae4cec9 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -410,6 +411,7 @@ struct hisi_hba { struct hisi_sas_iost *debugfs_iost; struct hisi_sas_itct *debugfs_itct; u64 *debugfs_iost_cache; + u64 debugfs_timestamp; 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 a7bac5dc389a..a983d08c03aa 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -3194,6 +3194,7 @@ static const struct file_operations hisi_sas_debugfs_itct_cache_fops = { static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) { + u64 *debugfs_timestamp; struct dentry *dump_dentry; struct dentry *dentry; char name[256]; @@ -3201,10 +3202,14 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) int c; int d; + debugfs_timestamp = &hisi_hba->debugfs_timestamp; /* Create dump dir inside device dir */ dump_dentry = debugfs_create_dir("dump", hisi_hba->debugfs_dir); hisi_hba->debugfs_dump_dentry = dump_dentry; + debugfs_create_u64("timestamp", 0400, dump_dentry, + debugfs_timestamp); + debugfs_create_file("global", 0400, dump_dentry, hisi_hba, &hisi_sas_debugfs_global_fops); @@ -3684,7 +3689,9 @@ void hisi_sas_debugfs_work_handler(struct work_struct *work) { struct hisi_hba *hisi_hba = container_of(work, struct hisi_hba, debugfs_work); + u64 timestamp = local_clock() / NSEC_PER_MSEC; + hisi_hba->debugfs_timestamp = timestamp; if (hisi_hba->debugfs_snapshot) return; hisi_hba->debugfs_snapshot = true; From patchwork Mon Oct 21 16:22:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177114 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3636054ill; Mon, 21 Oct 2019 09:26:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzK0DMtPRGhhNJG2CZnBMouQXh6I7YzK/kkBYO+uCbftaQjYzBSxQfnhrfLbjSAsryBgHZZ X-Received: by 2002:a50:fb0d:: with SMTP id d13mr2832890edq.200.1571675176129; Mon, 21 Oct 2019 09:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571675176; cv=none; d=google.com; s=arc-20160816; b=JG6S3ZZxGtLDsG840RYugyydkIdwO0RX2NPHv4IgI3Rm6MIfGvehLrntfi3l5arXO9 NclOs6/oz+hj+tTDPIKWZXJs64VjSdH0Sg7WvTXX3Bw6vS5C87hnLU8RGWRsunM/uOVq mh+jtAJiQJAB7Qrbhx9atFyYAnH1VWK7K3nO/SB+Ueuz1CDFTcuP/VOKZrBfbnhWZ/TI JXNvJXHpuaRaCurdDNEejmVXz7budRRdCDRwUL99AnSJZdrEo/njvWb3peD9m1qLNz4w PWUlFoa+2kjmwkQ9YyBroQEWxS6arZFUlYOZm26+cpENrrA2PiACWOsHhzl9R8UU+WSG i8Wg== 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=TrMJ9WWIbFdii90dP49jZ/djd1gN43fklX8XCtE+nwk=; b=b9QdwOuUjL+kmNP23ctbZYvddPrS5CxA7tgb8UEmC3UNeUzDkzKvrcCwBpOPnI1j3Z /6UdSrpLwfArSihjKO2651vWN9BixPAxOGNAhy7ZOYheyKfMNK2ICbnRkhcYMYDmvHuQ AaRprGU5HLC4u1H4bcpKvyWHHzjGOcoowBBKqdDXqAE7Si1oOfYerCKqKlIgx8gyWsB4 US/ZG+p+a5IHhnOUaz96ZqYBbJKR+HV56EurTNfjL3Dgmk+laCy3L8GhsbRbVWoNPJkt SgXnL0LDvcx6MsWAgE735h4QSvL2hIe9ndTW7Hp0R0qQ8LxISh0lJQosnU9lfxxN8pWj bqOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 b16si9058399ejb.165.2019.10.21.09.26.15 for ; Mon, 21 Oct 2019 09:26:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730037AbfJUQ0O (ORCPT ); Mon, 21 Oct 2019 12:26:14 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33168 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728639AbfJUQZ3 (ORCPT ); Mon, 21 Oct 2019 12:25:29 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 00945D827347EB20B329; Tue, 22 Oct 2019 00:25:25 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Tue, 22 Oct 2019 00:25:18 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 06/18] scsi: hisi_sas: Add debugfs file structure for CQ Date: Tue, 22 Oct 2019 00:22:03 +0800 Message-ID: <1571674935-108326-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571674935-108326-1-git-send-email-john.garry@huawei.com> References: <1571674935-108326-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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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 a983d08c03aa..d2e50d12e075 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); } @@ -3713,7 +3714,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]); @@ -3761,11 +3762,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 Mon Oct 21 16:22:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177116 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3636076ill; Mon, 21 Oct 2019 09:26:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2eCIZhtoKLn557h53IOtCs887r8LKwUyebb019UNKLxR9RFxa88UCH/mGSkQLQS0B/Eio X-Received: by 2002:a17:906:4488:: with SMTP id y8mr11588724ejo.322.1571675176778; Mon, 21 Oct 2019 09:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571675176; cv=none; d=google.com; s=arc-20160816; b=ZeHxYxeDdVCcggcWpXPRPforXHRYRjcuJi1BlAAyCdgP28EoGbTFgo/VFOK0iVWMBI kcTxlGFhWo7tSRBI0iaR7/Ftggoq1I59wmotIJYH69XsdUawhPcHXqr9+osa80XeMEv6 rabvx05JxfOLOJQONaS6LJO8pg7FLX+aUirtAb68HQnc3z5irP7XiePDQnkW2Ghf3OHM xd1TTTDyiPlw6dNqmSAtyBwZT7DOwS98WzzM074gIuXWzHAtpzGQf5EdymhCaUmzZENr 7eQ93DVq9xydJm5lj7OfN7SyUfU0UCUULP8/A5ANpmCuobhIj0J0xdRFkKQVdWM8H31J TNwQ== 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=HXDOFHBjfzInTccnbyaX9Qmh6EAzrcCSBdX5FOBIJDY=; b=FFPcf4VVW1k5mTXFoNI1yv3rNi45YavmVxnmaXl7+sdJif/ETeXCHnThLw3PaGJDS4 GC5nwH+53snntWHxiFlDnX17pyuZP+W2bnH4xnIyzmDFpVrLfk8o+uhS6jmybCcYZf8P ZCq0kIiELRGEEEn4foC95L9cTA37PClI2Bx9anESsONmrfVY6dXVLsqFUPOO+f1D0n1B ZKcIQ/aIKPAxw0Cc/oHDyYep/NcKxbXaZ9fWFgjQ+Aa85ZJfMJCALh8XlqIKdTPKHftd OsVCd50r3HEqkOzMFLa6lk5X8fSLbinuDiStFO6Y/gGiKW9O2YHyniJZDTxxtg9c0XtV D1Ig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 b16si9058399ejb.165.2019.10.21.09.26.16 for ; Mon, 21 Oct 2019 09:26:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728776AbfJUQ0P (ORCPT ); Mon, 21 Oct 2019 12:26:15 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33166 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727303AbfJUQZ3 (ORCPT ); Mon, 21 Oct 2019 12:25:29 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0F7AA335752A7A844510; Tue, 22 Oct 2019 00:25:25 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Tue, 22 Oct 2019 00:25:18 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 07/18] scsi: hisi_sas: Add debugfs file structure for DQ Date: Tue, 22 Oct 2019 00:22:04 +0800 Message-ID: <1571674935-108326-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571674935-108326-1-git-send-email-john.garry@huawei.com> References: <1571674935-108326-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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Luo Jiaxing Create a file structure which was used to save the memory address and DQ pointer for DQ 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 | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 5b0f08286af7..91c10be3dfb7 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -328,6 +328,11 @@ struct hisi_sas_debugfs_cq { void *complete_hdr; }; +struct hisi_sas_debugfs_dq { + struct hisi_sas_dq *dq; + struct hisi_sas_cmd_hdr *hdr; +}; + struct hisi_hba { /* This must be the first element, used by SHOST_TO_SAS_HA */ struct sas_ha_struct *p; @@ -412,7 +417,7 @@ struct hisi_hba { u32 *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_cmd_hdr *debugfs_cmd_hdr[HISI_SAS_MAX_QUEUES]; + struct hisi_sas_debugfs_dq debugfs_dq[HISI_SAS_MAX_QUEUES]; struct hisi_sas_iost *debugfs_iost; struct hisi_sas_itct *debugfs_itct; u64 *debugfs_iost_cache; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index d2e50d12e075..d28461e65bde 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2711,10 +2711,10 @@ static void hisi_sas_debugfs_snapshot_dq_reg(struct hisi_hba *hisi_hba) int i; for (i = 0; i < hisi_hba->queue_count; i++) { - struct hisi_sas_cmd_hdr *debugfs_cmd_hdr, *cmd_hdr; + struct hisi_sas_cmd_hdr *debugfs_cmd_hdr, *cmd_hdr; int j; - debugfs_cmd_hdr = hisi_hba->debugfs_cmd_hdr[i]; + debugfs_cmd_hdr = hisi_hba->debugfs_dq[i].hdr; cmd_hdr = hisi_hba->cmd_hdr[i]; for (j = 0; j < HISI_SAS_QUEUE_SLOTS; j++) @@ -3024,9 +3024,8 @@ static const struct file_operations hisi_sas_debugfs_cq_fops = { static void hisi_sas_dq_show_slot(struct seq_file *s, int slot, void *dq_ptr) { - struct hisi_sas_dq *dq = dq_ptr; - struct hisi_hba *hisi_hba = dq->hisi_hba; - void *cmd_queue = hisi_hba->debugfs_cmd_hdr[dq->id]; + struct hisi_sas_debugfs_dq *debugfs_dq = dq_ptr; + void *cmd_queue = debugfs_dq->hdr; __le32 *cmd_hdr = cmd_queue + sizeof(struct hisi_sas_cmd_hdr) * slot; @@ -3237,7 +3236,8 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) for (d = 0; d < hisi_hba->queue_count; d++) { snprintf(name, 256, "%d", d); - debugfs_create_file(name, 0400, dentry, &hisi_hba->dq[d], + debugfs_create_file(name, 0400, dentry, + &hisi_hba->debugfs_dq[d], &hisi_sas_debugfs_dq_fops); } @@ -3711,7 +3711,7 @@ static void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba) devm_kfree(dev, hisi_hba->debugfs_iost); for (i = 0; i < hisi_hba->queue_count; i++) - devm_kfree(dev, hisi_hba->debugfs_cmd_hdr[i]); + devm_kfree(dev, hisi_hba->debugfs_dq[i].hdr); for (i = 0; i < hisi_hba->queue_count; i++) devm_kfree(dev, hisi_hba->debugfs_cq[i].complete_hdr); @@ -3773,11 +3773,13 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) sz = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS; for (d = 0; d < hisi_hba->queue_count; d++) { - hisi_hba->debugfs_cmd_hdr[d] = - devm_kmalloc(dev, sz, GFP_KERNEL); + struct hisi_sas_debugfs_dq *dq = + &hisi_hba->debugfs_dq[d]; - if (!hisi_hba->debugfs_cmd_hdr[d]) + dq->hdr = devm_kmalloc(dev, sz, GFP_KERNEL); + if (!dq->hdr) goto fail; + dq->dq = &hisi_hba->dq[d]; } sz = HISI_SAS_MAX_COMMANDS * sizeof(struct hisi_sas_iost); From patchwork Mon Oct 21 16:22:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177115 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3636067ill; Mon, 21 Oct 2019 09:26:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0KaEsUuwYIAsXzPFdq98r0Dh2kLmqLiKxXG5LgMqSuxgOBXCoegmzFFWyANcN8fBEFd8r X-Received: by 2002:a17:906:19cf:: with SMTP id h15mr23718626ejd.184.1571675176467; Mon, 21 Oct 2019 09:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571675176; cv=none; d=google.com; s=arc-20160816; b=sGb5kTdXfDr4z3pllaUFevpK3FpXaH1MS473oK69GbJ8CpdLrBQjdkcQ8nA11eb7B3 zUGaPNAO6PfGCVmh3Re5rQKYg8zYsMMZjDAbLm9p0a7qIJBQbmAOOSqU0bInX8yEYFfb 94dmyCh3hXxVJty5olHWmlOzQl2Df6pEkf5wTu+mAnbXx5+pwV1aGIlP6MqirSmlDu1k V3vDGOgCm4ZA1i9QjiKSDXv4pdjD426c9/OAzeCWyDrjhnwbckW3d2C425yAzuZ3L83Y snVJrbTM0Ek8NTebf2zHM1SvN1ce9i3FyP59GSH2M2SytJoFWHt2x6iepTe9t9Fmx4iC 97cg== 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=aNJeZXwg0QUWq2ewHNdOtTb1cO4GW5Ye0QfqEuqinbA=; b=giwNf/QcS2P30SZAeJpGk/2L5BrV0HP1wSKTHoLzSjF3W19e4ohY8PfWH96L0f9NJC Fr83pjLb7WUxhFnUy366vYmsvRCsQKyKCEdgtck1vo0fejtfTPWuwq2ty4J0ISluyQy3 iltLRcAimnrVThBeNdyMAfVFA/gHiTOhi6xzCEeZiEJFAHE84rUrx5raxDMjR0NqfGCC sSccKqNz5LSba6af8//gKMuXSV2KWS7urBFyXAKjCLFnni35DbUN2r2t8o08sxkQrWS0 Opafn1rPl6h1IhN/iwRfOkXJQI8vgbj/xvx3mFbn2Z7llJCQB9h7bzmCKwA0QFcO76dJ YKBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 b16si9058399ejb.165.2019.10.21.09.26.16 for ; Mon, 21 Oct 2019 09:26:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730042AbfJUQ0P (ORCPT ); Mon, 21 Oct 2019 12:26:15 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33164 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728565AbfJUQZ3 (ORCPT ); Mon, 21 Oct 2019 12:25:29 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0A19F4DC16E510E604D3; Tue, 22 Oct 2019 00:25:25 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Tue, 22 Oct 2019 00:25:18 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 08/18] scsi: hisi_sas: Add debugfs file structure for registers Date: Tue, 22 Oct 2019 00:22:05 +0800 Message-ID: <1571674935-108326-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571674935-108326-1-git-send-email-john.garry@huawei.com> References: <1571674935-108326-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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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 d28461e65bde..2553fb75c2ca 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; @@ -3717,7 +3723,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]); @@ -3727,15 +3733,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++) { @@ -3746,20 +3756,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 Mon Oct 21 16:22:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177111 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3635810ill; Mon, 21 Oct 2019 09:26:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyB9+Fi3GZi2sWjjguDoNJMpZC2nNTZaAKNKPuHxQHW3TcreOWHmFNaHhjZ0F6t6jSNVxoA X-Received: by 2002:a17:906:684:: with SMTP id u4mr22185037ejb.155.1571675165857; Mon, 21 Oct 2019 09:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571675165; cv=none; d=google.com; s=arc-20160816; b=lxs321H8IEkk7QdbDSc0zKTcb/BucuQ2tDL47rMcj59F2DR+rLSGVYokJcXlSrk27z ED0d2Cosw2OcFXJAtZeO33lFRcNusrrRbDcWCvM9j1cqoovo2kqU8WzvacNBL/IBKWLv sEhwWzSPGgs1irbUu857mYVkqirml7oawuechmXL29+/DG67dBqEpzEAZuXBGHa2QdET +eaT9BdZADYba0L2HPHNfDbMpQ1mwOfSTYNUBnGP/bhGxm/5TrpDjLWLlBLYN7A53XCf cOCZDtJbN3OwTs2gmY4wnJ2hBOYJxwxWpfLXZi7CAjq6wPHzvxty+bOUF1kv3F6iehxr F04g== 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=qslrKfCapNdx8Yqf8ksrDGadY3rUcTdwf4NcoIWit34=; b=vs82EMmgWtWPWPyqSihElGdu8+kSxeoldEKMIz5GwD2X2z+WrsBGBSysC18gwQBTq/ Bb4EciryxbFCFvJw7rXTPOkjRmdtnVau9ELc2Sn91FFtraL3mbC8Po5vfSiBhWTb54ZN 6rdUuXvrYlE6DlDo+47fiL7RoLd/S9Ra5OIf6x9PsBI+vE4HMGrftWwbxu/mpi4az3vf KTDzDTAmh9iZpua6wzS/lOl31WMRO0BHs3RSoqjDIOIzOK7prQ6Ff4xchEtOOV2zgq7v JC4iIYOix/7KAUj8n5nSkqFL00mg4lO8CdWFt3kSL1JmMjbtPNvdIMBvsNOUF7MpOIis JMCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 31si5715841edq.208.2019.10.21.09.26.05 for ; Mon, 21 Oct 2019 09:26:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727017AbfJUQ0C (ORCPT ); Mon, 21 Oct 2019 12:26:02 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:36362 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729725AbfJUQZg (ORCPT ); Mon, 21 Oct 2019 12:25:36 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 04EB91C6F7191697085A; Tue, 22 Oct 2019 00:25:30 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Tue, 22 Oct 2019 00:25:19 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 11/18] scsi: hisi_sas: Add debugfs file structure for ITCT Date: Tue, 22 Oct 2019 00:22:08 +0800 Message-ID: <1571674935-108326-12-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571674935-108326-1-git-send-email-john.garry@huawei.com> References: <1571674935-108326-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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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 0d647ffef06e..20fc122e3d04 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, @@ -3805,8 +3806,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;