Commit e3297246 authored by Eli Cohen's avatar Eli Cohen Committed by David S. Miller

net/mlx5_core: Wait for FW readiness on startup

On device initialization, wait till firmware indicates that that it is done
with initialization before proceeding to initialize the device.

Also update initialization segment layout to match driver/firmware
interface definitions.
Signed-off-by: default avatarEli Cohen <eli@mellanox.com>
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 89d44f0a
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/io-mapping.h> #include <linux/io-mapping.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/mlx5/driver.h> #include <linux/mlx5/driver.h>
#include <linux/mlx5/cq.h> #include <linux/mlx5/cq.h>
#include <linux/mlx5/qp.h> #include <linux/mlx5/qp.h>
...@@ -152,6 +153,25 @@ static struct mlx5_profile profile[] = { ...@@ -152,6 +153,25 @@ static struct mlx5_profile profile[] = {
}, },
}; };
#define FW_INIT_TIMEOUT_MILI 2000
#define FW_INIT_WAIT_MS 2
static int wait_fw_init(struct mlx5_core_dev *dev, u32 max_wait_mili)
{
unsigned long end = jiffies + msecs_to_jiffies(max_wait_mili);
int err = 0;
while (fw_initializing(dev)) {
if (time_after(jiffies, end)) {
err = -EBUSY;
break;
}
msleep(FW_INIT_WAIT_MS);
}
return err;
}
static int set_dma_caps(struct pci_dev *pdev) static int set_dma_caps(struct pci_dev *pdev)
{ {
int err; int err;
...@@ -913,6 +933,13 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv) ...@@ -913,6 +933,13 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
goto out_err; goto out_err;
} }
err = wait_fw_init(dev, FW_INIT_TIMEOUT_MILI);
if (err) {
dev_err(&dev->pdev->dev, "Firmware over %d MS in initializing state, aborting\n",
FW_INIT_TIMEOUT_MILI);
goto out_err;
}
mlx5_pagealloc_init(dev); mlx5_pagealloc_init(dev);
err = mlx5_core_enable_hca(dev); err = mlx5_core_enable_hca(dev);
......
...@@ -439,7 +439,8 @@ struct mlx5_init_seg { ...@@ -439,7 +439,8 @@ struct mlx5_init_seg {
__be32 cmdq_addr_h; __be32 cmdq_addr_h;
__be32 cmdq_addr_l_sz; __be32 cmdq_addr_l_sz;
__be32 cmd_dbell; __be32 cmd_dbell;
__be32 rsvd1[121]; __be32 rsvd1[120];
__be32 initializing;
struct health_buffer health; struct health_buffer health;
__be32 rsvd2[884]; __be32 rsvd2[884];
__be32 health_counter; __be32 health_counter;
......
...@@ -826,6 +826,11 @@ void mlx5_core_put_rsc(struct mlx5_core_rsc_common *common); ...@@ -826,6 +826,11 @@ void mlx5_core_put_rsc(struct mlx5_core_rsc_common *common);
int mlx5_query_odp_caps(struct mlx5_core_dev *dev, int mlx5_query_odp_caps(struct mlx5_core_dev *dev,
struct mlx5_odp_caps *odp_caps); struct mlx5_odp_caps *odp_caps);
static inline int fw_initializing(struct mlx5_core_dev *dev)
{
return ioread32be(&dev->iseg->initializing) >> 31;
}
static inline u32 mlx5_mkey_to_idx(u32 mkey) static inline u32 mlx5_mkey_to_idx(u32 mkey)
{ {
return mkey >> 8; return mkey >> 8;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment