Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp725661pxb; Tue, 2 Feb 2021 16:48:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLvkdxicnoJZqP06I/dp4CDpHYnA5Cf3RBUFOh/tCMaACrbi1qLuddszavaMBxIAOfjANp X-Received: by 2002:a17:906:c9d8:: with SMTP id hk24mr648287ejb.468.1612313339283; Tue, 02 Feb 2021 16:48:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313339; cv=none; d=google.com; s=arc-20160816; b=aX5PamC5L0Qrz+AXADe8wkbw0PUxRZMjsXkGsa5z4ycv7aAPw+oqRplMLPrEDSzLp3 P2/wLBP1oQ9W+cS+gNuWDwU3XQqldy3ikARYuYWqXYUebk/iHQQMnnQ5zKGjIWRetQXk pBWFDAXq+4rPWRVBhmty2SotfyP9gZMwS/bV+uScRyvcHAFhLYkBVDjvF9hm1jSFWfQA fKihcxBFbIDfCS9NkFmsGLrRoXTYSMisRm7cYkz9WTchu2ixsRDXcJGuOR5nLUMss6Uf wXyHO0A09b1BaJ78PLnD+uYUW1TFW69sEFj3Yqdy2YLXe4nXeu8+MKfoRWvfgwqcmfUi 1EWA== 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=TsEXsg4hd4qhYHI6Epn1mKqkyaIJz++OTQreQK9f1b8=; b=JywLj+pkhRK72Qp99RV4uftOzOeMnmnlgWPxCw9iAJHgqeY7NRzMkfNaIfokoOssvi x4/t9/W5nnAKfu61SJLmfwPZGxuaCfiskFHaOIAl2Rs/5s17EjNDi8th9CS0fmhkI1kl sriFR3ezyvmrpXO6kSIsquZttqJSAbW1psY8PF+pMgmOVmkW7uEEux9hdkY3zyU4Iu3l AaFnBqPcMdOqDe7I23RZT8w743jSUMAMA27lfDsfggPTBJoSZM4cBhSFtU6kLPssRnGL B3ACAnPUoBHxw3ATFYcr6AIsV96rUYypiVktaTCM2TIbGCSWbbNZi++qv5p90YVE10oo sWVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=INJQbQKW; 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 j19si219895edq.356.2021.02.02.16.48.35; Tue, 02 Feb 2021 16:48:59 -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=INJQbQKW; 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 S233223AbhBBTlw (ORCPT + 99 others); Tue, 2 Feb 2021 14:41:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:42642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232971AbhBBNyh (ORCPT ); Tue, 2 Feb 2021 08:54:37 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5262D64FD7; Tue, 2 Feb 2021 13:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273479; bh=A28gzi2WDvFKHk/b98Fb/Cqxt30A78Zzq7MV7CkN7xM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=INJQbQKWuXaCHb2WS/Rgt6lK8BzV+d+qnTf8fJOJBC71oI6HQv79T4hFbGZyufz+5 HvchjmNYRC6hESIkn2/YBBwjad9GcatmzXpzO3nRFNyXiTnJpTW/LaBtnamVUXuyfJ wHSWyqiW6rViuf4U6g6ki+lgftq5Nlo89wlchFNI= 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 123/142] net/mlx5e: Revert parameters on errors when changing MTU and LRO state without reset Date: Tue, 2 Feb 2021 14:38:06 +0100 Message-Id: <20210202133002.776835451@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 8355060f5ec381abda77659f91f56302203df535 ] Sometimes, channel params are changed without recreating the channels. It happens in two basic cases: when the channels are closed, and when the parameter being changed doesn't affect how channels are configured. Such changes invoke a hardware command that might fail. The whole operation should be reverted in such cases, but the code that restores the parameters' values in the driver was missing. This commit adds this handling. Fixes: 2e20a151205b ("net/mlx5e: Fail safe mtu and lro setting") Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- .../net/ethernet/mellanox/mlx5/core/en_main.c | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 000dacaa3333c..c9b5d7f29911e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3730,7 +3730,7 @@ static int set_feature_lro(struct net_device *netdev, bool enable) struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5_core_dev *mdev = priv->mdev; struct mlx5e_channels new_channels = {}; - struct mlx5e_params *old_params; + struct mlx5e_params *cur_params; int err = 0; bool reset; @@ -3743,8 +3743,8 @@ static int set_feature_lro(struct net_device *netdev, bool enable) goto out; } - old_params = &priv->channels.params; - if (enable && !MLX5E_GET_PFLAG(old_params, MLX5E_PFLAG_RX_STRIDING_RQ)) { + cur_params = &priv->channels.params; + if (enable && !MLX5E_GET_PFLAG(cur_params, MLX5E_PFLAG_RX_STRIDING_RQ)) { netdev_warn(netdev, "can't set LRO with legacy RQ\n"); err = -EINVAL; goto out; @@ -3752,18 +3752,23 @@ static int set_feature_lro(struct net_device *netdev, bool enable) reset = test_bit(MLX5E_STATE_OPENED, &priv->state); - new_channels.params = *old_params; + new_channels.params = *cur_params; new_channels.params.lro_en = enable; - if (old_params->rq_wq_type != MLX5_WQ_TYPE_CYCLIC) { - if (mlx5e_rx_mpwqe_is_linear_skb(mdev, old_params, NULL) == + if (cur_params->rq_wq_type != MLX5_WQ_TYPE_CYCLIC) { + if (mlx5e_rx_mpwqe_is_linear_skb(mdev, cur_params, NULL) == mlx5e_rx_mpwqe_is_linear_skb(mdev, &new_channels.params, NULL)) reset = false; } if (!reset) { - *old_params = new_channels.params; + struct mlx5e_params old_params; + + old_params = *cur_params; + *cur_params = new_channels.params; err = mlx5e_modify_tirs_lro(priv); + if (err) + *cur_params = old_params; goto out; } @@ -4037,9 +4042,16 @@ int mlx5e_change_mtu(struct net_device *netdev, int new_mtu, } if (!reset) { + unsigned int old_mtu = params->sw_mtu; + params->sw_mtu = new_mtu; - if (preactivate) - preactivate(priv, NULL); + if (preactivate) { + err = preactivate(priv, NULL); + if (err) { + params->sw_mtu = old_mtu; + goto out; + } + } netdev->mtu = params->sw_mtu; goto out; } -- 2.27.0