From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:23:16
From: Leon Romanovsky <leonro@nvidia.com>
This is second version of patch series
https://lore.kernel.org/netdev/cover.1628599239.git.leonro@nvidia.com/
The main change is addition of delayed notification logic that will
allowed us to delete devlink_params_publish API (future series will
remove it completely) and conversion of all drivers to have devlink_register
being last commend.
The series itself is pretty straightforward, except liquidio driver
which performs initializations in various workqueues without proper
locks. That driver doesn't hole device_lock and it is clearly broken
for any parallel driver core flows (modprobe + devlink + PCI reset will
100% crash it).
In order to annotate devlink_register() will lockdep of holding
device_lock, I added workaround in this driver.
Thanks
----------------------
From previous cover letter:
Hi Dave and Jakub,
This series prepares code to remove devlink_reload_enable/_disable API
and in order to do, we move all devlink_register() calls to be right
before devlink_reload_enable().
The best place for such a call should be right before exiting from
the probe().
This is done because devlink_register() opens devlink netlink to the
users and gives them a venue to issue commands before initialization
is finished.
1. Some drivers were aware of such "functionality" and tried to protect
themselves with extra locks, state machines and devlink_reload_enable().
Let's assume that it worked for them, but I'm personally skeptical about
it.
2. Some drivers copied that pattern, but without locks and state
machines. That protected them from reload flows, but not from any _set_
routines.
3. And all other drivers simply didn't understand the implications of early
devlink_register() and can be seen as "broken".
Thanks
Leon Romanovsky (21):
devlink: Notify users when objects are accessible
bnxt_en: Register devlink instance at the end devlink configuration
liquidio: Overcome missing device lock protection in init/remove flows
dpaa2-eth: Register devlink instance at the end of probe
net: hinic: Open device for the user access when it is ready
ice: Open devlink when device is ready
octeontx2: Move devlink registration to be last devlink command
net/prestera: Split devlink and traps registrations to separate
routines
net/mlx4: Move devlink_register to be the last initialization command
net/mlx5: Accept devlink user input after driver initialization
complete
mlxsw: core: Register devlink instance last
net: mscc: ocelot: delay devlink registration to the end
nfp: Move delink_register to be last command
ionic: Move devlink registration to be last devlink command
qed: Move devlink registration to be last devlink command
net: ethernet: ti: Move devlink registration to be last devlink
command
netdevsim: Move devlink registration to be last devlink command
net: wwan: iosm: Move devlink_register to be last devlink command
ptp: ocp: Move devlink registration to be last devlink command
staging: qlge: Move devlink registration to be last devlink command
net: dsa: Move devlink registration to be last devlink command
.../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 15 +--
.../net/ethernet/cavium/liquidio/lio_main.c | 19 ++--
.../freescale/dpaa2/dpaa2-eth-devlink.c | 14 ++-
.../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 9 +-
.../net/ethernet/freescale/dpaa2/dpaa2-eth.h | 5 +-
.../net/ethernet/huawei/hinic/hinic_hw_dev.c | 7 +-
drivers/net/ethernet/intel/ice/ice_main.c | 6 +-
.../marvell/octeontx2/af/rvu_devlink.c | 10 +-
.../marvell/octeontx2/nic/otx2_devlink.c | 15 +--
.../marvell/prestera/prestera_devlink.c | 29 +----
.../marvell/prestera/prestera_devlink.h | 4 +-
.../ethernet/marvell/prestera/prestera_main.c | 8 +-
drivers/net/ethernet/mellanox/mlx4/main.c | 8 +-
.../net/ethernet/mellanox/mlx5/core/devlink.c | 9 +-
.../net/ethernet/mellanox/mlx5/core/main.c | 2 +
.../mellanox/mlx5/core/sf/dev/driver.c | 2 +
drivers/net/ethernet/mellanox/mlxsw/core.c | 19 +---
drivers/net/ethernet/mscc/ocelot_vsc7514.c | 5 +-
.../ethernet/netronome/nfp/devlink_param.c | 9 +-
.../net/ethernet/netronome/nfp/nfp_net_main.c | 5 +-
.../ethernet/pensando/ionic/ionic_devlink.c | 4 +-
drivers/net/ethernet/qlogic/qed/qed_devlink.c | 7 +-
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 15 +--
drivers/net/ethernet/ti/cpsw_new.c | 7 +-
drivers/net/netdevsim/dev.c | 8 +-
drivers/net/wwan/iosm/iosm_ipc_devlink.c | 7 +-
drivers/ptp/ptp_ocp.c | 6 +-
drivers/staging/qlge/qlge_main.c | 8 +-
net/core/devlink.c | 107 +++++++++++++++---
net/dsa/dsa2.c | 10 +-
30 files changed, 202 insertions(+), 177 deletions(-)
--
2.31.1
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:23:16
From: Leon Romanovsky <leonro@nvidia.com>
The devlink core code notified users about add/remove objects without
relation if this object can be accessible or not. In this patch we unify
such user visible notifications in one place.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
net/core/devlink.c | 107 +++++++++++++++++++++++++++++++++++++++------
1 file changed, 93 insertions(+), 14 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:23:20
From: Leon Romanovsky <leonro@nvidia.com>
Move devlink_register() to be last command in devlink configuration
sequence, so no user space access will be possible till devlink instance
is fully operable. As part of this change, the devlink_params_publish
call is removed as not needed.
This change fixes forgotten devlink_params_unpublish() too.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:23:26
From: Leon Romanovsky <leonro@nvidia.com>
Move devlink_register to be the last command in the initialization
sequence.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
.../ethernet/freescale/dpaa2/dpaa2-eth-devlink.c | 14 +++++++++++---
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 9 ++++++---
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 5 ++++-
3 files changed, 21 insertions(+), 7 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:23:32
From: Leon Romanovsky <leonro@nvidia.com>
Move devlink registration to be the last command in device activation,
so it opens the driver to accept such devlink commands from the user
when it is fully initialized.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:23:39
From: Leon Romanovsky <leonro@nvidia.com>
The liquidio driver is broken by design. It initialize PCI devices
in separate delayed works. It causes to the situation where device lock
is dropped during initialize and remove sequences.
That lock is part of driver/core and needed to protect from races during
init, destroy and bus invocations.
In addition to lack of locking protection, it has incorrect order of
destroy flows and very questionable synchronization scheme based on
atomic_t.
This change doesn't fix that driver but makes sure that rest of the
netdev subsystem doesn't suffer from such basic protection by adding
device_lock over devlink_*() APIs and by moving devlink_register()
to be last command in setup_nic_devices().
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
.../net/ethernet/cavium/liquidio/lio_main.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
@@ -1279,6 +1279,14 @@ static int liquidio_stop_nic_module(struct octeon_device *oct)structlio*lio;dev_dbg(&oct->pci_dev->dev,"Stopping network interfaces\n");+device_lock(&oct->pci_dev->dev);+if(oct->devlink){+devlink_unregister(oct->devlink);+devlink_free(oct->devlink);+oct->devlink=NULL;+}+device_unlock(&oct->pci_dev->dev);+if(!oct->ifcount){dev_err(&oct->pci_dev->dev,"Init for Octeon was not completed\n");return1;
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:23:44
From: Leon Romanovsky <leonro@nvidia.com>
This change prevents from users to access device before devlink is fully
configured. This change allows us to delete call to devlink_params_publish()
and impossible check during unregister flow.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
.../ethernet/marvell/octeontx2/af/rvu_devlink.c | 10 ++--------
.../ethernet/marvell/octeontx2/nic/otx2_devlink.c | 15 +++------------
2 files changed, 5 insertions(+), 20 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:23:50
From: Leon Romanovsky <leonro@nvidia.com>
Separate devlink registrations and traps registrations so devlink will
be registered when driver is fully initialized.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
.../marvell/prestera/prestera_devlink.c | 29 ++++---------------
.../marvell/prestera/prestera_devlink.h | 4 ++-
.../ethernet/marvell/prestera/prestera_main.c | 8 +++--
3 files changed, 14 insertions(+), 27 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:23:56
From: Leon Romanovsky <leonro@nvidia.com>
Move devlink_registration routine to be the last command, when the
device is fully initialized.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
@@ -4493,6 +4491,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)dev_warn(dev,"RDMA is not supported on this device\n");}+ice_devlink_register(pf);return0;err_init_aux_unroll:
@@ -4629,7 +4628,6 @@ static void ice_remove(struct pci_dev *pdev)ice_deinit_pf(pf);ice_devlink_destroy_regions(pf);ice_deinit_hw(&pf->hw);-ice_devlink_unregister(pf);/* Issue a PFR as part of the prescribed driver unload flow. Do not*doitviaice_schedule_reset()sincethereisnoneedtorebuild
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:24:00
From: Leon Romanovsky <leonro@nvidia.com>
Make sure that devlink is open to receive user input when all
parameters are initialized.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/ethernet/mellanox/mlxsw/core.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
@@ -2080,8 +2075,10 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,{structdevlink*devlink=priv_to_devlink(mlxsw_core);-if(!reload)+if(!reload){devlink_reload_disable(devlink);+devlink_unregister(devlink);+}if(devlink_is_reload_failed(devlink)){if(!reload)/* Only the parts that were not de-initialized in the
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:24:11
From: Leon Romanovsky <leonro@nvidia.com>
Refactor the code to make sure that devlink_register() is the last
command during initialization stage.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx4/main.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:24:22
From: Leon Romanovsky <leonro@nvidia.com>
Open user space access to the devlink after driver is probed.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/ethernet/netronome/nfp/devlink_param.c | 9 ++-------
drivers/net/ethernet/netronome/nfp/nfp_net_main.c | 5 ++---
2 files changed, 4 insertions(+), 10 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:24:26
From: Leon Romanovsky <leonro@nvidia.com>
This change prevents from users to access device before devlink is
fully configured.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/ethernet/pensando/ionic/ionic_devlink.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:24:29
From: Leon Romanovsky <leonro@nvidia.com>
Open access to the devlink interface when the driver fully initialized.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/ethernet/mscc/ocelot_vsc7514.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
@@ -2429,7 +2429,6 @@ static int am65_cpsw_nuss_register_devlink(struct am65_cpsw_common *common)dl_priv=devlink_priv(common->devlink);dl_priv->common=common;-devlink_register(common->devlink);/* Provide devlink hook to switch mode when multiple external ports*arepresentNUSSswitchdevdriverisenabled.*/
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:24:41
From: Leon Romanovsky <leonro@nvidia.com>
This change prevents from users to access device before devlink is
fully configured.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/netdevsim/dev.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:24:43
From: Leon Romanovsky <leonro@nvidia.com>
This change prevents from users to access device before devlink is
fully configured.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/ethernet/qlogic/qed/qed_devlink.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:24:50
From: Leon Romanovsky <leonro@nvidia.com>
This change prevents from users to access device before devlink is
fully configured. Indirectly this change fixes the commit mentioned
below where devlink_unregister() was prematurely removed.
Fixes: db4278c55fa5 ("devlink: Make devlink_register to be void")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/wwan/iosm/iosm_ipc_devlink.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:24:54
From: Leon Romanovsky <leonro@nvidia.com>
This change prevents from users to access device before devlink is
fully configured.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/staging/qlge/qlge_main.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
@@ -4614,10 +4614,9 @@ static int qlge_probe(struct pci_dev *pdev,gotonetdev_free;}-devlink_register(devlink);err=qlge_health_create_reporters(qdev);if(err)-gotodevlink_unregister;+gotonetdev_free;/* Start up the timer to trigger EEH if*thebusgoesdead
@@ -4628,10 +4627,9 @@ static int qlge_probe(struct pci_dev *pdev,qlge_display_dev_info(ndev);atomic_set(&qdev->lb_count,0);cards_found++;+devlink_register(devlink);return0;-devlink_unregister:-devlink_unregister(devlink);netdev_free:free_netdev(ndev);devlink_free:
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:24:57
From: Leon Romanovsky <leonro@nvidia.com>
This change prevents from users to access device before devlink
is fully configured.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
net/dsa/dsa2.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
@@ -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()canregisterregionsetc,againsttheports*/
@@ -874,8 +873,6 @@ static int dsa_switch_setup(struct dsa_switch *ds)if(err)gototeardown;-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);return0;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;returnerr;
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-25 11:24:59
From: Leon Romanovsky <leonro@nvidia.com>
This change prevents from users to access device before devlink is
fully configured.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/ptp/ptp_ocp.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
On Sat, Sep 25, 2021 at 02:22:51PM +0300, Leon Romanovsky wrote:
From: Leon Romanovsky <leonro@nvidia.com>
Make sure that devlink is open to receive user input when all
parameters are initialized.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-27 11:53:32
On Mon, Sep 27, 2021 at 10:39:24AM +0200, Simon Horman wrote:
On Sat, Sep 25, 2021 at 02:22:53PM +0300, Leon Romanovsky wrote:
quoted
From: Leon Romanovsky <leonro@nvidia.com>
Open user space access to the devlink after driver is probed.
Hi Leon,
I think a description of why is warranted here.
After devlink_register(), users can send GET and SET netlink commands to
the uninitialized driver. In some cases, nothing will happen, but not in
all and hard to prove that ALL drivers are safe with such early access.
It means that local users can (in theory for some and in practice for
others) crash the system (or leverage permissions) with early devlink_register()
by accessing internal to driver pointers that are not set yet.
Like I said in the commit message, I'm not fixing all drivers.
https://lore.kernel.org/netdev/cover.1632565508.git.leonro@nvidia.com/T/#m063eb4e67389bafcc3b3ddc07197bf43181b7209
Because some of the driver authors made a wonderful job to obfuscate their
driver and write completely unmanageable code.
I do move devlink_register() to be last devlink command for all drivers,
to allow me to clean devlink core locking and API in next series.
This series should raise your eyebrow and trigger a question: "is my
driver vulnerable too?". And the answer will depend on devlink_register()
position in the .probe() call.
Thanks
quoted
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
From: Simon Horman <hidden> Date: 2021-09-27 12:21:20
On Mon, Sep 27, 2021 at 02:53:24PM +0300, Leon Romanovsky wrote:
On Mon, Sep 27, 2021 at 10:39:24AM +0200, Simon Horman wrote:
quoted
On Sat, Sep 25, 2021 at 02:22:53PM +0300, Leon Romanovsky wrote:
quoted
From: Leon Romanovsky <leonro@nvidia.com>
Open user space access to the devlink after driver is probed.
Hi Leon,
I think a description of why is warranted here.
After devlink_register(), users can send GET and SET netlink commands to
the uninitialized driver. In some cases, nothing will happen, but not in
all and hard to prove that ALL drivers are safe with such early access.
It means that local users can (in theory for some and in practice for
others) crash the system (or leverage permissions) with early devlink_register()
by accessing internal to driver pointers that are not set yet.
Like I said in the commit message, I'm not fixing all drivers.
https://lore.kernel.org/netdev/cover.1632565508.git.leonro@nvidia.com/T/#m063eb4e67389bafcc3b3ddc07197bf43181b7209
Because some of the driver authors made a wonderful job to obfuscate their
driver and write completely unmanageable code.
I do move devlink_register() to be last devlink command for all drivers,
to allow me to clean devlink core locking and API in next series.
This series should raise your eyebrow and trigger a question: "is my
driver vulnerable too?". And the answer will depend on devlink_register()
position in the .probe() call.
Thanks
Thanks for the explanation.
And thanks for taking time to update the NFP driver.
quoted
quoted
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
From: Shannon Nelson <hidden> Date: 2021-09-27 16:07:13
On 9/25/21 4:22 AM, Leon Romanovsky wrote:
From: Leon Romanovsky <leonro@nvidia.com>
This change prevents from users to access device before devlink is
fully configured.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Thanks for the work,
Acked-by: Shannon Nelson <redacted>
From: Leon Romanovsky <leonro@nvidia.com>
Move devlink_registration routine to be the last command, when the
device is fully initialized.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
For the ice driver, thanks for fixing it!
Reviewed-by: Jesse Brandeburg <redacted>
From: Eric Dumazet <hidden> Date: 2021-09-28 02:49:32
On 9/25/21 4:22 AM, Leon Romanovsky wrote:
quoted hunk
From: Leon Romanovsky <leonro@nvidia.com>
The devlink core code notified users about add/remove objects without
relation if this object can be accessible or not. In this patch we unify
such user visible notifications in one place.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
net/core/devlink.c | 107 +++++++++++++++++++++++++++++++++++++++------
1 file changed, 93 insertions(+), 14 deletions(-)
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-28 07:35:07
On Mon, Sep 27, 2021 at 07:49:18PM -0700, Eric Dumazet wrote:
On 9/25/21 4:22 AM, Leon Romanovsky wrote:
quoted
From: Leon Romanovsky <leonro@nvidia.com>
The devlink core code notified users about add/remove objects without
relation if this object can be accessible or not. In this patch we unify
such user visible notifications in one place.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
net/core/devlink.c | 107 +++++++++++++++++++++++++++++++++++++++------
1 file changed, 93 insertions(+), 14 deletions(-)
Thanks for the report, it is combination of my rebase error and missing
loop of devlink_rate_notify in the devlink_notify_register() function.
I'll fix and resubmit.
Thanks
From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2021-09-29 13:02:35
Hi Leon,
On Sat, Sep 25, 2021 at 02:23:01PM +0300, Leon Romanovsky wrote:
quoted hunk
From: Leon Romanovsky <leonro@nvidia.com>
This change prevents from users to access device before devlink
is fully configured.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
net/dsa/dsa2.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
@@ -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()canregisterregionsetc,againsttheports*/
@@ -874,8 +873,6 @@ static int dsa_switch_setup(struct dsa_switch *ds)if(err)gototeardown;-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);return0;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;returnerr;
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-29 13:07:56
On Wed, Sep 29, 2021 at 01:02:27PM +0000, Vladimir Oltean wrote:
Hi Leon,
On Sat, Sep 25, 2021 at 02:23:01PM +0300, Leon Romanovsky wrote:
quoted
From: Leon Romanovsky <leonro@nvidia.com>
This change prevents from users to access device before devlink
is fully configured.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
net/dsa/dsa2.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
@@ -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()canregisterregionsetc,againsttheports*/
@@ -874,8 +873,6 @@ static int dsa_switch_setup(struct dsa_switch *ds)if(err)gototeardown;-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);return0;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;returnerr;