From patchwork Tue May 18 05:16:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 12263529 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BDFCC43462 for ; Tue, 18 May 2021 05:17:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0472B6108B for ; Tue, 18 May 2021 05:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241489AbhERFSf (ORCPT ); Tue, 18 May 2021 01:18:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241356AbhERFS1 (ORCPT ); Tue, 18 May 2021 01:18:27 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86878C06175F for ; Mon, 17 May 2021 22:16:42 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id q15so6173502pgg.12 for ; Mon, 17 May 2021 22:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version; bh=4JVupst1A19UNL/R6oG3nMjTe13P1z5gHVkbVj3baWk=; b=LWmWrUp0w8aXGpz206TkMZcAyxdrQpCnZaikTKXoXxp+b9JOLav/KOP8ASHyNVKsPD ulYdatylXBTXMIrKcXRiFNbv365WamaVfUI4GK3T+WYEU11nVil2NzldiW+hopLUzh3j RF+E59yho0pNM1yxWis4m/gwdOy51HV3zjZAE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=4JVupst1A19UNL/R6oG3nMjTe13P1z5gHVkbVj3baWk=; b=AjSJDqNtjgTZE5eC+HCQqTbEXhhCe6ELG/aUErxTGaFt3UDTqXPdioJ2RTDkBgBC5q 1fX/Fkd5VAYbKX367ZCVcw7kWZk4F3kF/ylxa0c6WF8toHmBIxz2E/BO9qrsUi0rl3U3 EJD2sstlGSqNyYXzKK5lOc2c8B0HAK09Wp423c/0vvCcp5AKz3yuyeesdrCOSF8s/yt9 AtfRrFrZ7V6iRnku7cDfiqmfWXHmEM2ZwjCOceOcIqFvzb7OoBT8SRGa7ai5yM4IcfVS +kjkkD0v6Agi2yo4+pG6LyUqAHTy9/BTcPzN3MjBrhAEldNDjQIdiUcMIcDx2YzuiOVa KQwQ== X-Gm-Message-State: AOAM532+z+PTSTwzjaROnyfO01ebQ+m4BpYixm5qZmh5gqL55hGzmE+m UiTCOfhDyXoH/Tq2CIX4n38iV8yBzdKNx1Su1mlH0Sc+VboKw6d7ZF/XeXw8Ka8fxVeepMqyd33 N85Sr0o84BUPxqYInuLSKJAQpnZUOsuy86+5o7aiLf9hW6HoHEAgDKel+QRXYGoQnY6FuU/kaWX +XLxcGZTuYfaxzO/9BnL+y X-Google-Smtp-Source: ABdhPJyf5+UU0k/sl95GQxejcQm2Ydd+DS7t7DjunkRDVbwXsEMvU0rWNV4BHpMf0c2xeBcuP3frhA== X-Received: by 2002:a62:3242:0:b029:2d5:5913:7fd with SMTP id y63-20020a6232420000b02902d5591307fdmr3242707pfy.30.1621315001016; Mon, 17 May 2021 22:16:41 -0700 (PDT) Received: from dhcp-10-123-20-76.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id hk15sm437556pjb.53.2021.05.17.22.16.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 22:16:40 -0700 (PDT) From: Suganath Prabu S To: linux-scsi@vger.kernel.org, martin.petersen@oracle.com Cc: Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu S Subject: [Patch 1/3] mpt3sas: Fix deadlock while cancelling the running FW event Date: Tue, 18 May 2021 10:46:23 +0530 Message-Id: <20210518051625.1596742-2-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210518051625.1596742-1-suganath-prabu.subramani@broadcom.com> References: <20210518051625.1596742-1-suganath-prabu.subramani@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Don't cancel current running Firmware event work if the FW event type is other than MPT3SAS_REMOVE_UNRESPONDING_DEVICES. Otherwise user may observe deadlock while cancelling the current FW event work if hard reset operation is called as part of processing the current FW event. Signed-off-by: Suganath Prabu S --- 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 d00aca3..79e34b5 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3697,6 +3697,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