Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2461564yba; Mon, 15 Apr 2019 12:08:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPaW+OY4kXmzK6WrC/1I/KMYbVC5ynyQrXc1V4e5rLZgGOM/U22sNr6LDqJiYUe9ty0w/s X-Received: by 2002:a17:902:24a2:: with SMTP id w31mr44633263pla.78.1555355302309; Mon, 15 Apr 2019 12:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555355302; cv=none; d=google.com; s=arc-20160816; b=XB0EKHZCT6XWt9W4AGpqdbAQCGhz7poeZAMJOQ0hHKWmjUw4eNdpCcYKg5hkKXo5kM y+2NOMRpRI7a8HVbqrQSREt7CMqeUyei2aoTQLvlOd8VXGoGUCV6I7nOx3YJqh+BpI4M XIrNAvwaSYl61/j8Osp7BOYteOJ2WEIAV5vbquooayeceYQu2AHfQQ8XK+dBuGCKwFF7 hYR2WTsC4aOy5fhqoXNmGhYjk/rda6aftu9liCC8QdPxLvs0hXdrRn84My0720yswO98 Ubi0BAciv8Guy9st1stAxGrl3tJ1uq02cxwrZkSqsBvTGWft+qp4fq5ckRVMestNDpyJ dleA== 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=Cf+dwYWlU7a8B/gSgdhobp9JBFGQM20Xr3ZavOdrqsk=; b=a1kX+c+XHUsQqLmxNvQB50S1WOXjmwehop2yz7lB0chyaOrIe+eM/faP3lZqkV2cZV PzNskh7f1huoP49cNETKIwbyM37CI68/Mn2fW8Zed0oTyMoMgFzHtw4m0ONqMZ2dyG+q Ud5ljVDBS7KHwq6/X2hpp1lun4Ca2ndha9C++PsDkw4HN5fe+t3Ejr6oWAuCfC9HzbQM h5X6EDUC0EynkaNs03geqJoa88Nl/jDvljKFgcIkQ9vzwW2L13gvw7+fcygio+DtOTgb DJ0PtyO4TG5MdVqseMS7tRsAGKxvkCezDLLgw5HbHF3fQ+IEc5ZtdSTyHFclNYU/SgQH IrDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dAYGSvw8; 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 l11si22396949plb.370.2019.04.15.12.08.05; Mon, 15 Apr 2019 12:08:22 -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=dAYGSvw8; 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 S1729741AbfDOTFi (ORCPT + 99 others); Mon, 15 Apr 2019 15:05:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:39312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729724AbfDOTFe (ORCPT ); Mon, 15 Apr 2019 15:05:34 -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 56677218EA; Mon, 15 Apr 2019 19:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355132; bh=471birNPpVUpM6Dyigla+QC/0KH3q4F/G7aSQFvIc+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dAYGSvw8jaAd9D/X9QAfWLviwFmFLI+S4ytW4Fn+wvQ3o4CjDTuHHGdH0UvAhYpmR X44Kfik+R/I9AftHu3Lx/oJzeuqEA0gH25xpewldCGDG2kyZ06l24J2lq4pxPOQ88C de65lWb2b/fb2Joq2g+QTbmfeW4c6H5M5MVETu9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yuval Avnery , Saeed Mahameed , Sasha Levin Subject: [PATCH 4.19 025/101] net/mlx5e: Add a lock on tir list Date: Mon, 15 Apr 2019 20:58:23 +0200 Message-Id: <20190415183741.726681579@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@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 [ 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: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/en_common.c | 7 +++++++ include/linux/mlx5/driver.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c index 1e28866e3924..124e4567a4ee 100644 --- 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_dev *mdev, 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_dev *mdev, 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 mlx5_core_dev *mdev) } INIT_LIST_HEAD(&mdev->mlx5e_res.td.tirs_list); + mutex_init(&mdev->mlx5e_res.td.list_lock); return 0; @@ -159,6 +164,7 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb) 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); @@ -170,6 +176,7 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb) 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; } diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index bbcfe2e5fd91..e8b92dee5a72 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -776,6 +776,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; }; -- 2.19.1