Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3077061rwb; Mon, 15 Aug 2022 17:33:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR6gWIHJRdBN1N53vLlVecGwzs0AR4TtwuUS7io9eZ9VWhy+kgWD2lFLZbkoqw+kuILhPwVN X-Received: by 2002:a17:907:2714:b0:730:851d:66b1 with SMTP id w20-20020a170907271400b00730851d66b1mr11661676ejk.184.1660610006837; Mon, 15 Aug 2022 17:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610006; cv=none; d=google.com; s=arc-20160816; b=QTkPBZqqYh4P2WvXUeEElCv4dlQbrDTvEmd0dmv8c2jUPr5CHCvNUDVTiKXJcCcoZr kJ82Ur2/IihcNMz/8MylCtGggoxk3DSW2QKVvVKBgE9J6mnp83yxT+JggYyXXVDsrsL0 ZPFzGPPUCuwRawzjHgpF+vBhTKl+My1TrmSsFhIkIUAzTpw8aRUe6gIn2P5liZQ0yX5m N79nhedjFjkjnN3UfMWlBSEXWXhwQO8/cmol8vlKIwagMX1NpVs+SEsgUdmCwYcmCs12 O/acbsr6HlMFuFf5iMd7TXLXorKwZ5Eme+eyMMG3fjQJMULFt6c6M3GQeZiuxpV4KiUo zRUw== 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=QjxiiVtGEiYmFiQy2b+fPqVXdUNLFHMD6JTCBJHcrbY=; b=ftCbhtaoBtK8fBLswC+mK8R9LPpYUY3MOdirlXW1+bghCRXHojcY0VQJb43zXC44m6 7ubqLSuTVBFx49XDHiwq5y+QKgDd5bsl6TY4DC6LhXhKS9A6/5xRWsFq/1knNa1rWjjF tYB2HsSuLka07VNzsVvJlCaT+6fwtqTXWZlC/MIDzTKMEv6JdxEb6HkmXlLjSpqMQG3H IpH1iqm0uUyVDqd8I4o0VXvg0vQu/uSFdx8KyAtuN8d96cyckg+k/Fk4lSOgogAC32yA q/KfHRyqsh+Qfi6Q6K2xgQSNT2bDyThEmfgn7DKFqkEmCS+fAYwZrw1kAY6mmQqu98Tc Z6RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Bh8E6bmX; 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 d11-20020aa7c1cb000000b004403b2f0179si8328533edp.515.2022.08.15.17.32.59; Mon, 15 Aug 2022 17:33:26 -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=Bh8E6bmX; 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 S1356600AbiHPAHm (ORCPT + 99 others); Mon, 15 Aug 2022 20:07:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352027AbiHPAAX (ORCPT ); Mon, 15 Aug 2022 20:00:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0773D43E5B; Mon, 15 Aug 2022 13:21:22 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 9560161007; Mon, 15 Aug 2022 20:21:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D831C433D6; Mon, 15 Aug 2022 20:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594881; bh=FX9Ax3Z/cmlPDDEf6qOtcz300bPFrJUo0VquF6pu9PY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bh8E6bmX5bt9hFSRYiT+Jcsi+1IVqUfezjltrry+AQ9Z1qYzeSO2J/fJoLAO4v3db HKqonC3KbROjB782bc+P5EfQzTiCTuHquZvf4RWW0x0BzPsRAeLAbgg5+njlrIW8Rc uNlsOKl1uT7IGOUXVuMvbUGFt8l/3Gvbm6BOIw/s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shay Drory , Moshe Shemesh , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.19 0555/1157] net/mlx5: Fix driver use of uninitialized timeout Date: Mon, 15 Aug 2022 19:58:31 +0200 Message-Id: <20220815180501.828367540@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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: Shay Drory [ Upstream commit 42b4f7f66a43cdb9216e76e595c8a9af154806da ] Currently, driver is setting default values to all timeouts during function setup. The offending commit is using a timeout before function setup, meaning: the timeout is 0 (or garbage), since no value have been set. This may result in failure to probe the driver: mlx5_function_setup:1034:(pid 69850): Firmware over 4294967296 MS in pre-initializing state, aborting probe_one:1591:(pid 69850): mlx5_init_one failed with error code -16 Hence, set default values to timeouts during tout_init() Fixes: 37ca95e62ee2 ("net/mlx5: Increase FW pre-init timeout for health recovery") Signed-off-by: Shay Drory Reviewed-by: Moshe Shemesh Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/lib/tout.c | 11 ++++------- drivers/net/ethernet/mellanox/mlx5/core/lib/tout.h | 1 - drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 -- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/tout.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/tout.c index d758848d34d0..696e45e2bd06 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/tout.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/tout.c @@ -32,20 +32,17 @@ static void tout_set(struct mlx5_core_dev *dev, u64 val, enum mlx5_timeouts_type dev->timeouts->to[type] = val; } -void mlx5_tout_set_def_val(struct mlx5_core_dev *dev) +int mlx5_tout_init(struct mlx5_core_dev *dev) { int i; - for (i = 0; i < MAX_TIMEOUT_TYPES; i++) - tout_set(dev, tout_def_sw_val[i], i); -} - -int mlx5_tout_init(struct mlx5_core_dev *dev) -{ dev->timeouts = kmalloc(sizeof(*dev->timeouts), GFP_KERNEL); if (!dev->timeouts) return -ENOMEM; + for (i = 0; i < MAX_TIMEOUT_TYPES; i++) + tout_set(dev, tout_def_sw_val[i], i); + return 0; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/tout.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/tout.h index 257c03eeab36..bc9e9aeda847 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/tout.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/tout.h @@ -35,7 +35,6 @@ int mlx5_tout_init(struct mlx5_core_dev *dev); void mlx5_tout_cleanup(struct mlx5_core_dev *dev); void mlx5_tout_query_iseg(struct mlx5_core_dev *dev); int mlx5_tout_query_dtor(struct mlx5_core_dev *dev); -void mlx5_tout_set_def_val(struct mlx5_core_dev *dev); u64 _mlx5_tout_ms(struct mlx5_core_dev *dev, enum mlx5_timeouts_types type); #define mlx5_tout_ms(dev, type) _mlx5_tout_ms(dev, MLX5_TO_##type##_MS) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 95f26624b57c..ba2e5232b90b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1023,8 +1023,6 @@ static int mlx5_function_setup(struct mlx5_core_dev *dev, u64 timeout) if (mlx5_core_is_pf(dev)) pcie_print_link_status(dev->pdev); - mlx5_tout_set_def_val(dev); - /* wait for firmware to accept initialization segments configurations */ err = wait_fw_init(dev, timeout, -- 2.35.1