Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2459614yba; Mon, 15 Apr 2019 12:06:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIwky3wlkC8m5QcP8faFIX5rGSAmkwF49Cwd9uDXnGcgaeTR9lA2q/opKECJBBzB3veItE X-Received: by 2002:aa7:83d1:: with SMTP id j17mr78483839pfn.78.1555355164271; Mon, 15 Apr 2019 12:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555355164; cv=none; d=google.com; s=arc-20160816; b=nY4uWGpLDsoKe9iFe9ZNAV14Oa2cuKwF6He5tgcOcDSVSl4c8/7gMXG15GY1kLTpuP aPnvPJTpk5jN8RkyaUwz13cbHThN/QG4uiZMUwnSpyzEi8MFCf/ecm4l9VVg4YPBT65X QZdJkZG46CAqkQjtxpsHzoRnGMEEMcTu9OaHL6GjkNd9WwqezDkPShpMRXeKT1hg34lY bMtyzwniYhgqNqqY38i0OKgRSIM0LAL3rbqa5yTQofBoEfvb0yqv0fxkwatIp62YRymd 1+QT6mc5f13PVeVVYiGR4Z6YkBfysaYf5/FDY9GXhoWWV7oR/KQc1ES7S+MrS3eNPUiY tfYQ== 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=VSr71KVsuyYeLppzHhz8pZ0MK9/ZvgCShOAo6Gc8Vkc=; b=PkL0PmdrgQXOgntF5XPAZNeR4J7YYnyWtzcQtLfKTRudA/+USvc7kNDqtfksCqyAiD FTaTxfVrVrGwHnl0F1kHf1rM7tI6F22nlR+1jEsm5TzN3thhd2HAMQs5R+E9m8zUXrKR 5mPgoKSHUtzpX81CPIrKWem2IwO1U1kwxskthd25XyKeBQrKQitgdpRKaM/r8u8Vqn6b 6APv4tnwOGDc4DlPlKLN92U41Iah222zxreYFgrTruDLprkvuEeDr1noOfrtQpBHMQDe k00ztem0jnBqHWDtNe7y7XBPh5gFcO97ko6I1hJLeBUsaYebyHAixGhAj3yU/t99yAGs A1Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v4MNQ5pC; 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 t9si33937710pgp.273.2019.04.15.12.05.48; Mon, 15 Apr 2019 12:06:04 -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=v4MNQ5pC; 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 S1729195AbfDOTDU (ORCPT + 99 others); Mon, 15 Apr 2019 15:03:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:35054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728218AbfDOTDT (ORCPT ); Mon, 15 Apr 2019 15:03:19 -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 D1105218A1; Mon, 15 Apr 2019 19:03:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555354998; bh=CD9aeoQYBzUegyoEVuQ8PxltnK7joKUEea7G6XiUeT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v4MNQ5pCI/qBz4VNKcWxb+z79+PGhk+e6bdAwhiYBswUfzEcILTX7WhAfYcyjions cLuVAxvxYhgHJihurgrFhUZ0q93Nya0OjVYWRgq0O6Ne6OG01Y5jYPGDh3Op3Gv5Xt siO/O5nEattFcSvM2QOPIwBeYQBlTEs3HVL2Tck4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yuval Avnery , Saeed Mahameed Subject: [PATCH 4.14 29/69] net/mlx5e: Add a lock on tir list Date: Mon, 15 Apr 2019 20:58:47 +0200 Message-Id: <20190415183731.455738394@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183726.036654568@linuxfoundation.org> References: <20190415183726.036654568@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: Yuval Avnery [ Upstream commit 80a2a9026b24c6bd34b8d58256973e22270bedec ] Refresh tirs is looping over a global list of tirs while netdevs are adding and removing tirs from that list. That is why a lock is required. Fixes: 724b2aa15126 ("net/mlx5e: TIRs management refactoring") Signed-off-by: Yuval Avnery Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/en_common.c | 7 +++++++ include/linux/mlx5/driver.h | 2 ++ 2 files changed, 9 insertions(+) --- a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c @@ -45,7 +45,9 @@ int mlx5e_create_tir(struct mlx5_core_de if (err) return err; + mutex_lock(&mdev->mlx5e_res.td.list_lock); list_add(&tir->list, &mdev->mlx5e_res.td.tirs_list); + mutex_unlock(&mdev->mlx5e_res.td.list_lock); return 0; } @@ -53,8 +55,10 @@ int mlx5e_create_tir(struct mlx5_core_de void mlx5e_destroy_tir(struct mlx5_core_dev *mdev, struct mlx5e_tir *tir) { + mutex_lock(&mdev->mlx5e_res.td.list_lock); mlx5_core_destroy_tir(mdev, tir->tirn); list_del(&tir->list); + mutex_unlock(&mdev->mlx5e_res.td.list_lock); } static int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn, @@ -114,6 +118,7 @@ int mlx5e_create_mdev_resources(struct m } INIT_LIST_HEAD(&mdev->mlx5e_res.td.tirs_list); + mutex_init(&mdev->mlx5e_res.td.list_lock); return 0; @@ -158,6 +163,7 @@ int mlx5e_refresh_tirs(struct mlx5e_priv MLX5_SET(modify_tir_in, in, bitmask.self_lb_en, 1); + mutex_lock(&mdev->mlx5e_res.td.list_lock); list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) { tirn = tir->tirn; err = mlx5_core_modify_tir(mdev, tirn, in, inlen); @@ -169,6 +175,7 @@ out: kvfree(in); if (err) netdev_err(priv->netdev, "refresh tir(0x%x) failed, %d\n", tirn, err); + mutex_unlock(&mdev->mlx5e_res.td.list_lock); return err; } --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -743,6 +743,8 @@ struct mlx5_pagefault { }; struct mlx5_td { + /* protects tirs list changes while tirs refresh */ + struct mutex list_lock; struct list_head tirs_list; u32 tdn; };