diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2008-10-02 19:33:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-02 21:28:13 -0400 |
commit | 717d438d1fde94decef874b9808379d1f4523453 (patch) | |
tree | a0c2d71c2219e111668870f2692a92e3065d34fd /drivers/net | |
parent | 4fa7553a075918e1e02a6039f9e826c8872b7049 (diff) |
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>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/e1000e/ich8lan.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c index f4b6744d71d..0b6095ba3ce 100644 --- a/drivers/net/e1000e/ich8lan.c +++ b/drivers/net/e1000e/ich8lan.c | |||
@@ -380,6 +380,9 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter) | |||
380 | return 0; | 380 | return 0; |
381 | } | 381 | } |
382 | 382 | ||
383 | static DEFINE_MUTEX(nvm_mutex); | ||
384 | static pid_t nvm_owner = -1; | ||
385 | |||
383 | /** | 386 | /** |
384 | * e1000_acquire_swflag_ich8lan - Acquire software control flag | 387 | * e1000_acquire_swflag_ich8lan - Acquire software control flag |
385 | * @hw: pointer to the HW structure | 388 | * @hw: pointer to the HW structure |
@@ -393,6 +396,15 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) | |||
393 | u32 extcnf_ctrl; | 396 | u32 extcnf_ctrl; |
394 | u32 timeout = PHY_CFG_TIMEOUT; | 397 | u32 timeout = PHY_CFG_TIMEOUT; |
395 | 398 | ||
399 | WARN_ON(preempt_count()); | ||
400 | |||
401 | if (!mutex_trylock(&nvm_mutex)) { | ||
402 | WARN(1, KERN_ERR "e1000e mutex contention. Owned by pid %d\n", | ||
403 | nvm_owner); | ||
404 | mutex_lock(&nvm_mutex); | ||
405 | } | ||
406 | nvm_owner = current->pid; | ||
407 | |||
396 | while (timeout) { | 408 | while (timeout) { |
397 | extcnf_ctrl = er32(EXTCNF_CTRL); | 409 | extcnf_ctrl = er32(EXTCNF_CTRL); |
398 | extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; | 410 | extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; |
@@ -407,6 +419,8 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) | |||
407 | 419 | ||
408 | if (!timeout) { | 420 | if (!timeout) { |
409 | hw_dbg(hw, "FW or HW has locked the resource for too long.\n"); | 421 | hw_dbg(hw, "FW or HW has locked the resource for too long.\n"); |
422 | nvm_owner = -1; | ||
423 | mutex_unlock(&nvm_mutex); | ||
410 | return -E1000_ERR_CONFIG; | 424 | return -E1000_ERR_CONFIG; |
411 | } | 425 | } |
412 | 426 | ||
@@ -428,6 +442,9 @@ static void e1000_release_swflag_ich8lan(struct e1000_hw *hw) | |||
428 | extcnf_ctrl = er32(EXTCNF_CTRL); | 442 | extcnf_ctrl = er32(EXTCNF_CTRL); |
429 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; | 443 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; |
430 | ew32(EXTCNF_CTRL, extcnf_ctrl); | 444 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
445 | |||
446 | nvm_owner = -1; | ||
447 | mutex_unlock(&nvm_mutex); | ||
431 | } | 448 | } |
432 | 449 | ||
433 | /** | 450 | /** |