From patchwork Tue May 14 22:26:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Duyck, Alexander H" X-Patchwork-Id: 2568881 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7251A3FC5A for ; Tue, 14 May 2013 22:29:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758559Ab3ENW3Z (ORCPT ); Tue, 14 May 2013 18:29:25 -0400 Received: from mga14.intel.com ([143.182.124.37]:15800 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758537Ab3ENW3Y (ORCPT ); Tue, 14 May 2013 18:29:24 -0400 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 14 May 2013 15:29:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,672,1363158000"; d="scan'208";a="241588324" Received: from ahduyck-cp1.jf.intel.com ([10.23.152.162]) by AZSMGA002.ch.intel.com with ESMTP; 14 May 2013 15:29:15 -0700 Subject: [PATCH] pci: Avoid reentrant calls to work_on_cpu To: bhelgaas@google.com, yinghai@kernel.org From: Alexander Duyck Cc: guz.fnst@cn.fujitsu.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Date: Tue, 14 May 2013 15:26:53 -0700 Message-ID: <20130514221748.6180.30597.stgit@ahduyck-cp1.jf.intel.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This change is meant to fix a deadlock seen when pci_enable_sriov was called from within a driver's probe routine. The issue was that work_on_cpu calls flush_work which attempts to flush a work queue for a cpu that we are currently working in. In order to avoid the reentrant path we just skip the call to work_on_cpu in the case that the device node matches our current node. Reported-by: Yinghai Lu Signed-off-by: Alexander Duyck Tested-by: Yinghai Lu --- This patch is meant to address the issue pointed out in an earlier patch sent by Yinghai Lu titled: [PATCH 6/7] PCI: Make sure VF's driver get attached after PF's drivers/pci/pci-driver.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" 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/pci/pci-driver.c b/drivers/pci/pci-driver.c index 79277fb..caeb1c0 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -277,12 +277,16 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, int error, node; struct drv_dev_and_id ddi = { drv, dev, id }; - /* Execute driver initialization on node where the device's - bus is attached to. This way the driver likely allocates - its local memory on the right node without any need to - change it. */ + /* + * Execute driver initialization on the node where the device's + * bus is attached. This way the driver likely allocates + * its local memory on the right node without any need to + * change it. If the node is the current node just call + * local_pci_probe and avoid the possibility of reentrant + * calls to work_on_cpu. + */ node = dev_to_node(&dev->dev); - if (node >= 0) { + if ((node >= 0) && (node != numa_node_id())) { int cpu; get_online_cpus();