Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2063549pxb; Mon, 12 Apr 2021 13:21:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAYOrPFB6FzcST1D1A3Y8WrN5s+Ql5NNCozzpdiw/63pueXGZvVC5JnhtiSg/xc0AMkSgF X-Received: by 2002:a63:5c25:: with SMTP id q37mr28285116pgb.218.1618258895076; Mon, 12 Apr 2021 13:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618258895; cv=none; d=google.com; s=arc-20160816; b=g8WVUXob1fz6a+4/H4XsNQI3x7QFwdjQ5NILyNefwNY1QxNJXxZNmWyUj1GoZTBA8+ zY+ykZOfK6X1vnTPmkmwyw+9Mt3UV4OhUorOE3AZp283sJTvut7wIb23IbCAMgQET6z0 IKoZyUvSo3OHEKTWQhhOMG3MGZfRtTKsqRnOLwxok7Uk58AJTXj48z1Ong//qLaCq1mw 8VQFdQ1m3rVjfx+oT91n0QDXX6qqvu7T1n+6DXTQTBdWUvaSs/wxdMOmKXM4qVj0U5ih RpY/5RIdeww5VSvQo8IBNzTAQzSuIGGT7rx2kt+8Q8mI5fNYzWxCPpAWA+qHX6sNl3PV xYCw== 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=Kq6069ZDre6kmnWvgFDiGM1Wdg1M0SbMh9ROxVJvaIU=; b=LAKbR47BYCXu3fTplCBNlkMgzcdZgm3ZZKn4U1GKoN9gzhtTSIxDM3OQXpC6z8osvd sTHo70W7avHDk6IytAwYHB/GeuolPX+aD2usgZ0+07NxTwTwjL4IRqN79wB/ZOKMzT1R 5ooibgJsd2vtmcizEvSUn66cZNd4tc9gK/CaNYcB0+7zIDNBhZr3kMFDQYGTWm+mJAHZ uigWR0/YZ7vBWckiX2EEhccd8NaQ6B9yQeP3TWDYXHebB7qJVUFpCac+X7WWh1KAJZOc mnTx6OlV6v/MpewOmPAfMXAyn0/jRtdoq4HiA0VOPWf5NufC8NApzZGss5fIXEzMAagH VX5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k8CV+y9Q; 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 z16si15193742pgg.595.2021.04.12.13.21.17; Mon, 12 Apr 2021 13:21:35 -0700 (PDT) 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=k8CV+y9Q; 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 S238131AbhDLI4B (ORCPT + 99 others); Mon, 12 Apr 2021 04:56:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:40388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238457AbhDLItz (ORCPT ); Mon, 12 Apr 2021 04:49:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 715766125F; Mon, 12 Apr 2021 08:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217338; bh=f4S7kv1Yr06FeGh7tleKoX/IiDEAYoDTl2zrP6EAEIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k8CV+y9Qy9UtQe8TNWj7UevqNaybr9BEYvu102zDXzZ32p4hZ0Z5xNxd0ZN3ET1xY g46bEeoGDb+dkqB53fEbpDJTXBOkvyU4ILL6u39+3r2mPBwkjUanLtWmquomDxdPLk RWr8WynvruH/uUe+urxKt/q37isdZtSKk9KeUsjo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eryk Rybak , Grzegorz Szczurek , Aleksandr Loktionov , Konrad Jankowski , Tony Nguyen , Sasha Levin Subject: [PATCH 5.4 054/111] i40e: Fix kernel oops when i40e driver removes VFs Date: Mon, 12 Apr 2021 10:40:32 +0200 Message-Id: <20210412084006.062638851@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084004.200986670@linuxfoundation.org> References: <20210412084004.200986670@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: Eryk Rybak [ Upstream commit 347b5650cd158d1d953487cc2bec567af5c5bf96 ] Fix the reason of kernel oops when i40e driver removed VFs. Added new __I40E_VFS_RELEASING state to signalize releasing process by PF, that it makes possible to exit of reset VF procedure. Without this patch, it is possible to suspend the VFs reset by releasing VFs resources procedure. Retrying the reset after the timeout works on the freed VF memory causing a kernel oops. Fixes: d43d60e5eb95 ("i40e: ensure reset occurs when disabling VF") Signed-off-by: Eryk Rybak Signed-off-by: Grzegorz Szczurek Reviewed-by: Aleksandr Loktionov Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index 678e4190b8a8..e571c6116c4b 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -152,6 +152,7 @@ enum i40e_state_t { __I40E_VIRTCHNL_OP_PENDING, __I40E_RECOVERY_MODE, __I40E_VF_RESETS_DISABLED, /* disable resets during i40e_remove */ + __I40E_VFS_RELEASING, /* This must be last as it determines the size of the BITMAP */ __I40E_STATE_SIZE__, }; diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c index 5acd599d6b9a..e56107305486 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c @@ -137,6 +137,7 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf) **/ static inline void i40e_vc_disable_vf(struct i40e_vf *vf) { + struct i40e_pf *pf = vf->pf; int i; i40e_vc_notify_vf_reset(vf); @@ -147,6 +148,11 @@ static inline void i40e_vc_disable_vf(struct i40e_vf *vf) * ensure a reset. */ for (i = 0; i < 20; i++) { + /* If PF is in VFs releasing state reset VF is impossible, + * so leave it. + */ + if (test_bit(__I40E_VFS_RELEASING, pf->state)) + return; if (i40e_reset_vf(vf, false)) return; usleep_range(10000, 20000); @@ -1506,6 +1512,8 @@ void i40e_free_vfs(struct i40e_pf *pf) if (!pf->vf) return; + + set_bit(__I40E_VFS_RELEASING, pf->state); while (test_and_set_bit(__I40E_VF_DISABLE, pf->state)) usleep_range(1000, 2000); @@ -1563,6 +1571,7 @@ void i40e_free_vfs(struct i40e_pf *pf) } } clear_bit(__I40E_VF_DISABLE, pf->state); + clear_bit(__I40E_VFS_RELEASING, pf->state); } #ifdef CONFIG_PCI_IOV -- 2.30.2