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: 9269263 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3C747607D6 for ; Mon, 8 Aug 2016 19:14:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ADE327F95 for ; Mon, 8 Aug 2016 19:14:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F7C727FA7; Mon, 8 Aug 2016 19:14:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A7A9281A7 for ; Mon, 8 Aug 2016 19:14:36 +0000 (UTC) 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 X-Virus-Scanned: ClamAV using ClamSMTP 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;