From patchwork Wed Jun 7 15:20:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 103269 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp1796795obh; Wed, 7 Jun 2017 07:52:11 -0700 (PDT) X-Received: by 10.101.85.14 with SMTP id f14mr32579412pgr.112.1496847131264; Wed, 07 Jun 2017 07:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496847131; cv=none; d=google.com; s=arc-20160816; b=lyRWHgPCbJkCmmNnC5PyeeP1HzCiTu6g26mRfQbfZ7u+UHJJKyXFwjaS/hKoki1luf RDfUV/3juk2PTSumJCUtbVxVw+SrbE8ZRf88jjWbwtHUZGuGLPjEwR9H5OQVRgjs28Tt NdTPBL3QGEtdG95pKJ85cn/jnANQEgTK4Q6YS9YhrWy7hIgSVUA2a/w71vOi1KlfTAFM oqGMkDxHPW+DCD4NF424ql1xIPcQfJXiw+u5gp2XsR0iItYdQZHEf6g/w+0yct/3ISkz vj1hTxqjkGvZatl3YDvhOv8NZhzvPTaSlwZw+OtnA1/Z41RBqDNTcmJQGwxm/2YF4+xJ 33og== 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=4Pep7ZyeMDlfuhXLRMkurEwtLRDkHm0fkdfkuIG7hMc=; b=xZACqax8DUzba4iDBolZ43mcS0BpghOrwu6XkxZSA0Hp+oa1fu2OM7ooyCwJFWKp7E 5KIvM8OhPeOXq5AAu6Ytb9AdlNHCIQll16ZnKodpMs75DSmSC8xCsLAfgcL2nMPHJj5e /ogDNbPy5Mu4jx5es8GUpZw9e4LQqEYlUNzjSmk7Xzu3K38QkUMFxAr+LK5CKSV79kqo 7cRCutV/VYDp5A7XEpflM+PuJRqQMXA59WaREUKaYu2chIdgRYt5MQaF4qAX5m1AcdZk bWhAB2tLmxK76EnmGOuL9D1fIBNvT4xChkVFWxVN9PYooWrjCQPXoUC5iUVuF0SaS5pD kgNg== 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 c186si2013625pfb.27.2017.06.07.07.52.10; Wed, 07 Jun 2017 07:52:11 -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 S1751748AbdFGOwI (ORCPT + 25 others); Wed, 7 Jun 2017 10:52:08 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:7324 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751713AbdFGOwG (ORCPT ); Wed, 7 Jun 2017 10:52:06 -0400 Received: from 172.30.72.55 (EHLO DGGEML403-HUB.china.huawei.com) ([172.30.72.55]) by dggrg02-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AOX57446; Wed, 07 Jun 2017 22:50:55 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEML403-HUB.china.huawei.com (10.3.17.33) with Microsoft SMTP Server id 14.3.301.0; Wed, 7 Jun 2017 22:50:43 +0800 From: John Garry To: , CC: , , , , , Xiang Chen , John Garry Subject: [PATCH v4 01/23] scsi: hisi_sas: fix timeout check in hisi_sas_internal_task_abort() Date: Wed, 7 Jun 2017 23:20:04 +0800 Message-ID: <1496848826-20534-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1496848826-20534-1-git-send-email-john.garry@huawei.com> References: <1496848826-20534-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.0A020203.593812CF.0271, 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: 49a2a2a1f2d4061720fc2142323942bc Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen We need to check for timeout before task status, or the task will be mistook as completed internal abort command. Also add protection for sas_task.task_state_flags in hisi_sas_tmf_timedout(). Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 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 f720d3c..3605d28 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -691,8 +691,13 @@ static void hisi_sas_task_done(struct sas_task *task) static void hisi_sas_tmf_timedout(unsigned long data) { struct sas_task *task = (struct sas_task *)data; + unsigned long flags; + + spin_lock_irqsave(&task->task_state_lock, flags); + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) + task->task_state_flags |= SAS_TASK_STATE_ABORTED; + spin_unlock_irqrestore(&task->task_state_lock, flags); - task->task_state_flags |= SAS_TASK_STATE_ABORTED; complete(&task->slow_task->completion); } @@ -1247,6 +1252,17 @@ static int hisi_sas_query_task(struct sas_task *task) wait_for_completion(&task->slow_task->completion); res = TMF_RESP_FUNC_FAILED; + /* Internal abort timed out */ + if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { + struct hisi_sas_slot *slot = task->lldd_task; + + if (slot) + slot->task = NULL; + dev_err(dev, "internal task abort: timeout.\n"); + } + } + if (task->task_status.resp == SAS_TASK_COMPLETE && task->task_status.stat == TMF_RESP_FUNC_COMPLETE) { res = TMF_RESP_FUNC_COMPLETE; @@ -1259,13 +1275,6 @@ static int hisi_sas_query_task(struct sas_task *task) goto exit; } - /* Internal abort timed out */ - if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { - if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { - dev_err(dev, "internal task abort: timeout.\n"); - } - } - exit: dev_dbg(dev, "internal task abort: task to dev %016llx task=%p " "resp: 0x%x sts 0x%x\n",