Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp649030pxb; Tue, 2 Feb 2021 14:19:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZrEYthW3zBZvOagtS2/q6dHGbcwfHHz5hL8c0bQctDgSbKzXl4ebB1TVotuDG2maaOal1 X-Received: by 2002:aa7:ce15:: with SMTP id d21mr244318edv.246.1612304373218; Tue, 02 Feb 2021 14:19:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612304373; cv=none; d=google.com; s=arc-20160816; b=zfNpg0WZmjH7go8r9MaiAcod6+4Nn1e+SIsAc+GNPkaQiasuDRvMombi3ZGVssZzSw R+O/Ic+CQoq3v234Sen/4UtPYhB1s/H9kP+OGQ50Bhb7XfMqvyCnTS9ywh8G75iJMHqi vXOGigPyPXyz8qimuf4lYTbTuDhloKndd3TT6STxwWWHIWF2VztQ58nTz1ZcCKzW9u9M 78IhHrfIFOxLlZZ2YK1rgBVYR35isrT/eDuHR9k536em6kKqA7+VpRqelP+jf8z2GgIX 0w1I2yzCi+ovoN2eUSMieDD7gn2JgNKTJMyYkclDtFy2AwtvCcv+I4YTMc4MBjj1/oVk r3Iw== 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=uzBTeVuR5AEKrQBbYU4E9vF9Sd1J2EJdKq10zalIezU=; b=Q3sT31TRURQNykyKy0XFm1ljAwXnufKFiunOnAAjaZH4gZ0dRtd742Z0mgO4c3UEYo AWfVtdeopLNo3hNBRC5pIcEMP7f9J6pBBYgFpYlPPSbyeff5aiMazUM8iJTip/HZl3Th 8aI5vQJ3cKFYPwAOMSfwWk+nXIL+wb3Nw8cDBo0nOC6a1yKDbBSSDuGIcKKz2bjDJFfh qTH13l7ITw+Pnsqgd9UEyZnkXYHewdobLjBVcA357UnBrWZQlcPgVGzN1qJ/y0aCNlcT kwPxzHxlods3XOwDJKz3XLdfwzMHxraKYdbvrFRyLp6Qh+y57/Om9zsnRXJclIiHIa5R wIag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nl4voCFW; 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 a16si121288ejb.377.2021.02.02.14.19.04; Tue, 02 Feb 2021 14:19:33 -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=nl4voCFW; 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 S233671AbhBBODm (ORCPT + 99 others); Tue, 2 Feb 2021 09:03:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:43044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233445AbhBBN5O (ORCPT ); Tue, 2 Feb 2021 08:57:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C40BE64FE6; Tue, 2 Feb 2021 13:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273538; bh=/lLlyxXowQpB/M6WztW+zCZJBN6fW1vr/XvfWBHPnww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nl4voCFWEpxdw0UyK+JjcB09yKra2zKAo0tr2v+5dA7ZDks6qnU18Ish+jvxJTjZK ccddMFfD6CVuRzJce21YIR+az/Z4y+duhCy/0IVJOQiOQhf7Bwcd8y1Mx2m0jtTd/a jGQE7qSW4JPWwB3slgc3n8d9B6epcTalcHKMjUHo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Assmann , Jacob Keller , Konrad Jankowski , Tony Nguyen , Sasha Levin Subject: [PATCH 5.10 112/142] i40e: acquire VSI pointer only after VF is initialized Date: Tue, 2 Feb 2021 14:37:55 +0100 Message-Id: <20210202133002.326802141@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: Stefan Assmann [ Upstream commit 67a3c6b3cc40bb217c3ff947a55053151a00fea0 ] This change simplifies the VF initialization check and also minimizes the delay between acquiring the VSI pointer and using it. As known by the commit being fixed, there is a risk of the VSI pointer getting changed. Therefore minimize the delay between getting and using the pointer. Fixes: 9889707b06ac ("i40e: Fix crash caused by stress setting of VF MAC addresses") Signed-off-by: Stefan Assmann Reviewed-by: Jacob Keller Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c index 61968e9174dab..2872c4dc77f07 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c @@ -4046,20 +4046,16 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) goto error_param; vf = &pf->vf[vf_id]; - vsi = pf->vsi[vf->lan_vsi_idx]; /* When the VF is resetting wait until it is done. * It can take up to 200 milliseconds, * but wait for up to 300 milliseconds to be safe. - * If the VF is indeed in reset, the vsi pointer has - * to show on the newly loaded vsi under pf->vsi[id]. + * Acquire the VSI pointer only after the VF has been + * properly initialized. */ for (i = 0; i < 15; i++) { - if (test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) { - if (i > 0) - vsi = pf->vsi[vf->lan_vsi_idx]; + if (test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) break; - } msleep(20); } if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) { @@ -4068,6 +4064,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) ret = -EAGAIN; goto error_param; } + vsi = pf->vsi[vf->lan_vsi_idx]; if (is_multicast_ether_addr(mac)) { dev_err(&pf->pdev->dev, -- 2.27.0