Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3938048pxj; Mon, 21 Jun 2021 09:46:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ7KAhktdMg4QeHXcjTDK/q4NWyfQJWJMiEk6vrLlBKOFAyKV1fCLpXALnSXSwCgUhJsxB X-Received: by 2002:a05:6402:419:: with SMTP id q25mr22887696edv.331.1624293985730; Mon, 21 Jun 2021 09:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293985; cv=none; d=google.com; s=arc-20160816; b=y8jTWQaRViu0MPtjX8bKSIjbOCZskGFYUxZ6MXaCEJGrjFdZAR/Dcg7lfxcFpC0ycU otrZh4LT2pDQPjH6424kPSCx7ouxAl4p74Ek6/QQg07lO4n1PByuKwhMqMkD4Zu0OpBO WiOp5+/W32DGLsrkShHDLCFRGoadQa855+I4AquImXps+9hgKycZusTU8jfEPsvmJwVC 2aqDRUgIZpU5BnnLt9TmM8ztJvNPyuxKUQKrWGFOReDkl4dULq/buWtxuz38PYQwrmid G/bpW1xwJq8cG+uETqTYH8BQe5P/gSghkGu3PLq4EkrDW1f6c8NipWxQsrIhdYobXcz4 qppw== 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=SyL9xIgBYgRKg4ckPl5YvzCv4EHs8SFohV0QOBZifW4=; b=kgmOCdPyR/HgCPozr40x2mFenJ+WguOfYzCgQN7r04S2c+NBp9M5Of4/IG0MUsOC4b CZpOm19ZYEfUMSWgXtv66nsQUcun58Ar3snAHMJwCzzks3ZaLMv9Bze2o/syhmca+nX2 KE+AVRgM0Mg7MCLGMMSIcN2Xy2hMDGgzPRPLOHWqltG2G1xQbOawf2TA2qn7DEU95ODY aNyFosBJbIKyDWlCssG81i6GlCrbKO+OZ+Mh2byZOC/XNWOK/rnkT3J6Mv1CBwXKcy8l 0DG+4pU/cUtuNsHM4dlhMGTB40XoMndadjVH7MFAuDwP71nS6qkKvsQKhLP6Z7WqLNLK w2bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pD9nI3AA; 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 a14si4997372edt.405.2021.06.21.09.46.03; Mon, 21 Jun 2021 09:46:25 -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=pD9nI3AA; 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 S232209AbhFUQqP (ORCPT + 99 others); Mon, 21 Jun 2021 12:46:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:60770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232747AbhFUQlU (ORCPT ); Mon, 21 Jun 2021 12:41:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DDC3F61443; Mon, 21 Jun 2021 16:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624293043; bh=PWyAofjo/tiPpJ3UOrmLuyAavbAesjZ8yhnKPvd76Ps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pD9nI3AAqlufawPNGJSMvP3Vev/+JcRCDRdFYAN9MLXWGckpRlDF1T8jG+z3/szR5 KrwOzOA6brtuhWcY6Q9tXUFWooRnfGG9uPC6tE9SKRL1WKkWCdZXGYvRP6KAaP3P14 G50lNQFGPZPeqjqcMJuFChhZwkEMBNF87O/pJR4s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmytro Linkin , Leon Romanovsky , Roi Dayan , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.12 077/178] net/mlx5e: Dont create devices during unload flow Date: Mon, 21 Jun 2021 18:14:51 +0200 Message-Id: <20210621154925.215524026@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154921.212599475@linuxfoundation.org> References: <20210621154921.212599475@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: Dmytro Linkin [ Upstream commit a5ae8fc9058e37437c8c1f82b3d412b4abd1b9e6 ] Running devlink reload command for port in switchdev mode cause resources to corrupt: driver can't release allocated EQ and reclaim memory pages, because "rdma" auxiliary device had add CQs which blocks EQ from deletion. Erroneous sequence happens during reload-down phase, and is following: 1. detach device - suspends auxiliary devices which support it, destroys others. During this step "eth-rep" and "rdma-rep" are destroyed, "eth" - suspended. 2. disable SRIOV - moves device to legacy mode; as part of disablement - rescans drivers. This step adds "rdma" auxiliary device. 3. destroy EQ table - . Driver shouldn't create any device during unload flows. To handle that implement MLX5_PRIV_FLAGS_DETACH flag, set it on device detach and unset on device attach. If flag is set do no-op on drivers rescan. Fixes: a925b5e309c9 ("net/mlx5: Register mlx5 devices to auxiliary virtual bus") Signed-off-by: Dmytro Linkin Reviewed-by: Leon Romanovsky Reviewed-by: Roi Dayan Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 4 ++++ include/linux/mlx5/driver.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c index f0623e94716b..897853a68cd0 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c @@ -306,6 +306,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev) int ret = 0, i; mutex_lock(&mlx5_intf_mutex); + priv->flags &= ~MLX5_PRIV_FLAGS_DETACH; for (i = 0; i < ARRAY_SIZE(mlx5_adev_devices); i++) { if (!priv->adev[i]) { bool is_supported = false; @@ -378,6 +379,7 @@ skip_suspend: del_adev(&priv->adev[i]->adev); priv->adev[i] = NULL; } + priv->flags |= MLX5_PRIV_FLAGS_DETACH; mutex_unlock(&mlx5_intf_mutex); } @@ -466,6 +468,8 @@ int mlx5_rescan_drivers_locked(struct mlx5_core_dev *dev) struct mlx5_priv *priv = &dev->priv; lockdep_assert_held(&mlx5_intf_mutex); + if (priv->flags & MLX5_PRIV_FLAGS_DETACH) + return 0; delete_drivers(dev); if (priv->flags & MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV) diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 133967c40214..6a31bbba1b6f 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -541,6 +541,10 @@ struct mlx5_core_roce { enum { MLX5_PRIV_FLAGS_DISABLE_IB_ADEV = 1 << 0, MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV = 1 << 1, + /* Set during device detach to block any further devices + * creation/deletion on drivers rescan. Unset during device attach. + */ + MLX5_PRIV_FLAGS_DETACH = 1 << 2, }; struct mlx5_adev { -- 2.30.2