Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1149037pxv; Fri, 9 Jul 2021 19:34:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe2soz7reeUL8QE5xer/uSB+dJcr0FlczeRh05GVGp7MpPLmUvopL1Z6MHUPcLnqWegYn/ X-Received: by 2002:aa7:c352:: with SMTP id j18mr50149053edr.67.1625884496243; Fri, 09 Jul 2021 19:34:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884496; cv=none; d=google.com; s=arc-20160816; b=jddDXYM5EQMcXdxqqkBmzFipw7BRV7Eslp/zAf1pf5mNkUnwngELQ5wTtP21jjDfX9 gr1O/BmpkAvWv2enbBw5ngN/rduMv9I0DVIGdLWMvqBVSB1UhMouqsPOCRzfkr2hE9VA fUiXF7bc40/b+lMCWdpyiF9P12GsCdHgbpbzsExf2G56xlonkbrvvNf+KIcUBj3g/kT5 ta8L4xImm45+NhEML+5upgnyKS9bveWvADM3DY1jYRLfroc0yAPhqkFruqYr2CEvK1j7 OnSUXP0rywoa1h5VFJ+zRXVdWMP40//5WzFTBhF2mzUANc2TNc2ezN0GFboD4R+nRd0x McSQ== 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=0y7TLA8BkGdQ/FB0sILoQgnEcLAMfOX+oPJqfeoFDAA=; b=GSVTTSDb8mVHC3jRdlK/cFjuF3PlLIGo5sRboxyqPt8RxHi/j3ICCZFvEcyWueHJy5 Qxmx11cy25OoKtu9g4V50EnzC9l9rkhppIMZI8dxoYQUe5wRs09SCwedFj649DxcTIAD ZnNyyfndP6v2P9WiStPYZol8WT5iO942Lb73UW6i8JgkLtxHjXLdWC/Tgs5JbYd3OOFe MPVDy7hSi1pt2NK7VLILt3mWSx3vpcuZTIZYiwxx/jQTcsKLvWUaHgV/11mWBdSavtmB 8aXNjCukkGnoNeCGLxh/Os3sCgxPGkATk8Un9vLAzb1TVs7/0bQmQihD3fGsDQGWDXG2 A9kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="vQCDnv/o"; 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 f16si9496128edy.166.2021.07.09.19.34.33; Fri, 09 Jul 2021 19:34:56 -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="vQCDnv/o"; 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 S235113AbhGJCeg (ORCPT + 99 others); Fri, 9 Jul 2021 22:34:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:43262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233655AbhGJC2P (ORCPT ); Fri, 9 Jul 2021 22:28:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6ADF26141A; Sat, 10 Jul 2021 02:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883908; bh=xcdolrNeNMaw5/ECuZ9AThaPRl2bBtKdmrWZmvYR+2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vQCDnv/o/Jh2VoOLVlyuSHJ+WqRgtcyQsY2QYHoikgD7QUeGd9FXDPaUOl1rl1BEw XUUQld9kFRKO/jUOrsxwep+q/ysptQi8pCClkU4aSyxdRSM4JQBTh8X0wm3aJ3oR5N GZUGtuaMXjEVvSzNZzzP4PPzRi+MNUFhdnUY8xABZLMWI+5ihEuMLiH57oXuRQiHO5 oQOosBwqa/oCIIMQVpj2KL4g5L5MPrsPAT2wTqIbFv2Vxc8V4X6VtSzrObnmBZFl0X o7Ae8NPsM2Zc3KK9Ag7XzOUf262WaUrUPe/Nt7V3xRxLc8IgvYxOp3L4KI6Ms20oCZ cfPUMQJf02bxA== 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.10 30/93] scsi: mpt3sas: Fix deadlock while cancelling the running firmware event Date: Fri, 9 Jul 2021 22:23:24 -0400 Message-Id: <20210710022428.3169839-30-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022428.3169839-1-sashal@kernel.org> References: <20210710022428.3169839-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 5f845d7094fc..738b71653e9c 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3526,6 +3526,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