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, Tariq Toukan <tariqt@nvidia.com>,
Gal Pressman <gal@nvidia.com>,
Leon Romanovsky <leonro@nvidia.com>,
Moshe Shemesh <moshe@nvidia.com>
Subject: [net-next V2 10/15] net/mlx5: Return specific error code for timeout on wait_fw_init
Date: Wed, 31 Jan 2024 23:31:53 -0800 [thread overview]
Message-ID: <20240201073158.22103-11-saeed@kernel.org> (raw)
In-Reply-To: <20240201073158.22103-1-saeed@kernel.org>
From: Moshe Shemesh <moshe@nvidia.com>
The function wait_fw_init() returns same error code either if it breaks
waiting due to timeout or other reason. Thus, the function callers print
error message on timeout without checking error type.
Return different error code for different failure reason and print error
message accordingly on wait_fw_init().
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/main.c | 38 +++++++++----------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index bccf6e53556c..c2593625c09a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -187,31 +187,36 @@ static struct mlx5_profile profile[] = {
};
static int wait_fw_init(struct mlx5_core_dev *dev, u32 max_wait_mili,
- u32 warn_time_mili)
+ u32 warn_time_mili, const char *init_state)
{
unsigned long warn = jiffies + msecs_to_jiffies(warn_time_mili);
unsigned long end = jiffies + msecs_to_jiffies(max_wait_mili);
u32 fw_initializing;
- int err = 0;
do {
fw_initializing = ioread32be(&dev->iseg->initializing);
if (!(fw_initializing >> 31))
break;
- if (time_after(jiffies, end) ||
- test_bit(MLX5_BREAK_FW_WAIT, &dev->intf_state)) {
- err = -EBUSY;
- break;
+ if (time_after(jiffies, end)) {
+ mlx5_core_err(dev, "Firmware over %u MS in %s state, aborting\n",
+ max_wait_mili, init_state);
+ return -ETIMEDOUT;
+ }
+ if (test_bit(MLX5_BREAK_FW_WAIT, &dev->intf_state)) {
+ mlx5_core_warn(dev, "device is being removed, stop waiting for FW %s\n",
+ init_state);
+ return -ENODEV;
}
if (warn_time_mili && time_after(jiffies, warn)) {
- mlx5_core_warn(dev, "Waiting for FW initialization, timeout abort in %ds (0x%x)\n",
- jiffies_to_msecs(end - warn) / 1000, fw_initializing);
+ mlx5_core_warn(dev, "Waiting for FW %s, timeout abort in %ds (0x%x)\n",
+ init_state, jiffies_to_msecs(end - warn) / 1000,
+ fw_initializing);
warn = jiffies + msecs_to_jiffies(warn_time_mili);
}
msleep(mlx5_tout_ms(dev, FW_PRE_INIT_WAIT));
} while (true);
- return err;
+ return 0;
}
static void mlx5_set_driver_version(struct mlx5_core_dev *dev)
@@ -1151,12 +1156,10 @@ static int mlx5_function_enable(struct mlx5_core_dev *dev, bool boot, u64 timeou
/* wait for firmware to accept initialization segments configurations
*/
err = wait_fw_init(dev, timeout,
- mlx5_tout_ms(dev, FW_PRE_INIT_WARN_MESSAGE_INTERVAL));
- if (err) {
- mlx5_core_err(dev, "Firmware over %llu MS in pre-initializing state, aborting\n",
- timeout);
+ mlx5_tout_ms(dev, FW_PRE_INIT_WARN_MESSAGE_INTERVAL),
+ "pre-initializing");
+ if (err)
return err;
- }
err = mlx5_cmd_enable(dev);
if (err) {
@@ -1166,12 +1169,9 @@ static int mlx5_function_enable(struct mlx5_core_dev *dev, bool boot, u64 timeou
mlx5_tout_query_iseg(dev);
- err = wait_fw_init(dev, mlx5_tout_ms(dev, FW_INIT), 0);
- if (err) {
- mlx5_core_err(dev, "Firmware over %llu MS in initializing state, aborting\n",
- mlx5_tout_ms(dev, FW_INIT));
+ err = wait_fw_init(dev, mlx5_tout_ms(dev, FW_INIT), 0, "initializing");
+ if (err)
goto err_cmd_cleanup;
- }
dev->caps.embedded_cpu = mlx5_read_embedded_cpu(dev);
mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_UP);
--
2.43.0
next prev parent reply other threads:[~2024-02-01 7:32 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 7:31 [pull request][net-next V2 00/15] mlx5 updates 2024-01-26 Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 01/15] xfrm: generalize xdo_dev_state_update_curlft to allow statistics update Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 02/15] xfrm: get global statistics from the offloaded device Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 03/15] net/mlx5e: Connect mlx5 IPsec statistics with XFRM core Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 04/15] net/mlx5e: Delete obsolete IPsec code Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 05/15] Documentation: Fix counter name of mlx5 vnic reporter Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 06/15] net/mlx5: Rename mlx5_sf_dev_remove Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 07/15] net/mlx5: remove fw_fatal reporter dump option for non PF Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 08/15] net/mlx5: remove fw " Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 09/15] net/mlx5: SF, Stop waiting for FW as teardown was called Saeed Mahameed
2024-02-01 7:31 ` Saeed Mahameed [this message]
2024-02-01 7:31 ` [net-next V2 11/15] net/mlx5: Remove initial segmentation duplicate definitions Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 12/15] net/mlx5: Change missing SyncE capability print to debug Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 13/15] net/mlx5: DR, Change SWS usage to debug fs seq_file interface Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 14/15] net/mlx5e: XSK, Exclude tailroom from non-linear SKBs memory calculations Saeed Mahameed
2024-02-01 7:31 ` [net-next V2 15/15] net/mlx5e: XDP, Exclude headroom and tailroom from " Saeed Mahameed
2024-02-02 5:02 ` [pull request][net-next V2 00/15] mlx5 updates 2024-01-26 Jakub Kicinski
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=20240201073158.22103-11-saeed@kernel.org \
--to=saeed@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.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 \
--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 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).