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 return 0; 381 } 382 383 /** 384 * e1000_acquire_swflag_ich8lan - Acquire software control flag 385 * @hw: pointer to the HW structure ··· 395 { 396 u32 extcnf_ctrl; 397 u32 timeout = PHY_CFG_TIMEOUT; 398 399 while (timeout) { 400 extcnf_ctrl = er32(EXTCNF_CTRL); ··· 419 420 if (!timeout) { 421 hw_dbg(hw, "FW or HW has locked the resource for too long.\n"); 422 return -E1000_ERR_CONFIG; 423 } 424 ··· 442 extcnf_ctrl = er32(EXTCNF_CTRL); 443 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 444 ew32(EXTCNF_CTRL, extcnf_ctrl); 445 } 446 447 /**
··· 380 return 0; 381 } 382 383 + static DEFINE_MUTEX(nvm_mutex); 384 + static pid_t nvm_owner = -1; 385 + 386 /** 387 * e1000_acquire_swflag_ich8lan - Acquire software control flag 388 * @hw: pointer to the HW structure ··· 392 { 393 u32 extcnf_ctrl; 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; 404 405 while (timeout) { 406 extcnf_ctrl = er32(EXTCNF_CTRL); ··· 407 408 if (!timeout) { 409 hw_dbg(hw, "FW or HW has locked the resource for too long.\n"); 410 + nvm_owner = -1; 411 + mutex_unlock(&nvm_mutex); 412 return -E1000_ERR_CONFIG; 413 } 414 ··· 428 extcnf_ctrl = er32(EXTCNF_CTRL); 429 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 430 ew32(EXTCNF_CTRL, extcnf_ctrl); 431 + 432 + nvm_owner = -1; 433 + mutex_unlock(&nvm_mutex); 434 } 435 436 /**