Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp778184ybc; Sat, 16 Nov 2019 08:31:30 -0800 (PST) X-Google-Smtp-Source: APXvYqy93pWMxNzJTtvb/cQKYyK4DMb8lNxohRWw8cxowjYgd4CPUcWKk/8b7JUtbiSzYtXWPdjp X-Received: by 2002:a17:906:7c5:: with SMTP id m5mr10892393ejc.231.1573921889948; Sat, 16 Nov 2019 08:31:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921889; cv=none; d=google.com; s=arc-20160816; b=De+2r9aVS5zQtUVkhmOqyuS8i3Sj3DLgDQg+Xk0RW6jEqqbCDEerygynW4/a9KDpts Xb3T0T9j3+mCK2nRIP4p7ltMhQN4IjrP2TWyARmyRoexFXxW9gJn/4Dp7wUeqxUET9ZI LBVAyOE1I1xX12sfGEdUQ9ZIRTTvuUJ3+fTbVUYoBgSXuKFUeubOXUrkpXaG4S3P7lKY 7dqBn2ljpDc8dk6UY8m8mIcvTiRKAWTjG1d/QK/qeQbonmQStFNCVCMKA2Ypmp8DOMlz 4fvTAhAjqjcrQUFFundCAYdJnf35zv3bmwX8Y7lCb6Qho2P1c111KxI7OLymY3vZ4yYd Yxvg== 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=G6NkcNE8ozhpahBCLbvJbXa5pHB80fFFuOb3OUi1aAU=; b=jbqkfjeZA2me+vTrBVIm+WCd4eeOGnzuUVgPxVdzdNSVYmbPSIbvNu00RFEj3+Zv6S iHaY5kL8HZ3z3PY+bvem1VzA+M/bwMEWJsSAl2GKPwf9ttYW8V9OWNmxM/r4MAmQjlPD minCm7ZxRnF+5/vT7yz+qkBzUk9eE5cmm2VwZBoLsnDDPDuIsdgj8DRnFXQGyreOAOq1 XzyJltdxKb+7nrqJfcnY1x4TzGDP3SX3PbgAPj1JlVYTMJ8vqMO6JcyW8GVkQkW8mkfD 2bBV35ozweNrvYqa3ILN7h1gbMPsuQ+fxBxnFIejN2jkQ+wkMUSSXSnYxcDTvxSckngc wkpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aXZgbZzY; 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 gw9si7998465ejb.284.2019.11.16.08.31.04; Sat, 16 Nov 2019 08:31:29 -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=aXZgbZzY; 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 S1731960AbfKPQ0g (ORCPT + 99 others); Sat, 16 Nov 2019 11:26:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:45210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728029AbfKPPlx (ORCPT ); Sat, 16 Nov 2019 10:41:53 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (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 1C7692084B; Sat, 16 Nov 2019 15:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573918912; bh=y5GylDGsCz7qIrBi3/WJS/VV0/tGA8o9bj7XaPDIqYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aXZgbZzYIsW2LDqYUzi4yNCtw2SUlHMrmwvfcyHRH3yZDKc0F+OXNS/tCY8ryd9ct r79yv9ubxmoFGhvvIqH4tC4DM29o54vtCLS0KI3Lredk5fGh5epeB3Ay/lXjGrrMGB BgwGEHnkCGWUuBGHb2kgt1VaeaW71m1QmwL1qG6A= 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 4.19 036/237] scsi: hisi_sas: Free slot later in slot_complete_vx_hw() Date: Sat, 16 Nov 2019 10:37:51 -0500 Message-Id: <20191116154113.7417-36-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review 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 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