From patchwork Fri Mar 2 15:06:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 130550 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1377002lja; Fri, 2 Mar 2018 07:09:37 -0800 (PST) X-Google-Smtp-Source: AG47ELsIs/jotJA0k9kkohvvutOux8W3uopjtKQPHKYu9oCmdy7Trk+kbB66kGUPLQUc7kfbfR2n X-Received: by 10.101.97.139 with SMTP id c11mr4766040pgv.433.1520003377282; Fri, 02 Mar 2018 07:09:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520003377; cv=none; d=google.com; s=arc-20160816; b=vONtJU9KFL3vmwqB/kaEyYWg3EIUON715BhLdLwelMh0sRLD7KicR5BUQ+QvYf8uBS GOKPh92A/Bi3QfyLyZFzKDlFzRw/8w2G3yAQ9ZA6u9FdBO90Qa5EO8U1150/GRfO0hmx axNFGPYQAPk54W6l2RTSxDvywF9vYt9J5K2C7fWwFjpiOQgM7v28NSVuhHAA3d5rzXpJ 1mo3+2xkj1mkvxIsJTLiCASEip9Dw2skL4JAd3Fr4ZvKTc3To9mSknqlfO0rM/fxycNF Cmk1DRBh54FXElZgFyNH/5Ie6ESKBb8TpGsyhZ49Fc6YvnN4eMniM6GX1oIGRemInJh8 nbHw== 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=1JdZy+fwEMfFdf3xVh6Zg5nGbx09Ra0a2BaLHOIgYek=; b=iw2lW71Or4E/VeKn5QgnJw0z5/Sd4+T9Q2ACB+SxXbasP2TySfzyrNvTL9iEtVTPTR 0c7vG/17+YpLFcX9UBF1Fn5ohILc5w6dHXtVt2AogzQpyc8KtNqRS2kmCe6mJyNjSIjJ RZdlXm7NldvfLvdDHgGb5j+fx7Jrza9W8FdKBKtENmGS844vfC4586ApkPcNbPXt+UT/ rHGG44L6yn0cgIGd7hdsy9C5QzanYReraF3tIrxrvv1F0jShrUjZTTmSSupUx0yggrmb UYwVzGQ5yOm/J8NBo+zmlp83Dcoj7K8MgbVG3CuBBJqSunT7+rc3bUFLe+cA+guFslBp 6PRg== 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 k12si4127799pgs.166.2018.03.02.07.09.36; Fri, 02 Mar 2018 07:09:37 -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 S1429105AbeCBPJb (ORCPT + 28 others); Fri, 2 Mar 2018 10:09:31 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5731 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1423587AbeCBPH4 (ORCPT ); Fri, 2 Mar 2018 10:07:56 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3899CECD4C858; Fri, 2 Mar 2018 23:07:33 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Fri, 2 Mar 2018 23:07:26 +0800 From: John Garry To: , , , CC: , , , , Xiaofei Tan , John Garry Subject: [PATCH v2 1/8] dt-bindings: scsi: hisi_sas: add an property of signal attenuation Date: Fri, 2 Mar 2018 23:06:15 +0800 Message-ID: <1520003182-26277-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520003182-26277-1-git-send-email-john.garry@huawei.com> References: <1520003182-26277-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 For some new boards with hip07 chipset we are required to set PHY config registers differently. The hw property which determines how to set these registers is in the PHY signal attenuation readings. This patch add an devicetree property, hisi-signal-attenuation, which is used to describe the signal attenuation of an board. Cc: Rob Herring Cc: Mark Rutland Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- Documentation/devicetree/bindings/scsi/hisilicon-sas.txt | 7 +++++++ 1 file changed, 7 insertions(+) -- 1.9.1 diff --git a/Documentation/devicetree/bindings/scsi/hisilicon-sas.txt b/Documentation/devicetree/bindings/scsi/hisilicon-sas.txt index df3bef7..6f6876a 100644 --- a/Documentation/devicetree/bindings/scsi/hisilicon-sas.txt +++ b/Documentation/devicetree/bindings/scsi/hisilicon-sas.txt @@ -53,6 +53,13 @@ Main node required properties: Optional main node properties: - hip06-sas-v2-quirk-amt : when set, indicates that the v2 controller has the "am-max-transmissions" limitation. + - hisi-signal-attenuation : array of 3 32-bit values, containing de-emphasis, + preshoot, and boost attenuation readings for the board. They + are used to describe the signal attenuation of the board. These + values' range is 7600 to 12400, and used to represent -24dB to + 24dB. + The formula is "y = (x-10000)/10000". For example, 10478 + means 4.78dB. Example: sas0: sas@c1000000 { From patchwork Fri Mar 2 15:06:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 130553 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1378141lja; Fri, 2 Mar 2018 07:10:38 -0800 (PST) X-Google-Smtp-Source: AG47ELulFXCU7Sl87PgtMUaMu/EieK91KN/KWseVyN7fp/1LGTMUkB8rme3SXMRV9pfMMtUbk7sX X-Received: by 10.98.19.21 with SMTP id b21mr5956290pfj.236.1520003437955; Fri, 02 Mar 2018 07:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520003437; cv=none; d=google.com; s=arc-20160816; b=pm2bws5ZvKrXqTiQvA2uWZ2nNZadxOAe3Z8v3jfABD/crwttDB6bqmVyW6Fu7Ds/cw lp4V22JPKeJ9Qci7NDvzrKg8x9qWonOZl3z/Bzbo+WU30f31GnweaXhJJT+es0J9/smv a1jGZyQBJ9mLJto6aVzHTF96JNPrUPkUP6gKbFnA7dim1lfUwyZ5mVBcqLpPiZYSVc8m rA8gO2ulFweGjGNyBzzZpuV881cxL4v2Mj/QY/MpocK0x+JEnHeOVxX+rgFulr5+WpLU pToLagMy7rl/kHk2hi/TGPSczsGzKHTEe5v5qt5rAsBSegmhLEURtNBjIfL34QsVkgzE EqBQ== 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=FV9y6K5esOAyywxm9ws3ZkLe7u/VORy71yET5aCdaw4=; b=BYPVVmQAoppJmE/MPqs8xQ1rrIvAYl2HuiRTsraQW+8n5B0fm9uOzQDjCs/WwimNuo h8DlnR0X0YtIfOvP6jH9R3UYC+wkg+LzWs6E8utQpTHJc0OKcpdRWBOKzcuMcCAgChXB 2Xt9xxgTByDIICn+fUFaoBDoFtNA5GPaqw+qC8GW6Sv+GbTHeE4wXiX6AjDc8SqVjjld fJMbyKX9GfleDu1dzJ8u8xgJlEvhzWueHj7cqUP8ABwLcDXq0+lsmmMKn3tnqqWpFltn WtUBxjLt+MBrFXat7BY481NcqC8jp0qEbbMO2KkrF6cZuVCh0vvXoFxVqSEbt9WkLrma koIg== 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 d64si5014768pfa.384.2018.03.02.07.10.37; Fri, 02 Mar 2018 07:10:37 -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 S1427097AbeCBPKe (ORCPT + 28 others); Fri, 2 Mar 2018 10:10:34 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5728 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1429001AbeCBPHv (ORCPT ); Fri, 2 Mar 2018 10:07:51 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0B5F6F2764121; Fri, 2 Mar 2018 23:07:33 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Fri, 2 Mar 2018 23:07:27 +0800 From: John Garry To: , , , CC: , , , , Xiaofei Tan , John Garry Subject: [PATCH v2 3/8] scsi: hisi_sas: fix the issue of link rate inconsistency Date: Fri, 2 Mar 2018 23:06:17 +0800 Message-ID: <1520003182-26277-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520003182-26277-1-git-send-email-john.garry@huawei.com> References: <1520003182-26277-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 In sysfs, there are two files about minimum linkrate, and also two files for maximum linkrate. Take maximum linkrate example, maximum_linkrate_hw is read-only and indicated by the register HARD_PHY_LINKRATE, and maximum_linkrate is read-write and corresponding to the register PROG_PHY_LINK_RATE. But in the function phy_up_v*_hw(), we get *_linkrate value from HARD_PHY_LINKRATE. It is not right. This patch is to fix this issue. Unreferenced PHY-interrupt enum is also removed for v3 hw. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 ++ drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 1 - drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 8 +------- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 13 +------------ 4 files changed, 4 insertions(+), 20 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 2d4dbed..9d16372 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -683,6 +683,8 @@ static void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int phy_no) phy->hisi_hba = hisi_hba; phy->port = NULL; + phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS; + phy->maximum_linkrate = hisi_hba->hw->phy_get_max_linkrate(); sas_phy->enabled = (phy_no < hisi_hba->n_phy) ? 1 : 0; sas_phy->class = SAS; sas_phy->iproto = SAS_PROTOCOL_ALL; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 679e76f..38bbda9 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -873,7 +873,6 @@ static void phy_set_linkrate_v1_hw(struct hisi_hba *hisi_hba, int phy_no, sas_phy->phy->maximum_linkrate = max; sas_phy->phy->minimum_linkrate = min; - min -= SAS_LINK_RATE_1_5_GBPS; max -= SAS_LINK_RATE_1_5_GBPS; for (i = 0; i <= max; i++) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 3a0b4ed..edd0c89 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -1603,7 +1603,6 @@ static void phy_set_linkrate_v2_hw(struct hisi_hba *hisi_hba, int phy_no, sas_phy->phy->maximum_linkrate = max; sas_phy->phy->minimum_linkrate = min; - min -= SAS_LINK_RATE_1_5_GBPS; max -= SAS_LINK_RATE_1_5_GBPS; for (i = 0; i <= max; i++) @@ -2684,7 +2683,7 @@ static int prep_abort_v2_hw(struct hisi_hba *hisi_hba, static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba) { int i, res = IRQ_HANDLED; - u32 port_id, link_rate, hard_phy_linkrate; + u32 port_id, link_rate; struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; struct asd_sas_phy *sas_phy = &phy->sas_phy; struct device *dev = hisi_hba->dev; @@ -2723,11 +2722,6 @@ static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba) } sas_phy->linkrate = link_rate; - hard_phy_linkrate = hisi_sas_phy_read32(hisi_hba, phy_no, - HARD_PHY_LINKRATE); - phy->maximum_linkrate = hard_phy_linkrate & 0xf; - phy->minimum_linkrate = (hard_phy_linkrate >> 4) & 0xf; - sas_phy->oob_mode = SAS_OOB_MODE; memcpy(sas_phy->attached_sas_addr, &id->sas_addr, SAS_ADDR_SIZE); dev_info(dev, "phyup: phy%d link_rate=%d\n", phy_no, link_rate); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index a1f1868..1ee95ab 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -340,12 +340,6 @@ struct hisi_sas_err_record_v3 { #define HISI_SAS_COMMAND_ENTRIES_V3_HW 4096 #define HISI_SAS_MSI_COUNT_V3_HW 32 -enum { - HISI_SAS_PHY_PHY_UPDOWN, - HISI_SAS_PHY_CHNL_INT, - HISI_SAS_PHY_INT_NR -}; - #define DIR_NO_DATA 0 #define DIR_TO_INI 1 #define DIR_TO_DEVICE 2 @@ -1121,7 +1115,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; - u32 context, port_id, link_rate, hard_phy_linkrate; + 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; struct device *dev = hisi_hba->dev; @@ -1139,10 +1133,6 @@ static int phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) goto end; } sas_phy->linkrate = link_rate; - hard_phy_linkrate = hisi_sas_phy_read32(hisi_hba, phy_no, - HARD_PHY_LINKRATE); - phy->maximum_linkrate = hard_phy_linkrate & 0xf; - phy->minimum_linkrate = (hard_phy_linkrate >> 4) & 0xf; phy->phy_type &= ~(PORT_TYPE_SAS | PORT_TYPE_SATA); /* Check for SATA dev */ @@ -1864,7 +1854,6 @@ static void phy_set_linkrate_v3_hw(struct hisi_hba *hisi_hba, int phy_no, sas_phy->phy->maximum_linkrate = max; sas_phy->phy->minimum_linkrate = min; - min -= SAS_LINK_RATE_1_5_GBPS; max -= SAS_LINK_RATE_1_5_GBPS; for (i = 0; i <= max; i++) From patchwork Fri Mar 2 15:06:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 130548 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1375925lja; Fri, 2 Mar 2018 07:08:43 -0800 (PST) X-Google-Smtp-Source: AG47ELsLxKv2DA/QwpxdxBSk02LviAbyq8vClQ0cyGXfZmcjQAZIWFwNE1eiFbpd8wmz1WJ2jvla X-Received: by 10.98.89.85 with SMTP id n82mr5886612pfb.233.1520003323686; Fri, 02 Mar 2018 07:08:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520003323; cv=none; d=google.com; s=arc-20160816; b=TMmqX3zM/E1O9cTq3s1GAVIaN/AKJfIAeCUgwS2aPvwNIezHKc2lLJFBCaxeY2/vZX IMrp+8KIds+nFqtJjeJA0JILEEu4mMHay7EC7cRTkU0H9128Wcm/L04fQ6Ec9WrUVfR5 49bm3T9ZifXN22CmzkBItEKQtyFTVnnIxZX5pDOUHAIdR1aJ4ICe2vfavYhSTxSmTyyv PeVKRcmRP5lEhiLb6Jsd21uTJGlFue7gfm+Un8NMxb88/eKyZmyq4YSrozM+kl53AbTo Kjdbui5cAOIq/dTQGCvgHgrFYNKqe2DXAv/MJTmf1nJRC5w6I0lOG4nkoBd5Fa9h7A9k SydQ== 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=N8ML33DnilT1ugPYAQtrJPnftYNidopYSc69Jy6ZpYA=; b=NfYtcDdQM9OjC2tuiiu+ui47aSfB/a/8PVK1Cm1P018KnoNX/mGtakOwVcmCS3Vtjo OPgaDNje/NRO9498NmjU2y6J7OWrQp+O0s5s5hRjgRHPOGnM5lpiUWITPbsCk32twmWr eLSD3kiwANvTWVoVbuhjRnQK7fM51irl/QTSVJ3bcRK4QK+HlXGIzXoY9BbJp19Gg3pN PwOQAmnHQ1Dtdje0BsxzF6k5dY1gcpaDDrlh3KRvEqgSHtWRJlbFjXJZWeo/5+922z43 jj1lDgjyX2pAWQ9+WuzCfM92o6hGHvrBawogLEX2qpTlbnfvWgilljCSZ0v+M8Q3GVpg Wl0A== 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 n61-v6si4958571plb.797.2018.03.02.07.08.43; Fri, 02 Mar 2018 07:08: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 S1429093AbeCBPIi (ORCPT + 28 others); Fri, 2 Mar 2018 10:08:38 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5732 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1429002AbeCBPIE (ORCPT ); Fri, 2 Mar 2018 10:08:04 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 470A32B1ED5; Fri, 2 Mar 2018 23:07:33 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Fri, 2 Mar 2018 23:07:28 +0800 From: John Garry To: , , , CC: , , , , Xiaofei Tan , John Garry Subject: [PATCH v2 4/8] scsi: hisi_sas: fix the issue of setting linkrate register Date: Fri, 2 Mar 2018 23:06:18 +0800 Message-ID: <1520003182-26277-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520003182-26277-1-git-send-email-john.garry@huawei.com> References: <1520003182-26277-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 edd0c89..80fd4f4 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 Fri Mar 2 15:06:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 130549 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1376556lja; Fri, 2 Mar 2018 07:09:14 -0800 (PST) X-Google-Smtp-Source: AG47ELsKABADSOBFY3Cq3k+Vb9sT1LjH1tPiQhkzlwLqCdvtLzK8hnqWxQ+v/SvR9jQ3KjdXRn2i X-Received: by 2002:a17:902:724b:: with SMTP id c11-v6mr5526903pll.352.1520003354564; Fri, 02 Mar 2018 07:09:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520003354; cv=none; d=google.com; s=arc-20160816; b=m0fQVJiZeXgP7v8exEH8vu9hsDdzj6I8j7isTTYYQX0ImSfeJMchKqDmkd1QSyIH7j kZuAZy6daNzE5YlsIx3nvX2Typj10wlvH0+jRAGQpgwbbFxO+/sHdpGQw2yyznYjC/6I D0RwQzYAYapbDSc5ZaEV6yJeydMUmriFM+jeFNuFFin2ug5pY33EQhV/s+j+9lk77Me4 fMES8n6amBK8y3LhDfUSO+03/9ejY7wVK5zMwjUPSEzunYHVI+e4T28rKPvH6u/8hJND vlUjwIxrIQhBJIY/9Mnd06eXyxiqdQuE6c5efBfqTwY72t8UBcLhvcFh9bHpe2Ja5G/F AzTw== 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=dhQj25UHgAqz0fi2vBcFen4tBEnixxIOY4PNNRKJxgo=; b=A010a7KZmgCrmXxIbl9JbrtvZYGyCdkzhTtIYSdKaejpp2IE7O8hDYsoiKl1AFyEm4 S8IYDcRVA5/q9+Kr7tqZ3pvzf+zMH5fylzKhXVw9o1zP55YL93bG/U3+Xd4MqkS+86Xp QNPMduPcJxnP37UJqxJXq1N1HlXfGGc+id2/SzoZ6G0ze8wSG7dj8hiCZErvqqv5zk9W B28XVBtPHOIURrVpVICh8r3SdB/H8rfW7KbMc+UMtHhIFAWk7j9tMkQF0lsekx7ieOBW 9N/DlVQOhESVj04tfWbpggBaXstCbopL+a6lm1x5tUM3uXeh4yHzA71LAnd7lUdsa12b oShw== 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 d9-v6si1578357pli.389.2018.03.02.07.09.14; Fri, 02 Mar 2018 07:09:14 -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 S1429104AbeCBPJI (ORCPT + 28 others); Fri, 2 Mar 2018 10:09:08 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5733 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1429022AbeCBPIC (ORCPT ); Fri, 2 Mar 2018 10:08:02 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 559168B5D30AD; Fri, 2 Mar 2018 23:07:33 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Fri, 2 Mar 2018 23:07:28 +0800 From: John Garry To: , , , CC: , , , , Xiaofei Tan , John Garry Subject: [PATCH v2 5/8] scsi: hisi_sas: increase timer expire of internal abort task Date: Fri, 2 Mar 2018 23:06:19 +0800 Message-ID: <1520003182-26277-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520003182-26277-1-git-send-email-john.garry@huawei.com> References: <1520003182-26277-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 current 110ms expiry time is not long enough for the internal abort task. The reason is that the internal abort task could be blocked in HW if the HW is retrying to set up link. The internal abort task will be executed only when the retry process finished. The maximum time is 5s for the retry of setting up link. So, the timer expire should be more than 5s. This patch increases it from 110ms to 6s. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 9d16372..9ff8790 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -871,6 +871,7 @@ static void hisi_sas_tmf_timedout(struct timer_list *t) #define TASK_TIMEOUT 20 #define TASK_RETRY 3 +#define INTERNAL_ABORT_TIMEOUT 6 static int hisi_sas_exec_internal_tmf_task(struct domain_device *device, void *parameter, u32 para_len, struct hisi_sas_tmf_task *tmf) @@ -1574,7 +1575,7 @@ static int hisi_sas_query_task(struct sas_task *task) task->task_proto = device->tproto; task->task_done = hisi_sas_task_done; task->slow_task->timer.function = hisi_sas_tmf_timedout; - task->slow_task->timer.expires = jiffies + msecs_to_jiffies(110); + task->slow_task->timer.expires = jiffies + INTERNAL_ABORT_TIMEOUT*HZ; add_timer(&task->slow_task->timer); res = hisi_sas_internal_abort_task_exec(hisi_hba, sas_dev->device_id, From patchwork Fri Mar 2 15:06:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 130552 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1377368lja; Fri, 2 Mar 2018 07:09:56 -0800 (PST) X-Google-Smtp-Source: AG47ELvKXGxVO+3IEGdO69ib8gOgMT904Te3Y/7wtFqut5g+lAZJzAjO44eySvqFDJkjCyv+u54K X-Received: by 10.99.44.22 with SMTP id s22mr4813252pgs.111.1520003396143; Fri, 02 Mar 2018 07:09:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520003396; cv=none; d=google.com; s=arc-20160816; b=oY353XmIWxfRBMN2MLQLmQlUhgbUc9MtHpFjcDK7TtYYnF73LBXqU57pTCiMXi0TB9 UZPIMtY4TOHKobtxVyhgfhgDjmXA59EXzHLBuz1EMT/5TSZBgom+ULMG9UPilc6AU0+e IVoqOUD02MC77zghYhIqaxvzF12tikeDC4zlz7Xxondz6/LJj/HPyWydSJuWKOtTSgrv 7nHkJVssX/wufrwWSD5KxWrabdFYdDw0fRrkIlbG0l/DwInWaBvJ/EuwAFpqZOwwz9Jk Oq/xsPC8VwjOUKnManNNV/RoXn5Go8JfRVAe4/DJ3hAZnR+2PDwhZbYgpp3pH4gt5FEw KiwQ== 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=8UAzgAWWlizfrbRx3qWOnEynZ3imRD4cJK0Psd/vlFs=; b=oMDUhsz7bXxFA3uY33m0vUH6n/dyIY66rwEE4hPPLF5othubF4HkIfcPiaa7egHpZ1 1N85Fuh8i/Hte+svt6r4r3YqpgX47iPSB8yToB7Z+FVaQSAUwpFp4a08HEcMJtMeuvct YS2gayYuw27QXyAQ5A2/yxZ+A+fdaGY9/ztqsdn0aA4a4mJYX1lOjJdW6WNY+kZtKlbu l/fvBpkLane2oQQd1zHG5tuKfpXWj8zolIG/nj+CU7/savFRuJeY2A3mx+HymXFgGguk nzTMe7Q2IwzhHC0UUyVq1cZf0Rux08NgMJ9juxbwIp+ZK8KqZWSsAo3SohT2qvJliaRw duJQ== 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 u6-v6si4964040pld.129.2018.03.02.07.09.55; Fri, 02 Mar 2018 07:09:56 -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 S1429040AbeCBPHz (ORCPT + 28 others); Fri, 2 Mar 2018 10:07:55 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5727 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1423518AbeCBPHu (ORCPT ); Fri, 2 Mar 2018 10:07:50 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id F040616E736B0; Fri, 2 Mar 2018 23:07:32 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Fri, 2 Mar 2018 23:07:29 +0800 From: John Garry To: , , , CC: , , , , Xiang Chen , John Garry Subject: [PATCH v2 6/8] scsi: hisi_sas: remove unused variable hisi_sas_devices.running_req Date: Fri, 2 Mar 2018 23:06:20 +0800 Message-ID: <1520003182-26277-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520003182-26277-1-git-send-email-john.garry@huawei.com> References: <1520003182-26277-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 structure element hisi_sas_devices.running_req to count how many commands are active is in effect only ever written in the code, so remove it. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 1 - drivers/scsi/hisi_sas/hisi_sas_main.c | 9 --------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 3 --- 3 files changed, 13 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index e7fd287..d1153e8 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -175,7 +175,6 @@ struct hisi_sas_device { struct hisi_sas_dq *dq; struct list_head list; u64 attached_phy; - atomic64_t running_req; enum sas_device_type dev_type; int device_id; int sata_idx; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 9ff8790..88ad8d4 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -200,8 +200,6 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, if (task) { struct device *dev = hisi_hba->dev; - struct domain_device *device = task->dev; - struct hisi_sas_device *sas_dev = device->lldd_dev; if (!task->lldd_task) return; @@ -213,9 +211,6 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, dma_unmap_sg(dev, task->scatter, task->num_scatter, task->data_dir); - - if (sas_dev) - atomic64_dec(&sas_dev->running_req); } if (slot->buf) @@ -431,8 +426,6 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq spin_unlock_irqrestore(&task->task_state_lock, flags); dq->slot_prep = slot; - - atomic64_inc(&sas_dev->running_req); ++(*pass); return 0; @@ -1517,8 +1510,6 @@ static int hisi_sas_query_task(struct sas_task *task) dq->slot_prep = slot; - atomic64_inc(&sas_dev->running_req); - /* send abort command to the chip */ hisi_hba->hw->start_delivery(dq); spin_unlock_irqrestore(&dq->lock, flags_dq); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 2eb8980..8dd0e6a6 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1407,9 +1407,6 @@ static int slot_complete_v1_hw(struct hisi_hba *hisi_hba, } out: - if (sas_dev) - atomic64_dec(&sas_dev->running_req); - hisi_sas_slot_task_free(hisi_hba, task, slot); sts = ts->stat; From patchwork Fri Mar 2 15:06:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 130545 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1375153lja; Fri, 2 Mar 2018 07:08:02 -0800 (PST) X-Google-Smtp-Source: AG47ELuHrsrkkmOBtJfxT3nFDr+DNW7HY/i6gwFLvoHZgsFWbRK2JImScwN2P8gx4qkSaY//nv5d X-Received: by 10.98.172.18 with SMTP id v18mr5967192pfe.175.1520003282247; Fri, 02 Mar 2018 07:08:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520003282; cv=none; d=google.com; s=arc-20160816; b=c0piAiiUeGakxui5Db5Tc5gvccwNnFzqxmWTMbubWtYbgRYPFzmWgTRi57nQdWTgA/ aNEA1zJw/PeqSNjiZDSCRMKMXNh74CXMpPpANY8dOi2FALoD9/s85fJeX8MU2TrFSf0N 9uhfhuH1SRtvok4XtQAWAdOgUG3U4CYKDOs/Ism5nrvlaKHjXcohqfQDmf6bszpwbfDH OldX/1vgTtwXgq0UodUAX34RMVWRaWeCd9n60ga5V+rqRt9E5k/lnAJirsF2oRwabggX dymxD6idnvBXonP1uqFSt2RAcJqYlvRxSUT/FzFSPd5c1GENpdLgDf7Gld4/9Qx/1Q46 ciTw== 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=u2CkqA40UIEigR76HOCrIz7edaHweCPCttveySbB8Zp5Noam/9/Wl21Ram42fIyk8r zga46oGZAe2V0Bwy37EFaFn4vBt4yXn7dRdD4ztvAtYdKiZ9KxcY31aMEo4uiGWbbrS9 +wlUXD6c8IsYwRKiHpIwgJY40MevKJreL/p9VNGNw7pRBNBv2YvzN/BqtB8EcSm7v6+2 UtVc5ZhCFn6i5t7rKOFY56Jk6PgGdn6oa4fblFlNBIFP25JTjASKbtOpefxygq/oBR42 OpW/3v5oG8eqywsPhBBBbs0QE7zkfcCHDNikZNWbYEgT5gMgabNsuwhh9G6WNiDzIEs4 w3JA== 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 i7-v6si5107942plk.139.2018.03.02.07.08.01; Fri, 02 Mar 2018 07:08:02 -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 S1429054AbeCBPH5 (ORCPT + 28 others); Fri, 2 Mar 2018 10:07:57 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5729 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1429002AbeCBPHu (ORCPT ); Fri, 2 Mar 2018 10:07:50 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 1AB24436D8FAF; Fri, 2 Mar 2018 23:07:33 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Fri, 2 Mar 2018 23:07:29 +0800 From: John Garry To: , , , CC: , , , , Xiaofei Tan , John Garry Subject: [PATCH v2 7/8] scsi: hisi_sas: fix return value of hisi_sas_task_prep() Date: Fri, 2 Mar 2018 23:06:21 +0800 Message-ID: <1520003182-26277-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520003182-26277-1-git-send-email-john.garry@huawei.com> References: <1520003182-26277-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 Fri Mar 2 15:06:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 130547 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1375340lja; Fri, 2 Mar 2018 07:08:12 -0800 (PST) X-Google-Smtp-Source: AG47ELtN7iOYoA8ee1sdF5WzL8YGJ9/43Oi7KuocAPCLb4H49eXSVRu+lj4Fw5LOkJ3dqBVVid2X X-Received: by 10.101.66.1 with SMTP id c1mr3412331pgq.137.1520003292706; Fri, 02 Mar 2018 07:08:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520003292; cv=none; d=google.com; s=arc-20160816; b=vcG2+5HG28z9nOJHDfXotCy1f4PajCW4uzATp58JpRqJio78zInPsGMoZlKaqSel1B L7tA5lXV1zrMV1bs0VIjjzVby2oIvOHA578IYTteIq+7WS7lMLcyaGzAyDnWCkew0MFI mPfQIe4ia6ESxM6dXEIIoi+iZuxbg/cv1xWV0ULkF0ahPq5aMIQ1Pzy0LM01KKZEbyRj f2O2+f1neECem1gxLDqOYRkZe2lQyeBxkiPTM2CKLmHKQM5dUjrn4S8pLT3+UeWlFruL wrXDfyr0S7BHUOoPCahTDuQiQ35G6HoTG4muVLx8U8skFnh9cnqtVJu2838QjvKGJvKL cvuw== 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=qIgFLHA3WmE3x9ztEQjrr8fwrQYtzE9Nbz/3K7XltN0=; b=mmUAfH3GZO9Z+JgkeWHfASegBm+P31eL8F92Yr6cVTKzwJ+d4GC0lR4eStrKjIZwYq b7Rc+cG9ChpOh1nP96kcwzDVAre+4sealSMLIKpdfbUzhMLPXsA/ud7eL2J41Wf9y+Zj eiygS1YuuAZVK6KKn9eJAVL83XXbLbXxKMT2X7D4RSABeMuwO/WcH995Jrxzn+UHGgYn HU/4jmv38KKnYIYoJOtCLrjRIilzaxDF6t1PdYQZrr9dLnRnlYq6Ij4X0N06HFCtBZFE IfT8D+GcN6bjxIkoa8xBorzj6iciss2cLO+hSTM6eikJ0z2Rx0i8W200T7f6lZnC8JYm ROIg== 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 i7-v6si5107942plk.139.2018.03.02.07.08.12; Fri, 02 Mar 2018 07:08:12 -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 S1429088AbeCBPII (ORCPT + 28 others); Fri, 2 Mar 2018 10:08:08 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:5698 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1429004AbeCBPH4 (ORCPT ); Fri, 2 Mar 2018 10:07:56 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 1A7C12A8AB2D9; Fri, 2 Mar 2018 23:07:38 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Fri, 2 Mar 2018 23:07:29 +0800 From: John Garry To: , , , CC: , , , , Xiang Chen , Xiaofei Tan , John Garry Subject: [PATCH v2 8/8] scsi: hisi_sas: Code cleanup and minor bug fixes Date: Fri, 2 Mar 2018 23:06:22 +0800 Message-ID: <1520003182-26277-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520003182-26277-1-git-send-email-john.garry@huawei.com> References: <1520003182-26277-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 80fd4f4..02b77dc 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)) {