aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Kravkov <dmitry@broadcom.com>2011-05-22 06:11:26 -0400
committerDavid S. Miller <davem@davemloft.net>2011-05-22 21:01:24 -0400
commit1b6e2ceb4745b5838cb94463131d19dbea6cf0e3 (patch)
tree07308487a946e832bcf4cec695e49bdd7aef4f54
parent5e374b5aeb9a030c1859b3054e3b36dea3b29cfc (diff)
bnx2x: allow device properly initialize after hotplug
Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/bnx2x/bnx2x_main.c67
1 files changed, 24 insertions, 43 deletions
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index f7abebfa0f5d..a97d9be331d1 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -7288,51 +7288,35 @@ static inline void bnx2x_mcp_wait_one(struct bnx2x *bp)
7288 msleep(MCP_ONE_TIMEOUT); 7288 msleep(MCP_ONE_TIMEOUT);
7289} 7289}
7290 7290
7291static int bnx2x_reset_mcp_comp(struct bnx2x *bp, u32 magic_val) 7291/*
7292 * initializes bp->common.shmem_base and waits for validity signature to appear
7293 */
7294static int bnx2x_init_shmem(struct bnx2x *bp)
7292{ 7295{
7293 u32 shmem, cnt, validity_offset, val; 7296 int cnt = 0;
7294 int rc = 0; 7297 u32 val = 0;
7295
7296 msleep(100);
7297 7298
7298 /* Get shmem offset */ 7299 do {
7299 shmem = REG_RD(bp, MISC_REG_SHARED_MEM_ADDR); 7300 bp->common.shmem_base = REG_RD(bp, MISC_REG_SHARED_MEM_ADDR);
7300 if (shmem == 0) { 7301 if (bp->common.shmem_base) {
7301 BNX2X_ERR("Shmem 0 return failure\n"); 7302 val = SHMEM_RD(bp, validity_map[BP_PORT(bp)]);
7302 rc = -ENOTTY; 7303 if (val & SHR_MEM_VALIDITY_MB)
7303 goto exit_lbl; 7304 return 0;
7304 } 7305 }
7305 7306
7306 validity_offset = offsetof(struct shmem_region, validity_map[0]); 7307 bnx2x_mcp_wait_one(bp);
7307 7308
7308 /* Wait for MCP to come up */ 7309 } while (cnt++ < (MCP_TIMEOUT / MCP_ONE_TIMEOUT));
7309 for (cnt = 0; cnt < (MCP_TIMEOUT / MCP_ONE_TIMEOUT); cnt++) {
7310 /* TBD: its best to check validity map of last port.
7311 * currently checks on port 0.
7312 */
7313 val = REG_RD(bp, shmem + validity_offset);
7314 DP(NETIF_MSG_HW, "shmem 0x%x validity map(0x%x)=0x%x\n", shmem,
7315 shmem + validity_offset, val);
7316 7310
7317 /* check that shared memory is valid. */ 7311 BNX2X_ERR("BAD MCP validity signature\n");
7318 if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB))
7319 == (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB))
7320 break;
7321 7312
7322 bnx2x_mcp_wait_one(bp); 7313 return -ENODEV;
7323 } 7314}
7324
7325 DP(NETIF_MSG_HW, "Cnt=%d Shmem validity map 0x%x\n", cnt, val);
7326 7315
7327 /* Check that shared memory is valid. This indicates that MCP is up. */ 7316static int bnx2x_reset_mcp_comp(struct bnx2x *bp, u32 magic_val)
7328 if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) != 7317{
7329 (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) { 7318 int rc = bnx2x_init_shmem(bp);
7330 BNX2X_ERR("Shmem signature not present. MCP is not up !!\n");
7331 rc = -ENOTTY;
7332 goto exit_lbl;
7333 }
7334 7319
7335exit_lbl:
7336 /* Restore the `magic' bit value */ 7320 /* Restore the `magic' bit value */
7337 if (!CHIP_IS_E1(bp)) 7321 if (!CHIP_IS_E1(bp))
7338 bnx2x_clp_reset_done(bp, magic_val); 7322 bnx2x_clp_reset_done(bp, magic_val);
@@ -7845,10 +7829,12 @@ static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp)
7845 BNX2X_DEV_INFO("flash_size 0x%x (%d)\n", 7829 BNX2X_DEV_INFO("flash_size 0x%x (%d)\n",
7846 bp->common.flash_size, bp->common.flash_size); 7830 bp->common.flash_size, bp->common.flash_size);
7847 7831
7848 bp->common.shmem_base = REG_RD(bp, MISC_REG_SHARED_MEM_ADDR); 7832 bnx2x_init_shmem(bp);
7833
7849 bp->common.shmem2_base = REG_RD(bp, (BP_PATH(bp) ? 7834 bp->common.shmem2_base = REG_RD(bp, (BP_PATH(bp) ?
7850 MISC_REG_GENERIC_CR_1 : 7835 MISC_REG_GENERIC_CR_1 :
7851 MISC_REG_GENERIC_CR_0)); 7836 MISC_REG_GENERIC_CR_0));
7837
7852 bp->link_params.shmem_base = bp->common.shmem_base; 7838 bp->link_params.shmem_base = bp->common.shmem_base;
7853 bp->link_params.shmem2_base = bp->common.shmem2_base; 7839 bp->link_params.shmem2_base = bp->common.shmem2_base;
7854 BNX2X_DEV_INFO("shmem offset 0x%x shmem2 offset 0x%x\n", 7840 BNX2X_DEV_INFO("shmem offset 0x%x shmem2 offset 0x%x\n",
@@ -7860,11 +7846,6 @@ static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp)
7860 return; 7846 return;
7861 } 7847 }
7862 7848
7863 val = SHMEM_RD(bp, validity_map[BP_PORT(bp)]);
7864 if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB))
7865 != (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB))
7866 BNX2X_ERR("BAD MCP validity signature\n");
7867
7868 bp->common.hw_config = SHMEM_RD(bp, dev_info.shared_hw_config.config); 7849 bp->common.hw_config = SHMEM_RD(bp, dev_info.shared_hw_config.config);
7869 BNX2X_DEV_INFO("hw_config 0x%08x\n", bp->common.hw_config); 7850 BNX2X_DEV_INFO("hw_config 0x%08x\n", bp->common.hw_config);
7870 7851