Subject: [PATCH 2.6.12-rc5 9/9] tg3: Fix bug in tg3_load_firmware_cpu

From: "Michael Chan" <[email-masked]>
Date: Thu, 26 May 2005 11:00:11 -0700

Add tg3_nvram_lock() and tg3_nvram_unlock() calls around tg3_halt_cpu().
It is possible that the bootcode may be loading code from nvram during
this call and stopping the cpu without getting the lock may cause
uncompleted nvram data to be left in the nvram data register. Subsequent
calls to read/write nvram data will fail.

Signed-off-by: Michael Chan <[email-masked]>
diff -Nru d8/drivers/net/tg3.c d9/drivers/net/tg3.c
--- d8/drivers/net/tg3.c	2005-05-25 12:59:46.000000000 -0700
+++ d9/drivers/net/tg3.c	2005-05-25 12:59:55.000000000 -0700
@@ -4370,7 +4370,12 @@
 	 */
 	tp->tg3_flags |= TG3_FLAG_PCIX_TARGET_HWBUG;
 
+	/* It is possible that bootcode is still loading at this point.
+	 * Get the nvram lock first before halting the cpu.
+	 */
+	tg3_nvram_lock(tp);
 	err = tg3_halt_cpu(tp, cpu_base);
+	tg3_nvram_unlock(tp);
 	if (err)
 		goto out;