Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Stefan Metzmacher" <metze@samba.org>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net-next 2/3] net/mlx5: support the enable_rdma devlink param in runtime cmode
Date: Tue, 01 Dec 2026 22:10:39 +0000	[thread overview]
Message-ID: <sashiko-outbox-244321@kernel.org> (raw)
In-Reply-To: <1541f82d368a2a364c6acf1fc1334c2a5307d8a3.1796076486.git.metze@samba.org>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] net/mlx5: is_ib_enabled() blocks RoCE LAG RDMA creation when
  disabled on dev0
- [Medium] net/mlx5: unlocked and misordered LAG checks in
  mlx5_devlink_enable_rdma_set()
- [Medium] net/mlx5: mlx5_devlink_enable_rdma_set() fails to reject
  multiport master
--

commit 40c38becdfb875eecd41d559b9c2709d9abe8e93
Author: Stefan Metzmacher <metze@samba.org>

net/mlx5: support the enable_rdma devlink param in runtime cmode

This commit adds runtime cmode support to the enable_rdma devlink
parameter so that a function's RDMA auxiliary device can be unplugged or
plugged without reloading the function or tearing down the netdev.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> index df2e3ad01819f..a9aa12dabb70a 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> @@ -193,7 +193,7 @@ bool mlx5_rdma_supported(struct mlx5_core_dev *dev)
>  	return true;
>  }
>  
> -static bool is_ib_enabled(struct mlx5_core_dev *dev)
> +bool mlx5_rdma_driverinit_enabled(struct mlx5_core_dev *dev)
>  {
>  	union devlink_param_value val;
>  	int err;
> @@ -204,6 +204,14 @@ static bool is_ib_enabled(struct mlx5_core_dev *dev)
>  	return err ? false : val.vbool;
>  }
>  
> +static bool is_ib_enabled(struct mlx5_core_dev *dev)
> +{
> +	if (dev->priv.rdma_runtime_disabled)
> +		return false;
> +
> +	return mlx5_rdma_driverinit_enabled(dev);
> +}
> +

[Severity: Medium]
Does checking dev->priv.rdma_runtime_disabled unconditionally in
is_ib_enabled() prevent the RoCE LAG RDMA device from being created if
enable_rdma was runtime-disabled on the primary LAG function (dev0) before
bonding?

Although the commit message and documentation state that a RoCE LAG
activated later is not affected by the runtime value of its functions, RoCE
LAG creates its bonded RDMA auxiliary device using MLX5_INTERFACE_PROTOCOL_IB
on dev0 via mlx5_do_bond() -> mlx5_lag_rescan_dev_locked(ldev, dev0, true)
-> mlx5_rescan_drivers_locked(dev0) -> add_drivers(dev0).  When
dev0->priv.rdma_runtime_disabled is true, is_ib_enabled(dev0) returns false
and add_drivers(dev0) skips creating the RoCE LAG RDMA device, while
mlx5_do_bond() still calls mlx5_nic_vport_enable_roce() on the secondary
function's NIC vport so incoming RoCEv2 packets on the secondary port are
consumed by the NIC with no mlx5_ib driver bound:

drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c:mlx5_do_bond() {
    ...
			if (roce_lag) {
				struct mlx5_core_dev *dev;

				mlx5_lag_rescan_dev_locked(ldev, dev0, true);
				mlx5_ldev_for_each(i, 0, ldev) {
					if (i == idx)
						continue;
					dev = mlx5_lag_fn(ldev, i)->dev;
					if (mlx5_get_roce_state(dev))
						mlx5_nic_vport_enable_roce(dev);
				}
			}
    ...
}

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
> index 30a97e48dda7b..94bab50cf22c6 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
[ ... ]
> @@ -793,9 +796,72 @@ static int mlx5_devlink_enable_rdma_validate(struct devlink *devlink, u32 id,
>  	return 0;
>  }
[ ... ]
> +static int mlx5_devlink_enable_rdma_set(struct devlink *devlink, u32 id,
> +					struct devlink_param_gset_ctx *ctx,
> +					struct netlink_ext_ack *extack)
> +{
> +	struct mlx5_core_dev *dev = devlink_priv(devlink);
> +	bool disable = !ctx->val.vbool;
> +	int err;
> +
> +	if (!disable && !mlx5_rdma_driverinit_enabled(dev)) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "RDMA is disabled in driverinit cmode, enable it there and reload");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	if (dev->priv.rdma_runtime_disabled == disable)
> +		return 0;
> +	if (!mlx5_rdma_supported(dev)) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "RDMA can't be changed at runtime in switchdev or multiport mode");
> +		return -EOPNOTSUPP;
> +	}

