From patchwork Fri Dec 8 17:16:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 121209 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp867679qgn; Fri, 8 Dec 2017 08:35:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMYaW7MALAfAbeP8L+0Eb1QY8JF52ThrJUbMVM6fJ8nC9I4RCfuMlZuGlrKG236uLq5XqRlK X-Received: by 10.84.252.23 with SMTP id x23mr31172912pll.54.1512750913169; Fri, 08 Dec 2017 08:35:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512750913; cv=none; d=google.com; s=arc-20160816; b=s2369pdCl2X11LhvGvRZXT32quIyRFFtpyU34VzAsa33rh33I3BtH4VQjwRdpNxa9z +KmShoY1j2no7jL7UYODotRRrISu0kNg9Ajt6fKh1CRMZ4hj19oWL/EDMurCD1Kpx+st ctt/romkr+C5ifpsb3wQtlOxliOrHJueY4NYy4otPwyKaSQEBv4iz4m/vHWw717d8F61 JOn4Z++iGTwSOIwCP8uPPlB5SZXPBHrfehp+ZxDiHNxJ/3FTeM8s01jC22VcrspzgALb WsMd0Xc2c2sBINXLhBCMfu1CeydBOAwgr9LdhH+f10purQ34Md9iyjDDYfqboGWV2qJG rH3g== 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=PA7JQSVZPoIU5lW6y6bIa8T2G2mjWVD5yey+v1ZSWbU=; b=MzzRg3Ne+IgyBfaahRaQZPAGPigwGNpnHNIu/K811tQJGY0zjMCTMwhDJ4qIXsYgYU tfH5NhWwfLZhloNwNc0YTZZHKWLTbm/PlNS2fPKayX1fJmDDKPB1UGuy1esYM6nuBVex US1qGJD8D4VYRzwKumkpfbdFnHJEnccF1c8bqxCbcd1YC7VxxiA0dzR82fCWDxKfkh7J EyelGf85s2PqyhZmGsmm9VpmI8UUSehHM7DWZXnA85jNkqyG7FrJCziYHqccgb3ZxBi5 yrrkRQS8iM3Yp+U7+9oUIWCSospwCw8YVAGHnn5Pg03GcK6fFVdNlj4j5TUrWABp/EsH +z+A== 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 i191si5704252pge.391.2017.12.08.08.35.12; Fri, 08 Dec 2017 08:35:13 -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 S1754633AbdLHQfK (ORCPT + 18 others); Fri, 8 Dec 2017 11:35:10 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2231 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753812AbdLHQbE (ORCPT ); Fri, 8 Dec 2017 11:31:04 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id EB6C5D0A280C8; Sat, 9 Dec 2017 00:30:44 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.361.1; Sat, 9 Dec 2017 00:30:38 +0800 From: John Garry To: , CC: , , , Xiaofei Tan , "John Garry" Subject: [PATCH 07/19] scsi: hisi_sas: add an mechanism to do reset work synchronously Date: Sat, 9 Dec 2017 01:16:38 +0800 Message-ID: <1512753410-50924-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512753410-50924-1-git-send-email-john.garry@huawei.com> References: <1512753410-50924-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 Sometimes it is required to know when the controller reset has completed and also if it has completed successfully. For such places, we call hisi_sas_controller_reset() directly before. That may lead to multiple calls to this function. This patch create a per-reset structure which contains a completion structure and status flag to know when the reset completes and also the status. It is also in hisi_hba.wq to do reset work. As all host reset works are done in hisi_hba.wq, we don't worry multiple calls to hisi_sas_controller_reset(). Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 26 ++++++++++++++++++++++++++ drivers/scsi/hisi_sas/hisi_sas_main.c | 19 ++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index b2534ca..71bc8ea 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -99,6 +99,31 @@ struct hisi_sas_hw_error { const struct hisi_sas_hw_error *sub; }; +struct hisi_sas_rst { + struct hisi_hba *hisi_hba; + struct completion *completion; + struct work_struct work; + bool done; +}; + +#define HISI_SAS_RST_WORK_INIT(r, c) \ + { .hisi_hba = hisi_hba, \ + .completion = &c, \ + .work = __WORK_INITIALIZER(r.work, \ + hisi_sas_sync_rst_work_handler), \ + .done = false, \ + } + +#define HISI_SAS_DECLARE_RST_WORK_ON_STACK(r) \ + DECLARE_COMPLETION_ONSTACK(c); \ + DECLARE_WORK(w, hisi_sas_sync_rst_work_handler); \ + struct hisi_sas_rst r = HISI_SAS_RST_WORK_INIT(r, c) + +enum hisi_sas_bit_err_type { + HISI_SAS_ERR_SINGLE_BIT_ECC = 0x0, + HISI_SAS_ERR_MULTI_BIT_ECC = 0x1, +}; + struct hisi_sas_phy { struct hisi_hba *hisi_hba; struct hisi_sas_port *port; @@ -426,5 +451,6 @@ extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot); extern void hisi_sas_init_mem(struct hisi_hba *hisi_hba); extern void hisi_sas_rst_work_handler(struct work_struct *work); +extern void hisi_sas_sync_rst_work_handler(struct work_struct *work); extern void hisi_sas_kill_tasklets(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 e4b3092..fb162c0 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1299,8 +1299,14 @@ static int hisi_sas_lu_reset(struct domain_device *device, u8 *lun) static int hisi_sas_clear_nexus_ha(struct sas_ha_struct *sas_ha) { struct hisi_hba *hisi_hba = sas_ha->lldd_ha; + HISI_SAS_DECLARE_RST_WORK_ON_STACK(r); - return hisi_sas_controller_reset(hisi_hba); + queue_work(hisi_hba->wq, &r.work); + wait_for_completion(r.completion); + if (r.done) + return TMF_RESP_FUNC_COMPLETE; + + return TMF_RESP_FUNC_FAILED; } static int hisi_sas_query_task(struct sas_task *task) @@ -1820,6 +1826,17 @@ void hisi_sas_rst_work_handler(struct work_struct *work) } EXPORT_SYMBOL_GPL(hisi_sas_rst_work_handler); +void hisi_sas_sync_rst_work_handler(struct work_struct *work) +{ + struct hisi_sas_rst *rst = + container_of(work, struct hisi_sas_rst, work); + + if (!hisi_sas_controller_reset(rst->hisi_hba)) + rst->done = true; + complete(rst->completion); +} +EXPORT_SYMBOL_GPL(hisi_sas_sync_rst_work_handler); + int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba) { struct device *dev = hisi_hba->dev;