From patchwork Tue Oct 24 15:51:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 116965 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5916644qgn; Tue, 24 Oct 2017 08:08:55 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QrmgVLU9xGXG19iZCAB1Aus7W720Sxx5kkaN8bQvyMcWJBGzY8GC8Ov76yiY/1GoJWGt5E X-Received: by 10.98.105.199 with SMTP id e190mr16852746pfc.275.1508857735427; Tue, 24 Oct 2017 08:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508857735; cv=none; d=google.com; s=arc-20160816; b=tPLF9o/4ysbJ929qZOsAbXeRazhxJOgDGIY17vEsNOUJDLA0NW2K6Uv5xJqe/h7gc7 GoH3gvXNDMkcy89+zEPWwOuIUJc0v6tL6yy41zdPl52Fd9U6D3bsXE4IlFptPRdkpnuM kLmdSPYJZRNFn1vVL1CmAEcdf9Dy/2wGqECL+XPEclkA5YI5QYe6WFDl1Senl0YKNHDh MHZaSdTwrThKY4C8ryFVymavMpHrWgXbfoood0Sp8CzKezergm4Bwq97qB5y1eGObjmn LtLWKKohv/afeRG+Nx72PoPW979/sa32JLryRJpLr7R0tiRn2Y0yFRrbWFZN49ygiF02 auRQ== 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=rIfK5thYjiILQozM12DWaCQaZ/c34BgxGMqpiuuIlY4=; b=OzeKcm9itMjY6YvOYnbB9tus+kjEHM37zKTiaUcNsLwsrj8KcPp6bqKptud+AHOok9 ZARQ8cKHvsKuA2HzCrhxKoipRXThlnng0hhgDXrRJnOWB8Eube7ZDTnRzU5IR7Y0vcUQ yEACOPmYvWE7PRhVPtQhWEpvAaQrDiL/goPBE/DCvVU+xZzgML7IEeYrPCUw5PZiURqs qxM2IN2VJywUs2/QYC3jk9MxMV7IPceh8O95h8H5XUIYDHACMQP3G6D9ekiUQz+FIkkK CTPXnxoVIve9pw/t9567A/1/4sbrf8HiBGgl3DO8ybeuWmm5F6j2cIaMxud+nOAMbLEB HfQw== 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 g8si273703plt.186.2017.10.24.08.08.55; Tue, 24 Oct 2017 08:08:55 -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 S1751917AbdJXPIw (ORCPT + 27 others); Tue, 24 Oct 2017 11:08:52 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9043 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751686AbdJXPIr (ORCPT ); Tue, 24 Oct 2017 11:08:47 -0400 Received: from 172.30.72.58 (EHLO DGGEMS406-HUB.china.huawei.com) ([172.30.72.58]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DJW29921; Tue, 24 Oct 2017 23:05:30 +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.361.1; Tue, 24 Oct 2017 23:05:20 +0800 From: John Garry To: , CC: , , , , Xiaofei Tan , John Garry Subject: [PATCH 17/19] scsi: hisi_sas: complete all tasklets prior to host reset Date: Tue, 24 Oct 2017 23:51:47 +0800 Message-ID: <1508860309-212397-18-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508860309-212397-1-git-send-email-john.garry@huawei.com> References: <1508860309-212397-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0207.59EF56BA.012E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 48b47beb8ebb43b616191086e89ab7b5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaofei Tan The CQ event is handled in tasklet context, and it could be delayed if the system loading is high. It is possible to run into some problems when executing a host reset when cq_tasklet_vx_hw() is being executed. So, prior to host reset, execute tasklet_kill() to ensure that all CQ tasklets are complete. Besides, as the function hisi_sas_wait_tasklets_done() is added to do tasklet_kill(), this patch refactors some code where tasklet_kill() is used. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 1 + drivers/scsi/hisi_sas/hisi_sas_main.c | 11 +++++++++++ drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 8 ++------ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 ++- 4 files changed, 16 insertions(+), 7 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 00fefea..636cdf8 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -435,4 +435,5 @@ 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_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 1d417a4..4cbb999 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1548,6 +1548,17 @@ void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy) } EXPORT_SYMBOL_GPL(hisi_sas_phy_down); +void hisi_sas_kill_tasklets(struct hisi_hba *hisi_hba) +{ + int i; + + for (i = 0; i < hisi_hba->queue_count; i++) { + struct hisi_sas_cq *cq = &hisi_hba->cq[i]; + + tasklet_kill(&cq->tasklet); + } +} +EXPORT_SYMBOL_GPL(hisi_sas_kill_tasklets); struct scsi_transport_template *hisi_sas_stt; EXPORT_SYMBOL_GPL(hisi_sas_stt); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 8626d9f..433412a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -3512,6 +3512,7 @@ static int soft_reset_v2_hw(struct hisi_hba *hisi_hba) interrupt_disable_v2_hw(hisi_hba); hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0x0); + hisi_sas_kill_tasklets(hisi_hba); hisi_sas_stop_phys(hisi_hba); @@ -3595,16 +3596,11 @@ static int hisi_sas_v2_remove(struct platform_device *pdev) { struct sas_ha_struct *sha = platform_get_drvdata(pdev); struct hisi_hba *hisi_hba = sha->lldd_ha; - int i; if (timer_pending(&hisi_hba->timer)) del_timer(&hisi_hba->timer); - for (i = 0; i < hisi_hba->queue_count; i++) { - struct hisi_sas_cq *cq = &hisi_hba->cq[i]; - - tasklet_kill(&cq->tasklet); - } + hisi_sas_kill_tasklets(hisi_hba); return hisi_sas_remove(pdev); } diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 243fa1d..18cc3b4 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1768,6 +1768,7 @@ static int soft_reset_v3_hw(struct hisi_hba *hisi_hba) interrupt_disable_v3_hw(hisi_hba); hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0x0); + hisi_sas_kill_tasklets(hisi_hba); hisi_sas_stop_phys(hisi_hba); @@ -1977,7 +1978,6 @@ static int soft_reset_v3_hw(struct hisi_hba *hisi_hba) struct hisi_sas_cq *cq = &hisi_hba->cq[i]; free_irq(pci_irq_vector(pdev, i+16), cq); - tasklet_kill(&cq->tasklet); } pci_free_irq_vectors(pdev); } @@ -1993,6 +1993,7 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev) sas_remove_host(sha->core.shost); hisi_sas_v3_destroy_irqs(pdev, hisi_hba); + hisi_sas_kill_tasklets(hisi_hba); pci_release_regions(pdev); pci_disable_device(pdev); hisi_sas_free(hisi_hba);