Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2330465pxb; Sat, 25 Sep 2021 04:29:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznkQra8LmVzh5YBIgdfmrp1JhgAW8UovTjrHUUhJzK+w7/PsnEnLy0/dZiSOWD+StG/UGK X-Received: by 2002:a17:906:d541:: with SMTP id cr1mr17141346ejc.81.1632569352129; Sat, 25 Sep 2021 04:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632569352; cv=none; d=google.com; s=arc-20160816; b=0eP4tpVJt9cfyAPnhVen8PKzIohN1RJBX4/Wx3O5P7qFhGU4w6V6EN/7xGIF+kInrR RD/98FdVbDy4NUCQaX9SFZ5TY/gqX62pvAyk125OHvnRO9PMENBODWzLxvY8frr/U0ER Q/iTE2MAO8pzCB/A7PzNTkJg7ReW9SdNz1qDCMS1I304JfJK6gWWuUnrrY6GQe/yygIS +Vykhs47WFzwlcmwO86XLQeP0dT1YYpvfco5flqFX7JQidQdnFUBLBxnDGoaBDSB2NhK rXZNYnG+AxZ14G9zqH1qzKHMWLqwoyP/H5+lZ5ly0NHH9RA0BrqTqmSmc6O36UjauCty 2txg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oWQ1WMb7oWdPWzIULFR6eaaLUOJRGhSrv5U3wxGNnPc=; b=pcrfcRDW7vVIEM1KUAxUyQ1WKgAE7d/xy8C8x2+R8oLPBumTBC4W/Wv3aTVd8fw0ZD kIb2hHN0iuSMBorPhNJPzCVv1cpQU0aWt0FEYzamCy7T/JNExD4YQra67UQ+jgjFPR2E JdDiTWGOs4qgkVAQ4ZJF3T9pSri0PAica0k6dC0JXOU/5OhuizIKTa2y58/csD58HSes dtn442Cuv5c/W6srvmSFW21hWthIlH5barn53rZc2QVWLh5t7MM4NfCnjE0PifLdlMW+ HgEQg3c0OvY3qbnVV92cX6zO52HfxEleXwWVk9qX4IWb98RKaJMMgDHzla8ngKAsRDuc zRsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pR22exCj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id 13si11839660ejr.788.2021.09.25.04.28.48; Sat, 25 Sep 2021 04:29:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pR22exCj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1343922AbhIYL01 (ORCPT + 99 others); Sat, 25 Sep 2021 07:26:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:57524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244756AbhIYLZx (ORCPT ); Sat, 25 Sep 2021 07:25:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D1B0761352; Sat, 25 Sep 2021 11:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632569058; bh=iRLV6v3e7JYAyZzq3uX24jBWmOHmWur2DvK8Vt/2i+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pR22exCjUS7YCkjkCvD8Rnb9sosGeBFWlArr/YA3QFWWrtyauBEi7+Tuhqd4afoJR eRUaq5hWn2OMw9LPTV8rZEfeRlENaJNpc2E4GJnYKmRa7zvr8b5JTcEqZmvEYOvhf/ 2YLSW8fytAdZTjkgmt/8HJ/SHvzIf7/eRAOikZt9Oa1UDm8a+EloI0pZzg2GkXLWp/ kbdu3Un5+qwR8prVYLnTt23VXb+LJjt7pgc76zL+oyZsh181Sb/7IqLOeqFUK9InuA voqdYkfrjahsfJjF/DzkF/YIBNWKLGBMyC3/4eZXseBdGBO3ITOoLCyUVllM0CXPr8 8zF7KKkx596zg== From: Leon Romanovsky To: "David S . Miller" , Jakub Kicinski Cc: Leon Romanovsky , Alexandre Belloni , Andrew Lunn , Ariel Elior , Bin Luo , Claudiu Manoil , Coiby Xu , Derek Chickles , drivers@pensando.io, Felix Manlunas , Florian Fainelli , Geetha sowjanya , Greg Kroah-Hartman , GR-everest-linux-l2@marvell.com, GR-Linux-NIC-Dev@marvell.com, hariprasad , Ido Schimmel , Intel Corporation , intel-wired-lan@lists.osuosl.org, Ioana Ciornei , Jerin Jacob , Jesse Brandeburg , Jiri Pirko , Jonathan Lemon , Linu Cherian , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-rdma@vger.kernel.org, linux-staging@lists.linux.dev, Loic Poulain , Manish Chopra , M Chetan Kumar , Michael Chan , Michael Guralnik , netdev@vger.kernel.org, oss-drivers@corigine.com, Richard Cochran , Saeed Mahameed , Satanand Burla , Sergey Ryazanov , Shannon Nelson , Simon Horman , Subbaraya Sundeep , Sunil Goutham , Taras Chornyi , Tariq Toukan , Tony Nguyen , UNGLinuxDriver@microchip.com, Vadym Kochan , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next v1 21/21] net: dsa: Move devlink registration to be last devlink command Date: Sat, 25 Sep 2021 14:23:01 +0300 Message-Id: <66dd7979b44ac307711c382054f428f9287666a8.1632565508.git.leonro@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky This change prevents from users to access device before devlink is fully configured. Signed-off-by: Leon Romanovsky --- net/dsa/dsa2.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index a020339e1973..8ca6a1170c9d 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -848,7 +848,6 @@ static int dsa_switch_setup(struct dsa_switch *ds) dl_priv = devlink_priv(ds->devlink); dl_priv->ds = ds; - devlink_register(ds->devlink); /* Setup devlink port instances now, so that the switch * setup() can register regions etc, against the ports */ @@ -874,8 +873,6 @@ static int dsa_switch_setup(struct dsa_switch *ds) if (err) goto teardown; - devlink_params_publish(ds->devlink); - if (!ds->slave_mii_bus && ds->ops->phy_read) { ds->slave_mii_bus = mdiobus_alloc(); if (!ds->slave_mii_bus) { @@ -891,7 +888,7 @@ static int dsa_switch_setup(struct dsa_switch *ds) } ds->setup = true; - + devlink_register(ds->devlink); return 0; free_slave_mii_bus: @@ -906,7 +903,6 @@ static int dsa_switch_setup(struct dsa_switch *ds) list_for_each_entry(dp, &ds->dst->ports, list) if (dp->ds == ds) dsa_port_devlink_teardown(dp); - devlink_unregister(ds->devlink); devlink_free(ds->devlink); ds->devlink = NULL; return err; @@ -919,6 +915,9 @@ static void dsa_switch_teardown(struct dsa_switch *ds) if (!ds->setup) return; + if (ds->devlink) + devlink_unregister(ds->devlink); + if (ds->slave_mii_bus && ds->ops->phy_read) { mdiobus_unregister(ds->slave_mii_bus); mdiobus_free(ds->slave_mii_bus); @@ -934,7 +933,6 @@ static void dsa_switch_teardown(struct dsa_switch *ds) list_for_each_entry(dp, &ds->dst->ports, list) if (dp->ds == ds) dsa_port_devlink_teardown(dp); - devlink_unregister(ds->devlink); devlink_free(ds->devlink); ds->devlink = NULL; } -- 2.31.1