Subject: Re: [patch net-next 1/8] devlink: call devlink_port_register/unregister() on registered instance

From: Leon Romanovsky <[email-masked]>
Date: Tue, 6 Dec 2022 09:56:38 +0200

On Tue, Dec 06, 2022 at 08:41:36AM +0100, Jiri Pirko wrote:
> Tue, Dec 06, 2022 at 12:55:32AM CET, [email-masked] wrote:
> >On 12/5/22 7:22 AM, Jiri Pirko wrote:
> >> 
> >> From: Jiri Pirko <[email-masked]>
> >> 
> >> Change the drivers that use devlink_port_register/unregister() to call
> >> these functions only in case devlink is registered.
> >> 
> >> Signed-off-by: Jiri Pirko <[email-masked]>
> >> ---
> >> RFC->v1:
> >> - shortened patch subject
> >> ---
> >>   .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 29 ++++++++++---------
> >>   .../net/ethernet/freescale/dpaa2/dpaa2-eth.c  |  7 +++--
> >>   .../ethernet/fungible/funeth/funeth_main.c    | 17 +++++++----
> >>   drivers/net/ethernet/intel/ice/ice_main.c     | 21 ++++++++------
> >>   .../ethernet/marvell/prestera/prestera_main.c |  6 ++--
> >>   drivers/net/ethernet/mscc/ocelot_vsc7514.c    | 10 +++----
> >>   .../ethernet/pensando/ionic/ionic_devlink.c   |  6 ++--
> >>   drivers/net/ethernet/ti/am65-cpsw-nuss.c      |  7 +++--
> >>   8 files changed, 60 insertions(+), 43 deletions(-)
> >> 

<...>

> >I don't know about the rest of the drivers, but this seems to be the exact
> >opposite of what Leon did in this patch over a year ago:
> >https://lore.kernel.org/netdev/[email-masked]/
> 
> This patch did move for all objects, even for those where no issue
> existed. Ports are such.

Yeah, I was focused to move devlink_register() without any checks if
other devlink_* calls can be after it. The reason for that was desire
to make sure that we have devl_lock() on all netlink devlink calls.

Now, all commands are locked and we don't have commands which unlock
devlink internally and it is safe to move some devlink_* calls to be
after devlink_register() as long as they take devl_lock() and don't
mess with static devlink object data.

Thanks