e1000e: debug contention on NVM SWFLAG

This patch adds a mutex to the e1000e driver that would help
catch any collisions of two e1000e threads accessing hardware
at the same time.

description and patch updated by Jesse

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Thomas Gleixner and committed by Linus Torvalds 717d438d 4fa7553a

+17
+17
drivers/net/e1000e/ich8lan.c
··· 380 380 return 0; 381 381 } 382 382 383 + static DEFINE_MUTEX(nvm_mutex); 384 + static pid_t nvm_owner = -1; 385 + 383 386 /** 384 387 * e1000_acquire_swflag_ich8lan - Acquire software control flag 385 388 * @hw: pointer to the HW structure ··· 395 392 { 396 393 u32 extcnf_ctrl; 397 394 u32 timeout = PHY_CFG_TIMEOUT; 395 + 396 + WARN_ON(preempt_count()); 397 + 398 + if (!mutex_trylock(&nvm_mutex)) { 399 + WARN(1, KERN_ERR "e1000e mutex contention. Owned by pid %d\n", 400 + nvm_owner); 401 + mutex_lock(&nvm_mutex); 402 + } 403 + nvm_owner = current->pid; 398 404 399 405 while (timeout) { 400 406 extcnf_ctrl = er32(EXTCNF_CTRL); ··· 419 407 420 408 if (!timeout) { 421 409 hw_dbg(hw, "FW or HW has locked the resource for too long.\n"); 410 + nvm_owner = -1; 411 + mutex_unlock(&nvm_mutex); 422 412 return -E1000_ERR_CONFIG; 423 413 } 424 414 ··· 442 428 extcnf_ctrl = er32(EXTCNF_CTRL); 443 429 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 444 430 ew32(EXTCNF_CTRL, extcnf_ctrl); 431 + 432 + nvm_owner = -1; 433 + mutex_unlock(&nvm_mutex); 445 434 } 446 435 447 436 /**