Skip to contentSkip to conversation

: Add missing wait in bnx2_init_5709_context().

PATCH Applied Michael Chan 3 participants 5 messages Jun 4, 2007 – Jun 5, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/5 : Add missing wait in bnx2_init_5709_context().

[BNX2]: Add missing wait in bnx2_init_5709_context().

For correctness, we need to wait for the MEM_INIT bit to be cleared in the BNX2_CTX_COMMAND register before proceeding.

drivers/net/bnx2.c +6 -0
index 5d69e5b..daa62d9 100644
@@ -1778,6 +1778,12 @@ bnx2_init_5709_context(struct bnx2 *bp)
 	val = BNX2_CTX_COMMAND_ENABLED | BNX2_CTX_COMMAND_MEM_INIT | (1 << 12);
 	val |= (BCM_PAGE_BITS - 8) << 16;
 	REG_WR(bp, BNX2_CTX_COMMAND, val);
+	for (i = 0; i < 10; i++) {
+		val = REG_RD(bp, BNX2_CTX_COMMAND);
+		if (!(val & BNX2_CTX_COMMAND_MEM_INIT))
+			break;
+		udelay(2);
+	}
 	for (i = 0; i < bp->ctx_pages; i++) {
 		int j;
 
#1 lore raw
Quoted 13 lines · Michael Chan

[BNX2]: Add missing wait in bnx2_init_5709_context().

For correctness, we need to wait for the MEM_INIT bit to be cleared in the BNX2_CTX_COMMAND register before proceeding.

drivers/net/bnx2.c +0 -0
index 5d69e5b..daa62d9 100644
@@ -1778,6 +1778,12 @@ bnx2_init_5709_context(struct bnx2 *bp)
 	val = BNX2_CTX_COMMAND_ENABLED | BNX2_CTX_COMMAND_MEM_INIT | (1 << 12);

drivers/net/bnx2.c bnx2_init_5709_context(struct bnx2 *bp) · line 1788

Quoted 10 lines
drivers/net/bnx2.c +6 -0
 	val |= (BCM_PAGE_BITS - 8) << 16;
 	REG_WR(bp, BNX2_CTX_COMMAND, val);
+	for (i = 0; i < 10; i++) {
+		val = REG_RD(bp, BNX2_CTX_COMMAND);
+		if (!(val & BNX2_CTX_COMMAND_MEM_INIT))
+			break;
+		udelay(2);
+	}
 	for (i = 0; i < bp->ctx_pages; i++) {
 		int j;

If the bit does not clear after 10 loops, it seems to me you should complain or somehow otherwise make note of the failure.

Jeff

#2 lore raw

[BNX2]: Add missing wait in bnx2_init_5709_context().

For correctness, we need to wait for the MEM_INIT bit to be cleared in the BNX2_CTX_COMMAND register before proceeding.

[Added return -EBUSY when the MEM_INIT bit doesn't clear, suggested by Jeff Garzik.]

drivers/net/bnx2.c +14 -3
index 5d69e5b..0f861e2 100644
@@ -1778,6 +1778,15 @@ bnx2_init_5709_context(struct bnx2 *bp)
 	val = BNX2_CTX_COMMAND_ENABLED | BNX2_CTX_COMMAND_MEM_INIT | (1 << 12);
 	val |= (BCM_PAGE_BITS - 8) << 16;
 	REG_WR(bp, BNX2_CTX_COMMAND, val);
+	for (i = 0; i < 10; i++) {
+		val = REG_RD(bp, BNX2_CTX_COMMAND);
+		if (!(val & BNX2_CTX_COMMAND_MEM_INIT))
+			break;
+		udelay(2);
+	}
+	if (val & BNX2_CTX_COMMAND_MEM_INIT)
+		return -EBUSY;
+
 	for (i = 0; i < bp->ctx_pages; i++) {
 		int j;
 
@@ -3696,9 +3705,11 @@ bnx2_init_chip(struct bnx2 *bp)
 
 	/* Initialize context mapping and zero out the quick contexts.  The
 	 * context block must have already been enabled. */
-	if (CHIP_NUM(bp) == CHIP_NUM_5709)
-		bnx2_init_5709_context(bp);
-	else
+	if (CHIP_NUM(bp) == CHIP_NUM_5709) {
+		rc = bnx2_init_5709_context(bp);
+		if (rc)
+			return rc;
+	} else
 		bnx2_init_context(bp);
 
 	if ((rc = bnx2_init_cpus(bp)) != 0)
#3 lore raw
Quoted 9 lines · Michael Chan

[BNX2]: Add missing wait in bnx2_init_5709_context().

For correctness, we need to wait for the MEM_INIT bit to be cleared in the BNX2_CTX_COMMAND register before proceeding.

[Added return -EBUSY when the MEM_INIT bit doesn't clear, suggested by Jeff Garzik.]

ACK

maintainer Applied
#4 lore raw

From: Jeff Garzik <[email protected]>
Date: Mon, 4 Jun 2007 21:23:51 -0400

Quoted 6 lines · Michael Chan
Quoted 5 lines

[BNX2]: Add missing wait in bnx2_init_5709_context().

For correctness, we need to wait for the MEM_INIT bit to be cleared in the BNX2_CTX_COMMAND register before proceeding.

Quoted 6 lines
Quoted 4 lines

[Added return -EBUSY when the MEM_INIT bit doesn't clear, suggested by Jeff Garzik.]

ACK

Applied, thanks.