From patchwork Fri Jan 25 14:22:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 156603 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp418771jaa; Fri, 25 Jan 2019 06:23:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN6jw1n2ojHxlFg+j27nBVEoCSc2lAV5w3SJMcKeVw+X+8lNKrkKh82KlUHzjTrEnJVptPL8 X-Received: by 2002:a17:902:ab84:: with SMTP id f4mr10943936plr.207.1548426206455; Fri, 25 Jan 2019 06:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426206; cv=none; d=google.com; s=arc-20160816; b=X0TW5tHbSAlpazbhdpPoK6d7/AOIbYkWuHTfLg3ujMBsInGyRI1cKna/ApYaH1fxd5 3xCmThPa47AqR4yufbGIWmU2bPLU5CSbJlktBL1M4kASb66mX7wTfWZHSqDqOhXam+pr z1UwRclQiBtP0EZdUlo9h8Jjbs10b77kFeES4Y1jmafzi0P9X2QISy19hyKNMwzMtxkY GG2FojtVIQDG06yWD5xrW/lHB2oFPOX8LRt4kBcsKBCMThAYs6/FCV4Ej3C4//UPhGpu D2hUbYcWi6qsY0Jo9GNR3znJFKGODsQjHxkjNlL+P6BNcRun/ml9eP6ZMx3/MFZcBZ1A Pf2Q== 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=en6q0PJuJQKlXLjlPg+48B+MS0+b9LZ3NSU9Jma3A6c=; b=q1Czk11DQk/4ZOS5y1lVrtHDEYfdYBvunrEDcZr0zGOBtP9wS86QrKA26uwcOd9iJh Cawai6S4ujX5YtxsMnLhLUGb8o7amOgScX5PKQpVTLN30jTyx6JQBT73e3YCmORh0zow tXH1HP6ffSdI9kHQ8xppocGFDx5cIPrMIGMdmIYbmZhLBwegNHdNtEndjkBq9BWxxjxw fYRuOR/TyEuk0sy2f2njCQIvOCKdcc+rVnN5cBAzX92oqeFzNxoNgtK7ecXgH3XvBlTK 0mmKZz5GNXWy6lrJitxKfEiE4KLlaHZA+KJK6RFQMlRPcL8nocNV/h6etSKhqDPTH0nn JFLA== 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 z86si16417499pfl.209.2019.01.25.06.23.26; Fri, 25 Jan 2019 06:23:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728797AbfAYOWD (ORCPT + 31 others); Fri, 25 Jan 2019 09:22:03 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2757 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728268AbfAYOWC (ORCPT ); Fri, 25 Jan 2019 09:22:02 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 306954F42F6138253C5E; Fri, 25 Jan 2019 22:21:59 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:50 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 01/13] scsi: hisi_sas: No need to check return value of debugfs_create functions Date: Fri, 25 Jan 2019 22:22:27 +0800 Message-ID: <1548426159-225679-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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 When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 1 + drivers/scsi/hisi_sas/hisi_sas_main.c | 53 +++++++++++------------------------ 2 files changed, 17 insertions(+), 37 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 6a1a5ad..b8b1ded 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -368,6 +368,7 @@ struct hisi_hba { struct dentry *debugfs_dir; struct dentry *debugfs_dump_dentry; + bool debugfs_snapshot; }; /* Generic HW DMA host memory structures */ diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 535d347..72d2295 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1429,8 +1429,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 && - !hisi_hba->debugfs_dump_dentry) + if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct) queue_work(hisi_hba->wq, &hisi_hba->debugfs_work); if (!hisi_hba->hw->soft_reset) @@ -2784,63 +2783,42 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) /* Create dump dir inside device dir */ dump_dentry = debugfs_create_dir("dump", hisi_hba->debugfs_dir); - if (!dump_dentry) - goto fail; - hisi_hba->debugfs_dump_dentry = dump_dentry; - if (!debugfs_create_file("global", 0400, dump_dentry, hisi_hba, - &hisi_sas_debugfs_global_fops)) - goto fail; + debugfs_create_file("global", 0400, dump_dentry, hisi_hba, + &hisi_sas_debugfs_global_fops); /* Create port dir and files */ dentry = debugfs_create_dir("port", dump_dentry); - if (!dentry) - goto fail; - for (p = 0; p < hisi_hba->n_phy; p++) { snprintf(name, 256, "%d", p); - if (!debugfs_create_file(name, 0400, dentry, - &hisi_hba->phy[p], - &hisi_sas_debugfs_port_fops)) - goto fail; + + debugfs_create_file(name, 0400, dentry, &hisi_hba->phy[p], + &hisi_sas_debugfs_port_fops); } /* Create CQ dir and files */ dentry = debugfs_create_dir("cq", dump_dentry); - if (!dentry) - goto fail; - for (c = 0; c < hisi_hba->queue_count; c++) { snprintf(name, 256, "%d", c); - if (!debugfs_create_file(name, 0400, dentry, - &hisi_hba->cq[c], - &hisi_sas_debugfs_cq_fops)) - goto fail; + debugfs_create_file(name, 0400, dentry, &hisi_hba->cq[c], + &hisi_sas_debugfs_cq_fops); } /* Create DQ dir and files */ dentry = debugfs_create_dir("dq", dump_dentry); - if (!dentry) - goto fail; - for (d = 0; d < hisi_hba->queue_count; d++) { snprintf(name, 256, "%d", d); - if (!debugfs_create_file(name, 0400, dentry, - &hisi_hba->dq[d], - &hisi_sas_debugfs_dq_fops)) - goto fail; + debugfs_create_file(name, 0400, dentry, &hisi_hba->dq[d], + &hisi_sas_debugfs_dq_fops); } - if (!debugfs_create_file("iost", 0400, dump_dentry, hisi_hba, - &hisi_sas_debugfs_iost_fops)) - goto fail; + debugfs_create_file("iost", 0400, dump_dentry, hisi_hba, + &hisi_sas_debugfs_iost_fops); return; -fail: - debugfs_remove_recursive(hisi_hba->debugfs_dir); } static void hisi_sas_debugfs_snapshot_regs(struct hisi_hba *hisi_hba) @@ -2864,6 +2842,10 @@ void hisi_sas_debugfs_work_handler(struct work_struct *work) struct hisi_hba *hisi_hba = container_of(work, struct hisi_hba, debugfs_work); + if (hisi_hba->debugfs_snapshot) + return; + hisi_hba->debugfs_snapshot = true; + hisi_sas_debugfs_snapshot_regs(hisi_hba); } EXPORT_SYMBOL_GPL(hisi_sas_debugfs_work_handler); @@ -2878,9 +2860,6 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) hisi_hba->debugfs_dir = debugfs_create_dir(dev_name(dev), hisi_sas_debugfs_dir); - if (!hisi_hba->debugfs_dir) - return; - /* Alloc buffer for global */ sz = hisi_hba->hw->debugfs_reg_global->count * 4; hisi_hba->debugfs_global_reg = From patchwork Fri Jan 25 14:22: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: 156602 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp418692jaa; Fri, 25 Jan 2019 06:23:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN5hk7FldZ+lxKXY8wnc+yKZw40indBwXT+jpv5UlIlzXM/ZLAXZMZB958/ZaJMeT0C139L8 X-Received: by 2002:a62:1c0a:: with SMTP id c10mr11103789pfc.213.1548426202299; Fri, 25 Jan 2019 06:23:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426202; cv=none; d=google.com; s=arc-20160816; b=GyTN400nKtAN6VZtWLMQ7PusWUzJYUrC1Az/h1jSzA377djlh83kKRdVNfXLs+oiuu fCvdslVv+ae8Gkpx+HNJ/IkQ2ptgrHJwvMFodjh7wxC6cJ/FLVqAi2tk20HHuwwf/xE6 wx85Jz4wY8Q/Ja0pYNl37eqgLlO7zonSy7Honn9mflFTHxNvt63RKOMKKf7OTy86k1rF Ie9F+sKsPnObLcPfJyzXUSdzwHOAo1Rqk0EPdlMUGxchSOXDIpcPRrqWyne16D1Ccbt2 NVLoZIy2pHHBp7E9GSrTR8mFgNnkqvSijT4bRy/Fn5LEMk05BSFBvduXxlWrqx1w6XSU b53g== 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=9NDrTPyFonDSg0TQruWRcNePkOXYQoVbQTVj3ZQ5lis=; b=Tvqw8KlC3wVn3No2kDJoytIrjkdoZC8DjLViVe7u9ILrdneYXd7jysqPpHpwkHmkku ju1XoMT/u7mC5/Vt9O7urYU4HHskMCCe6TOvl8wJvfcEhogD8oSiOeH4BYaoZbFB1t7U 5HUp4xqMAcM4aca+qGNUJ3bFMorH0SWsykOt8EryEc1wZT4OZhKut2F8ua7HwY2z1ulK Xbf5ZKyb3fb5g+Xh8xYWbhba7KHAAD726fy2qdnB3tBL0ZgtONI7qjo7rjG1tdkfBhp2 VowCf1QIZqKD1Nct9u7pKjzrZ1m9UD8vN3jSmZbsmNqIXEEEFH0rdLCXgCSeAM9qYccG zAhw== 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 e68si25047046pfb.101.2019.01.25.06.23.21; Fri, 25 Jan 2019 06:23:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729255AbfAYOXT (ORCPT + 31 others); Fri, 25 Jan 2019 09:23:19 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2756 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727264AbfAYOWE (ORCPT ); Fri, 25 Jan 2019 09:22:04 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3A94511CA24FCF14406F; Fri, 25 Jan 2019 22:21:59 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:51 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 02/13] scsi: hisi_sas: Fix type casting and missing static qualifier in debugfs code Date: Fri, 25 Jan 2019 22:22:28 +0800 Message-ID: <1548426159-225679-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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 Sparse can detect some type casting issues in the debugfs code, so fix it up. Also a missing static qualifier is added to hisi_sas_debugfs_to_reg_name(). Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 4 ++-- drivers/scsi/hisi_sas/hisi_sas_main.c | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index b8b1ded..5bb6759 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -359,8 +359,8 @@ struct hisi_hba { u32 intr_coal_count; /* Interrupt count to coalesce */ /* debugfs memories */ - void *debugfs_global_reg; - void *debugfs_port_reg[HISI_SAS_MAX_PHYS]; + u32 *debugfs_global_reg; + u32 *debugfs_port_reg[HISI_SAS_MAX_PHYS]; void *debugfs_complete_hdr[HISI_SAS_MAX_QUEUES]; struct hisi_sas_cmd_hdr *debugfs_cmd_hdr[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 72d2295..73a545a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2547,7 +2547,7 @@ static void hisi_sas_debugfs_snapshot_iost_reg(struct hisi_hba *hisi_hba) } } -const char * +static const char * hisi_sas_debugfs_to_reg_name(int off, int base_off, const struct hisi_sas_debugfs_reg_lu *lu) { @@ -2574,10 +2574,10 @@ static void hisi_sas_debugfs_print_reg(u32 *regs_val, const void *ptr, if (name) seq_printf(s, "0x%08x 0x%08x %s\n", off, - le32_to_cpu(regs_val[i]), name); + regs_val[i], name); else seq_printf(s, "0x%08x 0x%08x\n", off, - le32_to_cpu(regs_val[i])); + regs_val[i]); } } @@ -2587,7 +2587,7 @@ static int hisi_sas_debugfs_global_show(struct seq_file *s, void *p) const struct hisi_sas_hw *hw = hisi_hba->hw; const struct hisi_sas_debugfs_reg *reg_global = hw->debugfs_reg_global; - hisi_sas_debugfs_print_reg((u32 *)hisi_hba->debugfs_global_reg, + hisi_sas_debugfs_print_reg(hisi_hba->debugfs_global_reg, reg_global, s); return 0; @@ -2634,7 +2634,7 @@ static int hisi_sas_debugfs_port_open(struct inode *inode, struct file *filp) }; static int hisi_sas_show_row_64(struct seq_file *s, int index, - int sz, u64 *ptr) + int sz, __le64 *ptr) { int i; @@ -2652,7 +2652,7 @@ static int hisi_sas_show_row_64(struct seq_file *s, int index, } static int hisi_sas_show_row_32(struct seq_file *s, int index, - int sz, u32 *ptr) + int sz, __le32 *ptr) { int i; @@ -2672,7 +2672,7 @@ static int hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr) struct hisi_sas_cq *cq = cq_ptr; struct hisi_hba *hisi_hba = cq->hisi_hba; void *complete_queue = hisi_hba->debugfs_complete_hdr[cq->id]; - void *complete_hdr = complete_queue + + __le32 *complete_hdr = complete_queue + (hisi_hba->hw->complete_hdr_size * slot); return hisi_sas_show_row_32(s, slot, @@ -2711,8 +2711,8 @@ static int 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]; - void *cmd_hdr = cmd_queue + - hisi_hba->hw->complete_hdr_size * slot; + __le32 *cmd_hdr = cmd_queue + + sizeof(struct hisi_sas_cmd_hdr) * slot; return hisi_sas_show_row_32(s, slot, sizeof(struct hisi_sas_cmd_hdr), cmd_hdr); @@ -2748,10 +2748,11 @@ static int hisi_sas_debugfs_iost_show(struct seq_file *s, void *p) struct hisi_hba *hisi_hba = s->private; struct hisi_sas_iost *debugfs_iost = hisi_hba->debugfs_iost; int i, ret, max_command_entries = hisi_hba->hw->max_command_entries; + __le64 *iost = &debugfs_iost->qw0; for (i = 0; i < max_command_entries; i++, debugfs_iost++) { ret = hisi_sas_show_row_64(s, i, sizeof(*debugfs_iost), - (u64 *)debugfs_iost); + iost); if (ret) return ret; } From patchwork Fri Jan 25 14:22: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: 156591 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp417346jaa; Fri, 25 Jan 2019 06:22:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN4rO/OkiKKDuAPQUOree7zPE5puNFk0+wtwnVqK35nrChlZqUrSlKK0e8FFzlYa0yKH1j0s X-Received: by 2002:a63:5b48:: with SMTP id l8mr10211087pgm.80.1548426127558; Fri, 25 Jan 2019 06:22:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426127; cv=none; d=google.com; s=arc-20160816; b=tsfm122pF7XkvmJrqzklfe8JA9UZUmSECtx5bxgA/EAajuw8kTRK5TVrsMJsTbDPoc BqpzSKp4+tH5DhD5dymFe7zzG5XTPhMb2dWQS3jCyXwZgZAYoDEFGG3JnJAtiPYhESrA YPovjnvHzQYf5VQ2bEQOrJXvswDjevoqbWNBG3v7fb4VtdZZ/LG0jfGDjoYBk+SxrKW7 jE0MLWMimo6Cdbvwdv52hMOt5cGl9zn7m6obBkWhY3wmzLriSDf/RZONo+3xsm4XdFzZ gbWl2R/IOGZMfgiiFPi1VhDVdTRhxTAzNMM6V2rfFZVnUFH5E1y9VrPOd932jfFw3hxD 5HTQ== 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=V2fY2EI+lq3IcSVGb12nHVr1v0byeqdQ6dPZWleIbsc=; b=Dcce2vqYh9rVt1YS7DBFjQem9HhGtivUwbiJjwz4sYSPpVYjWJ/qD/Jp5P6YjseUgu igy1/EkxvNohpn7jYLfIe3Azh3ox/H1PRM/gYftUhXyprTJvOc1OiIeHYuMXMqPTVAaT mc9DWoX+qLRuWjbGYen5uSArKLsth1UaGtKroLQKMpqOcM6dLiOY7jY2VyY5ZnCHuEjS o/U5HweM1oHl0vkWxx8XbDXQfjciQYIRnPQA7Pp5KrZoOExXSklDFBkP9jOmeaFisqFl SIP4Lqv6tOFnxGAARdzmY+OZ3lxNJ+J8JIYCXEGdcH8FpfSwKBQyaSBk7zD+rl2JiWeW Xi7A== 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 i69si26261225pgd.71.2019.01.25.06.22.07; Fri, 25 Jan 2019 06:22:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728920AbfAYOWF (ORCPT + 31 others); Fri, 25 Jan 2019 09:22:05 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2760 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726347AbfAYOWC (ORCPT ); Fri, 25 Jan 2019 09:22:02 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 445879CF2A870C37387C; Fri, 25 Jan 2019 22:21:59 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:51 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 04/13] scsi: hisi_sas: send primitive NOTIFY to SSP situation only Date: Fri, 25 Jan 2019 22:22:30 +0800 Message-ID: <1548426159-225679-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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 Send primitive NOTIFY to SSP situation only, or it causes underflow issue when sending IO. And also rename hisi_sas_hw.sl_notify() to hisi_sas_hw. sl_notify_ssp(). Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 2 +- drivers/scsi/hisi_sas/hisi_sas_main.c | 3 ++- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 4 ++-- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 ++-- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 5bb6759..97f0fda 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -246,7 +246,7 @@ struct hisi_sas_hw { int (*slot_index_alloc)(struct hisi_hba *hisi_hba, struct domain_device *device); struct hisi_sas_device *(*alloc_dev)(struct domain_device *device); - void (*sl_notify)(struct hisi_hba *hisi_hba, int phy_no); + void (*sl_notify_ssp)(struct hisi_hba *hisi_hba, int phy_no); int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq); void (*start_delivery)(struct hisi_sas_dq *dq); void (*prep_ssp)(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 c0aacb0..e586660 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -778,7 +778,8 @@ static void hisi_sas_phyup_work(struct work_struct *work) struct asd_sas_phy *sas_phy = &phy->sas_phy; int phy_no = sas_phy->id; - hisi_hba->hw->sl_notify(hisi_hba, phy_no); /* This requires a sleep */ + if (phy->identify.target_port_protocols == SAS_PROTOCOL_SSP) + hisi_hba->hw->sl_notify_ssp(hisi_hba, phy_no); hisi_sas_bytes_dmaed(hisi_hba, 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 28ab52a..c8f808f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -835,7 +835,7 @@ static void phys_init_v1_hw(struct hisi_hba *hisi_hba) mod_timer(timer, jiffies + HZ); } -static void sl_notify_v1_hw(struct hisi_hba *hisi_hba, int phy_no) +static void sl_notify_ssp_v1_hw(struct hisi_hba *hisi_hba, int phy_no) { u32 sl_control; @@ -1826,7 +1826,7 @@ static int hisi_sas_v1_init(struct hisi_hba *hisi_hba) static const struct hisi_sas_hw hisi_sas_v1_hw = { .hw_init = hisi_sas_v1_init, .setup_itct = setup_itct_v1_hw, - .sl_notify = sl_notify_v1_hw, + .sl_notify_ssp = sl_notify_ssp_v1_hw, .clear_itct = clear_itct_v1_hw, .prep_smp = prep_smp_v1_hw, .prep_ssp = prep_ssp_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 9506ab1..fc0bcfa 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -1589,7 +1589,7 @@ static void phys_init_v2_hw(struct hisi_hba *hisi_hba) } } -static void sl_notify_v2_hw(struct hisi_hba *hisi_hba, int phy_no) +static void sl_notify_ssp_v2_hw(struct hisi_hba *hisi_hba, int phy_no) { u32 sl_control; @@ -3625,7 +3625,7 @@ static void debugfs_snapshot_restore_v2_hw(struct hisi_hba *hisi_hba) .setup_itct = setup_itct_v2_hw, .slot_index_alloc = slot_index_alloc_quirk_v2_hw, .alloc_dev = alloc_dev_quirk_v2_hw, - .sl_notify = sl_notify_v2_hw, + .sl_notify_ssp = sl_notify_ssp_v2_hw, .get_wideport_bitmap = get_wideport_bitmap_v2_hw, .clear_itct = clear_itct_v2_hw, .free_device = free_device_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 b780b52..726ac4bd 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -870,7 +870,7 @@ static void phys_init_v3_hw(struct hisi_hba *hisi_hba) } } -static void sl_notify_v3_hw(struct hisi_hba *hisi_hba, int phy_no) +static void sl_notify_ssp_v3_hw(struct hisi_hba *hisi_hba, int phy_no) { u32 sl_control; @@ -2520,7 +2520,7 @@ static void debugfs_snapshot_restore_v3_hw(struct hisi_hba *hisi_hba) .get_wideport_bitmap = get_wideport_bitmap_v3_hw, .complete_hdr_size = sizeof(struct hisi_sas_complete_v3_hdr), .clear_itct = clear_itct_v3_hw, - .sl_notify = sl_notify_v3_hw, + .sl_notify_ssp = sl_notify_ssp_v3_hw, .prep_ssp = prep_ssp_v3_hw, .prep_smp = prep_smp_v3_hw, .prep_stp = prep_ata_v3_hw, From patchwork Fri Jan 25 14:22:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 156599 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp418146jaa; Fri, 25 Jan 2019 06:22:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN6lV4DcWJRDV/Gwgk4zxJoRuyaVRy3O4Pzt2C1hEJTpMCN+cEuZndc4XieX4lVBrZsJtu+2 X-Received: by 2002:a62:4e83:: with SMTP id c125mr11292050pfb.101.1548426172085; Fri, 25 Jan 2019 06:22:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426172; cv=none; d=google.com; s=arc-20160816; b=pX6L8NxVDZWMUKk+Vmb4ByHL45WnBR0rZtpFFO7qsI1EWOvwIERbRlOMqHIBTSvLZo CXEUH9v4RYz4ptWvEFDI7tjlhEPOEOsFdaxKX5vA6C/a9arDOBezFVcotkHAduRyPwDC kOFuthWDTU4ranaovyGd8bicwwPEC8vRxTFPivg1Eh2YxYhQWg6ZrbCJU2lgGfu6RYpy ixncg8TkWe4ZkMCiyw1x8N2HHB+SOxKvMoHIuJAIQNwalxZqaLxSGjqcbSFAQGPz+Dg+ pjH9cIT9CCLMB955r75ADLqaWvVsG6BQTEseOI0GoikMYuqGVq6aSNzD2ss9gGSnhAPh SEvw== 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=R3t3d6cK5EIEZHIK9qMM01uF3eAVUR0GS1fjeoFPBPE=; b=CtYd62JG+iNqXNvXyI1mxd5z9bdG0ATi9WjkoRXAzjQKsQU9nKDJLK8czHZLVOvux5 rUz17P+FV8DPSKw1nog576imzP2HVRpZkcORP/59SaZHO7rscgOKrzkh7OL0Ltirk5x9 WkYDnjOGhG04KFI3JHt7g/HJbI55XvW8q81IXxuHr40tmwYaR8C+ttwP5C2CyKZ4HOLG VO1s79iexD/52OUZpNrUdvT9MN/PQAOmg1UEdmSjqhS7H63p6Bz8obG5Hbb79BDwKjhX gWO1D3ZbUvydOYe5kIpvXiaTR605CyFma2BuE1YgjuC1zoR6Tfy3BZ0CFzKRD1IslP8u gF7A== 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 l5si24016089plt.5.2019.01.25.06.22.51; Fri, 25 Jan 2019 06:22:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729215AbfAYOWn (ORCPT + 31 others); Fri, 25 Jan 2019 09:22:43 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2766 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728917AbfAYOWH (ORCPT ); Fri, 25 Jan 2019 09:22:07 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 5FA1568C4132576BA01C; Fri, 25 Jan 2019 22:21:59 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:51 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 05/13] scsi: hisi_sas: shutdown axi bus to avoid exception CQ returned Date: Fri, 25 Jan 2019 22:22:31 +0800 Message-ID: <1548426159-225679-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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 injecting 2 bit ECC error, it will cause fatal AXI interrupts. Before the recovery of SAS controller reset, the internal of SAS controller is in error. If CQ interrupts return at the time, actually it is exception CQ interrupt, and it may cause resource release in disorder. To avoid the exception situation, shutdown AXI bus after fatal AXI interrupt. In SAS controller reset, it will restart AXI bus. For later version of v3 hw, hardware will shutdown AXI bus for this situation, so just fix current ver of v3 hw. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 726ac4bd..d5eabfc 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1646,6 +1646,7 @@ static irqreturn_t fatal_axi_int_v3_hw(int irq_no, void *p) u32 irq_value, irq_msk; struct hisi_hba *hisi_hba = p; struct device *dev = hisi_hba->dev; + struct pci_dev *pdev = hisi_hba->pci_dev; int i; irq_msk = hisi_sas_read32(hisi_hba, ENT_INT_SRC_MSK3); @@ -1677,6 +1678,17 @@ static irqreturn_t fatal_axi_int_v3_hw(int irq_no, void *p) error->msg, irq_value); queue_work(hisi_hba->wq, &hisi_hba->rst_work); } + + if (pdev->revision < 0x21) { + u32 reg_val; + + reg_val = hisi_sas_read32(hisi_hba, + AXI_MASTER_CFG_BASE + + AM_CTRL_GLOBAL); + reg_val |= AM_CTRL_SHUTDOWN_REQ_MSK; + hisi_sas_write32(hisi_hba, AXI_MASTER_CFG_BASE + + AM_CTRL_GLOBAL, reg_val); + } } if (irq_value & BIT(ENT_INT_SRC3_ITC_INT_OFF)) { From patchwork Fri Jan 25 14:22: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: 156605 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp418830jaa; Fri, 25 Jan 2019 06:23:29 -0800 (PST) X-Google-Smtp-Source: ALg8bN7bVjR7R0UIYmtHvU6CpPeZ2C47PNbL0H/0La8Ud5/qYVRxKBRLHzIhT16I+v4TgKWZXmcb X-Received: by 2002:a63:cd4c:: with SMTP id a12mr10329278pgj.252.1548426209420; Fri, 25 Jan 2019 06:23:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426209; cv=none; d=google.com; s=arc-20160816; b=KKXhwiF8aAhcuOwOdzU8tkXUCED9eEQY26mltvTdc63g3qF9jTy1OgmuMIIMklPhbV vsLIlY1werplh80FDTruG4pUUm3d915pUhLhZNQGiIkNrW/oorcWsViV2wIuWUlhGqV4 h6mwraZtRgvYpE4gysY+56Fm8we2BRlx0pKkFdogp8xkIgKtTKAa3L8G11yCrmH6Q0V6 8tox2daXqEQnhq1aJDh0Edc0Nt8OMP9CDNPzdghK5se15M4WzCWp5ZdxFvEGYTFEfBQz 3JeD+Ys1s4zv5yq3LD4xMjhhzfA2XmUxsEOOjivGtJKvF1PFH04aQm4J88WEPl+iu9vm hvTg== 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=Ii+C7DzLbSVoLp59t55TSkb4W9vnz7NGCxmdKHMjkG4=; b=hmrOMdCdp5O1/uMA+pcJ7QOjONBEzqsS0Syy8KG75FSLjkyegxDFX0/xref12y1Flo 0fr+67syD3ylE458avvUWdqEhrNTtfK38LwX0sQA3njcAC8i3o4BOVU8VPrTaFOrXAlU /RC4yTT2s3P91qwR/X31sTtZb0gvTfpIpFC9Y2BDujOhvbPouul5nC4+B9YxKwy/9QBQ LQc7WsRwht53x+XuFCw/L48d4/8zgT98iPveZGZGCKXDt7gti3VWb8l5DvSPQVLTHITV +sL95YpN7nrCuz2aMrF2bvyM7v1alnhazWWml8jyzfi5eMGKyiaTA/+1l/ixA3Qghu9i em6w== 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 g34si8770093pld.15.2019.01.25.06.23.29; Fri, 25 Jan 2019 06:23:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729300AbfAYOX1 (ORCPT + 31 others); Fri, 25 Jan 2019 09:23:27 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2758 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728477AbfAYOWD (ORCPT ); Fri, 25 Jan 2019 09:22:03 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3F6FAC7A571B0D0D95DC; Fri, 25 Jan 2019 22:21:59 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:52 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 06/13] scsi: hisi_sas: remove the check of sas_dev status in hisi_sas_I_T_nexus_reset() Date: Fri, 25 Jan 2019 22:22:32 +0800 Message-ID: <1548426159-225679-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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 issing a hardreset to a SATA device when running IO, it is possible that abnormal CQs of the device are returned. Then enter error handle, it doesn't enter function hisi_sas_abort_task() as there is no timeout IO, and it doesn't set device as HISI_SAS_DEV_EH. So when hardreset by libata later, it actually doesn't issue hardreset as there is a check to judge whether device is in error. For this situation, actually need to hardreset the device to recover. So remove the check of sas_dev status in hisi_sas_I_T_nexus_reset(). Before we add the check to avoid the endless loop of reset for directly-attached SATA device at probe time, actually we flutter it for it, so it is not necessary to add the check now. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 6 ------ drivers/scsi/hisi_sas/hisi_sas_main.c | 9 --------- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 - 3 files changed, 16 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 97f0fda..aac8b38 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -83,11 +83,6 @@ enum { PORT_TYPE_SATA = (1U << 0), }; -enum dev_status { - HISI_SAS_DEV_NORMAL, - HISI_SAS_DEV_EH, -}; - enum { HISI_SAS_INT_ABT_CMD = 0, HISI_SAS_INT_ABT_DEV = 1, @@ -188,7 +183,6 @@ struct hisi_sas_device { enum sas_device_type dev_type; int device_id; int sata_idx; - u8 dev_status; }; struct hisi_sas_tmf_task { diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index e586660..b57a44b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -626,7 +626,6 @@ static struct hisi_sas_device *hisi_sas_alloc_dev(struct domain_device *device) hisi_hba->devices[i].device_id = i; sas_dev = &hisi_hba->devices[i]; - sas_dev->dev_status = HISI_SAS_DEV_NORMAL; sas_dev->dev_type = device->dev_type; sas_dev->hisi_hba = hisi_hba; sas_dev->sas_device = device; @@ -1495,7 +1494,6 @@ static int hisi_sas_abort_task(struct sas_task *task) task->task_state_flags |= SAS_TASK_STATE_ABORTED; spin_unlock_irqrestore(&task->task_state_lock, flags); - sas_dev->dev_status = HISI_SAS_DEV_EH; if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SSP) { struct scsi_cmnd *cmnd = task->uldd_task; struct hisi_sas_slot *slot = task->lldd_task; @@ -1639,15 +1637,10 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device) static int hisi_sas_I_T_nexus_reset(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 rc = TMF_RESP_FUNC_FAILED; - if (sas_dev->dev_status != HISI_SAS_DEV_EH) - return TMF_RESP_FUNC_FAILED; - sas_dev->dev_status = HISI_SAS_DEV_NORMAL; - rc = hisi_sas_internal_task_abort(hisi_hba, device, HISI_SAS_INT_ABT_DEV, 0); if (rc < 0) { @@ -1671,7 +1664,6 @@ static int hisi_sas_lu_reset(struct domain_device *device, u8 *lun) struct device *dev = hisi_hba->dev; int rc = TMF_RESP_FUNC_FAILED; - sas_dev->dev_status = HISI_SAS_DEV_EH; if (dev_is_sata(device)) { struct sas_phy *phy; @@ -2100,7 +2092,6 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost) for (i = 0; i < HISI_SAS_MAX_DEVICES; i++) { hisi_hba->devices[i].dev_type = SAS_PHY_UNUSED; hisi_hba->devices[i].device_id = i; - hisi_hba->devices[i].dev_status = HISI_SAS_DEV_NORMAL; } for (i = 0; i < hisi_hba->queue_count; i++) { diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index fc0bcfa..85236ef 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -868,7 +868,6 @@ hisi_sas_device *alloc_dev_quirk_v2_hw(struct domain_device *device) hisi_hba->devices[i].device_id = i; sas_dev = &hisi_hba->devices[i]; - sas_dev->dev_status = HISI_SAS_DEV_NORMAL; sas_dev->dev_type = device->dev_type; sas_dev->hisi_hba = hisi_hba; sas_dev->sas_device = device; From patchwork Fri Jan 25 14:22: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: 156592 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp417418jaa; Fri, 25 Jan 2019 06:22:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN5FqmeFy0tHD/CT3zwDmPrbM8hpZoFjHA2wxzSkYoKjY0/UdjF3nbMVFouiRPwvFgJKzLT4 X-Received: by 2002:a17:902:4222:: with SMTP id g31mr11154960pld.240.1548426131500; Fri, 25 Jan 2019 06:22:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426131; cv=none; d=google.com; s=arc-20160816; b=t9OCl1AXgJOwlpcCessYKB6rD/MZyAhOx1cx86o9gFE1QFEg7H6As7iIItgSOna75U XdigTfQZY1PNVU/IitzNaT3+Mw29kpeMn11B2aJGFiBc5QBaY/C/9KuWTzDv7Sichfyh GE4m6E06VVZD6aFjD9w2v29VTuBguN8i0hb3k8dWzKmpumeXBSvf8jvUmsXwA8m6KcoY FUSsq8ijpJw/B/11EIoloRwgIlzE1EGBd2xoOc5XnDb/DFk1snTH2zGeIhBE6MCFHyNe 4olW9PS5GqMN/QUjY+p0vNzX7/AG6cRsUHq0vr3VG1wDsKgCTxHbAhl8SI6/V5nMyUKs wI0g== 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=Llq0dncrX2lks6c3bwOxJsRmiL8zwkvK9Qshxo8tZEI=; b=ySfxZ01yir5nYvf89DCdd6g76NGyzJJbvDHT5T6EUElqTRZ4TZTZqIJy5TL8LRN/ZI TWRfv+J0/I2/1fjyOC8p29KKGePfjcZdYXeHGgCKKh19DLaOi/kUAfsHg2d9jTsPdLq/ PPWuaCieXbybZkNWceIY3E41jKxjvAG1b2f3LKG2kx0oLM9sHNBP0ozz5N/cF//vQgw/ PQahgAxN8tK4NY5a1nw7oKYHzrYoFYtXc5XvfMT/+uDb5oeE0Obp5nxTdqQHQDkJZhTS rUhuSiaykNzgb8SdKZ8l4Mh8EkBQ89vh0oBA1y5RFe2EEnWVXvcJDJsi5wrV0T/cDhRm bxMA== 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 d14si22659376pgi.158.2019.01.25.06.22.11; Fri, 25 Jan 2019 06:22:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728986AbfAYOWJ (ORCPT + 31 others); Fri, 25 Jan 2019 09:22:09 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2762 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728877AbfAYOWF (ORCPT ); Fri, 25 Jan 2019 09:22:05 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 4EA7CB86A3C2B86381CA; Fri, 25 Jan 2019 22:21:59 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:52 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 07/13] scsi: hisi_sas: Remove unused parameter of function hisi_sas_alloc() Date: Fri, 25 Jan 2019 22:22:33 +0800 Message-ID: <1548426159-225679-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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 Actually in function hisi_sas_alloc(), parameter shost is not used, so remove it. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 2 +- drivers/scsi/hisi_sas/hisi_sas_main.c | 4 ++-- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index aac8b38..235b819 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -497,7 +497,7 @@ struct hisi_sas_slot_buf_table { extern struct dentry *hisi_sas_debugfs_dir; extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba); -extern int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost); +extern int hisi_sas_alloc(struct hisi_hba *hisi_hba); extern void hisi_sas_free(struct hisi_hba *hisi_hba); extern u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis, int direction); diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index b57a44b..8f7f82d 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2074,7 +2074,7 @@ void hisi_sas_init_mem(struct hisi_hba *hisi_hba) } EXPORT_SYMBOL_GPL(hisi_sas_init_mem); -int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost) +int hisi_sas_alloc(struct hisi_hba *hisi_hba) { struct device *dev = hisi_hba->dev; int i, j, s, max_command_entries = hisi_hba->hw->max_command_entries; @@ -2358,7 +2358,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, goto err_out; } - if (hisi_sas_alloc(hisi_hba, shost)) { + if (hisi_sas_alloc(hisi_hba)) { hisi_sas_free(hisi_hba); goto err_out; } diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index d5eabfc..4b628c2 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2591,7 +2591,7 @@ static void debugfs_snapshot_restore_v3_hw(struct hisi_hba *hisi_hba) if (hisi_sas_get_fw_info(hisi_hba) < 0) goto err_out; - if (hisi_sas_alloc(hisi_hba, shost)) { + if (hisi_sas_alloc(hisi_hba)) { hisi_sas_free(hisi_hba); goto err_out; } From patchwork Fri Jan 25 14:22:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 156601 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp418576jaa; Fri, 25 Jan 2019 06:23:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN77WNHdczULClXLwWdW7D38E6W5YhgaUv6YE9xqGAujJY6ZXKXjldHfeCLDACbaDDCEfew7 X-Received: by 2002:a63:7b06:: with SMTP id w6mr10141143pgc.288.1548426195761; Fri, 25 Jan 2019 06:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426195; cv=none; d=google.com; s=arc-20160816; b=OVYncOM2QeP+Uci7/yYsHUhfMINvGs6bOuPhf9kz8E1vjFOAuKf6o06er/YRLUIyyn HOTPyVoVFGai30KaM3MSwlZJwskUTU31hACOOie5UeWMBUmoWXdaM+WVJOSakmRY7jiO m7mFtjr+dINilb+4/xdBhIKqxzpprt7d5m2inCmkLB5yBFqN4QS/T31/XlzfPYGxvuwi r1Fk0gDW6WAGRcNdcivgAQOsdOhuVZmMgf4xA9liG0yOIbrsvYHBGf2bRrgSHuFMsS5O VmqGyJ3YXI/iQkPl6e7GlZ+QgpaG93T7rOWlSjFwv5XpM53TwMB4SbZvxwkZ1bDbPKzv ItzA== 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=Y+NGZs2WGflQdxA9GMmD5FIt5RzaUvGALtbptUuDiJM=; b=IhzTj1l4r7sbKHzTgjluBJg6zv2O+EifNo65VHrd4L3Nbnfs2YONL4fuyxcIMIl2e5 CwVZ8Tl9QLYOlrkp01ivHb6k63nFnZm0sTDAITqY33a7J6FOWML1Plrap++Yd1NF50+4 U1xaujw+Lt5MxxN7S9c2bkyIyem3XrM7aoCS+kUFIlMq8GpVCfrlkz2JENSd3LKHEhju Vr8t9qfRtabq+UebapF9VEHtZa/fCqQbtEj9I5QajvoRpWqAypbXlfACNIJMeZ0t3hkV O5iJt5aBfGm+ywI66Q+X+jaepR58gdvFooE+tqPGFpFZCiIzGvfZV609ve2pIOjMNWKI UxeA== 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 x14si24398374plr.378.2019.01.25.06.23.15; Fri, 25 Jan 2019 06:23:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729230AbfAYOXN (ORCPT + 31 others); Fri, 25 Jan 2019 09:23:13 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2763 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728913AbfAYOWG (ORCPT ); Fri, 25 Jan 2019 09:22:06 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 572E1CA0BFAF0C75C47E; Fri, 25 Jan 2019 22:21:59 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:52 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 08/13] scsi: hisi_sas: Reject setting programmed minimum linkrate > 1.5G Date: Fri, 25 Jan 2019 22:22:34 +0800 Message-ID: <1548426159-225679-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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 The SAS controller cannot support a programmed minimum linkrate of > 1.5G (it will always negotiate to 1.5G at least), so just reject it. This solves a strange situation where the PHY negotiated linkrate may be less than the programmed minimum linkrate. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 8f7f82d..32f6928 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -946,7 +946,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) return hisi_sas_task_exec(task, gfp_flags, 0, NULL); } -static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, +static int hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, struct sas_phy_linkrates *r) { struct sas_phy_linkrates _r; @@ -955,6 +955,9 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, struct asd_sas_phy *sas_phy = &phy->sas_phy; enum sas_linkrate min, max; + if (r->minimum_linkrate > SAS_LINK_RATE_1_5_GBPS) + return -EINVAL; + if (r->maximum_linkrate == SAS_LINK_RATE_UNKNOWN) { max = sas_phy->phy->maximum_linkrate; min = r->minimum_linkrate; @@ -962,7 +965,7 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, max = r->maximum_linkrate; min = sas_phy->phy->minimum_linkrate; } else - return; + return -EINVAL; _r.maximum_linkrate = max; _r.minimum_linkrate = min; @@ -974,6 +977,8 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, msleep(100); hisi_hba->hw->phy_set_linkrate(hisi_hba, phy_no, &_r); hisi_hba->hw->phy_start(hisi_hba, phy_no); + + return 0; } static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, @@ -999,8 +1004,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, break; case PHY_FUNC_SET_LINK_RATE: - hisi_sas_phy_set_linkrate(hisi_hba, phy_no, funcdata); - break; + return hisi_sas_phy_set_linkrate(hisi_hba, phy_no, funcdata); case PHY_FUNC_GET_EVENTS: if (hisi_hba->hw->get_events) { hisi_hba->hw->get_events(hisi_hba, phy_no); From patchwork Fri Jan 25 14:22: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: 156595 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp417714jaa; Fri, 25 Jan 2019 06:22:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ZkkzkfDFc77wsCezZG0SECBg01ZM6SeViY1ss0cBfFCqbdi0jYqEFCxaH6SPVgZCwCUOE X-Received: by 2002:a62:2781:: with SMTP id n123mr11312901pfn.138.1548426148019; Fri, 25 Jan 2019 06:22:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426148; cv=none; d=google.com; s=arc-20160816; b=K39/GHXEZyW2vquinahl11wpGtiqfUNziAWNv+3bLTvSZB7pbyvcEz/XmORmatvzFp 6HRn+ZU6FD6DWWo/T/+WF6xbtJksp6dxRQ9lu3ROsaQf807T1xudF0d3gSF0sVW34j/Y GTUdhj2xyrgtFIm8GOD7x4jqlHiL0/BrQkvtNjOTCVXstq+dOiEYf+KdQ/+EMrm6tjr7 +5OhktCG2P8K0BOXxFnCI/xXcFDehvzO+C8Dxz/uNsh5A2alCc1lVOdxEs2/PNnMFWIJ pwnQ0yy/pZRN9wt6ldGv5VldQVQABipQNEPWze6/lh80l6ESyEp9Aw+LwUAlkLj/xA9g m9QQ== 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=A5QZrCzwzQABhadkceP+oTEDpzBB10BsYNTwm1KwNjo=; b=gtxfQPDnoz0L/VvZ8jFYzMDMzCyvYzpMxYLBDun8tAuH1lRJrbQdw0lWp8t7exS61d tDBqUUYfVckwH6hL5E6bdF+mCiDMe7SPK82w4YnLGqoWuutnjba0o4ulPboGq4jpGJG/ ApGldrKHQm96mydasc7t9cE40RxraNf2dm+rNXI7gSB+iTnftcbBo7T+/bzPTOYkfuww B7PEsWFKBhPaLZdpUw98491UwAFsUnPct3kHomaY4o6ERtda1xOsj0Rz/6lvtz4U8ve6 kJzp/RmKqUn3gsiMjvsxGcQzImxyhCZ7fMbro8YBcsCXDO7PipguuAzvgSDn6+G5Twq0 tY3g== 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 gn8si24731752plb.264.2019.01.25.06.22.27; Fri, 25 Jan 2019 06:22:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729108AbfAYOW0 (ORCPT + 31 others); Fri, 25 Jan 2019 09:22:26 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2761 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728937AbfAYOWH (ORCPT ); Fri, 25 Jan 2019 09:22:07 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 495A9CB15F08D0AB99D0; Fri, 25 Jan 2019 22:21:59 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:52 +0800 From: John Garry To: , CC: , , , Xiaofei Tan , "John Garry" Subject: [PATCH 09/13] scsi: hisi_sas: Fix losing directly attached disk when hot-plug Date: Fri, 25 Jan 2019 22:22:35 +0800 Message-ID: <1548426159-225679-10-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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: Xiaofei Tan Hot-plugging SAS wire of direct hard disk backplane may cause disk lost. We have done this test with several types of SATA disk from different venders, and only two models from Seagate has this problem, ST4000NM0035-1V4107 and ST3000VM002-1ET166. The root cause is that the disk doesn't send D2H frame after OOB finished. SAS controller will issue phyup interrupt only when D2H frame is received, otherwise, will be waiting there all the time. When this issue happen, we can find the disk again with link reset. To fix this issue, we setup an timer after OOB finished. If the PHY is not up in 20s, do link reset. Notes: the 20s is an experience value. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 4 ++++ drivers/scsi/hisi_sas/hisi_sas_main.c | 26 ++++++++++++++++++++++++++ drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 8 ++++++++ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 27 ++++++++++++++++++--------- 4 files changed, 56 insertions(+), 9 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 235b819..9b35f84 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -76,6 +76,8 @@ #define HISI_SAS_PROT_MASK (HISI_SAS_DIF_PROT_MASK) +#define HISI_SAS_WAIT_PHYUP_TIMEOUT 20 + struct hisi_hba; enum { @@ -141,6 +143,7 @@ struct hisi_sas_phy { struct asd_sas_phy sas_phy; struct sas_identify identify; struct completion *reset_completion; + struct timer_list timer; spinlock_t lock; u64 port_id; /* from hw */ u64 frame_rcvd_size; @@ -522,6 +525,7 @@ extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, extern void hisi_sas_rst_work_handler(struct work_struct *work); extern void hisi_sas_sync_rst_work_handler(struct work_struct *work); extern void hisi_sas_kill_tasklets(struct hisi_hba *hisi_hba); +extern void hisi_sas_phy_oob_ready(struct hisi_hba *hisi_hba, int phy_no); extern bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, enum hisi_sas_phy_event event); extern void hisi_sas_release_tasks(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 32f6928..0a817e9 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -808,6 +808,30 @@ bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, } EXPORT_SYMBOL_GPL(hisi_sas_notify_phy_event); +static void hisi_sas_wait_phyup_timedout(struct timer_list *t) +{ + struct hisi_sas_phy *phy = from_timer(phy, t, timer); + struct hisi_hba *hisi_hba = phy->hisi_hba; + struct device *dev = hisi_hba->dev; + int phy_no = phy->sas_phy.id; + + dev_warn(dev, "phy%d wait phyup timeout, issuing link reset\n", phy_no); + hisi_sas_notify_phy_event(phy, HISI_PHYE_LINK_RESET); +} + +void hisi_sas_phy_oob_ready(struct hisi_hba *hisi_hba, int phy_no) +{ + struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; + struct device *dev = hisi_hba->dev; + + if (!timer_pending(&phy->timer)) { + dev_dbg(dev, "phy%d OOB ready\n", phy_no); + phy->timer.expires = jiffies + HISI_SAS_WAIT_PHYUP_TIMEOUT * HZ; + add_timer(&phy->timer); + } +} +EXPORT_SYMBOL_GPL(hisi_sas_phy_oob_ready); + static void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int phy_no) { struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; @@ -836,6 +860,8 @@ static void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int phy_no) INIT_WORK(&phy->works[i], hisi_sas_phye_fns[i]); spin_lock_init(&phy->lock); + + timer_setup(&phy->timer, hisi_sas_wait_phyup_timedout, 0); } static void hisi_sas_port_notify_formed(struct asd_sas_phy *sas_phy) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 85236ef..6eb76f3 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -2676,6 +2676,8 @@ static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba) if (is_sata_phy_v2_hw(hisi_hba, phy_no)) goto end; + del_timer(&phy->timer); + if (phy_no == 8) { u32 port_state = hisi_sas_read32(hisi_hba, PORT_STATE); @@ -2755,6 +2757,7 @@ static int phy_down_v2_hw(int phy_no, struct hisi_hba *hisi_hba) struct hisi_sas_port *port = phy->port; struct device *dev = hisi_hba->dev; + del_timer(&phy->timer); hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 1); phy_state = hisi_sas_read32(hisi_hba, PHY_STATE); @@ -2943,6 +2946,9 @@ static irqreturn_t int_chnl_int_v2_hw(int irq_no, void *p) if (irq_value0 & CHL_INT0_SL_RX_BCST_ACK_MSK) phy_bcast_v2_hw(phy_no, hisi_hba); + if (irq_value0 & CHL_INT0_PHY_RDY_MSK) + hisi_sas_phy_oob_ready(hisi_hba, phy_no); + hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, irq_value0 & (~CHL_INT0_HOTPLUG_TOUT_MSK) @@ -3226,6 +3232,8 @@ static irqreturn_t sata_int_v2_hw(int irq_no, void *p) unsigned long flags; int phy_no, offset; + del_timer(&phy->timer); + phy_no = sas_phy->id; initial_fis = &hisi_hba->initial_fis[phy_no]; fis = &initial_fis->fis; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 4b628c2..f1009e2 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1290,6 +1290,7 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) struct device *dev = hisi_hba->dev; unsigned long flags; + del_timer(&phy->timer); hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_PHY_ENA_MSK, 1); port_id = hisi_sas_read32(hisi_hba, PHY_PORT_NUM_MA); @@ -1383,9 +1384,11 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) static irqreturn_t phy_down_v3_hw(int phy_no, struct hisi_hba *hisi_hba) { + struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; u32 phy_state, sl_ctrl, txid_auto; struct device *dev = hisi_hba->dev; + del_timer(&phy->timer); hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 1); phy_state = hisi_sas_read32(hisi_hba, PHY_STATE); @@ -1554,6 +1557,19 @@ static void handle_chl_int2_v3_hw(struct hisi_hba *hisi_hba, int phy_no) hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2, irq_value); } +static void handle_chl_int0_v3_hw(struct hisi_hba *hisi_hba, int phy_no) +{ + u32 irq_value0 = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT0); + + if (irq_value0 & CHL_INT0_PHY_RDY_MSK) + hisi_sas_phy_oob_ready(hisi_hba, phy_no); + + hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, + irq_value0 & (~CHL_INT0_SL_RX_BCST_ACK_MSK) + & (~CHL_INT0_SL_PHY_ENABLE_MSK) + & (~CHL_INT0_NOT_RDY_MSK)); +} + static irqreturn_t int_chnl_int_v3_hw(int irq_no, void *p) { struct hisi_hba *hisi_hba = p; @@ -1564,8 +1580,8 @@ static irqreturn_t int_chnl_int_v3_hw(int irq_no, void *p) & 0xeeeeeeee; while (irq_msk) { - u32 irq_value0 = hisi_sas_phy_read32(hisi_hba, phy_no, - CHL_INT0); + if (irq_msk & (2 << (phy_no * 4))) + handle_chl_int0_v3_hw(hisi_hba, phy_no); if (irq_msk & (4 << (phy_no * 4))) handle_chl_int1_v3_hw(hisi_hba, phy_no); @@ -1573,13 +1589,6 @@ static irqreturn_t int_chnl_int_v3_hw(int irq_no, void *p) if (irq_msk & (8 << (phy_no * 4))) handle_chl_int2_v3_hw(hisi_hba, phy_no); - if (irq_msk & (2 << (phy_no * 4)) && irq_value0) { - hisi_sas_phy_write32(hisi_hba, phy_no, - CHL_INT0, irq_value0 - & (~CHL_INT0_SL_RX_BCST_ACK_MSK) - & (~CHL_INT0_SL_PHY_ENABLE_MSK) - & (~CHL_INT0_NOT_RDY_MSK)); - } irq_msk &= ~(0xe << (phy_no * 4)); phy_no++; } From patchwork Fri Jan 25 14:22:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 156594 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp417512jaa; Fri, 25 Jan 2019 06:22:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN7qt8XHGDA14KlNqF/CraB3IkIUM6/vRhjvtkRRgh2COWQvRXJjqpzZmh5FdKw+AigBo7oo X-Received: by 2002:a63:6704:: with SMTP id b4mr10181929pgc.100.1548426137031; Fri, 25 Jan 2019 06:22:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426137; cv=none; d=google.com; s=arc-20160816; b=Ux77k0ZBNL5kru6suymLULPB4PLoK6BmTnHS1nZsgvqJTOEgUFoK3fTvVLi89kcC7I k2I7PVQeI4aiKwkKIOKuuxcPH/aVxYdo8Jfg7iGI0VwYdo++cMNgnCH3d6vE1f4dkGSA +Mf2O+fK76yTLBJX7kkd4JCBkOu5lqL0P5mwioSLRcisMkSizxALVxWy9qW1/el39HdZ XdaSbp74rlphcl5A0LFq1ceC1w6naQAKIBb7t8NEoejxS52sIrK9Ch2KEsexcY42i5RJ 8vW19HPAlYWAYuf3UlEQe2A8onTwm7fUn14DXbRwAsZV8FvUG3xTeyjfMzedcBZIZYXX 36Yw== 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=O7vmXXbzBoOsp7OnNY9SFJ2hwu0uG2ggCybQzphC2mw=; b=GqEr0qERBjC/3pk9i8iMhCLihWBzoKUkqelLyc7dfxiFFWVttstAdaXAhF4y9lYN+0 X89Fz0QCgSLy53aw2EBV+5X4QtUHBxUQvSZ/xVylCNMdt71MqbAhUDLoeuKr/ObeugCF Bqe4U4fm9AYjLZfJ79Wyg5AETgHIt0F39QaUldxEkurM6HD+CnzoiuP3OhWSSk7MifNK cQ4CaA+cKi/AvAbt1tuKV+BkzN3wdzKEskviA+DWW5eNjgw4Iw5/tNyhzu51N/hQpd6C 1f1+lX8w2T5QhSklCSgHWBRoE41M8o8W7eHEeLiV+YXoFJw6OD0FSgEB/P/zBEceCnUy DEmA== 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 t75si24975921pfa.170.2019.01.25.06.22.16; Fri, 25 Jan 2019 06:22:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729072AbfAYOWP (ORCPT + 31 others); Fri, 25 Jan 2019 09:22:15 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2764 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728936AbfAYOWK (ORCPT ); Fri, 25 Jan 2019 09:22:10 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 53177ACC1C4F67D353C1; Fri, 25 Jan 2019 22:21:59 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:53 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 10/13] scsi: hisi_sas: Correct memory allocation size for DQ debugfs Date: Fri, 25 Jan 2019 22:22:36 +0800 Message-ID: <1548426159-225679-11-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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 Some sizes we allocate for debugfs structure is incorrect, so fix them. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 0a817e9..89f1bc5 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2502,7 +2502,7 @@ static void hisi_sas_debugfs_snapshot_cq_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_dq_reg(struct hisi_hba *hisi_hba) { - int queue_entry_size = hisi_hba->hw->complete_hdr_size; + int queue_entry_size = sizeof(struct hisi_sas_cmd_hdr); int i; for (i = 0; i < hisi_hba->queue_count; i++) @@ -2945,7 +2945,7 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) } /* Alloc buffer for dq */ - sz = hisi_hba->hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; + 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); From patchwork Fri Jan 25 14:22:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 156597 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp417998jaa; Fri, 25 Jan 2019 06:22:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Sh2eCLWilHc01Z4FGr7MVBXZpUvqBUGJ8f2y4A2ZovKfhKPPbQA9hHJOEQaAheeEfuUb2 X-Received: by 2002:a63:d655:: with SMTP id d21mr10194079pgj.280.1548426163118; Fri, 25 Jan 2019 06:22:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426163; cv=none; d=google.com; s=arc-20160816; b=u8Dv6pGqBOmrlWHvwP2PBQR7kghxq1d423stMVbIcGYkDo9hStziVbZH/Px9Av+lRH o6MJaIBus7BZytptCY138m11C/7SXd54OSWsI4AceRDhdth63Xe5HhvKLN31VKFtojl3 owIudazu22/pn+91GIawDYQ4FGTOXpxijGIEOpC4Tl1Z0yGHDVSZWcTP7CFhZQ+XPeLJ WX+6xgR40+nPAXgMg3XKnBOMnM4rKpkOA26j9j5FuW4a9Moo7vK87NPo1YTIFZi6Brx+ bFheSc7pg+8vY7cFJdLk+pBaMQS67ZTN4nmovtwqbvMG5zTQNOr3bsPKai/gr5G3vJ1o 7Ztg== 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=+ejnYQ8PZxP+ICIGRpQs+zbcrnCI9JwF40qSI+yn5jA=; b=clWI+24qrxrnaufiGO4gEoNgzB4YKVvt0uvwuTxth8SKcM0I1rwLpw63EWbSU8BoiQ 1lC1syOHYJwZIUWdo1+Zk7q6ica+5CPZX/LmzFoTmo65xqXhybEemPDOzRR7UadYIF3p sGVqGcVYP0NXKtWhBfMuTXmRTSlaTqKPnFIih/rjkBsJqG6PndUDJRHnm+uRvgLO0c3u ViOd/+rISZyXvvgGIphpLf5cK2FSP8rjcBR2K4r3+4DPrv81Il0E4VKElt5cSgICCkys fM1sF9iRBbxZcsbp2R5pABWTl7hTZm+ARgVUuXjTh5JlQi7ZOWGOaSKoMTLXGaPNmcDQ 3x1A== 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 p26si20283653pfj.244.2019.01.25.06.22.42; Fri, 25 Jan 2019 06:22:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729180AbfAYOWl (ORCPT + 31 others); Fri, 25 Jan 2019 09:22:41 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:56364 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728641AbfAYOWH (ORCPT ); Fri, 25 Jan 2019 09:22:07 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 471E79C91A481FA10234; Fri, 25 Jan 2019 22:22:04 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:53 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 11/13] scsi: hisi_sas: Some misc tidy-up Date: Fri, 25 Jan 2019 22:22:37 +0800 Message-ID: <1548426159-225679-12-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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 Sparse detected some problems in the driver, so tidy them up. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 89f1bc5..e48b627 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2075,14 +2075,18 @@ void hisi_sas_kill_tasklets(struct hisi_hba *hisi_hba) void hisi_sas_init_mem(struct hisi_hba *hisi_hba) { - int i, s, max_command_entries = hisi_hba->hw->max_command_entries; + int i, s, j, max_command_entries = hisi_hba->hw->max_command_entries; + struct hisi_sas_breakpoint *sata_breakpoint = hisi_hba->sata_breakpoint; for (i = 0; i < hisi_hba->queue_count; i++) { struct hisi_sas_cq *cq = &hisi_hba->cq[i]; struct hisi_sas_dq *dq = &hisi_hba->dq[i]; + struct hisi_sas_cmd_hdr *cmd_hdr = hisi_hba->cmd_hdr[i]; + + s = sizeof(struct hisi_sas_cmd_hdr); + for (j = 0; j < HISI_SAS_QUEUE_SLOTS; j++) + memset(&cmd_hdr[j], 0, s); - s = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS; - memset(hisi_hba->cmd_hdr[i], 0, s); dq->wr_point = 0; s = hisi_hba->hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; @@ -2099,8 +2103,9 @@ void hisi_sas_init_mem(struct hisi_hba *hisi_hba) s = max_command_entries * sizeof(struct hisi_sas_breakpoint); memset(hisi_hba->breakpoint, 0, s); - s = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_sata_breakpoint); - memset(hisi_hba->sata_breakpoint, 0, s); + s = sizeof(struct hisi_sas_sata_breakpoint); + for (j = 0; j < HISI_SAS_MAX_ITCT_ENTRIES; j++) + memset(&sata_breakpoint[j], 0, s); } EXPORT_SYMBOL_GPL(hisi_sas_init_mem); @@ -2157,10 +2162,9 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) s = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_itct); hisi_hba->itct = dmam_alloc_coherent(dev, s, &hisi_hba->itct_dma, - GFP_KERNEL); + GFP_KERNEL | __GFP_ZERO); if (!hisi_hba->itct) goto err_out; - memset(hisi_hba->itct, 0, s); hisi_hba->slot_info = devm_kcalloc(dev, max_command_entries, sizeof(struct hisi_sas_slot), @@ -2505,10 +2509,17 @@ static void hisi_sas_debugfs_snapshot_dq_reg(struct hisi_hba *hisi_hba) int queue_entry_size = sizeof(struct hisi_sas_cmd_hdr); int i; - for (i = 0; i < hisi_hba->queue_count; i++) - memcpy(hisi_hba->debugfs_cmd_hdr[i], - hisi_hba->cmd_hdr[i], - HISI_SAS_QUEUE_SLOTS * queue_entry_size); + for (i = 0; i < hisi_hba->queue_count; i++) { + struct hisi_sas_cmd_hdr *debugfs_cmd_hdr, *cmd_hdr; + int j; + + debugfs_cmd_hdr = hisi_hba->debugfs_cmd_hdr[i]; + cmd_hdr = hisi_hba->cmd_hdr[i]; + + for (j = 0; j < HISI_SAS_QUEUE_SLOTS; j++) + memcpy(&debugfs_cmd_hdr[j], &cmd_hdr[j], + queue_entry_size); + } } static void hisi_sas_debugfs_snapshot_port_reg(struct hisi_hba *hisi_hba) From patchwork Fri Jan 25 14:22:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 156596 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp417783jaa; Fri, 25 Jan 2019 06:22:32 -0800 (PST) X-Google-Smtp-Source: ALg8bN4mikzmd6B1Vn+dqtl0/qenLWeaOeitffupyqu55Lsni9EHA5b2LdZ9JdQiAoiVjnVQRIuc X-Received: by 2002:a63:c848:: with SMTP id l8mr10042548pgi.78.1548426152684; Fri, 25 Jan 2019 06:22:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426152; cv=none; d=google.com; s=arc-20160816; b=GzZ0gn+UaRn94g5cavDxoAfVFxCIN+U6JgZLBnUhp2TxpJZtcfizwmHQO7LihQE7Yf Manu/fr9U1KtLmyr9hm2zxH6aeZ0XOFYmAg0/sZccjezXEZGrvMEvbpV7JtSDn/4PL6w E5wFQe0SbpXP73hrohgCJahgSIYFWR2BM7lIN/fLVXVYCpNievQQfeBl2yPPJoMgs6WM vAfiDVTZHAjBfOTRbO9CPyMoNck2rqOiAJKUO2jCR48gcrVPO5+jKlZ2SEWjzGtjnEvB dkpqanltb2FzVrCZGVZfBbBTmpYK20LIfQq+M0QxKJD6YKc7zpm/2bpbnZ6Q6QeLNvIi Nudg== 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=O3fftt//QpuwvpJKKLWtFfLZ3bzf9Y1OK28m694pX1s=; b=zmQPEw+3hqu9yl0AlKJtJeLzRnUyoFT8h7jbn6d8TrSUHGIkpJOAcvM+rnnnK1j5qr Hja4O+6jQfP+Ura+WHqEzjJFWFEsOqvfMbUPvb0E5+DeLZO9KacIAtmz0mSvBU/rYJWV 5M8ekHGVRBzt4iZBJntGGSDZqa+GSDtAWcbIDMLPhhMPi/km10sYNItfTmhEtlJ8nLln mNOXPWIoNDPxfJD4DY6tCQWemD0GE9OsQrUQQZqlx0T4YM52rhkO5i4OmD4XRaFsGomO /oCbwV3+YvtXBtBX/8uhJZ6OwynbK0uxYMyTGhrA07totdqt/RCeKxoDhOxSamIDkjmS 9luQ== 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 v34si24113534plg.205.2019.01.25.06.22.32; Fri, 25 Jan 2019 06:22:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728821AbfAYOWZ (ORCPT + 31 others); Fri, 25 Jan 2019 09:22:25 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:56362 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728933AbfAYOWH (ORCPT ); Fri, 25 Jan 2019 09:22:07 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 422B640F0E0E118A240A; Fri, 25 Jan 2019 22:22:04 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:54 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 12/13] scsi: hisi_sas: Fix to only call scsi_get_prot_op() for non-NULL scsi_cmnd Date: Fri, 25 Jan 2019 22:22:38 +0800 Message-ID: <1548426159-225679-13-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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 A NULL-pointer dereference was introduced for TMF SSP commands from the upstreaming reworking. Fix this by relocating the scsi_get_prot_op() callsite. Fixes: d6a9000b81be ("scsi: hisi_sas: Add support for DIF feature for v2 hw") Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index f1009e2..108683b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1035,8 +1035,8 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba, struct sas_ssp_task *ssp_task = &task->ssp_task; struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; struct hisi_sas_tmf_task *tmf = slot->tmf; - unsigned char prot_op = scsi_get_prot_op(scsi_cmnd); int has_data = 0, priority = !!tmf; + unsigned char prot_op; u8 *buf_cmd; u32 dw1 = 0, dw2 = 0, len = 0; @@ -1051,6 +1051,7 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba, dw1 |= 2 << CMD_HDR_FRAME_TYPE_OFF; dw1 |= DIR_NO_DATA << CMD_HDR_DIR_OFF; } else { + prot_op = scsi_get_prot_op(scsi_cmnd); dw1 |= 1 << CMD_HDR_FRAME_TYPE_OFF; switch (scsi_cmnd->sc_data_direction) { case DMA_TO_DEVICE: From patchwork Fri Jan 25 14:22:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 156598 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp418083jaa; Fri, 25 Jan 2019 06:22:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN5X6udJXqc2nnPvzjCbuoo3lm74azmsmJ+M1SXkda+IT/HOEXBlJfM060waIuf/lhMyBHeI X-Received: by 2002:a17:902:b118:: with SMTP id q24mr11367536plr.209.1548426168520; Fri, 25 Jan 2019 06:22:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426168; cv=none; d=google.com; s=arc-20160816; b=NxlpZouqBRPGBW+knaYk6sf6/v9fk/fSxdRyRdJirj+rrElMRRNbT7DP9PBeEtCGE2 lKFD/DSRXB4y1/QJ4fl7lCc3cmuCfCqnxGnDiAy/h7j0oIzp3E5UiXqQ4A/3A5Fnkvtj 9lzFFJpC7MhwuJ/hOfCfuG2hZ7Srb4oeediMx7qAlFURez+HuJDq3U6KOGb+ZpsfCHMq Z211UO4f/wr1dhKVL8XiSxdjGs1HBvrWIbd5CH4T0evBvkoh77oGRs7Tt6fVRMMMQGQD s3Cl7w0zno8ALvVMp8pg/Pd7s41Iz/9KUq+UkU9vWSYOxLRSzypTEaNS6t0UF8Bg9Mvq jz7g== 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=kUdveK5UOEQiEd7npgBgStjl7fUG7DZIX5Tnmcg0BFM=; b=tEBxIPQracT1pffj7ALf2YKVCxG7PL/HdKPeCWZE2hCdITgkW/Qy3N9IbrEZaMWgfG ZZSIdM54EcoSI02l580V+OX+sRRFdMhcJU3/lnW6wWtayxN/DStDJ7l3Dsa1PB1xFpY6 SntzEiatKK4//1sq9vq5x1NDMpkMw1Sh/vCG0HBYIIRhMO53huL8/IVy45TJzsLqyW0G iQu29M8vcKiZTIX1lIvf+MVMIfwDmf2+ah8RpERcM+8tiBzVsXJMGUAlWJQmWUDQ2xpg cG18vS943Gp7sU912Ey5hjMmWlQ+HUHOFdEICyPI5VjMFYhISbs1nfBKEEYASEm+ohet D2eg== 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 l5si24016089plt.5.2019.01.25.06.22.48; Fri, 25 Jan 2019 06:22:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729226AbfAYOWq (ORCPT + 31 others); Fri, 25 Jan 2019 09:22:46 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:56366 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728934AbfAYOWH (ORCPT ); Fri, 25 Jan 2019 09:22:07 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6B10F5992F04C7971629; Fri, 25 Jan 2019 22:22:04 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:54 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 13/13] scsi: hisi_sas: Add missing seq_printf() call in hisi_sas_show_row_32() Date: Fri, 25 Jan 2019 22:22:39 +0800 Message-ID: <1548426159-225679-14-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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 This call must have been missed when I reworked the debugfs feature for upstreaming, so add it back. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 1 + 1 file changed, 1 insertion(+) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index e48b627..13ab0ad 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2692,6 +2692,7 @@ static int hisi_sas_show_row_32(struct seq_file *s, int index, /* completion header size not fixed per HW version */ seq_printf(s, "index %04d:\n\t", index); for (i = 1; i <= sz / 4; i++, ptr++) { + seq_printf(s, " 0x%08x", le32_to_cpu(*ptr)); if (!(i % 4)) seq_puts(s, "\n\t"); }