Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp648288pxb; Tue, 2 Feb 2021 14:18:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJysMwEG5kpDP2V7oLzszGfKf39HDDgHjSiOpIM13UHOhg0z15WJ1Zf6Geb88cwT56OTLEN3 X-Received: by 2002:a17:906:3649:: with SMTP id r9mr159261ejb.202.1612304293996; Tue, 02 Feb 2021 14:18:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612304293; cv=none; d=google.com; s=arc-20160816; b=Al755cf6vXPCXL/3NZp3frx+aT/25MopjhaQ3ugmlA0pXVUTJxuYOu0dZzVn+L9xKG VBczK8OU0uTgRmS2I/TIdzVjfjC9kcKOPKhAtPwiyDNgpnoeQjBbZt1l2v1JptgbnPzS jF4pLP/xiyMzT9+vSKOt/I6aSLfuP3/0iU9Yqng/0AVFiwyDNCQM26hvcYoGI0ef8yJu gTJN+/lY4eRUSDPVRoftLsFWj7xEVe7mUNahYj4StlGQw+bndgPWmlPy+T87evz/MTN2 VIDMriIH3lkpxpCc8T3DEDXT0OrNkC9pfbEMnhYqh4mbEHu2LGreMBouw/w4GGDvYXN/ CTRA== 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=KfPfVqu2Y60Ju8uudUiH90Zb1Sx988PvxrWYtEqehcY=; b=rVUMQd2olsLQKwANqn/FgSWlwjtMujMiLcPG9pyD6j6vSsYTvYCI6YXTzlV8MwUqPu MLIjE8fTDVzpFyQ19L27VIcIDWcZ7MnaE85dxnznyZ4XKI2Ej0EirUp6IXYpBU/NokYH VfMnSTdBVw+pqJdIpUsVkrv3HsjzHbOlFmbAvKz/0CMVHYOC37ugRtsCyEB2AtfNVu+v WboGdOlpamCSB8FlQWmBjf81wP6g8ozzuR1aLLYvcFdqFST0TusGSRJZj4NbXQaNyPZz q7O094lIzeixqezZks2DIPJDkRK3VEWHLxlEWtTImBqolKfTWW82jFlreaY4gx4zjk0a cLHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v8vpqVo9; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si42950edw.347.2021.02.02.14.17.48; Tue, 02 Feb 2021 14:18:13 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=v8vpqVo9; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233625AbhBBOB7 (ORCPT + 99 others); Tue, 2 Feb 2021 09:01:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:42526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232819AbhBBNyb (ORCPT ); Tue, 2 Feb 2021 08:54:31 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A434764FD2; Tue, 2 Feb 2021 13:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273477; bh=tAf/gmNteQOAw2tG1ve7gD0+WpCk6tZkVGywhPNnGa0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v8vpqVo9vsQfpdPl9GwaSV73HYU8TOWYxU+aUJ8OjXAjDuES5z8wZbUQsShuJY0Bg OLRi5wLa30O7nM9CEi+GL8fO0WDY8Mh5GwLpa7M5z8a6VGSU44drZcWRV+CNq+vEa5 iVLBsIWWpV+npveGxfEeDA/+J6z1SPIoKqj9jrv4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Mikityanskiy , Tariq Toukan , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.10 122/142] net/mlx5e: Revert parameters on errors when changing trust state without reset Date: Tue, 2 Feb 2021 14:38:05 +0100 Message-Id: <20210202133002.736580288@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxim Mikityanskiy [ Upstream commit 912c9b5fcca1ab65b806c19dd3b3cb12d73c6fe2 ] Trust state may be changed without recreating the channels. It happens when the channels are closed, and when channel parameters (min inline mode) stay the same after changing the trust state. Changing the trust state is a hardware command that may fail. The current code didn't restore the channel parameters to their old values if an error happened and the channels were closed. This commit adds handling for this case. Fixes: 6e0504c69811 ("net/mlx5e: Change inline mode correctly when changing trust state") Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c index d20243d6a0326..f23c67575073a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c @@ -1151,6 +1151,7 @@ static int mlx5e_set_trust_state(struct mlx5e_priv *priv, u8 trust_state) { struct mlx5e_channels new_channels = {}; bool reset_channels = true; + bool opened; int err = 0; mutex_lock(&priv->state_lock); @@ -1159,22 +1160,24 @@ static int mlx5e_set_trust_state(struct mlx5e_priv *priv, u8 trust_state) mlx5e_params_calc_trust_tx_min_inline_mode(priv->mdev, &new_channels.params, trust_state); - if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) { - priv->channels.params = new_channels.params; + opened = test_bit(MLX5E_STATE_OPENED, &priv->state); + if (!opened) reset_channels = false; - } /* Skip if tx_min_inline is the same */ if (new_channels.params.tx_min_inline_mode == priv->channels.params.tx_min_inline_mode) reset_channels = false; - if (reset_channels) + if (reset_channels) { err = mlx5e_safe_switch_channels(priv, &new_channels, mlx5e_update_trust_state_hw, &trust_state); - else + } else { err = mlx5e_update_trust_state_hw(priv, &trust_state); + if (!err && !opened) + priv->channels.params = new_channels.params; + } mutex_unlock(&priv->state_lock); -- 2.27.0