Re: [PATCH net-next 7/9] devlink: allow registering parameters after the instance
From: Jiri Pirko <jiri@resnulli.us>
Date: 2023-01-06 12:57:36
Fri, Jan 06, 2023 at 07:34:00AM CET, kuba@kernel.org wrote:
quoted hunk ↗ jump to hunk
It's most natural to register the instance first and then its subobjects. Now that we can use the instance lock to protect the atomicity of all init - it should also be safe. Signed-off-by: Jakub Kicinski <kuba@kernel.org> --- net/devlink/leftover.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c index 491f821c8b77..1e23b2da78cc 100644 --- a/net/devlink/leftover.c +++ b/net/devlink/leftover.c@@ -5263,7 +5263,13 @@ static void devlink_param_notify(struct devlink *devlink,WARN_ON(cmd != DEVLINK_CMD_PARAM_NEW && cmd != DEVLINK_CMD_PARAM_DEL && cmd != DEVLINK_CMD_PORT_PARAM_NEW && cmd != DEVLINK_CMD_PORT_PARAM_DEL); - ASSERT_DEVLINK_REGISTERED(devlink); + + /* devlink_notify_register() / devlink_notify_unregister() + * will replay the notifications if the params are added/removed + * outside of the lifetime of the instance. + */ + if (!devl_is_registered(devlink)) + return;
This helper would be nice to use on other places as well. Like devlink_trap_group_notify(), devlink_trap_notify() and others. I will take care of that in a follow-up. Reviewed-by: Jiri Pirko <redacted>