From patchwork Tue Sep 11 08:48:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 10595295 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9C20920 for ; Tue, 11 Sep 2018 08:48:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A54D529238 for ; Tue, 11 Sep 2018 08:48:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9879C29243; Tue, 11 Sep 2018 08:48:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4D3429238 for ; Tue, 11 Sep 2018 08:48:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726701AbeIKNqj (ORCPT ); Tue, 11 Sep 2018 09:46:39 -0400 Received: from mail-eopbgr730064.outbound.protection.outlook.com ([40.107.73.64]:64736 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726587AbeIKNqj (ORCPT ); Tue, 11 Sep 2018 09:46:39 -0400 Received: from BN6PR02CA0044.namprd02.prod.outlook.com (2603:10b6:404:5f::30) by SN6PR02MB5309.namprd02.prod.outlook.com (2603:10b6:805:71::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.15; Tue, 11 Sep 2018 08:48:18 +0000 Received: from BN1BFFO11FD004.protection.gbl (2a01:111:f400:7c10::1:175) by BN6PR02CA0044.outlook.office365.com (2603:10b6:404:5f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1122.15 via Frontend Transport; Tue, 11 Sep 2018 08:48:17 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.23) smtp.mailfrom=microsemi.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=microsemi.com; Received-SPF: Pass (protection.outlook.com: domain of microsemi.com designates 208.19.100.23 as permitted sender) receiver=protection.outlook.com; client-ip=208.19.100.23; helo=AVMBX3.microsemi.net; Received: from AVMBX3.microsemi.net (208.19.100.23) by BN1BFFO11FD004.mail.protection.outlook.com (10.58.144.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.1122.11 via Frontend Transport; Tue, 11 Sep 2018 08:48:17 +0000 Received: from AVMBX3.microsemi.net (10.100.34.33) by AVMBX3.microsemi.net (10.100.34.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1531.3; Tue, 11 Sep 2018 01:48:09 -0700 Received: from localhost (10.187.72.82) by avmbx3.microsemi.net (10.100.34.33) with Microsoft SMTP Server id 15.1.1531.3 via Frontend Transport; Tue, 11 Sep 2018 01:48:09 -0700 From: Viswas G To: CC: , , , , Subject: [PATCH V2 1/4] pm80xx : Fix for phy enable/disable functionality. Date: Tue, 11 Sep 2018 14:18:02 +0530 Message-ID: <20180911084805.4802-2-Viswas.G@microsemi.com> X-Mailer: git-send-email 2.19.0-rc1 In-Reply-To: <20180911084805.4802-1-Viswas.G@microsemi.com> References: <20180911084805.4802-1-Viswas.G@microsemi.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:208.19.100.23;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(376002)(39860400002)(346002)(136003)(2980300002)(438002)(189003)(199004)(106002)(316002)(47776003)(97736004)(86362001)(51416003)(54906003)(76176011)(4326008)(53936002)(2351001)(50466002)(48376002)(57986006)(76506005)(186003)(11346002)(50226002)(8936002)(68736007)(8676002)(2616005)(476003)(5024004)(126002)(446003)(1076002)(478600001)(36756003)(106466001)(69596002)(2906002)(2870700001)(336012)(81156014)(26005)(77096007)(305945005)(81166006)(356003)(5660300001)(486006)(6666003)(6916009);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR02MB5309;H:AVMBX3.microsemi.net;FPR:;SPF:Pass;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD004;1:khKOD0J11AXq8R7e+07t+rEgXwOBfagf7XD85dV4KU++LPEPoheJ4Jn5hVsC62zkD1R1Wa2w5CPzqIhchhX1lnM0pfhxhIt49Fe7D5B1mYrZwY0kUp+/yKNStjQblHx+ X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ea3a3403-93ce-4b6b-7eb2-08d617c3518b X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:SN6PR02MB5309; X-Microsoft-Exchange-Diagnostics: 1;SN6PR02MB5309;3:nFTMYfw2NtQCvbFsUPExw7gVLFkojYtXYV1MO7yvR1seVgqgZ9c9Qk6rOudWKnk1A+C6QzqY57Z9vUVXApTMee5bgQPZ6T/RR6zmWkDxoRYjCsmi9v18IabGYc6PWcbn0HhsCVnp/nDM8g91wS2r7C9rnYloGza/qwySxZj4DhUD5NnRQRLNE8T8BhfyipNeH85uyLdYEWcKb6OLWisdhGhSQUKeamRrJ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WjEbPGVDK19aSJiQhpeuEBa0E7j8YAyaVwbP6c+7TTK5XRdci3t/qmF3oRcf5fcuz7HzCqvGhhKhjcNamPCF73jcu5tNQEgjMugn/xTdIB0C1VJDT8wtnfoWnM42+P2pozRcEbl64dXiv/+z3Lj5GFILJMb572x9M+YwBF2EcG94NLtOeJf+UdPhIkUp1usZEIWWt2nM0nQOzQDZiC9gpEPxbNdZdquR8YIgD5d35yxEy6FeA5Kp0xvJ2d8jgk/xr5412XSDSHJ4/g48+f1R2lw7xfQPYMosTr9yu2zLWw0Hk5Uf2q2UBWCaFsOSUOX7/Q6muEtpQo= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93004095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(201708071742011)(7699050);SRVR:SN6PR02MB5309;BCL:0;PCL:0;RULEID:;SRVR:SN6PR02MB5309; X-Microsoft-Exchange-Diagnostics: 1;SN6PR02MB5309;4:0jLhxpNWVhw55t+grE/7QUjiAr511QFSMyXTzKidYN3obsVFOz44wQmD/cbxdI411iG8JVoawMKsyiHPGEZWVHnJAxmn8GIzn3rZ9Gjym8wz/lv3fMz13auaNMrjvEwRaxIADNFbOCj6EvXYjrtnSlBA2MhZHuBGRkmsr5cVEaEAznSRAGtkmdZKAinfxhJsxj0bdRiJZxXOmN33m6PyCmOv+TqguZdG9cCEa83hr9fkSAlLvXKAx8gAuLQIgNTXSQQFa/gNQV0xNsIZRLOF4Q== X-Forefront-PRVS: 0792DBEAD0 X-Microsoft-Exchange-Diagnostics: 1;SN6PR02MB5309;23:GXmRHXbojdgVrgJTQRJNgWEC5rJU1vbOG/L0yfrMitS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jp/MB9iecySvba3TumyGsJ9etT4l8Aztn0Sz24NzrV+JU8Y6iyBaiLCo3qWwNHV8OZz9R8VTszwY=;7:nmq0NtxMeoW2w9OOLwDdA0oT/EB0KzeCfI4ywDIpKXR8n2GC9H8hYO1ZnnKhUhl+L2NzLBmsmfgB+Q3rx291aicGuIxEIuLzMgjT+FJjOWom4lZinaRV+suzEoqpaWKht1nVy9O3L4SOEdPLdqUyV3TYrbiXRc+ajmC3Ck2JsSA47kuvliHzJ4BNkVu1qnPeKB2wT2I5ex2bM/CfTQH0XmeXSJmkLknxA7TOnSxCQwIqLxuJn2/oppBhHmt8CzCq SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2018 08:48:17.1474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea3a3403-93ce-4b6b-7eb2-08d617c3518b X-MS-Exchange-CrossTenant-Id: f267a5c8-86d8-4cc9-af71-1fd2c67c8fad X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f267a5c8-86d8-4cc9-af71-1fd2c67c8fad;Ip=[208.19.100.23];Helo=[AVMBX3.microsemi.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB5309 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Deepak Ukey Added proper mask for phy id in mpi_phy_stop_resp(). V2: -Initialized the PM8001F_RUN_TIME flag in pm8001_pci_probe(). -Differentiated PHY_LINK_UP state for SPC and SPCv controller. -Used PHY_LINK_DOWN macro for phy state down. Signed-off-by: Deepak Ukey Signed-off-by: Viswas G Acked-by: Jack Wang --- drivers/scsi/pm8001/pm8001_defs.h | 8 ++++++++ drivers/scsi/pm8001/pm8001_hwi.c | 3 ++- drivers/scsi/pm8001/pm8001_hwi.h | 4 ---- drivers/scsi/pm8001/pm8001_init.c | 3 ++- drivers/scsi/pm8001/pm8001_sas.c | 28 +++++++++++++++++++++++++--- drivers/scsi/pm8001/pm80xx_hwi.c | 14 ++++++++------ drivers/scsi/pm8001/pm80xx_hwi.h | 6 ++++-- 7 files changed, 49 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_defs.h b/drivers/scsi/pm8001/pm8001_defs.h index 199527dbaaa1..48e0624ecc68 100644 --- a/drivers/scsi/pm8001/pm8001_defs.h +++ b/drivers/scsi/pm8001/pm8001_defs.h @@ -132,4 +132,12 @@ enum pm8001_hba_info_flags { PM8001F_RUN_TIME = (1U << 1), }; +/** + * Phy Status + */ +#define PHY_LINK_DISABLE 0x00 +#define PHY_LINK_DOWN 0x01 +#define PHY_STATE_LINK_UP_SPCV 0x2 +#define PHY_STATE_LINK_UP_SPC 0x1 + #endif diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 4dd6cad330e8..a14bf50a76d7 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -3810,7 +3810,8 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void* piomb) " status = %x\n", status)); if (status == 0) { phy->phy_state = 1; - if (pm8001_ha->flags == PM8001F_RUN_TIME) + if (pm8001_ha->flags == PM8001F_RUN_TIME && + phy->enable_completion != NULL) complete(phy->enable_completion); } break; diff --git a/drivers/scsi/pm8001/pm8001_hwi.h b/drivers/scsi/pm8001/pm8001_hwi.h index e4867e690c84..6d91e2446542 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.h +++ b/drivers/scsi/pm8001/pm8001_hwi.h @@ -131,10 +131,6 @@ #define LINKRATE_30 (0x02 << 8) #define LINKRATE_60 (0x04 << 8) -/* for phy state */ - -#define PHY_STATE_LINK_UP_SPC 0x1 - /* for new SPC controllers MEMBASE III is shared between BIOS and DATA */ #define GSM_SM_BASE 0x4F0000 struct mpi_msg_hdr{ diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 7a697ca68501..501830caba21 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -121,7 +121,7 @@ static void pm8001_phy_init(struct pm8001_hba_info *pm8001_ha, int phy_id) { struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; struct asd_sas_phy *sas_phy = &phy->sas_phy; - phy->phy_state = 0; + phy->phy_state = PHY_LINK_DISABLE; phy->pm8001_ha = pm8001_ha; sas_phy->enabled = (phy_id < pm8001_ha->chip->n_phy) ? 1 : 0; sas_phy->class = SAS; @@ -1067,6 +1067,7 @@ static int pm8001_pci_probe(struct pci_dev *pdev, if (rc) goto err_out_shost; scsi_scan_host(pm8001_ha->shost); + pm8001_ha->flags = PM8001F_RUN_TIME; return 0; err_out_shost: diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 947d6017d004..d8249675371e 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -157,9 +157,12 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, int rc = 0, phy_id = sas_phy->id; struct pm8001_hba_info *pm8001_ha = NULL; struct sas_phy_linkrates *rates; + struct sas_ha_struct *sas_ha; + struct pm8001_phy *phy; DECLARE_COMPLETION_ONSTACK(completion); unsigned long flags; pm8001_ha = sas_phy->ha->lldd_ha; + phy = &pm8001_ha->phy[phy_id]; pm8001_ha->phy[phy_id].enable_completion = &completion; switch (func) { case PHY_FUNC_SET_LINK_RATE: @@ -172,7 +175,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, pm8001_ha->phy[phy_id].maximum_linkrate = rates->maximum_linkrate; } - if (pm8001_ha->phy[phy_id].phy_state == 0) { + if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) { PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id); wait_for_completion(&completion); } @@ -180,7 +183,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, PHY_LINK_RESET); break; case PHY_FUNC_HARD_RESET: - if (pm8001_ha->phy[phy_id].phy_state == 0) { + if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) { PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id); wait_for_completion(&completion); } @@ -188,7 +191,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, PHY_HARD_RESET); break; case PHY_FUNC_LINK_RESET: - if (pm8001_ha->phy[phy_id].phy_state == 0) { + if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) { PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id); wait_for_completion(&completion); } @@ -200,6 +203,25 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, PHY_LINK_RESET); break; case PHY_FUNC_DISABLE: + if (pm8001_ha->chip_id != chip_8001) { + if (pm8001_ha->phy[phy_id].phy_state == + PHY_STATE_LINK_UP_SPCV) { + sas_ha = pm8001_ha->sas; + sas_phy_disconnected(&phy->sas_phy); + sas_ha->notify_phy_event(&phy->sas_phy, + PHYE_LOSS_OF_SIGNAL); + phy->phy_attached = 0; + } + } else { + if (pm8001_ha->phy[phy_id].phy_state == + PHY_STATE_LINK_UP_SPC) { + sas_ha = pm8001_ha->sas; + sas_phy_disconnected(&phy->sas_phy); + sas_ha->notify_phy_event(&phy->sas_phy, + PHYE_LOSS_OF_SIGNAL); + phy->phy_attached = 0; + } + } PM8001_CHIP_DISP->phy_stop_req(pm8001_ha, phy_id); break; case PHY_FUNC_GET_EVENTS: diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 42f0405601ad..91ff6a44e9d9 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -3118,8 +3118,9 @@ static int mpi_phy_start_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) pm8001_printk("phy start resp status:0x%x, phyid:0x%x\n", status, phy_id)); if (status == 0) { - phy->phy_state = 1; - if (pm8001_ha->flags == PM8001F_RUN_TIME) + phy->phy_state = PHY_LINK_DOWN; + if (pm8001_ha->flags == PM8001F_RUN_TIME && + phy->enable_completion != NULL) complete(phy->enable_completion); } return 0; @@ -3211,7 +3212,7 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void *piomb) return 0; } phy->phy_attached = 0; - phy->phy_state = 0; + phy->phy_state = PHY_LINK_DISABLE; break; case HW_EVENT_PORT_INVALID: PM8001_MSG_DBG(pm8001_ha, @@ -3384,13 +3385,14 @@ static int mpi_phy_stop_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) u32 status = le32_to_cpu(pPayload->status); u32 phyid = - le32_to_cpu(pPayload->phyid); + le32_to_cpu(pPayload->phyid) & 0xFF; struct pm8001_phy *phy = &pm8001_ha->phy[phyid]; PM8001_MSG_DBG(pm8001_ha, pm8001_printk("phy:0x%x status:0x%x\n", phyid, status)); - if (status == 0) - phy->phy_state = 0; + if (status == PHY_STOP_SUCCESS || + status == PHY_STOP_ERR_DEVICE_ATTACHED) + phy->phy_state = PHY_LINK_DISABLE; return 0; } diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h index 889e69ce3689..dead05a55aab 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.h +++ b/drivers/scsi/pm8001/pm80xx_hwi.h @@ -170,6 +170,10 @@ #define LINKRATE_60 (0x04 << 8) #define LINKRATE_120 (0x08 << 8) +/*phy_stop*/ +#define PHY_STOP_SUCCESS 0x00 +#define PHY_STOP_ERR_DEVICE_ATTACHED 0x1046 + /* phy_profile */ #define SAS_PHY_ANALOG_SETTINGS_PAGE 0x04 #define PHY_DWORD_LENGTH 0xC @@ -216,8 +220,6 @@ #define SAS_DOPNRJT_RTRY_TMO 128 #define SAS_COPNRJT_RTRY_TMO 128 -/* for phy state */ -#define PHY_STATE_LINK_UP_SPCV 0x2 /* Making ORR bigger than IT NEXUS LOSS which is 2000000us = 2 second. Assuming a bigger value 3 second, 3000000/128 = 23437.5 where 128