From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
netdev@vger.kernel.org, Moshe Shemesh <moshe@nvidia.com>,
Leon Romanovsky <leonro@nvidia.com>
Subject: [PATCH net-next 9/9] devlink: Hold the instance lock in port_new / port_del callbacks
Date: Mon, 11 Jul 2022 01:14:08 -0700 [thread overview]
Message-ID: <20220711081408.69452-10-saeed@kernel.org> (raw)
In-Reply-To: <20220711081408.69452-1-saeed@kernel.org>
From: Moshe Shemesh <moshe@nvidia.com>
Let the core take the devlink instance lock around port_new and port_del
callbacks and remove the now redundant locking in the only driver that
currently use them.
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c | 4 ----
net/core/devlink.c | 6 +-----
2 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c
index 2068c22ff367..7d955a4d9f14 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c
@@ -355,9 +355,7 @@ int mlx5_devlink_sf_port_new(struct devlink *devlink,
"Port add is only supported in eswitch switchdev mode or SF ports are disabled.");
return -EOPNOTSUPP;
}
- devl_lock(devlink);
err = mlx5_sf_add(dev, table, new_attr, extack, new_port_index);
- devl_unlock(devlink);
mlx5_sf_table_put(table);
return err;
}
@@ -402,9 +400,7 @@ int mlx5_devlink_sf_port_del(struct devlink *devlink, unsigned int port_index,
goto sf_err;
}
- devl_lock(devlink);
mlx5_esw_offloads_sf_vport_disable(esw, sf->hw_fn_id);
- devl_unlock(devlink);
mlx5_sf_id_erase(table, sf);
mutex_lock(&table->sf_state_lock);
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 970e5c2a52bd..e206cc90bec5 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -1712,7 +1712,7 @@ static int devlink_port_new_notifiy(struct devlink *devlink,
if (!msg)
return -ENOMEM;
- mutex_lock(&devlink->lock);
+ lockdep_assert_held(&devlink->lock);
devlink_port = devlink_port_get_by_index(devlink, port_index);
if (!devlink_port) {
err = -ENODEV;
@@ -1725,11 +1725,9 @@ static int devlink_port_new_notifiy(struct devlink *devlink,
goto out;
err = genlmsg_reply(msg, info);
- mutex_unlock(&devlink->lock);
return err;
out:
- mutex_unlock(&devlink->lock);
nlmsg_free(msg);
return err;
}
@@ -9067,13 +9065,11 @@ static const struct genl_small_ops devlink_nl_ops[] = {
.cmd = DEVLINK_CMD_PORT_NEW,
.doit = devlink_nl_cmd_port_new_doit,
.flags = GENL_ADMIN_PERM,
- .internal_flags = DEVLINK_NL_FLAG_NO_LOCK,
},
{
.cmd = DEVLINK_CMD_PORT_DEL,
.doit = devlink_nl_cmd_port_del_doit,
.flags = GENL_ADMIN_PERM,
- .internal_flags = DEVLINK_NL_FLAG_NO_LOCK,
},
{
.cmd = DEVLINK_CMD_LINECARD_GET,
--
2.36.1
next prev parent reply other threads:[~2022-07-11 8:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-11 8:13 [PATCH net-next 0/9] mlx5 devlink mutex removal part 1 Saeed Mahameed
2022-07-11 8:14 ` [PATCH net-next 1/9] net/mlx5: Remove devl_unlock from mlx5_eswtich_mode_callback_enter Saeed Mahameed
2022-07-11 8:14 ` [PATCH net-next 2/9] net/mlx5: Use devl_ API for rate nodes destroy Saeed Mahameed
2022-07-11 8:14 ` [PATCH net-next 3/9] devlink: Remove unused function devlink_rate_nodes_destroy Saeed Mahameed
2022-07-11 8:14 ` [PATCH net-next 4/9] net/mlx5: Use devl_ API in mlx5_esw_offloads_devlink_port_register Saeed Mahameed
2022-07-11 8:14 ` [PATCH net-next 5/9] net/mlx5: Use devl_ API in mlx5_esw_devlink_sf_port_register Saeed Mahameed
2022-07-11 8:14 ` [PATCH net-next 6/9] devlink: Remove unused functions devlink_rate_leaf_create/destroy Saeed Mahameed
2022-07-11 8:14 ` [PATCH net-next 7/9] net/mlx5: Use devl_ API in mlx5e_devlink_port_register Saeed Mahameed
2022-07-11 8:14 ` [PATCH net-next 8/9] net/mlx5: Remove devl_unlock from mlx5_devlink_eswitch_mode_set Saeed Mahameed
2022-07-11 8:14 ` Saeed Mahameed [this message]
2022-07-12 3:03 ` [PATCH net-next 0/9] mlx5 devlink mutex removal part 1 Jakub Kicinski
2022-07-12 8:50 ` patchwork-bot+netdevbpf
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=20220711081408.69452-10-saeed@kernel.org \
--to=saeed@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=leonro@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).