Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3706738imu; Mon, 28 Jan 2019 09:22:01 -0800 (PST) X-Google-Smtp-Source: AHgI3IYw9AQav8NKO1SGdflo2JHNxNGYTH9sq6okIJQV9CSx+l1MHkeVyM8Ze8SgIOJTz+7qR6TT X-Received: by 2002:a17:902:e01:: with SMTP id 1mr8068214plw.251.1548696121066; Mon, 28 Jan 2019 09:22:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696121; cv=none; d=google.com; s=arc-20160816; b=VCjudVCZKxx36TjQCCwUR0ze/WicxS2mBxyDJJSBZD79DhEqr0836H2supukdq6n92 GRxI/9COBhRXPTpAaaKtpCIForrAoogLgsGrMtbacPwCJW2SVAvH2UnHzSEJCYj+HAx5 MAjBjrrAIDihBX335JdAAaFS2pbFzM/E/yvJ2HbwbTf1xU5Jz3IFz1sbvgDmxdjPnzDg Yhe7difZf2tLpQh8Jqq36U8vSibqIW2KOWW2PS06HoaxvytAnUosivQA2+uiSJ54GyZ4 Wj7Gkrzr8oKjdCVz2EfuaPX95N64rUrfm9rtBdMyMOnVjubs/MyHa3+bvjKQvI6u7IfJ P/pg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8OYFy2fzF83jMB801kBIlyiYmOlIimpajF7xDzpP9oQ=; b=i3KJONM6ndxZXuMOULeCYRSZyt3rvixt01uz8VeIdGmZaxurriuOyy1G5QcEUCYQbM cEOglVGTVhB+zMrf+Pq/ALIvFQTWfivjEZyEnbU+xK99Qwgakfqm3Nds4XVtMj5taMY4 p7OYjH/GXhhapFPmZENTCneTN+ZZ6MPQRgpmi3FbprOyCbEaPiK8L61Gd15Rr2PRP66y 1B0vJ94V8TAKitTV4aCpvGrMpBDi8tSZ/YYEU8re5pJv5Hv/GJ/8oe4UBcQMPOaH28jT dnvA3wTtVOCCC/R2GvCauXStRmz6Ir2sTEDS98C0bWjgJ64aF9oPvwZETHct+goo5Uql XTcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PM9YdOHv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 38si9839679pln.313.2019.01.28.09.21.45; Mon, 28 Jan 2019 09:22:01 -0800 (PST) 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=PM9YdOHv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731502AbfA1QEG (ORCPT + 99 others); Mon, 28 Jan 2019 11:04:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:49350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730474AbfA1QEA (ORCPT ); Mon, 28 Jan 2019 11:04:00 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A828620855; Mon, 28 Jan 2019 16:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691439; bh=wY1K5xqo/IpGYlpakO7MoYy5+Y0mMYF8Mh5lQXN2ZRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PM9YdOHvcgBlWMEbeK2WeBJVar62dXuHgp1Upgzq0LFI+IFBZkHEQvjkYD1brxrff EUMFJ2cA221f02ZWBoWXapOnK3rsnle+zgXKFvL7mKqQdoYQ/StXRnZ5YZIH+J70Z6 g9Zp4BsBEGl8lCWuvbCw0cO8iRPft3CjvQ4xFTZ8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jakub Kicinski , "David S . Miller" , Sasha Levin , oss-drivers@netronome.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 094/258] nfp: add locking around representor changes Date: Mon, 28 Jan 2019 10:56:40 -0500 Message-Id: <20190128155924.51521-94-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jakub Kicinski [ Upstream commit 71844fac1ed459024dd2a448d63d5b28b8c87daa ] Up until now we never needed to keep a networking locks around representors accesses, we only accessed them when device was reconfigured (under nfp pf->lock) or on fast path (under RCU). Now we want to be able to iterate over all representors during notifications, so make sure representor assignment is done under RTNL lock. Signed-off-by: Jakub Kicinski Reviewed-by: John Hurley Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/netronome/nfp/abm/main.c | 4 ++++ drivers/net/ethernet/netronome/nfp/nfp_app.c | 2 ++ drivers/net/ethernet/netronome/nfp/nfp_net_repr.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/abm/main.c b/drivers/net/ethernet/netronome/nfp/abm/main.c index b84a6c2d387b..04ef4b986a43 100644 --- a/drivers/net/ethernet/netronome/nfp/abm/main.c +++ b/drivers/net/ethernet/netronome/nfp/abm/main.c @@ -415,7 +415,9 @@ nfp_abm_spawn_repr(struct nfp_app *app, struct nfp_abm_link *alink, reprs = nfp_reprs_get_locked(app, rtype); WARN(nfp_repr_get_locked(app, reprs, alink->id), "duplicate repr"); + rtnl_lock(); rcu_assign_pointer(reprs->reprs[alink->id], netdev); + rtnl_unlock(); nfp_info(app->cpp, "%s Port %d Representor(%s) created\n", ptype == NFP_PORT_PF_PORT ? "PCIe" : "Phys", @@ -441,7 +443,9 @@ nfp_abm_kill_repr(struct nfp_app *app, struct nfp_abm_link *alink, netdev = nfp_repr_get_locked(app, reprs, alink->id); if (!netdev) return; + rtnl_lock(); rcu_assign_pointer(reprs->reprs[alink->id], NULL); + rtnl_unlock(); synchronize_rcu(); /* Cast to make sure nfp_repr_clean_and_free() takes a nfp_repr */ nfp_repr_clean_and_free((struct nfp_repr *)netdev_priv(netdev)); diff --git a/drivers/net/ethernet/netronome/nfp/nfp_app.c b/drivers/net/ethernet/netronome/nfp/nfp_app.c index 8607d09ab732..ba6abe652cce 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_app.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_app.c @@ -156,7 +156,9 @@ nfp_app_reprs_set(struct nfp_app *app, enum nfp_repr_type type, struct nfp_reprs *old; old = nfp_reprs_get_locked(app, type); + rtnl_lock(); rcu_assign_pointer(app->reprs[type], reprs); + rtnl_unlock(); return old; } diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c index 18a09cdcd9c6..6985db8822bd 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c @@ -472,7 +472,9 @@ int nfp_reprs_resync_phys_ports(struct nfp_app *app) continue; nfp_app_repr_preclean(app, netdev); + rtnl_lock(); rcu_assign_pointer(reprs->reprs[i], NULL); + rtnl_unlock(); synchronize_rcu(); nfp_repr_clean(repr); } -- 2.19.1