From patchwork Mon Aug 8 19:14:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 656944 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3s7Rtd57S3z9t1K for ; Tue, 9 Aug 2016 05:14:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752938AbcHHTOc (ORCPT ); Mon, 8 Aug 2016 15:14:32 -0400 Received: from mga02.intel.com ([134.134.136.20]:19424 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752618AbcHHTOa (ORCPT ); Mon, 8 Aug 2016 15:14:30 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 08 Aug 2016 12:14:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,491,1464678000"; d="scan'208";a="1021836215" Received: from dcgshare.lm.intel.com ([10.232.118.254]) by fmsmga001.fm.intel.com with ESMTP; 08 Aug 2016 12:14:30 -0700 Received: by dcgshare.lm.intel.com (Postfix, from userid 1017) id DFD89E0C74; Mon, 8 Aug 2016 13:14:28 -0600 (MDT) From: Keith Busch To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Wei Zhang , Jens Axboe , Keith Busch Subject: [PATCH 1/3] pcie: Don't search capabilities on removed devices Date: Mon, 8 Aug 2016 13:14:25 -0600 Message-Id: <1470683667-28418-2-git-send-email-keith.busch@intel.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1470683667-28418-1-git-send-email-keith.busch@intel.com> References: <1470683667-28418-1-git-send-email-keith.busch@intel.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This patch returns immediately if trying to find a pcie capability on a removed device, as seen with an all 1's completion from config read. Previously this function would iterate the maximum 480 times to search for a capability at position 0xffc. There is never a case where we'd expect all 1's to a successful config read on a capability register, so this is a safe criteria to check before bailing on the device. While accessing a removed device shouldn't be fatal, it's doesn't accomplish anything. Instead, the code was testing completion synthesis capabilities which is observed to cause distruption to normal operations. Signed-off-by: Keith Busch --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index aab9d51..e884608 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -331,7 +331,7 @@ int pci_find_next_ext_capability(struct pci_dev *dev, int start, int cap) if (header == 0) return 0; - while (ttl-- > 0) { + while (ttl-- > 0 && header != -1) { if (PCI_EXT_CAP_ID(header) == cap && pos != start) return pos;