Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2918988rwb; Mon, 15 Aug 2022 14:03:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR7zHEeyPnTOaDpE76Y4hnfafqi/D3p8boVLGcMiaUhAExWvlkZn4NPdLRxa0iXPz90u9NDT X-Received: by 2002:a05:6402:35c6:b0:43d:c340:7799 with SMTP id z6-20020a05640235c600b0043dc3407799mr15948750edc.369.1660597411553; Mon, 15 Aug 2022 14:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597411; cv=none; d=google.com; s=arc-20160816; b=EoZS6tp9Vsu2T4bwcqm2uuj9Kwb4RnJ8+87nptJUw2z6En3nJNvEWmQ1H32PymZg3V z4Lx8i9DXRBMwTsA9Iy93xtqIEQnumcemUaVWQDJ3C7eNonMttOY4CU80wTVMN18xHtG JEzljNyVof91va4EHeRoKnvaVFDQKWpF7SK/PTzX2EXpNfzhuLXyouTHVpqPk0BzUja8 FnWmPBepmFeLhElINOTDz0z4zk5VIuChG8MnCpzLezfPxY9UepTrswFAUP2sxe1q8pVa 2BtXw0Y5BWSmiFbfyo8okQvopezbeetRopvgooY1ZeBFK9mwkAvdpfHWnY8lIPYSpale sRmA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qy3+/xO5LbznWbkLmMPhHS1hsYL1OBfZHo7JqW3PKZw=; b=CWpkN6ojDykrh274KqLflQwMEGDVVaeiHvXwxBEPDRIXB0lg6026+Ww3w0tm3V9dj1 Gwoe40ehZ232DJLfWw6sxDb9Ixd0Y+XowZu/zBSFHfsjkCD16uTSAA/yBkwJO6hYTNJy rOROoxLFfq9bx3wrX5iUmy7llCzfdrC3sFyWmROg/h8XQfgYMgZkhu2jyS76UwsGonY1 ZQAs6CvwL8X7KEPP6omXDlO99wgD3U4AXehNcGJMs7mjAeTEt1or2/a/AXsEJUNW5Wjr RhyGhjUZZ64zeKcCXjzD3JpU3TvyvfgzDByDLInH/9ZzHt1Q/M+XLe5T32ocmIwIbOGM FlJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cob0tQlR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb42-20020a1709077eaa00b00711988b5919si7769390ejc.810.2022.08.15.14.03.05; Mon, 15 Aug 2022 14:03:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cob0tQlR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345634AbiHOUDP (ORCPT + 99 others); Mon, 15 Aug 2022 16:03:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346022AbiHOUBa (ORCPT ); Mon, 15 Aug 2022 16:01:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B5CBEA4; Mon, 15 Aug 2022 11:53:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A2D85B810A0; Mon, 15 Aug 2022 18:53:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A381BC433C1; Mon, 15 Aug 2022 18:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589623; bh=Ki9OpC+liXeodytwk+5NFoK0HolAbgb1uPiEuSySNmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cob0tQlRDxrmAQCaH8v5hQWj5sP6AyZoYbwj6odXAOF+HDoPiHdLbU/KyfbYfcI35 JCkPtZr3M+0WBHcQrO9xS56P4F+LuR6qjpeRIN0oiPqt2gMfaknThBr0O7B4ZGgt0c MmPq6/k+f3Y9UlTNhvYj4p21JB4VyCs7yvyw1xuI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dick Kennedy , James Smart , "Martin K. Petersen" Subject: [PATCH 5.15 777/779] scsi: lpfc: Fix locking for lpfc_sli_iocbq_lookup() Date: Mon, 15 Aug 2022 20:07:01 +0200 Message-Id: <20220815180410.592934784@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Smart commit c26bd6602e1d348bfa754dc55e5608c922dd2801 upstream. The rules changed for lpfc_sli_iocbq_lookup() vs locking. Prior, the routine properly took out the lock. In newly refactored code, the locks must be held when calling the routine. Fix lpfc_sli_process_sol_iocb() to take the locks before calling the routine. Fix lpfc_sli_handle_fast_ring_event() to not release the locks to call the routine. Link: https://lore.kernel.org/r/20220323205545.81814-3-jsmart2021@gmail.com Fixes: 1b64aa9eae28 ("scsi: lpfc: SLI path split: Refactor fast and slow paths to native SLI4") Co-developed-by: Dick Kennedy Signed-off-by: Dick Kennedy Signed-off-by: James Smart Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/lpfc/lpfc_sli.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -3642,7 +3642,15 @@ lpfc_sli_process_sol_iocb(struct lpfc_hb unsigned long iflag; u32 ulp_command, ulp_status, ulp_word4, ulp_context, iotag; + if (phba->sli_rev == LPFC_SLI_REV4) + spin_lock_irqsave(&pring->ring_lock, iflag); + else + spin_lock_irqsave(&phba->hbalock, iflag); cmdiocbp = lpfc_sli_iocbq_lookup(phba, pring, saveq); + if (phba->sli_rev == LPFC_SLI_REV4) + spin_unlock_irqrestore(&pring->ring_lock, iflag); + else + spin_unlock_irqrestore(&phba->hbalock, iflag); ulp_command = get_job_cmnd(phba, saveq); ulp_status = get_job_ulpstatus(phba, saveq); @@ -3979,10 +3987,8 @@ lpfc_sli_handle_fast_ring_event(struct l break; } - spin_unlock_irqrestore(&phba->hbalock, iflag); cmdiocbq = lpfc_sli_iocbq_lookup(phba, pring, &rspiocbq); - spin_lock_irqsave(&phba->hbalock, iflag); if (unlikely(!cmdiocbq)) break; if (cmdiocbq->cmd_flag & LPFC_DRIVER_ABORTED)