From patchwork Thu May 31 12:50:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 137385 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6563922lji; Thu, 31 May 2018 05:54:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ7ASQNpH35hbTVofi1mOEHR2j+0HXHWWYYBW8eu0H0FUezQPzHDlcPy2F0tHzftj1XBby0 X-Received: by 2002:a63:b257:: with SMTP id t23-v6mr2443787pgo.431.1527771274532; Thu, 31 May 2018 05:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527771274; cv=none; d=google.com; s=arc-20160816; b=ruRXNftGJBtto7G3hlhOVomglJ7ti/KxWKEXgHHEGdBKN62FcxD4kVjtWKtVq471KT w5fEPaopZo9NxAi5kQDmJgFuks6VR99EuxxAP4jGP9sIKSwTDg3FRjkyImVACOhz/bFu hPkYk9UuROQhS9X1mQ6ogMmpP68w7DTNmgJzWp3gWWUhfp+PTQmxe3epX7GExmzWog6g b5qs+OuLCvQy4ywzaME2gUX1p+eKnry3+KSxyq/Gb3KiGiHaivgmLL6whoYMO3dnj+KU h6hXh5/OJKAlT4D7kWA1O9rl5LHzAjkWD1l3cw51DVkWUZqyag2H7YKQFtQfSKbs+R8T l4vw== 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=E2GO8PMn+Whk+3ujz9d/GyTHHzMKhtwuoSrWk4X94JA=; b=wWbS87MvTdXT2Hh5DbgyFnnWDap7tIHsR7VFDF6i6tfKfd16TOUsO9hXpDtRcxfACs QgO1L+7f/Wpn27coUpm5T342hb7xLrlJ68tqaODkLgVEqJt+NvOxnUBwF7NuTcXAPyEs nnimARVpLhwx43mTE0jhy+Eqk5VRqb3t7Vz5CGulb9u6mk+8UcVaKyPICoYUNp+Ua1BK WwVd43AZRUjSgBLeUFJHk4hd16yR/tfCX3J3OPyjrvHNDgTTRvTkLL80z4gu76sWgSU5 BFt52VCY6LLqncnCOZtoQJ7YLVsS4w0FTBql1I6xG9/w++GiVgaX02JlBfFALxeYhJjr Glrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 b60-v6si37427586plc.270.2018.05.31.05.54.34; Thu, 31 May 2018 05:54:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755289AbeEaMyd (ORCPT + 1 other); Thu, 31 May 2018 08:54:33 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:38681 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754941AbeEaMwU (ORCPT ); Thu, 31 May 2018 08:52:20 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B7BAE9250220E; Thu, 31 May 2018 20:52:15 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 20:52:11 +0800 From: John Garry To: , CC: , , , Xiaofei Tan , "John Garry" Subject: [PATCH 4/9] scsi: hisi_sas: Adjust task reject period during host reset Date: Thu, 31 May 2018 20:50:45 +0800 Message-ID: <1527771050-200916-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527771050-200916-1-git-send-email-john.garry@huawei.com> References: <1527771050-200916-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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Xiaofei Tan After soft_reset() for host reset, we should not be allowed to send commands to the HW before the PHYs have come up and the port ids have been refreshed. Prior to this point, any commands cannot be successfully completed. This exclusion is achieved by grabbing the host reset semaphore. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 21 ++++++++++++--------- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 +++- 2 files changed, 15 insertions(+), 10 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 823386f..090d3e0 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -536,8 +536,13 @@ static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, struct device *dev = hisi_hba->dev; struct hisi_sas_dq *dq = NULL; - if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) - return -EINVAL; + if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) { + if (in_softirq()) + return -EINVAL; + + down(&hisi_hba->sem); + up(&hisi_hba->sem); + } /* protect task_prep and start_delivery sequence */ rc = hisi_sas_task_prep(task, &dq, is_tmf, tmf, &pass); @@ -1383,30 +1388,28 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba) clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); up(&hisi_hba->sem); scsi_unblock_requests(shost); - goto out; + clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags); + return rc; } - clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); - /* Init and wait for PHYs to come up and all libsas event finished. */ hisi_hba->hw->phys_init(hisi_hba); msleep(1000); hisi_sas_refresh_port_id(hisi_hba); + clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); up(&hisi_hba->sem); if (hisi_hba->reject_stp_links_msk) hisi_sas_terminate_stp_reject(hisi_hba); hisi_sas_reset_init_all_devices(hisi_hba); scsi_unblock_requests(shost); + 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); dev_info(dev, "controller reset complete\n"); -out: - clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags); - - return rc; + return 0; } static int hisi_sas_abort_task(struct sas_task *task) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 0a126a82..c40fdb8 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2459,7 +2459,9 @@ static int hisi_sas_v3_suspend(struct pci_dev *pdev, pm_message_t state) return -ENODEV; } - set_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags); + if (test_and_set_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags)) + return -1; + scsi_block_requests(shost); set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); flush_workqueue(hisi_hba->wq); From patchwork Thu May 31 12:50:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 137379 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6561401lji; Thu, 31 May 2018 05:52:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJv8KxldetdoR5nxJGlcu8JNaIPulxsRM+SVGUB/6TwB2yYcezYO2W8mHYynLPrFFWsJH6L X-Received: by 2002:a65:5d8e:: with SMTP id f14-v6mr5573928pgt.25.1527771158307; Thu, 31 May 2018 05:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527771158; cv=none; d=google.com; s=arc-20160816; b=dgQz37sU1AuzgiAtdkxHfSDYwE08jzC6GmSDjkeD6sq9nHInnbZTkcPS80wm2i1I3w qT+CqCWgbo0u7AW17YFRqCRBkbb9H84HJOV9X8+1X/jIvcSvkFQT4g02gwjydGDh1unG Eos8R1cAWkjmRWcym0g2dmiR76VXpZBXAg5+4ermZ3TJj0xatmwY4+wQbQ6Ic3134mk7 0fUM2hX3gmcGL0HBlghFSHkUmllrWnjLkUfxJzKiMBiAgAZWNVhDxA5aV4k/EQD13QNG COLxjsYNhWCeP7QNCsJoKi6b3wAwCXxwSPAO8G9lniLguly+/uuJCMlYxeQn+WLDxxiX O5Ew== 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=Rwz+DD6DZg6hGumhx3/u+C2lgNt3vC+eKXiP1yeo3D0=; b=NVx80ank8MLYNJWmbP7PuxRTxCf5rZt9UTxcHrBx4RLBknkGJ8pbrF67yloRLj4YUG K/rEWjKwgKPKs6LVEztrJSsp8F0J88G7QFxxqEopRajUgn51C9m7f0Tz+lqCY4BYErY3 ak7dpqiRAZ6NCrhaUrV4VSgg79Y8bo7braarUpuRWnZjSGTZLEozSqoo4m32PXz7e+yP wTM+BP9EAiO9bPTnv7atA8pVIPOA+kqCcO8MQSvBU3g/87Y1THLJJmZRiiWpi0Qm35Eb tMkzl0M301d6x8LAdTLzVxfD/qEeMErEt1BxQ3QapUDMoQkU42iT1iYnmOEoHEFTJd6h dX/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 65-v6si38623106plb.301.2018.05.31.05.52.38; Thu, 31 May 2018 05:52:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755178AbeEaMwg (ORCPT + 1 other); Thu, 31 May 2018 08:52:36 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8236 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754733AbeEaMwe (ORCPT ); Thu, 31 May 2018 08:52:34 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 2E437B6015341; Thu, 31 May 2018 20:52:20 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 20:52:12 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 8/9] scsi: hisi_sas: Add missing PHY spinlock init Date: Thu, 31 May 2018 20:50:49 +0800 Message-ID: <1527771050-200916-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527771050-200916-1-git-send-email-john.garry@huawei.com> References: <1527771050-200916-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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The init is missed for hisi_sas_phy spinlock, so add it. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 ++ 1 file changed, 2 insertions(+) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 20aab10..781b2af 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -808,6 +808,8 @@ static void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int phy_no) for (i = 0; i < HISI_PHYES_NUM; i++) INIT_WORK(&phy->works[i], hisi_sas_phye_fns[i]); + + spin_lock_init(&phy->lock); } static void hisi_sas_port_notify_formed(struct asd_sas_phy *sas_phy)