[Severity: Medium]
Does relying on !mlx5_rdma_supported(dev) fail to reject multiport master
devices?

is_mp_supported(dev) only checks mlx5_core_is_mp_slave(dev), and
is_ib_rep_supported(dev) returns false when mlx5_core_mp_enabled(dev) is
true, so mlx5_rdma_supported(dev) returns true on a multiport master
(mlx5_core_is_mp_master(dev)) and allows runtime cmode to unplug the shared
multiport master RDMA device.  In addition, when setting enable_rdma to
true while !mlx5_rdma_supported(dev), mlx5_devlink_enable_rdma_validate()
runs before mlx5_devlink_enable_rdma_set() and returns -EOPNOTSUPP without
setting extack.

> +	if (mlx5_lag_is_active(dev)) {
> +		NL_SET_ERR_MSG_MOD(extack, "RDMA can't be changed at runtime while LAG is active");
> +		return -EBUSY;
> +	}
> +
> +	mlx5_devcom_comp_lock(dev->priv.hca_devcom_comp);

[Severity: Medium]
Can checking mlx5_rdma_supported(dev) and mlx5_lag_is_active(dev) before
acquiring dev->priv.hca_devcom_comp race with asynchronous LAG activation,
and does checking !mlx5_rdma_supported(dev) before mlx5_lag_is_active(dev)
return the wrong error on secondary LAG ports?

mlx5_do_bond_work() runs on ldev->wq without devl_lock and serializes LAG
state transitions and MLX5_PRIV_FLAGS_DISABLE_IB_ADEV updates with
hca_devcom_comp:

CPU0                                  CPU1 (ldev->wq)
mlx5_devlink_enable_rdma_set()
  mlx5_lag_is_active(dev0) -> false
                                      mlx5_do_bond_work()
                                        mlx5_devcom_comp_trylock(...)
                                        mlx5_do_bond()
                                          mlx5_activate_lag()
                                          mlx5_lag_rescan_dev_locked(dev0)
                                        mlx5_devcom_comp_unlock(...)
  mlx5_devcom_comp_lock(...)
  dev0->priv.rdma_runtime_disabled = true
  mlx5_rescan_drivers_locked(dev0)
    delete_drivers(dev0)              <-- unplugs active RoCE LAG RDMA dev

Also, while LAG is active, MLX5_PRIV_FLAGS_DISABLE_IB_ADEV is set on
non-primary LAG functions (and on all functions in Shared-FDB LAG), causing
mlx5_rdma_supported(dev) to return false.  Because !mlx5_rdma_supported(dev)
is checked before mlx5_lag_is_active(dev), changing enable_rdma at runtime
on a non-primary LAG port while LAG is active fails with -EOPNOTSUPP and the
switchdev/multiport extack message instead of -EBUSY.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796076486.git.metze@samba.org?part=2

  reply	other threads:[~2026-12-01 22:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 22:09 [PATCH net-next 0/3] devlink: support the enable_rdma param in runtime cmode for cxgb4, mlx5 and ice Stefan Metzmacher
2026-11-30 22:09 ` [PATCH net-next 1/3] cxgb4: support the enable_rdma devlink param in runtime cmode Stefan Metzmacher
2026-12-01 22:10   ` sashiko-bot
2026-11-30 22:09 ` [PATCH net-next 2/3] net/mlx5: " Stefan Metzmacher
2026-12-01 22:10   ` sashiko-bot [this message]
2026-11-30 22:10 ` [PATCH net-next 3/3] ice: " Stefan Metzmacher
2026-12-01 13:36   ` Przemek Kitszel
2026-12-01 22:10   ` sashiko-bot

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=sashiko-outbox-244321@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=metze@samba.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox