Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2234876ybi; Thu, 20 Jun 2019 11:20:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqycVgmgHZBJoeOSEZI2ADJ8MMs8Y2bkDGN5EutYRcuiBumDrJNX6jT9HmbcpwK0s1FWNs6o X-Received: by 2002:aa7:8ecb:: with SMTP id b11mr91437795pfr.220.1561054810983; Thu, 20 Jun 2019 11:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561054810; cv=none; d=google.com; s=arc-20160816; b=PKqIvqANVcEjsEhXL0ltir7elGm2gmupDFFt04KxhntxFcMy08ztNpk32wjuIXXg4P E9UzSS6L3lCdyOVnW0RlKgP7JiRHrgfH8l9Y+UYvR1ExN097GhDFP5icdO8wBxJx6fTy UrGify+c3mfL+jEUWVNyLRzbySCOLnTUcImOTCPC255F7GF02iK7sG6GPLTNkiWr7Jxu 35p/6jwswsryXCuRxD5bugqRbW8QJVdIfnnWwCs6B2oTWbCLNu8u3f+2OLa00a+uic/A 0iSfkczUNM3LQDT+u/gcWD/peF3M7SzKcIEQbZMobtIAjLFxC7Fm0cC1EcW5efka1Kdi +Qjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5bpuWrsa3zYvzZItKIRTAzIeUfP6URA2GXk/jyqD39s=; b=jQpwpYVyqoR4WUXHU6d0F9rwnvsYqpiTGbqXltejsWJ3Rm4ViuqQHxdRi03/kBnFZG D8TR8ycNSiilHYZROI2ZfUJPxI2Av1Vb39JxtZoLF767mgtkyWsDgPUj4j/+Le6BO3O3 6pdlkJNpYxN2oTG8UFkkDL3tXmmOq2zhrdQl/E9z9aNySP/wxgPnVqIN4U7GFq5HQ6yK ub3b1s03T6HxywU9NL6rVXh+KvkJUFw/tMqGsCAFi9ZmcPZCIp/GBoOkQZemeYh3jTeY bbgPgYAmqkIxUid1MDJ+OKeTCUphInDoCpULTZhtXMhr56sMkmmn/k+T1xNeNwVlH8gV /Ybw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tFNdLLql; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si189307pgh.53.2019.06.20.11.19.55; Thu, 20 Jun 2019 11:20:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tFNdLLql; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729564AbfFTSTw (ORCPT + 99 others); Thu, 20 Jun 2019 14:19:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:43128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726423AbfFTSOn (ORCPT ); Thu, 20 Jun 2019 14:14:43 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DCEDE205F4; Thu, 20 Jun 2019 18:14:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561054482; bh=SNhhTNTNJjo7lSzoUKnyQTkQF6RVht3rNB5TOKxyCyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tFNdLLql6jGRtJfj1H1r8My7AYgvAAFCuYH4L4YJNleY8UsMZMXxJ3k/QU4twkynd k03kgWDAeCTE9O1Vd+5DgL+jOUyI29XxDqKvemW6zVoRnSIZGQzDR0W9QWJaVW5hK0 u7MgOeCHqBPXWP8gUV8QwprqtOw4KI4myeNrorYo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alaa Hleihel , Saeed Mahameed Subject: [PATCH 5.1 16/98] net/mlx5: Avoid reloading already removed devices Date: Thu, 20 Jun 2019 19:56:43 +0200 Message-Id: <20190620174350.025778024@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174349.443386789@linuxfoundation.org> References: <20190620174349.443386789@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alaa Hleihel Prior to reloading a device we must first verify that it was not already removed. Otherwise, the attempt to remove the device will do nothing, and in that case we will end up proceeding with adding an new device that no one was expecting to remove, leaving behind used resources such as EQs that causes a failure to destroy comp EQs and syndrome (0x30f433). Fix that by making sure that we try to remove and add a device (based on a protocol) only if the device is already added. Fixes: c5447c70594b ("net/mlx5: E-Switch, Reload IB interface when switching devlink modes") Signed-off-by: Alaa Hleihel Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c @@ -248,11 +248,32 @@ void mlx5_unregister_interface(struct ml } EXPORT_SYMBOL(mlx5_unregister_interface); +/* Must be called with intf_mutex held */ +static bool mlx5_has_added_dev_by_protocol(struct mlx5_core_dev *mdev, int protocol) +{ + struct mlx5_device_context *dev_ctx; + struct mlx5_interface *intf; + bool found = false; + + list_for_each_entry(intf, &intf_list, list) { + if (intf->protocol == protocol) { + dev_ctx = mlx5_get_device(intf, &mdev->priv); + if (dev_ctx && test_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state)) + found = true; + break; + } + } + + return found; +} + void mlx5_reload_interface(struct mlx5_core_dev *mdev, int protocol) { mutex_lock(&mlx5_intf_mutex); - mlx5_remove_dev_by_protocol(mdev, protocol); - mlx5_add_dev_by_protocol(mdev, protocol); + if (mlx5_has_added_dev_by_protocol(mdev, protocol)) { + mlx5_remove_dev_by_protocol(mdev, protocol); + mlx5_add_dev_by_protocol(mdev, protocol); + } mutex_unlock(&mlx5_intf_mutex); }