Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1144992pxv; Fri, 9 Jul 2021 19:26:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUSJsgDxt5eEBabmXIKn0b/5PkqcHmgoP50dz6HAvJZ2fN0NbntWbM9doBfJieP3xbBwaW X-Received: by 2002:a17:907:212f:: with SMTP id qo15mr1214639ejb.400.1625883989939; Fri, 09 Jul 2021 19:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625883989; cv=none; d=google.com; s=arc-20160816; b=KH3y31MCAiRlmgN8g5ku5vBkgW/WrAZL4Ef0DQopwiN9MYVxWLHE8PZ+ZCTEEXl7N7 Lww6eOsIK82WtWiIPlm/IAGA1HMZlSngv3h4h9OZqgePMD+FbV19CV5YHQFTuQL/pwEr fCSVH0y8GS09Hv+uXI2h4Opv9IrLwp7B4w8wt47CceZ5DhaAgzrwbsSwQvHqpMVexwCd bmUymeE7YobnjNHpji2Uy9023z4hTUAaBOz5vfGqh68YtAU5EgNUT1BhrGfFpWTvn7ea 4VVvQb2I8jJ8Y8K7kDiQA4vWWQOWFXTJR8EUJgJO+tkhAaMBOV/WKB9d5QpsXICjBvuc h1Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bDlJVby1Qg5OC0HfrQzp+ADk5DPfD5d6bOGY5O16WRY=; b=fSu+z4ixAS9TyLSRdV1cXOhwtR6V0C14QJ9UBLaQmEm+e96N5+/hi/EWEnMQDTmfE3 FVv2zr8HoBtcBkFKUxQ7IScySnGomhwRaXlEyr64c5vsbN2tK65SnoJ3kGNToa3QcxCp BC4mY/ewoObluzzp0JcP3oHJRt2LtKvL99xfH/hOh15td+rlrpU85NhTI+cb2fyuVdh1 LunDJDo9bHB5IWlmlD+sgfywhKtESQwcutQpTCdd0PbnQskn54BLsTnFRkpqyaM2f6U6 njAgCZIgXR7PQ8o+LvhppZ6Ja+uzrd+SSqZjoIQDsnwmk9CYb9RV7Xjv6oE280/RiJKC PqYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fUlZUCUt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id hg16si9323169ejc.410.2021.07.09.19.26.07; Fri, 09 Jul 2021 19:26:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fUlZUCUt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233456AbhGJC0G (ORCPT + 99 others); Fri, 9 Jul 2021 22:26:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:41746 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233146AbhGJCZW (ORCPT ); Fri, 9 Jul 2021 22:25:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16A6A613B7; Sat, 10 Jul 2021 02:22:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883757; bh=1v074zr1y4wIdMNpxUqEowUJUqs4/NJN4Zf3nkxRxvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fUlZUCUt/bndpVEt62q431orYD8LfUYQ4yri3X2WnalgQh7nh7DVXuUgMnN3WmhIg +0MBUwCF+wHjZRjdNjolgBfi5sfj+0LA8idgrN8DOylsiaSyCylZy2Qzrf8C7FJmPs 9PzpB/jEqPIOvwZ4iRpaRvW1L3CBYkGNOjgZFc79iaGMkxLcE0fmmEH2Kx+GldQxmC nFGxhfSjQl3xtGNloAwNeL3GxA+0kSb534vgvp2CY44TYMhu83TTnB8tUiojHR7qMw H3iRjX6PhtlQQBbQfOBugqwRo+qrcyK2UI+AHnJlQT4ax/SdZhcP5PLY3JnyDQZu7b yjYuHMrayFHZg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Suganath Prabu S , "Martin K . Petersen" , Sasha Levin , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 032/104] scsi: mpt3sas: Fix deadlock while cancelling the running firmware event Date: Fri, 9 Jul 2021 22:20:44 -0400 Message-Id: <20210710022156.3168825-32-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022156.3168825-1-sashal@kernel.org> References: <20210710022156.3168825-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suganath Prabu S [ Upstream commit e2fac6c44ae06e58ac02181b048af31195883c31 ] Do not cancel current running firmware event work if the event type is different from MPT3SAS_REMOVE_UNRESPONDING_DEVICES. Otherwise a deadlock can be observed while cancelling the current firmware event work if a hard reset operation is called as part of processing the current event. Link: https://lore.kernel.org/r/20210518051625.1596742-2-suganath-prabu.subramani@broadcom.com Signed-off-by: Suganath Prabu S Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index ae1973878cc7..d68a3a42c3fb 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3696,6 +3696,28 @@ _scsih_fw_event_cleanup_queue(struct MPT3SAS_ADAPTER *ioc) ioc->fw_events_cleanup = 1; while ((fw_event = dequeue_next_fw_event(ioc)) || (fw_event = ioc->current_event)) { + + /* + * Don't call cancel_work_sync() for current_event + * other than MPT3SAS_REMOVE_UNRESPONDING_DEVICES; + * otherwise we may observe deadlock if current + * hard reset issued as part of processing the current_event. + * + * Orginal logic of cleaning the current_event is added + * for handling the back to back host reset issued by the user. + * i.e. during back to back host reset, driver use to process + * the two instances of MPT3SAS_REMOVE_UNRESPONDING_DEVICES + * event back to back and this made the drives to unregister + * the devices from SML. + */ + + if (fw_event == ioc->current_event && + ioc->current_event->event != + MPT3SAS_REMOVE_UNRESPONDING_DEVICES) { + ioc->current_event = NULL; + continue; + } + /* * Wait on the fw_event to complete. If this returns 1, then * the event was never executed, and we need a put for the -- 2.30.2