From patchwork Thu Oct 2 23:33:40 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Brandeburg X-Patchwork-Id: 2494 X-Patchwork-Delegate: jgarzik@pobox.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 37C76DDF20 for ; Fri, 3 Oct 2008 09:33:54 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754188AbYJBXdo (ORCPT ); Thu, 2 Oct 2008 19:33:44 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755731AbYJBXdn (ORCPT ); Thu, 2 Oct 2008 19:33:43 -0400 Received: from mga01.intel.com ([192.55.52.88]:57967 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755702AbYJBXdl (ORCPT ); Thu, 2 Oct 2008 19:33:41 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 02 Oct 2008 16:29:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.33,353,1220252400"; d="scan'208";a="386973955" Received: from orsmsx334.amr.corp.intel.com (HELO orsmsx334.jf.intel.com) ([10.22.226.45]) by fmsmga002.fm.intel.com with ESMTP; 02 Oct 2008 16:30:23 -0700 Received: from jbrandeb-bw.jf.intel.com ([134.134.3.227]) by orsmsx334.jf.intel.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 2 Oct 2008 16:33:40 -0700 From: Jesse Brandeburg Subject: [PATCH 2.6.27-rc8 5/6] e1000e: debug contention on NVM SWFLAG To: torvalds@linux-foundation.org Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, tglx@linutronix.de, arjan@linux.intel.com, airlied@gmail.com, davem@davemloft.net, jeff@garzik.org, Thomas Gleixner , Jesse Brandeburg Date: Thu, 02 Oct 2008 16:33:40 -0700 Message-ID: <20081002233340.12556.33137.stgit@jbrandeb-bw.jf.intel.com> In-Reply-To: <20081002233314.12556.49143.stgit@jbrandeb-bw.jf.intel.com> References: <20081002233314.12556.49143.stgit@jbrandeb-bw.jf.intel.com> User-Agent: StGIT/0.14.3.163.g06f9.dirty MIME-Version: 1.0 X-OriginalArrivalTime: 02 Oct 2008 23:33:40.0436 (UTC) FILETIME=[4CFB6940:01C924E7] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Thomas Gleixner 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 Signed-off-by: Jesse Brandeburg --- drivers/net/e1000e/ich8lan.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c index f4b6744..0b6095b 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) return 0; } +static DEFINE_MUTEX(nvm_mutex); +static pid_t nvm_owner = -1; + /** * e1000_acquire_swflag_ich8lan - Acquire software control flag * @hw: pointer to the HW structure @@ -393,6 +396,15 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) u32 extcnf_ctrl; u32 timeout = PHY_CFG_TIMEOUT; + WARN_ON(preempt_count()); + + if (!mutex_trylock(&nvm_mutex)) { + WARN(1, KERN_ERR "e1000e mutex contention. Owned by pid %d\n", + nvm_owner); + mutex_lock(&nvm_mutex); + } + nvm_owner = current->pid; + while (timeout) { extcnf_ctrl = er32(EXTCNF_CTRL); extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; @@ -407,6 +419,8 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) if (!timeout) { hw_dbg(hw, "FW or HW has locked the resource for too long.\n"); + nvm_owner = -1; + mutex_unlock(&nvm_mutex); return -E1000_ERR_CONFIG; } @@ -428,6 +442,9 @@ static void e1000_release_swflag_ich8lan(struct e1000_hw *hw) extcnf_ctrl = er32(EXTCNF_CTRL); extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; ew32(EXTCNF_CTRL, extcnf_ctrl); + + nvm_owner = -1; + mutex_unlock(&nvm_mutex); } /**