Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4383030ioa; Wed, 27 Apr 2022 02:34:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJu/LndtYudP5e825nH8MZeGvmvV24Xa97jKRM/1sfWSHPrKnDaFiFfDYviN5Q3y7bsSdn X-Received: by 2002:a17:902:ab96:b0:159:1ff:4ea0 with SMTP id f22-20020a170902ab9600b0015901ff4ea0mr28175598plr.60.1651052042949; Wed, 27 Apr 2022 02:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651052042; cv=none; d=google.com; s=arc-20160816; b=WgklOey56NsJ3ZRhV8edKVFOFsfqlYux6EDuf1hE0v38o8r9qmaHpS+ajlaEVxbk7g yWhrDOaQhzs10CUDEJ0/9d0TJxDQ1l/4FpNk57UY96xLG2RQBDQyXADJQNuWFYmDGpqJ JPy5EKnyAnP7hPlCPfVNAdQvRN0POC1UhgC036eCbvgeVI2st1cfwUl14M9Ea7A72dYo qQAFmGMT4MAjPqgeLE1uArXw67kK+TVlixhkqcGe17a0aFcAz4l8cqR26kAGwhsnihlL JUPYVP+kIMmROheqmb0Dpzh8WknE3z+NJOvegerveSsw4zirEy1oUDDuUGpx3DhKUkAi 46Cg== 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=Ka8x3rs95fuQiyqwuBu0LA4f7bi5Togb8/R9Kf0GAZo=; b=hJLHomoeOUbRb4Az0KT9GujkAfVnMMOmNeC5lPO9Dbq/zC9k5TXH/P9sHRuu9Cw88U QuD7NjfWLklylf23tlMz9ATQhD0TN2wUUQjH4emvrwyngHlhOyUiHLh+1RCj7WMIC3xa 4EPly6rweohhd+uWxwOV3aLVLMhmnC8BJOFvTsPBrRNyYPA40f+xafg6kuJDRlXGheEd 7LR6J3PXYdH8HfYPgw/WJacQP/sJkdXV/tA7ouL1FtioNewEs6MsuUkjTQru2hiosSyp 5gm9klHVDJ8RbhKP4JCKlvuvdEE8sluCemN6KorMe8INmVbH2r4P97qzpKPc40ep322f o4jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1nQL5YtC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c5-20020a631c45000000b003a1ce4187a0si963089pgm.769.2022.04.27.02.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 02:34:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1nQL5YtC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 04BD725CA06; Wed, 27 Apr 2022 02:13:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346582AbiDZJA4 (ORCPT + 99 others); Tue, 26 Apr 2022 05:00:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347072AbiDZIpq (ORCPT ); Tue, 26 Apr 2022 04:45:46 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB87843AD7; Tue, 26 Apr 2022 01:37:17 -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 sin.source.kernel.org (Postfix) with ESMTPS id 04B67CE1BC9; Tue, 26 Apr 2022 08:37:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9F68C385A0; Tue, 26 Apr 2022 08:37:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962234; bh=jESHIf0DUJpfwTSjPeAvmSihahXEUxYM6R7jE+M0Y+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1nQL5YtCsmBzsWMit+yQR3rwoCOnf6R/sna8YBx/5msxl87fLrjhHxwGHqtCx+rvD CzYaQv2k87ex04K23b+rtztNu8Tv/BSCdpekeGm4/seGl3ZKH4qAYrxQWwX0w3GE3/ zgFjXsD+0qWQ40Ll1KE5Q08wHj637GebFPQKLNSk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dima Ruinskiy , Sasha Neftin , Naama Meir , Tony Nguyen , Sasha Levin Subject: [PATCH 5.15 029/124] igc: Fix infinite loop in release_swfw_sync Date: Tue, 26 Apr 2022 10:20:30 +0200 Message-Id: <20220426081748.132334626@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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: Sasha Neftin [ Upstream commit 907862e9aef75bf89e2b265efcc58870be06081e ] An infinite loop may occur if we fail to acquire the HW semaphore, which is needed for resource release. This will typically happen if the hardware is surprise-removed. At this stage there is nothing to do, except log an error and quit. Fixes: c0071c7aa5fe ("igc: Add HW initialization code") Suggested-by: Dima Ruinskiy Signed-off-by: Sasha Neftin Tested-by: Naama Meir Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/igc/igc_i225.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_i225.c b/drivers/net/ethernet/intel/igc/igc_i225.c index b6807e16eea9..a0e2a404d535 100644 --- a/drivers/net/ethernet/intel/igc/igc_i225.c +++ b/drivers/net/ethernet/intel/igc/igc_i225.c @@ -156,8 +156,15 @@ void igc_release_swfw_sync_i225(struct igc_hw *hw, u16 mask) { u32 swfw_sync; - while (igc_get_hw_semaphore_i225(hw)) - ; /* Empty */ + /* Releasing the resource requires first getting the HW semaphore. + * If we fail to get the semaphore, there is nothing we can do, + * except log an error and quit. We are not allowed to hang here + * indefinitely, as it may cause denial of service or system crash. + */ + if (igc_get_hw_semaphore_i225(hw)) { + hw_dbg("Failed to release SW_FW_SYNC.\n"); + return; + } swfw_sync = rd32(IGC_SW_FW_SYNC); swfw_sync &= ~mask; -- 2.35.1