Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5656644img; Wed, 27 Mar 2019 12:34:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2JQb6wcaan83VFFgME0sU5HKcZ2v7F5UIK77p0vf+JwLizc9tKLRuWNn6dDETbscBJghI X-Received: by 2002:a17:902:b282:: with SMTP id u2mr20318514plr.9.1553715268582; Wed, 27 Mar 2019 12:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553715268; cv=none; d=google.com; s=arc-20160816; b=qYNsM1DxeTeFWAXIyw2+Ja03aV/Da4gtchFXb75y2SABNvYXQfBpESKg+slSGrCDXb 2kg9RWMOUS6X1VV3e+eRH869lLXpFgxuZAi+ipUJDo4F3P84t9KKnQPqzskgW0+m8gCF IydauWOHaxzNUaReBi8hXuYkeZPcLVbf3lhmH2mRufJqG9mZTeMam/igrFRQ3dDNhxSc e8BU+PfbVLsllEUaP7x0VZ1olbv1IalE31snnxWvNZAucmy7wchyk31OhnSSFISgTQQ5 9kZZlGnEBYYTjpqFfHKAYAPxNeIxwrprZLOK4mXm8m/BlVzfUbirzUJutsKy3hcDBIxx kFXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ulGTOO/yyUDyk/ETYuXjyvgBR+MbfHI5YwQSFM+HJ84=; b=Qz1KCbfmuvIIuniqaHb5wTIRVaKIUqQuA/sUVgLih6t6JNVhyWgGijS0bg1EkFQUmk GlwWY2vnK1wggm6JYP50AtZ/0ibxC0pOAkuMVMGmghVQZc6iIVq7R08WC9a9Y1RR8HpU QrCz5RKzJLu9RB2vxSrQxUlE1Sns0s7EUO2YiLDd3KmydomWOoVkPhmVID5MfNsBrvHl 9+Wml/z0IrLylPf+vM2V0/vmt5z6PylwFYahadXLp4daT97iLi02LyFjqviXFCGNdIRy VJcXmT+KlC/1QrRWUd8+WCydxSUX08P+OekSYymJ+KjwwralkP3Wdc6Uuuc9uZhhi4Nv vauw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PPKUOKOe; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v23si18445577pfm.187.2019.03.27.12.34.13; Wed, 27 Mar 2019 12:34:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=PPKUOKOe; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733187AbfC0Tc1 (ORCPT + 99 others); Wed, 27 Mar 2019 15:32:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:42604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730973AbfC0SCl (ORCPT ); Wed, 27 Mar 2019 14:02:41 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DF25821738; Wed, 27 Mar 2019 18:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709760; bh=uLV+b8csXIpp+5O77PUcn60dRftAUzlG52ayYezGYpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PPKUOKOeouO9JCPkCkjFi0XlrDyqwHEQguJiaeqpNq2gsqAGEsSnq3ykfzxoGw02p QdxeaxUxFiQWyIbET9EEnk1IHVgqsgKATL3JHej55RQDH3Dp0NnatugQIEW8tk0L9C Nk8Hy7j2MAf9HtWemqWWXKxVXQ1NmP8DSrmuFhJc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xiang Chen , John Garry , "Martin K . Petersen" , Sasha Levin , linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 026/262] scsi: hisi_sas: Fix a timeout race of driver internal and SMP IO Date: Wed, 27 Mar 2019 13:58:01 -0400 Message-Id: <20190327180158.10245-26-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen [ Upstream commit 4790595723d4b833b18c994973d39f9efb842887 ] For internal IO and SMP IO, there is a time-out timer for them. In the timer handler, it checks whether IO is done according to the flag task->task_state_lock. There is an issue which may cause system suspended: internal IO or SMP IO is sent, but at that time because of hardware exception (such as inject 2Bit ECC error), so IO is not completed and also not timeout. But, at that time, the SAS controller reset occurs to recover system. It will release the resource and set the status of IO to be SAS_TASK_STATE_DONE, so when IO timeout, it will never complete the completion of IO and wait for ever. [ 729.123632] Call trace: [ 729.126791] [] __switch_to+0x94/0xa8 [ 729.133106] [] __schedule+0x1e8/0x7fc [ 729.138975] [] schedule+0x34/0x8c [ 729.144401] [] schedule_timeout+0x1d8/0x3cc [ 729.150690] [] wait_for_common+0xdc/0x1a0 [ 729.157101] [] wait_for_completion+0x28/0x34 [ 729.165973] [] hisi_sas_internal_task_abort+0x2a0/0x424 [hisi_sas_test_main] [ 729.176447] [] hisi_sas_abort_task+0x244/0x2d8 [hisi_sas_test_main] [ 729.185258] [] sas_eh_handle_sas_errors+0x1c8/0x7b8 [ 729.192391] [] sas_scsi_recover_host+0x130/0x398 [ 729.199237] [] scsi_error_handler+0x148/0x5c0 [ 729.206009] [] kthread+0x10c/0x138 [ 729.211563] [] ret_from_fork+0x10/0x18 To solve the issue, callback function task_done of those IOs need to be called when on SAS controller reset. Signed-off-by: Xiang Chen Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/hisi_sas/hisi_sas_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 88ae415e907a..62d158574281 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -873,7 +873,8 @@ static void hisi_sas_do_release_task(struct hisi_hba *hisi_hba, struct sas_task spin_lock_irqsave(&task->task_state_lock, flags); task->task_state_flags &= ~(SAS_TASK_STATE_PENDING | SAS_TASK_AT_INITIATOR); - task->task_state_flags |= SAS_TASK_STATE_DONE; + if (!slot->is_internal && task->task_proto != SAS_PROTOCOL_SMP) + task->task_state_flags |= SAS_TASK_STATE_DONE; spin_unlock_irqrestore(&task->task_state_lock, flags); } -- 2.19.1