From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796327101; b=X9mq8EsJSqA0WWuEwno1MWrcs9jOTz8Z5KJEnXZmRBvMftD115Hon5TUnuzQ/O5CiJZ7 kqVsvTUW3DO27OplYRllbzgLw3W2OsmOIfdSmo2LiL4OB23L1NDApaaWm4E+OZftx8eYL +by0EypdOwmwud+qaIVOQkDM2ga6NNUE1KLmpHrZSH66HOCeSzri8X1mCmfhVa9Y0e+ub zx5r6xYKwmz7Nap67j7znBLFSKqLtC7mZrINE7JnJb/c09+foV8K5+0M1HpZTha5b7dnN xLJh+P2cNgxXSdxDz+EAjjRkWyW70qB+A9II/ZqRl/rWdnsyshuW5JOMVP99/iL3yOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796327101; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=3xONhX0krX8eN0U/mdkTr+sh8HYnrWv0P0nzU1kXwGI=; b=IDsbI2tpk6bM+wBwJcImUsNaIkDBdN1vukHjKbUu7vZD0Cp0uAdbKmolDvu15BbTtNvR G4aIgSFhOQf+ui3JInmlaUjK2UPtOlhJv7LdxLK3f02oglbm7XkGMQqrfzDdMgIMpYnG2 ZXo/KfkdWlJgfCk4kKR30I++WgkYm8Toh+ASUorxJPjVtu/xi4Nm8OkWC1Tw/Ur0hoCfU b3pbCiq+hDLApemmbKXRJEiRKPqCk2mmHD7IzsnlkrvcGlS980Y+blUGYtOtZHJG+ZT09 FsSWH9OhdHphtEkpeVMbZZAhg2YNNPI80/kgDCSpfT8MJvleZHsU7WFePDv5BDk6u1g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OYeTr9iU; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1CB3606A32F; Thu, 3 Dec 2026 19:45:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OYeTr9iU Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEC2C1F000C2; Thu, 3 Dec 2026 19:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796327101; bh=3xONhX0krX8eN0U/mdkTr+sh8HYnrWv0P0nzU1kXwGI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=OYeTr9iUUESxcPUGGdXHlGsGzLYSKIiYwYrcwH7HRYyA/ADw5MLR4ak4iYcwYhJ2q WqfD4TlrpqQW4P0lqCXUJghdQ8+acyggvFyonDdBqNhg162bLoZZgUiEC5k2+b1OCO gq54nI5Ah1lK6F80DuCUkKuAgtxjSdUYmaqcft0wRRBU5TJkXWC/PNLrKYfaq8oUzE t0wrg0bdQwnIvy18hokNdkTRLd5GF+3kykql+1RF/9I7e8ZRlLHOwVTSVtymuFh2R3 xkXOUrWJiDNE86WLI4oloi8WShiFgktBHgYFnkOyGEGARlRUYE7uvf7Fn4f1yxPNpi 0vEuR3WtxQJwg== Subject: Re: [PATCH net] net/mlx5: Serialize command interface flush From: netdev-bot+sashiko@kernel.org To: tariqt@nvidia.com Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, willemb@google.com, gal@nvidia.com, leon@kernel.org, linux-rdma@vger.kernel.org, mbloch@nvidia.com, moshe@nvidia.com, saeedm@nvidia.com, shayd@nvidia.com, udar@nvidia.com Date: Thu, 03 Dec 2026 19:45:00 +0000 Message-ID: <179632710033.3146.5432425460925812356@kernel.org> In-Reply-To: <20261202194338.3593396-1-tariqt@nvidia.com> References: <20261202194338.3593396-1-tariqt@nvidia.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The patch only partly closes the permit-splitting deadlock it targets. -- net/mlx5: Serialize command interface flush This commit adds a mutex, cmd->flush_lock, around mlx5_cmd_flush(). Two concurrent flushes can split the cmd->vars.sem permits and spin forever, and the mutex prevents that. The scenario given is the fatal health work calling enter_error_state() without intf_state_mutex while the PCI error handler enters error state. > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c > index 84583dc5eb1c0..4874c81b642a8 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c > @@ -1876,6 +1876,7 @@ void mlx5_cmd_flush(struct mlx5_core_dev *dev) > struct mlx5_cmd *cmd = &dev->cmd; > int i; > > + mutex_lock(&cmd->flush_lock); > for (i = 0; i < cmd->vars.max_reg_cmds; i++) { > while (down_trylock(&cmd->vars.sem)) { > mlx5_cmd_trigger_completions(dev); [Severity: High] Does this cover every function that collects all the permits? Two other functions in cmd.c also take every cmd->vars.sem permit one at a time, and they do not take flush_lock: drivers/net/ethernet/mellanox/mlx5/core/cmd.c:mlx5_cmd_allowed_opcode() { ... for (i = 0; i < cmd->vars.max_reg_cmds; i++) down(&cmd->vars.sem); down(&cmd->vars.pages_sem); ... } mlx5_cmd_change_mod() has the same loop. It is reached through mlx5_cmd_use_events() and mlx5_cmd_use_polling(). If one of these runs at the same time as mlx5_cmd_flush(), the two can still split the max_reg_cmds permits. The collector would then sleep in down() forever. mlx5_cmd_flush() would spin in its down_trylock() loop. Calling mlx5_cmd_trigger_completions() there would not help. No regular command slot can be allocated while the two collectors hold every permit, so ~bitmask & MLX5_CMD_MASK is 0 and nothing is completed. This looks reachable in the scenario from the commit message. The fatal health work drops intf_state_mutex before it flushes: mlx5_fw_fatal_reporter_err_work() mutex_unlock(&dev->intf_state_mutex); enter_error_state(dev, false); mlx5_cmd_flush() mlx5_pci_err_detected() calls mlx5_unload_one() before mlx5_drain_health_wq(): mlx5_pci_err_detected() mlx5_enter_error_state(dev, false); mlx5_error_sw_reset(dev); mlx5_unload_one(dev, false); mlx5_drain_health_wq(dev); The unload path reaches both collectors: mlx5_unload_one()->mlx5_unload()->mlx5_eq_table_destroy()->destroy_async_eqs() mlx5_cmd_allowed_opcode(dev, MLX5_CMD_OP_DESTROY_EQ); mlx5_cmd_use_polling(dev); mlx5_cmd_change_mod() create_async_eqs() on the load path calls mlx5_cmd_allowed_opcode() and mlx5_cmd_use_events() in the same way. If this happens, the PCI error handler or the load/unload thread sleeps forever in an uninterruptible down() while holding devl_lock and intf_state_mutex. The health kworker keeps spinning in mlx5_cmd_flush(). Should mlx5_cmd_allowed_opcode() and mlx5_cmd_change_mod() take the same mutex? If so, a more general name than flush_lock would fit better. The comment in struct mlx5_cmd in include/linux/mlx5/driver.h ("serialize command interface flush") would need updating as well. > cond_resched(); [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202194338.3593396-1-tariqt%40nvidia.com