Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2038309pxb; Mon, 12 Apr 2021 12:39:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtG3RsCmFZZ9nIdSBSswJrRz1F337wTtNZei6oGcwlu0Q76FftVrjEvxsXPV1CdBn9KsR/ X-Received: by 2002:a17:906:2e8f:: with SMTP id o15mr27853286eji.171.1618256347635; Mon, 12 Apr 2021 12:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618256347; cv=none; d=google.com; s=arc-20160816; b=DBOLehZ52aHp2u94+LpAo3qBZVnVG89FYoxIExYyJSAj2bUiCKP2X5ng2MJQSyzyTR vhcXwrI91aePJx8dLHrJbKgW/xIKhAeP6U1vRH03az5mOkXIe7eIxzu1qflbceIjWhEY +rEOdjlCwjmkqdKLQYYLEGQajWN5kzuLCiWcZeRri84jafaazlPp9W3Hk881YkXDGeef i4J3cLOVzLB0C81TuxQf7ZjBQoueoX2F8TRLEsi1y9RJVDIp9n0yeAu2X8xSu0q49sHj pgq7dDFjZpmEXqSnOj7vf5OHee+l4yxKiELCQBE10u3WLSurNfU2ZNiWBZcYVg1Wdl8b i6EA== 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=YGbLsSth7xiPckm+DU5j88abyp2LsKFwL52rK0Byv3U=; b=vWMYA4ZRWvPeoByOu3phQGo4/vYALvLi2e+HyJ+nAYQNkgYezdiYxtovwq6yfBxRmE hDC56t6+n7vOl+A+pOCSwybjUe1upz/hfDK0OuhsKNr6BSDcOg1avRiIv3L6tZLjUUSY 26GWyzYIFlgi3lXF5nPQznW26VHM1vhmHCCwTVgDnc2jXX79kp605RhI79nmDnk5Qpnb +Hu2kdDNSmMqNnf/LeaT062BQqQsK9/Ey4bo7HcGee3dCQS9hYiFaoDpUV70v1BBUSHm MRAylytckV0xJ2nLDApy+LlK2weCgg4uxrm7POtPepTg5NdekRbG8c0GdLeOjOQCIrAE oERg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AHcpqX01; 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 bm4si8348920edb.69.2021.04.12.12.38.43; Mon, 12 Apr 2021 12:39:07 -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=AHcpqX01; 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 S237904AbhDLIq0 (ORCPT + 99 others); Mon, 12 Apr 2021 04:46:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:37080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237768AbhDLIpO (ORCPT ); Mon, 12 Apr 2021 04:45:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AA5206109E; Mon, 12 Apr 2021 08:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217096; bh=qAE3fJG+cg/JqdB5Q7R+RWJsoeCSXspORQUoNyDSQq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AHcpqX01yc4FbSpmTqPH6haB9bLzON1AePKN9opJb7563Ra3jleMM+6YN31BpKO9+ kzg9gJXxGNEvw9hlcMiH9liTjAj7fFhnDM4EVldyWS8nBCI5alNrVB5NZ65jFya2za c8W1qmQt6QctjMUWA12+hfAL5elWvRrM5VQur6Tc= 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 4.19 34/66] i40e: Fix kernel oops when i40e driver removes VFs Date: Mon, 12 Apr 2021 10:40:40 +0200 Message-Id: <20210412083959.225849856@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412083958.129944265@linuxfoundation.org> References: <20210412083958.129944265@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 738acba7a9a3..3c921dfc2056 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -149,6 +149,7 @@ enum i40e_state_t { __I40E_CLIENT_L2_CHANGE, __I40E_CLIENT_RESET, __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 5d782148d35f..3c1533c627fd 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); @@ -1381,6 +1387,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); @@ -1438,6 +1446,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