Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2448561yba; Mon, 15 Apr 2019 11:51:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeh5d71QJM7L1/7X9NoyZJBCoklHnS0QbgStGVtLZcgd9CgaTu1SJL7OvOXsWslo/baGqs X-Received: by 2002:a62:e710:: with SMTP id s16mr69191283pfh.74.1555354305885; Mon, 15 Apr 2019 11:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555354305; cv=none; d=google.com; s=arc-20160816; b=PjaFYpOKX9CcNiX8zs86/NAaoeMhDYYH0Gk75aJMYmcbZxID7BuZQ2B1IvBpMovyMF MQElx9cGttNxwr+yggRJ58zGn44gD+2zGxtyoRpfAPKd1APuTdVb5S76gCnjZ55bTtSe j/sqgPmmGmV37tEm359eS0keM2iG1lbH9AgcQ+xTsqYLLs4mg3YcIa7yb6oeM5dsF9de aBJD8Ph0ZNN69RZxnUcPLDquQ7kuP8aEk8/4chovK3qCqqQIm0HiwKTVqvcNgCdSX8NK bLF8qoZhn4yYNIqPeUK3eIGwF1NZJanCQ/Xxfs4c1fATEdGnvjaCo7JSsYENYlOUPvJ+ XJPA== 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=jM6I2FKyQ+xKrrl59REn2BeZbDTwOllWvpWAdlPCCHE=; b=SiOEX2y/Fxc1jOwtSjK2/lnApbyUxAtQ+73z1S8okumjxzDQVjl7ED9fq3NPHkXnbl SP7Y3Xq0lw70HOKh4cO22kZ5svyaJ2280RXs+fCQQ2c0Dxll4wWOxhmcV5135/zcivmm 1hEEjFKzwGWWcPOcq5n3T5vg1r3BOEhE73J4yhLkhlCyIkvtPOcM7duFVhzO3/RL/gvM akhhXOmqysgcYnXseo5CPe4P8V9sXS9S0fb3C1qLxbURwH5crCUKDq9hVX+9YqH75emh PC2SMFd0y7A2A0G8MdWzhJ5I4w989MfxssmjZh+Yt3iFbfd+sPL99fXo1X5c3P6F+2MV +5Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o8PHjf9t; 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 k18si46221321pgb.351.2019.04.15.11.51.29; Mon, 15 Apr 2019 11:51:45 -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=o8PHjf9t; 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 S1729030AbfDOStE (ORCPT + 99 others); Mon, 15 Apr 2019 14:49:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:51306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728973AbfDOSro (ORCPT ); Mon, 15 Apr 2019 14:47:44 -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 715A92087C; Mon, 15 Apr 2019 18:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555354063; bh=6SBP+UepJ6h5naaSQnb5iAg08fqNy6u3wMbzA4kOzJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o8PHjf9tnhvSNIF4y+YDF70N2hEIsZTMdG9QXSeVnv9oT8ZmzXdBlscp4lHDamwY4 2IMwaWfvRcSCQMovCNjp9qlfbAs9h9dpyxEP1aSFViSZu1+4mCWeBIoKhwFfnS0qyd V6GaPBq5yCPvAkG7qsqqDg2LyH0/0XInYgYWI/xY= 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.9 59/76] net/mlx5e: Add a lock on tir list Date: Mon, 15 Apr 2019 20:44:23 +0200 Message-Id: <20190415183724.736253909@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183707.712011689@linuxfoundation.org> References: <20190415183707.712011689@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; @@ -151,6 +156,7 @@ int mlx5e_refresh_tirs_self_loopback_ena 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) { err = mlx5_core_modify_tir(mdev, tir->tirn, in, inlen); if (err) @@ -159,6 +165,7 @@ int mlx5e_refresh_tirs_self_loopback_ena out: kvfree(in); + mutex_unlock(&mdev->mlx5e_res.td.list_lock); return err; } --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -578,6 +578,8 @@ enum mlx5_pci_status { }; struct mlx5_td { + /* protects tirs list changes while tirs refresh */ + struct mutex list_lock; struct list_head tirs_list; u32 tdn; };