Subject: Re: [PATCH net v2] devlink: Delay health recover notification until devlink registered

From: Jakub Kicinski <[email-masked]>
Date: Thu, 10 Aug 2023 10:33:00 -0700

On Wed, 9 Aug 2023 23:35:21 +0300 Shay Drory wrote:
> From one side, devl_register() is done last in device initialization
> phase, in order to expose devlink to the user only when device is
> ready. From second side, it is valid to create health reporters
> during device initialization, in order to recover and/or notify the
> user.
> As a result, a health recover can be invoked before devl_register().
> However, invoking health recover before devl_register() triggers a
> WARN_ON.

My comment on v1 wasn't clear enough, I guess.

What I was trying to get across is that because drivers can take
devl_lock(), devl_register() does not have to be last.

AFAIU your driver does:

  devlink_port_health_reporter_create()
  ...
  devlink_register()

why not change it to do:

  devl_lock()
  devl_register()
  devl_port_health_reporter_create()
  ...
  devl_unlock() # until unlock user space can't access the instance

?