From patchwork Wed Jul 18 14:14:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 142283 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp594179ljj; Wed, 18 Jul 2018 07:16:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeQX7w4UViOPR/OJWhyGMH86Qhmijk7vHPayIkTjOy3DzDXboImlxcOLZFnjYrByCx0RLIL X-Received: by 2002:a63:40c7:: with SMTP id n190-v6mr5983798pga.116.1531923388816; Wed, 18 Jul 2018 07:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531923388; cv=none; d=google.com; s=arc-20160816; b=TDn6zH9ieBCn8SpARSZWzCLu53wrbyqsOjNt5O/hTd5ZcoRJT8GTrzeI6COvc+h3gK YJGPNTAunFaOOYfR6LMD/Ig4r4TtV265KYadThXMr2xxMSxL5dWGhub11yJqEvUrP4ev Wj6bKh8Q6tnkGTbHY/EIhek3eS27WqdPEWFVymMT0tTQ3jT0bI0mSomLQvqJQPplvDau DMYctfHb2ujC1kPeWUeVU9GAiZNiP9fi8CN43r08/HReou2tBrB745D14jhNHl8YIT0c 5XHwbItIyqJ2b83bp8bleYy0n/q4e1SgHRaFW6zjWsl2trG4PI7PkNMRfJN0vzsBTukX Kqug== 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=vgugLv0tvv97A+I98L7QWof4KST3s+YanhYNcyqNlQc=; b=qZlcSBxEOS1DUQFhnWchEYpKA6vI8taZK1KiUJafUse5fHeRqulS3N+lIJvI5Wj4DU 3Eg5DQ3DE5ZcPHU87TlwBuOvt4DGGevpILEaV2mSJcNyIipZXdtAtyiRWyKDC89SFqOu xGu8qj5gsrnBN+xi3EOFbtYNDaLSnwS4cVi9/S1pOkT3og9MSON7as40W5aRAkVZ/PQN rb09MOc8HDaH06SVkEBZKAyPgvYAsMW8tCDHWikcdNRFW37BTHBvmySz//JnPqPxxWrh gqjaUH2HFDj2lhRsfoh4b3T8tDmPHu7E+sB4dvGY51mC/ps/MzrW6RyVAu+vMZ3/Hyr9 QDWA== 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 a7-v6si3590736pfg.200.2018.07.18.07.16.28; Wed, 18 Jul 2018 07:16:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731379AbeGROyc (ORCPT + 31 others); Wed, 18 Jul 2018 10:54:32 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9695 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731246AbeGROyb (ORCPT ); Wed, 18 Jul 2018 10:54:31 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 43CCBDFABF429; Wed, 18 Jul 2018 22:16:04 +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.382.0; Wed, 18 Jul 2018 22:15:56 +0800 From: John Garry To: , CC: , , , Xiaofei Tan , "John Garry" Subject: [PATCH 4/9] scsi: hisi_sas: tidy host controller reset function a bit Date: Wed, 18 Jul 2018 22:14:28 +0800 Message-ID: <1531923273-193768-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1531923273-193768-1-git-send-email-john.garry@huawei.com> References: <1531923273-193768-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 This patch tidies host controller reset function by putting some code to two new functions, and exports these two functions out, so that they could be used by FLR feature to be realised. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 3 ++ drivers/scsi/hisi_sas/hisi_sas_main.c | 61 ++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 22 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 0ff9115..6c7d2e2 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -320,6 +320,7 @@ struct hisi_hba { const struct hisi_sas_hw *hw; /* Low level hw interface */ unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)]; struct work_struct rst_work; + u32 phy_state; }; /* Generic HW DMA host memory structures */ @@ -480,4 +481,6 @@ 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); extern u8 hisi_sas_get_prog_phy_linkrate_mask(enum sas_linkrate max); +extern void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba); +extern void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba); #endif diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index ed671af..b0bcd14 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1309,22 +1309,12 @@ static void hisi_sas_terminate_stp_reject(struct hisi_hba *hisi_hba) } } -static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba) +void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba) { - struct device *dev = hisi_hba->dev; struct Scsi_Host *shost = hisi_hba->shost; - u32 old_state, state; - int rc; - - if (!hisi_hba->hw->soft_reset) - return -1; - - if (test_and_set_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags)) - return -1; down(&hisi_hba->sem); - dev_info(dev, "controller resetting...\n"); - old_state = hisi_hba->hw->get_phys_state(hisi_hba); + hisi_hba->phy_state = hisi_hba->hw->get_phys_state(hisi_hba); scsi_block_requests(shost); hisi_hba->hw->wait_cmds_complete_timeout(hisi_hba, 100, 5000); @@ -1333,15 +1323,13 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba) del_timer_sync(&hisi_hba->timer); set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); - rc = hisi_hba->hw->soft_reset(hisi_hba); - if (rc) { - dev_warn(dev, "controller reset failed (%d)\n", rc); - clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); - up(&hisi_hba->sem); - scsi_unblock_requests(shost); - clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags); - return rc; - } +} +EXPORT_SYMBOL_GPL(hisi_sas_controller_reset_prepare); + +void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba) +{ + struct Scsi_Host *shost = hisi_hba->shost; + u32 state; /* Init and wait for PHYs to come up and all libsas event finished. */ hisi_hba->hw->phys_init(hisi_hba); @@ -1357,7 +1345,36 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba) clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags); state = hisi_hba->hw->get_phys_state(hisi_hba); - hisi_sas_rescan_topology(hisi_hba, old_state, state); + hisi_sas_rescan_topology(hisi_hba, hisi_hba->phy_state, state); +} +EXPORT_SYMBOL_GPL(hisi_sas_controller_reset_done); + +static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba) +{ + struct device *dev = hisi_hba->dev; + struct Scsi_Host *shost = hisi_hba->shost; + int rc; + + if (!hisi_hba->hw->soft_reset) + return -1; + + if (test_and_set_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags)) + return -1; + + dev_info(dev, "controller resetting...\n"); + hisi_sas_controller_reset_prepare(hisi_hba); + + rc = hisi_hba->hw->soft_reset(hisi_hba); + if (rc) { + dev_warn(dev, "controller reset failed (%d)\n", rc); + clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); + up(&hisi_hba->sem); + scsi_unblock_requests(shost); + clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags); + return rc; + } + + hisi_sas_controller_reset_done(hisi_hba); dev_info(dev, "controller reset complete\n"); return 0;