From: Mark Bloch <mbloch@nvidia.com>
To: Paolo Abeni <pabeni@redhat.com>, Jiri Pirko <jiri@resnulli.us>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH net-next V4 4/6] devlink: Apply eswitch mode boot defaults
Date: Fri, 3 Jul 2026 21:32:14 +0300 [thread overview]
Message-ID: <9bd07013-0d59-43a9-a5c2-0bbb8fa6a47b@nvidia.com> (raw)
In-Reply-To: <b8ff6104-790e-441f-a095-d50843d241c4@redhat.com>
On 02/07/2026 10:41, Paolo Abeni wrote:
> On 6/29/26 8:20 PM, Mark Bloch wrote:
>> Apply parsed devlink_eswitch_mode= defaults after devlink registration
>> and after successful reload.
>>
>> devl_register() may still be called before the device is ready for an
>> eswitch mode change, so keep a per-devlink delayed work item and pending
>> flag for the registration path. Registration queues the work, and the
>> worker tries to take the devlink instance lock.
>>
>> If the lock is busy, the worker requeues itself with a delay.
>>
>> For successful reloads that performed DRIVER_REINIT, devlink_reload()
>> already holds the devlink instance lock and the driver has completed
>> reload_up(). Clear pending work and apply the default directly from the
>> reload path instead of queueing work.
>>
>> If a user sets eswitch mode through netlink before the pending
>> registration work runs, clear the pending flag so the queued default does
>> not override that user request. Cancel pending default apply work when
>> freeing the devlink instance.
>>
>> Signed-off-by: Mark Bloch <mbloch@nvidia.com>
>> ---
>> net/devlink/core.c | 198 +++++++++++++++++++++++++++++++-----
>> net/devlink/dev.c | 6 ++
>> net/devlink/devl_internal.h | 5 +
>> 3 files changed, 182 insertions(+), 27 deletions(-)
>>
>> diff --git a/net/devlink/core.c b/net/devlink/core.c
>> index 5126509a9c4e..998e4ffd5dce 100644
>> --- a/net/devlink/core.c
>> +++ b/net/devlink/core.c
>> @@ -5,6 +5,7 @@
>> */
>>
>> #include <linux/init.h>
>> +#include <linux/jiffies.h>
>> #include <linux/list.h>
>> #include <linux/slab.h>
>> #include <linux/string.h>
>> @@ -22,8 +23,12 @@ DEFINE_XARRAY_FLAGS(devlinks, XA_FLAGS_ALLOC);
>>
>> static char *devlink_default_esw_mode_param;
>> static bool devlink_default_esw_mode_match_all;
>> +static bool devlink_default_esw_mode_enabled;
>> static enum devlink_eswitch_mode devlink_default_esw_mode;
>> static LIST_HEAD(devlink_default_esw_mode_nodes);
>> +static struct workqueue_struct *devlink_default_esw_mode_wq;
>> +
>> +#define DEVLINK_DEFAULT_ESW_MODE_APPLY_DELAY msecs_to_jiffies(100)
>>
>> struct devlink_default_esw_mode_node {
>> struct list_head list;
>> @@ -166,6 +171,7 @@ static void __init devlink_default_esw_mode_nodes_clear(void)
>> }
>>
>> devlink_default_esw_mode_match_all = false;
>> + devlink_default_esw_mode_enabled = false;
>> }
>>
>> static int __init devlink_default_esw_mode_parse(char *str)
>> @@ -192,14 +198,113 @@ static int __init devlink_default_esw_mode_parse(char *str)
>> return err;
>>
>> err = devlink_default_esw_mode_handles_parse(handles);
>> - if (err)
>> + if (err) {
>> devlink_default_esw_mode_nodes_clear();
>> - else
>> + } else {
>> devlink_default_esw_mode = esw_mode;
>> + devlink_default_esw_mode_enabled = true;
>> + }
>>
>> return err;
>> }
>>
>> +static bool devlink_default_esw_mode_match(struct devlink *devlink)
>> +{
>> + const char *bus_name = devlink_bus_name(devlink);
>> + const char *dev_name = devlink_dev_name(devlink);
>> + struct devlink_default_esw_mode_node *node;
>> +
>> + if (devlink_default_esw_mode_match_all)
>> + return true;
>> +
>> + node = devlink_default_esw_mode_node_find(bus_name, dev_name);
>> + return !!node;
>> +}
>> +
>> +void devlink_default_esw_mode_apply(struct devlink *devlink)
>> +{
>> + const struct devlink_ops *ops = devlink->ops;
>> + int err;
>> +
>> + devl_assert_locked(devlink);
>> +
>> + if (!devlink_default_esw_mode_match(devlink))
>> + return;
>> +
>> + if (!ops->eswitch_mode_set) {
>> + if (!devlink_default_esw_mode_match_all)
>> + devl_warn(devlink,
>> + "devlink_eswitch_mode= selected this device but eswitch mode setting is not supported\n");
>
> Not a very strong opinion on my side, but I *think* it would be more
> consistent to emit this warning even for devlink_default_esw_mode_match_all
>
I kept it only for the explicit handle case intentionally.
With "*" most devlink instances are not expected
to support eswitch mode. In the current tree I see 9 drivers
that do, and many more devlink users without it.
So warning for every unsupported instance in the "*" case would be noisy
and would look like errors for devices this knob was never meant for.
Mark
> /P
>
next prev parent reply other threads:[~2026-07-03 18:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 18:20 [PATCH net-next V4 0/6] evlink: Add boot-time eswitch mode defaults Mark Bloch
2026-06-29 18:20 ` [PATCH net-next V4 1/6] net/mlx5: Clear FW reset-in-progress bit before reload Mark Bloch
2026-06-29 18:20 ` [PATCH net-next V4 2/6] devlink: Factor out eswitch mode setting Mark Bloch
2026-06-29 18:20 ` [PATCH net-next V4 3/6] devlink: Parse eswitch mode boot defaults Mark Bloch
2026-07-01 9:38 ` Jiri Pirko
2026-07-01 12:55 ` Mark Bloch
2026-07-01 13:14 ` Mark Bloch
2026-06-29 18:20 ` [PATCH net-next V4 4/6] devlink: Apply " Mark Bloch
2026-07-01 9:48 ` Jiri Pirko
2026-07-01 12:57 ` Mark Bloch
2026-07-01 14:09 ` Jiri Pirko
2026-07-01 17:42 ` Mark Bloch
2026-07-02 7:52 ` Jiri Pirko
2026-07-03 18:27 ` Mark Bloch
2026-07-07 12:39 ` Jiri Pirko
2026-07-02 7:41 ` Paolo Abeni
2026-07-03 18:32 ` Mark Bloch [this message]
2026-06-29 18:21 ` [PATCH net-next V4 5/6] devlink: Add API to apply eswitch mode boot default Mark Bloch
2026-06-29 18:21 ` [PATCH net-next V4 6/6] net/mlx5: Apply devlink eswitch mode boot default on probe Mark Bloch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9bd07013-0d59-43a9-a5c2-0bbb8fa6a47b@nvidia.com \
--to=mbloch@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=skhan@linuxfoundation.org \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.