From patchwork Fri Sep 6 12:55:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 173232 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp600604oce; Fri, 6 Sep 2019 05:58:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWYQzcumwBMO8hdVe7c+CGemDChL6pe3tW6/6A6dfpp4t7Gh+7bpmUSuE+mjck3sCjUAiV X-Received: by 2002:a17:90a:2e15:: with SMTP id q21mr9377370pjd.97.1567774726706; Fri, 06 Sep 2019 05:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567774726; cv=none; d=google.com; s=arc-20160816; b=Njt/5hPJ4PzGZcpmHk16E5+gG60DvPcHxz4S0S6qo0xlXbhpnAVF7qUkWbeMzSrTZl EuwtY8KuaMSYuwHrPjk6GeS4KaxfuMfrZuvg1dF2+nSapg7oRqlrmJx0crPE2n1cHjmb jRkwB4E4aN7Q05es7IOp7BaXlf6TvesKlzWtBkxJgj9j0hV7XhgBn9rokOZny/Tm1UBO A+fNtlDfFjGsBzuzvIPM8lm55PYx6QpHoccFqtMpLmKlvuW7bLm6W8K0DUmvk/Ev/Fws sKvOQQCNo2vUcbl4LVAJxPdsxaJdG4FRQvcigaqbkWdyqXPbgo4gHys0Cfr6I3YnLZaL dgxA== 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=QlCfALBHhwKKCPLF16qvRjc2w4ZU/eoZL5Lky4tXDT0=; b=MQWDY67K0wnhOx4G8cWHuptY5a2b0nqPdXvnjaEIw5SZoGciyNq2CdMpYSVmPL3S/m PstCzRV7kJYOSXW/5DRGP1TU0w4h3OUhtrNECigpbsdjDNLbpmsl/VnicP3lf1qxXhra AiZf9dy5GPe+24WT054eMig8csy3vZWL/bdrtCLEaLNc16zG4gmmt9sJ2j0OEAllW6La 2grkl1JWJZ1Q1A/vHLQzX3Fqtpima+TvzKRsDKj/fgZ4O/5O5QXfbcx5r7rysmoQISFV A7IJo8moXnfuwldCX5sIzFdl1vDN9I21kVjoyWruEvvCxXPMwFWIgj/P6zHnSnpKlaMA twgA== 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 s5si4862251pjk.68.2019.09.06.05.58.46; Fri, 06 Sep 2019 05:58:46 -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 S2404996AbfIFM6p (ORCPT + 28 others); Fri, 6 Sep 2019 08:58:45 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7136 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404933AbfIFM6R (ORCPT ); Fri, 6 Sep 2019 08:58:17 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E0459D1663D03E407419; Fri, 6 Sep 2019 20:58:10 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Fri, 6 Sep 2019 20:58:02 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 04/13] scsi: hisi_sas: Remove sleep after issue phy reset if sas_smp_phy_control() fails Date: Fri, 6 Sep 2019 20:55:28 +0800 Message-ID: <1567774537-20003-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1567774537-20003-1-git-send-email-john.garry@huawei.com> References: <1567774537-20003-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing At expander environment, we delay after issue phy reset to wait for hardware to handle phy reset. But if sas_smp_phy_control() fails, the delay is unnecessary so remove it. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 5642c53cccae..247268983df9 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1791,9 +1791,10 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device) } else if (sas_dev->dev_status != HISI_SAS_DEV_INIT) { /* * If in init state, we rely on caller to wait for link to be - * ready; otherwise, delay. + * ready; otherwise, except phy reset is fail, delay. */ - msleep(2000); + if (!rc) + msleep(2000); } return rc; From patchwork Fri Sep 6 12:55:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 173235 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp600917oce; Fri, 6 Sep 2019 05:59:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuWi1qAFXHgV2k5u+5xfxCmZhB7OvX0yaKqbPUD+TjLmgUQi9bOSSB4DY1YHJAtl0HfT3Q X-Received: by 2002:a17:90b:f12:: with SMTP id br18mr9046275pjb.127.1567774748002; Fri, 06 Sep 2019 05:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567774747; cv=none; d=google.com; s=arc-20160816; b=Ljdo7yAOvr0R1pXXk70Rdsw2k/OQLaFqPUMsSkf5sdTQPb5Z0pmuS0mVsgehrDZ/tp TsQC1P2aIv8MCUNBAsQV9YMtf0kvU9CbzTEdsidZv1t7yyUMxSSgsIaDZIhlH70Ld+Zp US2G57O/g26Uil4OQOGMesJC7XB+pvME5o4UtMTflZ70aoEv0wf+aakwyzM9+qjAU5cM V0ScozSZ/gM4glzgzgTVScqW05SVJaFTabA+0GOo91On81qiclR27YrnAG2v292MuUvi rADwAe90o5Iov+3oVUgSxPZnOfJyeXnIdLWO30BLBByNnPtvi3Ifd87flFDiIOPJTjhP zbXw== 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=OI+3Gkj8g/75qk8NLN66MI+GjocoRcwYX+8hl8FoL+E=; b=YUhCp3z6+G6R9Sus/cuXXMf7PhxA6JMMpBmbk7muj96BbDbv5D7TEqZUITFAOisfcn Kkarwc602jelvVmA0sNU9IANDV9+U6O3gGPuCxqng9dROhhEzwyEWEvpxP8xiDbZLGLc izUQNI1GZY1e+LWxUrNxTalIwSCXJhAosECVwzpv72BanDBuQ1P6ro5mEqHGpn/XosY3 O58xImQaa8xlgrwjPgrXSBNJarm4r00szZhxbM6xz9rUc4AZIgb1+jT7LAfxbSieyuMX fluWcBv2tkHatZnssvdeKm5DNIbzIZgxweOIFKgZ4NGI+cP0xyJMn58DP14I3qe86K6h AtSQ== 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 132si4334929pgc.134.2019.09.06.05.59.07; Fri, 06 Sep 2019 05:59:07 -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 S2405055AbfIFM7H (ORCPT + 28 others); Fri, 6 Sep 2019 08:59:07 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7135 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404905AbfIFM6O (ORCPT ); Fri, 6 Sep 2019 08:58:14 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id DBDFB2FA6EC3306F9B8B; Fri, 6 Sep 2019 20:58:10 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Fri, 6 Sep 2019 20:58:02 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 05/13] scsi: hisi_sas: Retry 3 times TMF IO for SAS disks when init device Date: Fri, 6 Sep 2019 20:55:29 +0800 Message-ID: <1567774537-20003-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1567774537-20003-1-git-send-email-john.garry@huawei.com> References: <1567774537-20003-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen When init device for SAS disks, it will send TMF IO to clear disks. At that times TMF IO is broken by some operations such as injecting controller reset from HW RAs event, the TMF IO will be timeout, and at last device will be gone. Print is as followed: hisi_sas_v3_hw 0000:74:02.0: dev[240:1] found ... hisi_sas_v3_hw 0000:74:02.0: controller resetting... hisi_sas_v3_hw 0000:74:02.0: phyup: phy7 link_rate=10(sata) hisi_sas_v3_hw 0000:74:02.0: phyup: phy0 link_rate=9(sata) hisi_sas_v3_hw 0000:74:02.0: phyup: phy1 link_rate=9(sata) hisi_sas_v3_hw 0000:74:02.0: phyup: phy2 link_rate=9(sata) hisi_sas_v3_hw 0000:74:02.0: phyup: phy3 link_rate=9(sata) hisi_sas_v3_hw 0000:74:02.0: phyup: phy6 link_rate=10(sata) hisi_sas_v3_hw 0000:74:02.0: phyup: phy5 link_rate=11 hisi_sas_v3_hw 0000:74:02.0: phyup: phy4 link_rate=11 hisi_sas_v3_hw 0000:74:02.0: controller reset complete hisi_sas_v3_hw 0000:74:02.0: abort tmf: TMF task timeout and not done hisi_sas_v3_hw 0000:74:02.0: dev[240:1] is gone sas: driver on host 0000:74:02.0 cannot handle device 5000c500a75a860d, error:5 To improve the reliability, retry TMF IO max of 3 times for SAS disks which is the same as softreset does. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 247268983df9..4c279a285c20 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -698,13 +698,13 @@ static struct hisi_sas_device *hisi_sas_alloc_dev(struct domain_device *device) return sas_dev; } -#define HISI_SAS_SRST_ATA_DISK_CNT 3 +#define HISI_SAS_DISK_RECOVER_CNT 3 static int hisi_sas_init_device(struct domain_device *device) { int rc = TMF_RESP_FUNC_COMPLETE; struct scsi_lun lun; struct hisi_sas_tmf_task tmf_task; - int retry = HISI_SAS_SRST_ATA_DISK_CNT; + int retry = HISI_SAS_DISK_RECOVER_CNT; struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); struct device *dev = hisi_hba->dev; struct sas_phy *local_phy; @@ -714,10 +714,14 @@ static int hisi_sas_init_device(struct domain_device *device) int_to_scsilun(0, &lun); tmf_task.tmf = TMF_CLEAR_TASK_SET; - rc = hisi_sas_debug_issue_ssp_tmf(device, lun.scsi_lun, - &tmf_task); - if (rc == TMF_RESP_FUNC_COMPLETE) - hisi_sas_release_task(hisi_hba, device); + while (retry-- > 0) { + rc = hisi_sas_debug_issue_ssp_tmf(device, lun.scsi_lun, + &tmf_task); + if (rc == TMF_RESP_FUNC_COMPLETE) { + hisi_sas_release_task(hisi_hba, device); + break; + } + } break; case SAS_SATA_DEV: case SAS_SATA_PM: From patchwork Fri Sep 6 12:55:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 173230 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp600335oce; Fri, 6 Sep 2019 05:58:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsZ6olchs/ssCjyXU+qq+S/7513h9iCi16hriq5GA1lM/un8ESxvWsV8Eg+L4WHqm/6+8H X-Received: by 2002:a17:902:6a8c:: with SMTP id n12mr8937972plk.159.1567774710417; Fri, 06 Sep 2019 05:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567774710; cv=none; d=google.com; s=arc-20160816; b=KBk+XlDpIPW959mYqtozRFi5sXrL4a9RV7HkJ87qH0uBOwy2WaZ1sZBLb/G3YlFhvW l/lIKyqUlIuVWFz5Lcb4YJWvmCd6CDuEYv8rCHxPDaIFEOgwQT8ZHxiSoOTTs+lVg/uc eDrGvS/NnzQkXvAL8V+bJVt1/ARtb/SO5sJEk63rsZQfpsfPkRzxB/EQtax5uw7hF/tC vetmnhYtvuFRLaGZkvE9WW9PZJC82UamttjInqmPcFUhbJzWdLE+KEHkItrnfX1MT2Bw 64RV1/pKelHDxc81vUbUDcJKYLOpdgjsrLggC5RH1egHVmNYlrZuSvIfdtnST85XAPK+ QgZA== 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=IdPBJG2qB3w0InA68TKnfwJYnQQyYumICE2+M8H9vOk=; b=PVZ29WihBd4qOc3sNJrZlY8pZUFlKfBHSZhYApa4GXYFP9RzyVRDRUYxuXbTGwCpl2 RpAvQanTqOV0b/XpmRLLkA3x64XNDmhEuZEgs5S0z+Sj6Lg4UEgLdfJfrtJhmE1wFLcy 2dqx9b0Ew4pXJX3+Klo813QM7UPHdl0O72MRVjnbqjzW4jzS49itUVMLKPutNyNE393o IAmNm57v8Cd8dL6a40AkAcyHpMuZSid+qhxC6eGhtSBI0h10rkMFLPUxqbgzOBebMBSY 658oFZ1aH2sdxm7uDhE2jY68clvmfkqHiIVZWvMs+WQDkTSFxRSY8Ox2APud5nzqZYYd 4yAw== 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 76si4555379pgh.564.2019.09.06.05.58.30; Fri, 06 Sep 2019 05:58:30 -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 S2404966AbfIFM62 (ORCPT + 28 others); Fri, 6 Sep 2019 08:58:28 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7138 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404920AbfIFM6R (ORCPT ); Fri, 6 Sep 2019 08:58:17 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E81A1300CF5314035A46; Fri, 6 Sep 2019 20:58:10 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Fri, 6 Sep 2019 20:58:02 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 06/13] scsi: hisi_sas: Update all the registers after suspend and resume Date: Fri, 6 Sep 2019 20:55:30 +0800 Message-ID: <1567774537-20003-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1567774537-20003-1-git-send-email-john.garry@huawei.com> References: <1567774537-20003-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen After suspend and resume, the HW registers will be set back to their initial value. We use init_reg_v3_hw() to set some registers, but some registers are set via firmware in ACPI "_RST" method, so add reset handler before init_reg_v3_hw(). Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 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 2adb5c93bd81..4c32088b9199 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3283,15 +3283,21 @@ static int hisi_sas_v3_resume(struct pci_dev *pdev) pci_enable_wake(pdev, PCI_D0, 0); pci_restore_state(pdev); rc = pci_enable_device(pdev); - if (rc) + if (rc) { dev_err(dev, "enable device failed during resume (%d)\n", rc); + return rc; + } pci_set_master(pdev); scsi_unblock_requests(shost); clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); sas_prep_resume_ha(sha); - init_reg_v3_hw(hisi_hba); + rc = hw_init_v3_hw(hisi_hba); + if (rc) { + scsi_remove_host(shost); + pci_disable_device(pdev); + } hisi_hba->hw->phys_init(hisi_hba); sas_resume_ha(sha); clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags); From patchwork Fri Sep 6 12:55:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 173234 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp600715oce; Fri, 6 Sep 2019 05:58:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQKDLqxVD3xYHeWjFWxaxoDsQkZD1Moybe0dRJlypjKz20lXkweIW5aouOfKkC1KVla6ho X-Received: by 2002:a63:534d:: with SMTP id t13mr7858878pgl.313.1567774734344; Fri, 06 Sep 2019 05:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567774734; cv=none; d=google.com; s=arc-20160816; b=hfdSXiRF+YVlC5a12HPCxdTm5lntIo89b8DuwPAe5FnnebFRaDlG8hSJNi6gX8CZTc IKp1sXFyNGTuGp2wd7uw1AzKfLTm3G/fyv+PxDRYMxlcoy3WLNj+qY+4C9DndvTWgAnr 7rRx7sHZCo9kiV4WlREe6IfzNhopa5z39NOl3PwaF0p+7jnr6/+K1esv8ghREk2xQ/jI gqfEc2QXENezl52GPQAlLnXabRLxGdz5ml3paeZhP1oi7/RabW99hiaXeFaxELH/+kdU uk5FvjiTT7pJa96pf02+Qj3mgeDrTxR5zoHB5VF4xhZQS1X0mLf8cdiBP5uOFj9PJpjC aJBA== 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=c3OrEwQMZczp2d/YxQjWedmgIfHUMmPuGn1C3AWozKw=; b=T1rVPz3GCDnn2B89XjJL4IvPQAZYJy6YHJi+8PG8lvLQBNHv4WHpCGFFCBTmf/zI81 shfgg2ypo7LLXKnlf8k63yEGBg75QkhRzAJzXz0U84UnQGOTF1pyFdUsJbPpikGshq3F W0s/o7wF256gvlV8EjZnTYlkG6GAYSotUs1pbHKfHAzf6YpbFYW7EtTIvr44xDUgTGbT 43onSw00AeCFp4U1fMwHLlXaqf5qD66/8L2uJdnL99ebP1IpTK+yff943yRO35Ug4dQY 5GAscAjDQaDk7H4aNcPU1jHeluA4Q3/voaFprq2W9bQE16ZI+SdHZ6Bz87FttmwOSVJK VWhg== 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 3si1546836pli.317.2019.09.06.05.58.53; Fri, 06 Sep 2019 05:58:54 -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 S2405018AbfIFM6w (ORCPT + 28 others); Fri, 6 Sep 2019 08:58:52 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7139 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404923AbfIFM6R (ORCPT ); Fri, 6 Sep 2019 08:58:17 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id EC04DF22272FF64F6E53; Fri, 6 Sep 2019 20:58:10 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Fri, 6 Sep 2019 20:58:03 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 08/13] scsi: hisi_sas: Remove hisi_sas_hw.slot_complete Date: Fri, 6 Sep 2019 20:55:32 +0800 Message-ID: <1567774537-20003-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1567774537-20003-1-git-send-email-john.garry@huawei.com> References: <1567774537-20003-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing We never call hisi_sas_hw.slot_complete, so remove it. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 2 -- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 1 - drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 - drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 1 - 4 files changed, 5 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index a72d06d973ff..a6b53d29a8a1 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -289,8 +289,6 @@ struct hisi_sas_hw { void (*prep_abort)(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot, int device_id, int abort_flag, int tag_to_abort); - int (*slot_complete)(struct hisi_hba *hisi_hba, - struct hisi_sas_slot *slot); void (*phys_init)(struct hisi_hba *hisi_hba); void (*phy_start)(struct hisi_hba *hisi_hba, int phy_no); void (*phy_disable)(struct hisi_hba *hisi_hba, int phy_no); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 3a584feca843..b861a0f14c9d 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1782,7 +1782,6 @@ static const struct hisi_sas_hw hisi_sas_v1_hw = { .prep_smp = prep_smp_v1_hw, .prep_ssp = prep_ssp_v1_hw, .start_delivery = start_delivery_v1_hw, - .slot_complete = slot_complete_v1_hw, .phys_init = phys_init_v1_hw, .phy_start = start_phy_v1_hw, .phy_disable = disable_phy_v1_hw, diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 9d316f28c74c..b01ccb38b00a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -3561,7 +3561,6 @@ static const struct hisi_sas_hw hisi_sas_v2_hw = { .prep_stp = prep_ata_v2_hw, .prep_abort = prep_abort_v2_hw, .start_delivery = start_delivery_v2_hw, - .slot_complete = slot_complete_v2_hw, .phys_init = phys_init_v2_hw, .phy_start = start_phy_v2_hw, .phy_disable = disable_phy_v2_hw, diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index cd901213a59b..0a159df87d7b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2961,7 +2961,6 @@ static const struct hisi_sas_hw hisi_sas_v3_hw = { .prep_stp = prep_ata_v3_hw, .prep_abort = prep_abort_v3_hw, .start_delivery = start_delivery_v3_hw, - .slot_complete = slot_complete_v3_hw, .phys_init = phys_init_v3_hw, .phy_start = start_phy_v3_hw, .phy_disable = disable_phy_v3_hw, From patchwork Fri Sep 6 12:55:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 173228 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp600247oce; Fri, 6 Sep 2019 05:58:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqykjRRcIcwe5FgeGji7te9J3SdwQppYyazkUC/Bj+F77pbAD2j9U/b56dWLpK+ksftbRVy9 X-Received: by 2002:a17:902:a607:: with SMTP id u7mr9081832plq.43.1567774704818; Fri, 06 Sep 2019 05:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567774704; cv=none; d=google.com; s=arc-20160816; b=d0lySykYPqBE5PojJ4veRqv3nL3kBVsfV+IjZBiwDCgU6Bbz5yd36dcYnTwSQdfQ9H qb0RTccT2JRLm7kcO72E88QY+ou0GMOUDwPSChRsemjfODqiMrUQOlL+TovIC/HuO6ms 1axHs81PxXLrFNLAuUHsJWZ5HcQ7d53NgWQx4Q1IyJbRq4/w9rb0dzXjqQIqND9zw9Cs 2nPqFLbqB+vgSIcFwswZ3taBlA5DI5tw37SRJcK+5HHG5adon9Hh77lS5qM5+VDWdgh/ vm/l2mcf2/54YWZj5O+uv7a0XOhqJ5Cak1DJz2yvIO+LO/qnSqcwCZ7BaPwcXF6MlwM+ 6XEg== 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=DZUrm/91Br6fNAHi1oT2hkpg/hK21ATXyVM/GfCug2c=; b=lRlOxrDcN0eFkB8W6+emj9c5p74+8+vNDYy5IHatDOjHipeaFrW6bG3LIKJKirjs6V g0T3But1obDe89xoPhrvAdcb+8JlSA/aQc3w7aAP81sQprlwQQToZV/2DZsSeMTw7fTV oQ26WEAFpV2ypTm4/ab+ttvqo/WezyAwUaWFd9bz8EgX0x1H16jD6kgtMEmuVmg5Qc/k nBC2YolpE+xR1J0rGPr4gnT3IqKKdnTHVP+0LNUPmIGVSgQUvAtgzd6kPacG4oLz2N84 TTtsj02GvRRu5sNx+G3M/2X2i8DTLkhXpTtvIQihwySDpC+XWQ0iIXDl0+1fuCRayC2y p/Gw== 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 d7si2024552pfr.217.2019.09.06.05.58.24; Fri, 06 Sep 2019 05:58:24 -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 S2404958AbfIFM6V (ORCPT + 28 others); Fri, 6 Sep 2019 08:58:21 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7137 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404921AbfIFM6R (ORCPT ); Fri, 6 Sep 2019 08:58:17 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E47001F02828A4D1F5CC; Fri, 6 Sep 2019 20:58:10 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Fri, 6 Sep 2019 20:58:03 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 09/13] scsi: hisi_sas: Remove redundant work declaration Date: Fri, 6 Sep 2019 20:55:33 +0800 Message-ID: <1567774537-20003-10-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1567774537-20003-1-git-send-email-john.garry@huawei.com> References: <1567774537-20003-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen Remove redundant work declaration in HISI_SAS_DECLARE_RST_WORK_ON_STACK Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 1 - 1 file changed, 1 deletion(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index a6b53d29a8a1..d02ab2699b9b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -134,7 +134,6 @@ struct hisi_sas_rst { #define HISI_SAS_DECLARE_RST_WORK_ON_STACK(r) \ DECLARE_COMPLETION_ONSTACK(c); \ - DECLARE_WORK(w, hisi_sas_sync_rst_work_handler); \ struct hisi_sas_rst r = HISI_SAS_RST_WORK_INIT(r, c) enum hisi_sas_bit_err_type { From patchwork Fri Sep 6 12:55:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 173226 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp600096oce; Fri, 6 Sep 2019 05:58:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKME/Y9F/5v0ithBOGdIDXkcx52TCedSLT2m+ePtb3APMCjIYJi9+iwDHjOvpiAA20xs60 X-Received: by 2002:a63:e70f:: with SMTP id b15mr7805199pgi.152.1567774696376; Fri, 06 Sep 2019 05:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567774696; cv=none; d=google.com; s=arc-20160816; b=g9wvNywB6DQ/TgRiBJgUgu5FiK1VlFCe7ZSLWj5asDUYLGlb7aXhnzFT0LIVSRIALX +wy09s29SJ9gJpApq9S7fSrc8PORcyetAugGEEgl0JkMDSZlsYL/bAvP2cvRVGAnPrWQ SqB9kDQfSewB0uNgiFHIsYBG4OtecwuxKx5/qj+BRWgFOxg4jZB7MSBhpvXeTc9hmUzb LahNiaQSALFbcKx4enXlSLP1wcXz0oGoQkdhhNwa8M0Q9cXkYkLeRhzH5CHM4DkOqmSE 111i1N/2wGK59Xz9jwH1rlyTxSX9DEYbG0m+xQGN6YGLj+yqy508ERtvoMVeoH6t5YIk 9QiA== 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=AV4zFPYFIHZPdAq/+1ROj4kdFbAz7/jE9F4lhdpfRNA=; b=GKgDSyprj1FND5UCplcIPLN+OOi9LFpUa77EH++Dz0ksz37F8UO7zcfmg5Jyr8VlYE qAbzw1qyQnMyjpNRFpodhrPSisGkeSmGpNRDUr8CrW1gYWZUgRzalTIyElM99+pylomQ mE2rPQKpxjyY3U7mr99hDkns8Pc2lAOKD7J54Skio0mWj6huDH2SrulB7WGrzljVwc3J QmRxRCXFtBNFNdqyRkiN/8DpTYSGewzqF0x3OxRz8hOAmL8KV0SkEQqav0UGweppNduY hCqRh1LiX8yK8llCtovcRKdqZMwznQ82tz3acYVBUpu1RVW86aUKTu0HKeo2dFTpPTeB Gjxg== 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 t185si4228259pgb.329.2019.09.06.05.58.15; Fri, 06 Sep 2019 05:58:16 -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 S2404917AbfIFM6P (ORCPT + 28 others); Fri, 6 Sep 2019 08:58:15 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6697 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404882AbfIFM6M (ORCPT ); Fri, 6 Sep 2019 08:58:12 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id CA170DB4D3AA848288DE; Fri, 6 Sep 2019 20:58:10 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Fri, 6 Sep 2019 20:58:04 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 11/13] scsi: hisi_sas: Add hisi_sas_debugfs_alloc() to centralise allocation Date: Fri, 6 Sep 2019 20:55:35 +0800 Message-ID: <1567774537-20003-12-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1567774537-20003-1-git-send-email-john.garry@huawei.com> References: <1567774537-20003-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing We extract the code of memory allocate and construct an new function for it. We think it's convenient for subsequent optimization. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 102 +++++++++++++++----------- 1 file changed, 58 insertions(+), 44 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index b96732493137..e7056bbad7d7 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -3307,27 +3307,44 @@ void hisi_sas_debugfs_work_handler(struct work_struct *work) } EXPORT_SYMBOL_GPL(hisi_sas_debugfs_work_handler); -void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) +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_itct_cache); + 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]); + + for (i = 0; i < hisi_hba->queue_count; i++) + devm_kfree(dev, hisi_hba->debugfs_complete_hdr[i]); + + for (i = 0; i < DEBUGFS_REGS_NUM; i++) + devm_kfree(dev, hisi_hba->debugfs_regs[i]); + + for (i = 0; i < hisi_hba->n_phy; i++) + devm_kfree(dev, hisi_hba->debugfs_port_reg[i]); +} + +int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) { - int max_command_entries = HISI_SAS_MAX_COMMANDS; const struct hisi_sas_hw *hw = hisi_hba->hw; struct device *dev = hisi_hba->dev; - int p, i, c, d; + int p, c, d; size_t sz; - hisi_hba->debugfs_dir = debugfs_create_dir(dev_name(dev), - hisi_sas_debugfs_dir); - debugfs_create_file("trigger_dump", 0600, - hisi_hba->debugfs_dir, - hisi_hba, - &hisi_sas_debugfs_trigger_dump_fops); + hisi_hba->debugfs_dump_dentry = + debugfs_create_dir("dump", hisi_hba->debugfs_dir); sz = hw->debugfs_reg_array[DEBUGFS_GLOBAL]->count * 4; hisi_hba->debugfs_regs[DEBUGFS_GLOBAL] = devm_kmalloc(dev, sz, GFP_KERNEL); if (!hisi_hba->debugfs_regs[DEBUGFS_GLOBAL]) - goto fail_global; + goto fail; sz = hw->debugfs_reg_port->count * 4; for (p = 0; p < hisi_hba->n_phy; p++) { @@ -3335,7 +3352,7 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) devm_kmalloc(dev, sz, GFP_KERNEL); if (!hisi_hba->debugfs_port_reg[p]) - goto fail_port; + goto fail; } sz = hw->debugfs_reg_array[DEBUGFS_AXI]->count * 4; @@ -3343,14 +3360,14 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) devm_kmalloc(dev, sz, GFP_KERNEL); if (!hisi_hba->debugfs_regs[DEBUGFS_AXI]) - goto fail_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_ras; + goto fail; sz = hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; for (c = 0; c < hisi_hba->queue_count; c++) { @@ -3358,7 +3375,7 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) devm_kmalloc(dev, sz, GFP_KERNEL); if (!hisi_hba->debugfs_complete_hdr[c]) - goto fail_cq; + goto fail; } sz = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS; @@ -3367,60 +3384,57 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) devm_kmalloc(dev, sz, GFP_KERNEL); if (!hisi_hba->debugfs_cmd_hdr[d]) - goto fail_iost_dq; + goto fail; } - sz = max_command_entries * sizeof(struct hisi_sas_iost); + sz = HISI_SAS_MAX_COMMANDS * sizeof(struct hisi_sas_iost); hisi_hba->debugfs_iost = devm_kmalloc(dev, sz, GFP_KERNEL); if (!hisi_hba->debugfs_iost) - goto fail_iost_dq; + goto fail; 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) - goto fail_iost_cache; + goto fail; 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) - goto fail_itct_cache; + goto fail; /* 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) - goto fail_itct; + goto fail; - return; -fail_itct: - devm_kfree(dev, hisi_hba->debugfs_iost_cache); -fail_itct_cache: - devm_kfree(dev, hisi_hba->debugfs_iost_cache); -fail_iost_cache: - devm_kfree(dev, hisi_hba->debugfs_iost); -fail_iost_dq: - for (i = 0; i < d; i++) - devm_kfree(dev, hisi_hba->debugfs_cmd_hdr[i]); -fail_cq: - for (i = 0; i < c; i++) - devm_kfree(dev, hisi_hba->debugfs_complete_hdr[i]); - devm_kfree(dev, hisi_hba->debugfs_regs[DEBUGFS_RAS]); -fail_ras: - devm_kfree(dev, hisi_hba->debugfs_regs[DEBUGFS_AXI]); -fail_axi: -fail_port: - for (i = 0; i < p; i++) - devm_kfree(dev, hisi_hba->debugfs_port_reg[i]); - devm_kfree(dev, hisi_hba->debugfs_regs[DEBUGFS_GLOBAL]); -fail_global: - debugfs_remove_recursive(hisi_hba->debugfs_dir); - dev_dbg(dev, "failed to init debugfs!\n"); + return 0; +fail: + hisi_sas_debugfs_release(hisi_hba); + return -ENOMEM; +} + +void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) +{ + struct device *dev = hisi_hba->dev; + + hisi_hba->debugfs_dir = debugfs_create_dir(dev_name(dev), + hisi_sas_debugfs_dir); + debugfs_create_file("trigger_dump", 0600, + hisi_hba->debugfs_dir, + hisi_hba, + &hisi_sas_debugfs_trigger_dump_fops); + + if (hisi_sas_debugfs_alloc(hisi_hba)) { + debugfs_remove_recursive(hisi_hba->debugfs_dir); + dev_dbg(dev, "failed to init debugfs!\n"); + } } EXPORT_SYMBOL_GPL(hisi_sas_debugfs_init);