From patchwork Mon Feb 19 19:13:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 128842 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3801660ljc; Mon, 19 Feb 2018 10:23:38 -0800 (PST) X-Google-Smtp-Source: AH8x224eWDbqNxdVg8YNfVbfUEZs8VrkbVSGexvrbr9PnM9ljK8ET+2QuQaO9Hkt3FXb/1Z2qxIB X-Received: by 2002:a17:902:34a:: with SMTP id 68-v6mr15282872pld.276.1519064618479; Mon, 19 Feb 2018 10:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519064618; cv=none; d=google.com; s=arc-20160816; b=vT23DodIqh2pEAlrGnK/tWja1DeQ9rWdxPyWoc5FKuyA11iKmzPTDvszuspfxIBvyt TngHStxwQ3iQmFBNBPWSR2iOv8K0NDzPlBeVmE5c/oaBFANot+28UXzg+JMLyZLtlxUL MslUgIOe6A6dqJ+01aCKFN58PstPCcxhBKGoq4rA5doKR699S1ViV2J8QilOEX2SGQ5G 2gwaUEPurzHyo8zcgXkaO0iRsFDCMytZXxGjgQWy72F1O4GMbc8RNoYObXMb+01lf7fF Xl2hFhnzuknC8Hfs7gFkVcatoIaEBZoRigDTv5SG0RjnCAIJKTipJY4Y0Tok20ajGRya g5Qg== 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:arc-authentication-results; bh=/CrMue9HbsBxIV0jPmPgeYRWQedTXlzLHFlymRVa1qI=; b=ov3H3h8iiIQhJ0wX0bqJ6mt4O+n4cVwBxD0yx7j7wc+JWDu45FlhSA8e3eR8kZ63g2 cvN7AnNAl+6UAt/cy4CGrBR/8IbWYsz+mKMNiVgpZo+Vh1jfE1N1N16nmVYc+nF7QdZR CqEV7UCSztEYNn+kEqzhfzTbFRmrCo5nlOQLwkZmMH6GGJjuxykfhqkD7ScVaebvLutT 2jLaEgLn1HqBO4loiM+9N3ItY2BCDsg2uuuqG4GpvA+wTIlZaU3NzMT3g6GatxcdlDtR Rmkk6hH2bl/hXz7sectwG5tz/dHSDyCXHWOm3zhGHLaVmSBlLTzEqymln42wwjeVlqkJ tFDg== 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 i11si3508430pgq.332.2018.02.19.10.23.38; Mon, 19 Feb 2018 10:23:38 -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 S1753704AbeBSSXf (ORCPT + 28 others); Mon, 19 Feb 2018 13:23:35 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5252 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753434AbeBSSWQ (ORCPT ); Mon, 19 Feb 2018 13:22:16 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 183041E528CCC; Tue, 20 Feb 2018 02:22:00 +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.361.1; Tue, 20 Feb 2018 02:21:52 +0800 From: John Garry To: , , , CC: , , , , Xiaofei Tan , John Garry Subject: [PATCH 2/8] scsi: hisi_sas: support the property of signal attenuation for v2 hw Date: Tue, 20 Feb 2018 03:13:25 +0800 Message-ID: <1519067611-206638-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519067611-206638-1-git-send-email-john.garry@huawei.com> References: <1519067611-206638-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 The register SAS_PHY_CTRL is configured according to signal quality. The signal quality is calculated by signal attenuation of hardware physical link. It may be different for different PCB layout. So, in order to give better support to new board, this patch add support to reading the devicetree property, signal-attenuation. Of course, we still keep an default value in driver to adapt old board. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 39 +++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 4ccb61e..ab6db50 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -406,6 +406,17 @@ struct hisi_sas_err_record_v2 { __le32 dma_rx_err_type; }; +struct signal_attenuation_s { + u32 de_emphasis; + u32 preshoot; + u32 boost; +}; + +struct sig_atten_lu_s { + const struct signal_attenuation_s *att; + u32 sas_phy_ctrl; +}; + static const struct hisi_sas_hw_error one_bit_ecc_errors[] = { { .irq_msk = BIT(SAS_ECC_INTR_DQE_ECC_1B_OFF), @@ -1130,9 +1141,16 @@ static void phys_try_accept_stp_links_v2_hw(struct hisi_hba *hisi_hba) } } +static const struct signal_attenuation_s x6000 = {9200, 0, 10476}; +static const struct sig_atten_lu_s sig_atten_lu[] = { + { &x6000, 0x3016a68 }, +}; + static void init_reg_v2_hw(struct hisi_hba *hisi_hba) { struct device *dev = hisi_hba->dev; + u32 sas_phy_ctrl = 0x30b9908; + u32 signal[3]; int i; /* Global registers init */ @@ -1176,9 +1194,28 @@ static void init_reg_v2_hw(struct hisi_hba *hisi_hba) hisi_sas_write32(hisi_hba, AXI_AHB_CLK_CFG, 1); hisi_sas_write32(hisi_hba, HYPER_STREAM_ID_EN_CFG, 1); + /* Get sas_phy_ctrl value to deal with TX FFE issue. */ + if (!device_property_read_u32_array(dev, "signal-attenuation", + signal, ARRAY_SIZE(signal))) { + for (i = 0; i < ARRAY_SIZE(sig_atten_lu); i++) { + const struct sig_atten_lu_s *lookup = &sig_atten_lu[i]; + const struct signal_attenuation_s *att = lookup->att; + + if ((signal[0] == att->de_emphasis) && + (signal[1] == att->preshoot) && + (signal[2] == att->boost)) { + sas_phy_ctrl = lookup->sas_phy_ctrl; + break; + } + } + + if (i == ARRAY_SIZE(sig_atten_lu)) + dev_warn(dev, "unknown signal attenuation values, using default PHY ctrl config\n"); + } + for (i = 0; i < hisi_hba->n_phy; i++) { hisi_sas_phy_write32(hisi_hba, i, PROG_PHY_LINK_RATE, 0x855); - hisi_sas_phy_write32(hisi_hba, i, SAS_PHY_CTRL, 0x30b9908); + hisi_sas_phy_write32(hisi_hba, i, SAS_PHY_CTRL, sas_phy_ctrl); hisi_sas_phy_write32(hisi_hba, i, SL_TOUT_CFG, 0x7d7d7d7d); hisi_sas_phy_write32(hisi_hba, i, SL_CONTROL, 0x0); hisi_sas_phy_write32(hisi_hba, i, TXID_AUTO, 0x2); From patchwork Mon Feb 19 19:13:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 128841 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3801477ljc; Mon, 19 Feb 2018 10:23:26 -0800 (PST) X-Google-Smtp-Source: AH8x226TurHr9LMhOrQgPgScQIQh/Ol8up+mxQmBms8aIcjqF8C1IZbfUHr0uy3s/Ae/ouLsVff/ X-Received: by 10.99.96.73 with SMTP id u70mr12547348pgb.199.1519064606392; Mon, 19 Feb 2018 10:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519064606; cv=none; d=google.com; s=arc-20160816; b=nBxqe0TuAOBicwJSShmGtTZ5IeV8EnoG9jAAKJi/ftq7/sJ0cGLs5Bk/Bn+pBjWaal eBZWJ7TjHNiz3KwgZPpsSnmOo8/LRFppcAtX1TMY5aMpAEkZmE32in12Qv/MbWm/WUt0 WXusWaOLOK8EBF8HVQE8pGVUiWxIWFhaXP9rUvtfK6L89antrW8OzYM06GQCB9nvyEOa jNehJQXE4/dDvi2xHFSa+tWz5LaV6AHsYMNrrRPweO9oEsuYk0VzHrINQE9JPrZ25caf xtPR1Ftl+4seVWAW8W/jqDHLyvoDI2LAO8yENIe1omDy2CaEzqipALy/mTXQVGLqEXpD G8CA== 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:arc-authentication-results; bh=kwRZLtWXSDpiYnHARKX13AKFxUCttGhCKKOlWtFWGPY=; b=iBoXFlAxnWoGhtQxubf3yU9qdSycApnNDmCZI1lV2+770ePjYg3YZsiirGPi+T9umW XzgyGoQK5LFNo2avy/TnSf2orR19nEEcT600HxUqtvg339Zk/Nno2nfs9K1ASzPjqjoJ 62ju3QkVYcaX2sJMci5GNwfTu73RCVtIcRN54GjsfafK0LrX6YjxP/gdUsSCDbEm5IDG tNekGhkwdkVGxOHQDXLiIzu4a4hBkYa5EB3/D07z/yxTITeINXNHIfJVV/gLx5hsenri 1WObWuXPYPatdgPKHGbeEQSMjlYosV+f7eA4r24gGyhqTPlVcYlB2JzCFlWQsfJE2lr+ Ytbg== 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 91-v6si6015931plh.570.2018.02.19.10.23.26; Mon, 19 Feb 2018 10: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 S1753512AbeBSSWS (ORCPT + 28 others); Mon, 19 Feb 2018 13:22:18 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5245 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753397AbeBSSWN (ORCPT ); Mon, 19 Feb 2018 13:22:13 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id A2FC1B919054; Tue, 20 Feb 2018 02: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.361.1; Tue, 20 Feb 2018 02:21:53 +0800 From: John Garry To: , , , CC: , , , , Xiaofei Tan , John Garry Subject: [PATCH 4/8] scsi: hisi_sas: fix the issue of setting linkrate register Date: Tue, 20 Feb 2018 03:13:27 +0800 Message-ID: <1519067611-206638-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519067611-206638-1-git-send-email-john.garry@huawei.com> References: <1519067611-206638-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 It is not right to set the register PROG_PHY_LINK_RATE while PHY is still enabled. So if we want to change PHY linkrate, we need to disable PHY before setting the register PROG_PHY_LINK_RATE, and then start-up PHY. This patch is to fix this issue. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 5 +++-- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 5 +++-- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 38bbda9..2eb8980 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -881,10 +881,11 @@ static void phy_set_linkrate_v1_hw(struct hisi_hba *hisi_hba, int phy_no, prog_phy_link_rate &= ~0xff; prog_phy_link_rate |= rate_mask; + disable_phy_v1_hw(hisi_hba, phy_no); + msleep(100); hisi_sas_phy_write32(hisi_hba, phy_no, PROG_PHY_LINK_RATE, prog_phy_link_rate); - - phy_hard_reset_v1_hw(hisi_hba, phy_no); + start_phy_v1_hw(hisi_hba, phy_no); } static int get_wideport_bitmap_v1_hw(struct hisi_hba *hisi_hba, int port_id) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 662d259..357138f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -1611,10 +1611,11 @@ static void phy_set_linkrate_v2_hw(struct hisi_hba *hisi_hba, int phy_no, prog_phy_link_rate &= ~0xff; prog_phy_link_rate |= rate_mask; + disable_phy_v2_hw(hisi_hba, phy_no); + msleep(100); hisi_sas_phy_write32(hisi_hba, phy_no, PROG_PHY_LINK_RATE, prog_phy_link_rate); - - phy_hard_reset_v2_hw(hisi_hba, phy_no); + start_phy_v2_hw(hisi_hba, phy_no); } static int get_wideport_bitmap_v2_hw(struct hisi_hba *hisi_hba, int port_id) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 1ee95ab..8da9de7 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1862,10 +1862,11 @@ static void phy_set_linkrate_v3_hw(struct hisi_hba *hisi_hba, int phy_no, prog_phy_link_rate &= ~0xff; prog_phy_link_rate |= rate_mask; + disable_phy_v3_hw(hisi_hba, phy_no); + msleep(100); hisi_sas_phy_write32(hisi_hba, phy_no, PROG_PHY_LINK_RATE, prog_phy_link_rate); - - phy_hard_reset_v3_hw(hisi_hba, phy_no); + start_phy_v3_hw(hisi_hba, phy_no); } static void interrupt_disable_v3_hw(struct hisi_hba *hisi_hba) From patchwork Mon Feb 19 19:13:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 128839 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3800670ljc; Mon, 19 Feb 2018 10:22:27 -0800 (PST) X-Google-Smtp-Source: AH8x225J1unemXSazR4mpW4P2S50aGxADcL3cgHTPBAHDwXEbcnh0Zvz3Q7cxam0EYQY++mhDlRT X-Received: by 10.101.96.212 with SMTP id r20mr12978156pgv.139.1519064547840; Mon, 19 Feb 2018 10:22:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519064547; cv=none; d=google.com; s=arc-20160816; b=Urzpyv8WXWK9MsqZaxEICHPMkv4EFHl5wF70LlH+SQTQFrUmX6Xz+CgFycJj4pbdSe lCls29KWO0yhDE33KE1zdDLfvUPtcSQ3jmM7JGiE1xUGLSUqqZtsc+6nxHA9SzkojuY4 y09a0MlaGBVZquzi2hAXy+86Cz41XMv+QU8brW2lq9A8P0azdSmFnFuIZ1XkIYDwU0j7 GGYGGNEDxLLpZUl4FOS7IPkCVQK/QJZDBdVJJb9VRvNyrn7WdfHN+Joku/ReBkNMgMZq JoJeYONgkjcUDRPzhBaODq9Xw9ikwiI56jaPAirSElHasbRBbQUmmXjGp5jKzFLC23NB sa3w== 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:arc-authentication-results; bh=0mADjAhD8vNirl2KxJinAGhfM0hmPNYd14t60Q+9Kpk=; b=ZP5SZxqFQdJne0lWH4cupgrkQqourqCLnVew+WnTtoLir6/Qh71o3GMUMjY2rtKa4E wDAA8IeHqF+TPHed/GqVzQF1PjUlmcgzor4p0s6G8h8i8UF11vC6UZUCSL8y8un1Dz6s W7rpfCOqFWOX3ktDQ90Ab8eKB6sMfK2jbrfQA4VhEE/i4+EvP6Iy9B/JYeuVYXXYFeDG H27B3fuWttCe9q/npaI7+91kDgabJyUqIg9+n0np04vKIOPFAL1aNTkMRCLCIgihAajq XC0v6MvcwrL8/Mu1HS4yrPL8V2GVdA0NGqIP09hydMd12L3nsSGcoBhVxWH/j5pL4W3T 2p5w== 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 i2si69512pgo.550.2018.02.19.10.22.27; Mon, 19 Feb 2018 10:22:27 -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 S1753598AbeBSSWX (ORCPT + 28 others); Mon, 19 Feb 2018 13:22:23 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5250 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753430AbeBSSWP (ORCPT ); Mon, 19 Feb 2018 13:22:15 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id EF764C857F287; Tue, 20 Feb 2018 02: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.361.1; Tue, 20 Feb 2018 02:21:54 +0800 From: John Garry To: , , , CC: , , , , Xiaofei Tan , John Garry Subject: [PATCH 7/8] scsi: hisi_sas: fix return value of hisi_sas_task_prep() Date: Tue, 20 Feb 2018 03:13:30 +0800 Message-ID: <1519067611-206638-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519067611-206638-1-git-send-email-john.garry@huawei.com> References: <1519067611-206638-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 It is an implicit regulation that error code that function returned should be negative. But hisi_sas_task_prep() doesn't follow this. This may cause problems in the upper layer code. For example, in sas_expander.c of libsas, smp_execute_task_sg() may return the number of bytes of underrun. It will be conflicted with the scenaio lldd_execute_task() return an positive error code. This patch change the return value from SAS_PHY_DOWN to -ECOMM in hisi_sas_task_prep(). Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 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 88ad8d4..dff9723 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -316,7 +316,7 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq */ if (device->dev_type != SAS_SATA_DEV) task->task_done(task); - return SAS_PHY_DOWN; + return -ECOMM; } if (DEV_IS_GONE(sas_dev)) { @@ -327,7 +327,7 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq dev_info(dev, "task prep: device %016llx not ready\n", SAS_ADDR(device->sas_addr)); - return SAS_PHY_DOWN; + return -ECOMM; } port = to_hisi_sas_port(sas_port); @@ -337,7 +337,7 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq "SATA/STP" : "SAS", device->port->id); - return SAS_PHY_DOWN; + return -ECOMM; } if (!sas_protocol_ata(task->task_proto)) { From patchwork Mon Feb 19 19:13:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 128840 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3801325ljc; Mon, 19 Feb 2018 10:23:16 -0800 (PST) X-Google-Smtp-Source: AH8x226oD+DTvE9zle80a3nHkkc/rFQnAqeAtQnwjuu3fB3P6RdhbXcejyb8cGBY3TCMVZOM750B X-Received: by 2002:a17:902:9693:: with SMTP id n19-v6mr4565267plp.69.1519064596067; Mon, 19 Feb 2018 10:23:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519064596; cv=none; d=google.com; s=arc-20160816; b=DQK8uVySmWEruYAOBT5y4nZaHFDqFviJdCU0cfuWRDA8WicymCGe7j2Gtis1D6AuoF kmMb+8IwJNkqvzLO5UzsqOPZESREwpl9Ti8y962M0eQKRrl8nE4KpUbQ8O0wDaajQEgf HYrNQJnNH8R7UCoPgFiq79AVFi1gNsRWY+airaOhwxtX+HuO/oDrh6LyhAVm+O8zfxVp 8ZzWHxO0zmj4eTL4HZv0yh+3BjKEU8XcScu2YX+RGWUjfnS5/sED5qFhveWsooHpNZdB HtLRYH4LXzB7X81ODhw56Mili1Qzc4FbMmMt9Knu3hmfJVwNOyOWttpk5AARtaw5cWLe ADCg== 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:arc-authentication-results; bh=5MM/gCSk5SutIhw53KLDaHhGMtoVgeMwa+a6i8CROpw=; b=OOCpCPE09IjindUe16oQsb7KdttYPR+RI7ctuciR3huKMrv6/dHe68/a587+E/SHYg GHpDeED6yafOa6rr9Qg2zgebSQZ6x0I45E1tQ/P6HF5racfR5A6GL8HMW8Bb9gW1rSvy 13LjfZpDnK8LTlFsV22NzUu7KwaG4hbVtxLPdIhkFs1a50BHa6AhCviHemXQP9AoIOOl nGehxjozkBqm+vkxyKMD7+ATDGY60WpdldYrC69+uViMtybUyTbydfN9QHsiP9aYIONK sS34tso5F3vQgcIbzeD3jbO7kzSOox1f6YIDK99rdrr8+eJlcErzmyHy50LOhME18jj2 xYyQ== 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 91-v6si6015931plh.570.2018.02.19.10.23.15; Mon, 19 Feb 2018 10:23:16 -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 S1753538AbeBSSWT (ORCPT + 28 others); Mon, 19 Feb 2018 13:22:19 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5248 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753396AbeBSSWN (ORCPT ); Mon, 19 Feb 2018 13:22:13 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id D08DAFC1AD77B; Tue, 20 Feb 2018 02: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.361.1; Tue, 20 Feb 2018 02:21:54 +0800 From: John Garry To: , , , CC: , , , , Xiang Chen , Xiaofei Tan , John Garry Subject: [PATCH 8/8] scsi: hisi_sas: Code cleanup and minor bug fixes Date: Tue, 20 Feb 2018 03:13:31 +0800 Message-ID: <1519067611-206638-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519067611-206638-1-git-send-email-john.garry@huawei.com> References: <1519067611-206638-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 The patch does some code cleanup and fixes some small bugs: - Correct return status of phy_up_v3_hw() - Add static for function phy_get_max_linkrate_v3_hw() - Change exception return status when no reset method - Change magic value to ts->stat in slot_complete_vx_hw() - Remove unnecessary check for dev_is_sata() - Fix some issues of alignment and indents (Authored by Xiaofei Tan in another patch, but added here to be practical) Signed-off-by: Xiaofei Tan Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 14 +++++++------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 4 +++- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 10 ++++++---- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 16 +++++++++------- 4 files changed, 25 insertions(+), 19 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 dff9723..49c1fa6 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -33,7 +33,7 @@ u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis, int direction) case ATA_CMD_FPDMA_RECV: case ATA_CMD_FPDMA_SEND: case ATA_CMD_NCQ_NON_DATA: - return HISI_SAS_SATA_PROTOCOL_FPDMA; + return HISI_SAS_SATA_PROTOCOL_FPDMA; case ATA_CMD_DOWNLOAD_MICRO: case ATA_CMD_ID_ATA: @@ -45,7 +45,7 @@ u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis, int direction) case ATA_CMD_WRITE_LOG_EXT: case ATA_CMD_PIO_WRITE: case ATA_CMD_PIO_WRITE_EXT: - return HISI_SAS_SATA_PROTOCOL_PIO; + return HISI_SAS_SATA_PROTOCOL_PIO; case ATA_CMD_DSM: case ATA_CMD_DOWNLOAD_MICRO_DMA: @@ -64,7 +64,7 @@ u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis, int direction) case ATA_CMD_WRITE_LOG_DMA_EXT: case ATA_CMD_WRITE_STREAM_DMA_EXT: case ATA_CMD_ZAC_MGMT_IN: - return HISI_SAS_SATA_PROTOCOL_DMA; + return HISI_SAS_SATA_PROTOCOL_DMA; case ATA_CMD_CHK_POWER: case ATA_CMD_DEV_RESET: @@ -77,21 +77,21 @@ u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis, int direction) case ATA_CMD_STANDBY: case ATA_CMD_STANDBYNOW1: case ATA_CMD_ZAC_MGMT_OUT: - return HISI_SAS_SATA_PROTOCOL_NONDATA; + return HISI_SAS_SATA_PROTOCOL_NONDATA; default: { if (fis->command == ATA_CMD_SET_MAX) { switch (fis->features) { case ATA_SET_MAX_PASSWD: case ATA_SET_MAX_LOCK: - return HISI_SAS_SATA_PROTOCOL_PIO; + return HISI_SAS_SATA_PROTOCOL_PIO; case ATA_SET_MAX_PASSWD_DMA: case ATA_SET_MAX_UNLOCK_DMA: - return HISI_SAS_SATA_PROTOCOL_DMA; + return HISI_SAS_SATA_PROTOCOL_DMA; default: - return HISI_SAS_SATA_PROTOCOL_NONDATA; + return HISI_SAS_SATA_PROTOCOL_NONDATA; } } if (direction == DMA_NONE) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 8dd0e6a6..520ba69 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -651,8 +651,10 @@ static int reset_hw_v1_hw(struct hisi_hba *hisi_hba) dev_err(dev, "De-reset failed\n"); return -EIO; } - } else + } else { dev_warn(dev, "no reset method\n"); + return -EIO; + } return 0; } diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 357138f..f2cddff 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -1095,8 +1095,10 @@ static int reset_hw_v2_hw(struct hisi_hba *hisi_hba) dev_err(dev, "SAS de-reset fail.\n"); return -EIO; } - } else - dev_warn(dev, "no reset method\n"); + } else { + dev_err(dev, "no reset method\n"); + return -EIO; + } return 0; } @@ -2408,7 +2410,7 @@ static void slot_err_v2_hw(struct hisi_hba *hisi_hba, spin_lock_irqsave(&hisi_hba->lock, flags); hisi_sas_slot_task_free(hisi_hba, task, slot); spin_unlock_irqrestore(&hisi_hba->lock, flags); - return -1; + return ts->stat; } if (unlikely(!sas_dev)) { @@ -2667,7 +2669,7 @@ static int prep_abort_v2_hw(struct hisi_hba *hisi_hba, /* dw0 */ hdr->dw0 = cpu_to_le32((5 << CMD_HDR_CMD_OFF) | /*abort*/ (port->id << CMD_HDR_PORT_OFF) | - ((dev_is_sata(dev) ? 1:0) << + (dev_is_sata(dev) << CMD_HDR_ABORT_DEVICE_TYPE_OFF) | (abort_flag << CMD_HDR_ABORT_FLAG_OFF)); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 8da9de7..b9b5d9f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -670,8 +670,10 @@ static int reset_hw_v3_hw(struct hisi_hba *hisi_hba) dev_err(dev, "Reset failed\n"); return -EIO; } - } else + } else { dev_err(dev, "no reset method!\n"); + return -EIO; + } return 0; } @@ -731,7 +733,7 @@ static void phy_hard_reset_v3_hw(struct hisi_hba *hisi_hba, int phy_no) start_phy_v3_hw(hisi_hba, phy_no); } -enum sas_linkrate phy_get_max_linkrate_v3_hw(void) +static enum sas_linkrate phy_get_max_linkrate_v3_hw(void) { return SAS_LINK_RATE_12_0_GBPS; } @@ -1096,7 +1098,7 @@ static int prep_abort_v3_hw(struct hisi_hba *hisi_hba, /* dw0 */ hdr->dw0 = cpu_to_le32((5 << CMD_HDR_CMD_OFF) | /*abort*/ (port->id << CMD_HDR_PORT_OFF) | - ((dev_is_sata(dev) ? 1:0) + (dev_is_sata(dev) << CMD_HDR_ABORT_DEVICE_TYPE_OFF) | (abort_flag << CMD_HDR_ABORT_FLAG_OFF)); @@ -1114,7 +1116,7 @@ static int prep_abort_v3_hw(struct hisi_hba *hisi_hba, static int phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) { - int i, res = 0; + int i, res; u32 context, port_id, link_rate; struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; struct asd_sas_phy *sas_phy = &phy->sas_phy; @@ -1186,7 +1188,7 @@ static int phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) phy->port_id = port_id; phy->phy_attached = 1; hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP); - + res = IRQ_HANDLED; end: hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, CHL_INT0_SL_PHY_ENABLE_MSK); @@ -1217,7 +1219,7 @@ static int phy_down_v3_hw(int phy_no, struct hisi_hba *hisi_hba) hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, CHL_INT0_NOT_RDY_MSK); hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 0); - return 0; + return IRQ_HANDLED; } static void phy_bcast_v3_hw(int phy_no, struct hisi_hba *hisi_hba) @@ -1573,7 +1575,7 @@ static irqreturn_t fatal_axi_int_v3_hw(int irq_no, void *p) spin_lock_irqsave(&hisi_hba->lock, flags); hisi_sas_slot_task_free(hisi_hba, task, slot); spin_unlock_irqrestore(&hisi_hba->lock, flags); - return -1; + return ts->stat; } if (unlikely(!sas_dev)) {