From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5B4072 for ; Sat, 25 Sep 2021 11:24:18 +0000 (UTC) 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: Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leon Romanovsky Date: Sat, 25 Sep 2021 14:23:01 +0300 Subject: [Intel-wired-lan] [PATCH net-next v1 21/21] net: dsa: Move devlink registration to be last devlink command In-Reply-To: References: Message-ID: <66dd7979b44ac307711c382054f428f9287666a8.1632565508.git.leonro@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: intel-wired-lan@osuosl.org List-ID: 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