From patchwork Tue Oct 24 15:51:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 116967 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5917019qgn; Tue, 24 Oct 2017 08:09:16 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Rn9P5zoZMuCLIQi3QO2s0V2bleGWhyUlFfPyTsniMayLUDQl9zWjvXhc+5Gd0kzD08dD8X X-Received: by 10.99.114.19 with SMTP id n19mr14880243pgc.356.1508857755988; Tue, 24 Oct 2017 08:09:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508857755; cv=none; d=google.com; s=arc-20160816; b=ToBNM+HY4i+XNB5u6gvNjHBYo/D/AFA01j5dTsgWwp4bllM0hEjUXJwIv/FHh3/D4v vh1wJVJf4jxb0FkMHm+eBeMa0GUd8GhyeGOXRcP6x86NATZhVUOR8n2aiCgG9xRV7Zhf Aq7PyJ1lmpsZ4N380kMJ9/qy8hW9ytHdPUD7nuUt4sgLwojwPFa9oAnjkLLIRsz08Wh3 e0xgwp4G5uut1aXs5fNQMzYBeJSJ84H9POQ2aFyqGN2xuWrNG4SK4HUeh3qnaKDcrmIa pKtVJWrq3JP81qBHx8C5sjfJC4gR0P46GWReBzDxaBTOeXRM26JdN/QOrEH16c1ic/u9 6c+g== 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=Y3f/70WCSTr3Xkvkc0VkAIb1GrF1lIFPsP7yPL0BPN0=; b=ZUrIO2+M55+7Ikmv5Te2ORuXEgGu5bB+4aiB/I+R/4oGw4vEzPBOBqgqGGK4HM6i57 Eetm7GAHQq0Fsfo9vfg6YRFM70kCHCALl+H+S64Dbj5LtXCxBwJnYky7RUcoe/fb+2ex x2eCviFqeABZd4rpzQKN4arggYOHK3y4X518ewS4pHlUFpTs5JcIX9zX4gBFsoLddRgg ef3rHlG9gov7uSLS19N2znJFZ967lkkviwdvHOvPzxeQVuAmoW+jGfuFMYbEysT9/KPW fQOOJeJuYqkwm8ib710pop9qAxSjFYubzYF/obo/7L1WlREBq3VwxdFxCwyOUIXUZK69 KD+Q== 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 c30si294953pgn.815.2017.10.24.08.09.15; Tue, 24 Oct 2017 08:09:15 -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 S932215AbdJXPJO (ORCPT + 27 others); Tue, 24 Oct 2017 11:09:14 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9045 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751969AbdJXPJJ (ORCPT ); Tue, 24 Oct 2017 11:09:09 -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 DJW29925; Tue, 24 Oct 2017 23:05:31 +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: , , , , Xiang Chen , John Garry Subject: [PATCH 16/19] scsi: hisi_sas: fix a bug when free device for v3 hw Date: Tue, 24 Oct 2017 23:51:46 +0800 Message-ID: <1508860309-212397-17-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.59EF56BB.0061, 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: 121beb882c87e1daadb7504a4b33e160 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen Use completion to wait on ITCT CLR interrupt finishing before processing other things when freeing a device. This is safer than the pre-existing process of polling the register. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 1f8995b..243fa1d 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -393,7 +393,7 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) hisi_sas_write32(hisi_hba, ENT_INT_SRC3, 0xffffffff); hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK1, 0xfefefefe); hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK2, 0xfefefefe); - hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK3, 0xffffffff); + hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK3, 0xfffe20ff); hisi_sas_write32(hisi_hba, CHNL_PHYUPDOWN_INT_MSK, 0x0); hisi_sas_write32(hisi_hba, CHNL_ENT_INT_MSK, 0x0); hisi_sas_write32(hisi_hba, HGC_COM_INT_MSK, 0x0); @@ -582,35 +582,24 @@ static void setup_itct_v3_hw(struct hisi_hba *hisi_hba, static void free_device_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_device *sas_dev) { + DECLARE_COMPLETION_ONSTACK(completion); u64 dev_id = sas_dev->device_id; - struct device *dev = hisi_hba->dev; struct hisi_sas_itct *itct = &hisi_hba->itct[dev_id]; u32 reg_val = hisi_sas_read32(hisi_hba, ENT_INT_SRC3); + sas_dev->completion = &completion; + /* clear the itct interrupt state */ if (ENT_INT_SRC3_ITC_INT_MSK & reg_val) hisi_sas_write32(hisi_hba, ENT_INT_SRC3, ENT_INT_SRC3_ITC_INT_MSK); /* clear the itct table*/ - reg_val = hisi_sas_read32(hisi_hba, ITCT_CLR); - reg_val |= ITCT_CLR_EN_MSK | (dev_id & ITCT_DEV_MSK); + reg_val = ITCT_CLR_EN_MSK | (dev_id & ITCT_DEV_MSK); hisi_sas_write32(hisi_hba, ITCT_CLR, reg_val); - udelay(10); - reg_val = hisi_sas_read32(hisi_hba, ENT_INT_SRC3); - if (ENT_INT_SRC3_ITC_INT_MSK & reg_val) { - dev_dbg(dev, "got clear ITCT done interrupt\n"); - - /* invalid the itct state*/ - memset(itct, 0, sizeof(struct hisi_sas_itct)); - hisi_sas_write32(hisi_hba, ENT_INT_SRC3, - ENT_INT_SRC3_ITC_INT_MSK); - - /* clear the itct */ - hisi_sas_write32(hisi_hba, ITCT_CLR, 0); - dev_dbg(dev, "clear ITCT ok\n"); - } + wait_for_completion(sas_dev->completion); + memset(itct, 0, sizeof(struct hisi_sas_itct)); } static void dereg_device_v3_hw(struct hisi_hba *hisi_hba,