Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5989286ybc; Wed, 27 Nov 2019 13:00:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzZV6HcQCEjnbkLO74wji+3Wm5lDHB92mZ/rqbenslyMzeSfUXkUQleZU81oReIdhtdAsSK X-Received: by 2002:a17:906:edd2:: with SMTP id sb18mr52227591ejb.112.1574888432280; Wed, 27 Nov 2019 13:00:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888432; cv=none; d=google.com; s=arc-20160816; b=ojyelJAGtClhJ0wgV3WdI2gl38Y0JU52G2ToZAlH6cBUSMm3gbXK2M34mi0SinWOLj eVBmpLdNDO+uN11R+gp0ysrXudKmc+TMEPgaRpcdeTYnk67+1mtsf1dPSuE0PkyK78ta xDsPy7GIOB/M0mhR/BV2+FV4CFmUW2tvhHpe6UA/20lSDYginf3ZjzIyvKjiUxjTfUHP AvP5ZEbeG6r88ChdLOh2HdKnlbS4Cn60B1FeMmKeq5C47rNWLp5Dr/T0NHj0kEZpaGJF TCmuYHU1bPjTLLX4dIAo6xaK75rIgBkbb79Xy4fLfxL8FWh6mzV+ca/46lflIPfzisQD 8xZA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G6NkcNE8ozhpahBCLbvJbXa5pHB80fFFuOb3OUi1aAU=; b=YJUw43oiNYGlRz3nKLH9w24AQj2YznHJiroxgUSbohZTJ61J8S2fGaXUU6Dj1DrZRT G2yHXz3AGlwqgDxw+f+Y42VhO9b5RDoq2BC7BRbGdCKPiYJNwtE/kJAZgR+YWoE+xn3T FGO8tyt9GwmSdYhBeke9XuMoBXiK7S6nZVBV/cIQPO68tr7wqAHZGrWQmAdVaCPZdTHi 7sCDPR/hGK7C092O23dbBMGfO6L4OjozcIAkSFYEen8FkU1B3TmTNb4SVPhyMwT172UE /vKbhX8kllBBY9Y41EvIwEpxT/h+JHqkCehFzjiXY8aOf3yopZb645BybNPaQ/MNbaaw Wtyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NqSgk5WJ; 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 cb26si12658476edb.106.2019.11.27.13.00.09; Wed, 27 Nov 2019 13:00:32 -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; dkim=pass header.i=@kernel.org header.s=default header.b=NqSgk5WJ; 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 S1731148AbfK0U7P (ORCPT + 99 others); Wed, 27 Nov 2019 15:59:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:50616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731381AbfK0U7I (ORCPT ); Wed, 27 Nov 2019 15:59:08 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 466852084B; Wed, 27 Nov 2019 20:59:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888347; bh=y5GylDGsCz7qIrBi3/WJS/VV0/tGA8o9bj7XaPDIqYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NqSgk5WJHvMGgjmRm8qjwNWkSexFFFMriiZymPoZHnZd7E84VlvtQQQlg42Inq9BS fEX/28jYIrPhMoW70qBWKsiAm23aHnS0FxzrkoYwYSU8PznFbEiL/h8JYsgGcBwAfC mmzWDLXFUIFXxdV2PmkOZG+Nr/OqEsg/5xghWOdc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiang Chen , John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 056/306] scsi: hisi_sas: Free slot later in slot_complete_vx_hw() Date: Wed, 27 Nov 2019 21:28:26 +0100 Message-Id: <20191127203118.872281834@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 3e178f3ecfcf91a258e832b0f0843a4cfd9059ac ] If an SSP/SMP IO times out, it may be actually in reality be simultaneously processing completion of the slot in slot_complete_vx_hw(). Then if the slot is freed in slot_complete_vx_hw() (this IPTT is freed and it may be re-used by other slot), and we may abort the wrong slot in hisi_sas_abort_task(). So to solve the issue, free the slot after the check of SAS_TASK_STATE_ABORTED in slot_complete_vx_hw(). 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_v2_hw.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 1c4ea58da1ae1..c4774d63d5d04 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -2481,7 +2481,6 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) } out: - hisi_sas_slot_task_free(hisi_hba, task, slot); sts = ts->stat; spin_lock_irqsave(&task->task_state_lock, flags); if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { @@ -2491,6 +2490,7 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) } task->task_state_flags |= SAS_TASK_STATE_DONE; spin_unlock_irqrestore(&task->task_state_lock, flags); + hisi_sas_slot_task_free(hisi_hba, task, slot); if (!is_internal && (task->task_proto != SAS_PROTOCOL_SMP)) { spin_lock_irqsave(&device->done_lock, flags); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 3922b17e2ea39..fb2a5969181b5 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1749,7 +1749,6 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) } out: - hisi_sas_slot_task_free(hisi_hba, task, slot); sts = ts->stat; spin_lock_irqsave(&task->task_state_lock, flags); if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { @@ -1759,6 +1758,7 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) } task->task_state_flags |= SAS_TASK_STATE_DONE; spin_unlock_irqrestore(&task->task_state_lock, flags); + hisi_sas_slot_task_free(hisi_hba, task, slot); if (!is_internal && (task->task_proto != SAS_PROTOCOL_SMP)) { spin_lock_irqsave(&device->done_lock, flags); -- 2.20.1