From patchwork Wed Aug 23 04:56:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9916571 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 5584E60327 for ; Wed, 23 Aug 2017 04:57:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4792C28864 for ; Wed, 23 Aug 2017 04:57:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BD2828954; Wed, 23 Aug 2017 04:57:17 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 CFAB828864 for ; Wed, 23 Aug 2017 04:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753253AbdHWE4S (ORCPT ); Wed, 23 Aug 2017 00:56:18 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53142 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751436AbdHWE4R (ORCPT ); Wed, 23 Aug 2017 00:56:17 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A685D60415; Wed, 23 Aug 2017 04:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503464176; bh=K70AuNQZATZbVji4X69+sUcnX7fd/Jf8kcDV5r57vwE=; h=From:To:Cc:Subject:Date:From; b=YXPSAJek/klWcnlbP+gS4x55wnVP5U81sad12b9GMFDUqgzBQ3WGbjnTJl7bFO/kK fubZbR0cJaspkN2Hyv1JDRwG4r3usPh2r2eRgP7vDLHrXSOSd+S+b/KFM6gKc4lsBI mCsmHko9menaTqLSbluXJ19uBtPSPVrc9p6jFmDg= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 42C1E603D2; Wed, 23 Aug 2017 04:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503464176; bh=K70AuNQZATZbVji4X69+sUcnX7fd/Jf8kcDV5r57vwE=; h=From:To:Cc:Subject:Date:From; b=YXPSAJek/klWcnlbP+gS4x55wnVP5U81sad12b9GMFDUqgzBQ3WGbjnTJl7bFO/kK fubZbR0cJaspkN2Hyv1JDRwG4r3usPh2r2eRgP7vDLHrXSOSd+S+b/KFM6gKc4lsBI mCsmHko9menaTqLSbluXJ19uBtPSPVrc9p6jFmDg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 42C1E603D2 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org, timur@codeaurora.org, alex.williamson@redhat.com Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bjorn Helgaas , Sinan Kaya , linux-kernel@vger.kernel.org Subject: [PATCH V12 1/5] PCI: Don't ignore valid response before CRS timeout Date: Wed, 23 Aug 2017 00:56:07 -0400 Message-Id: <1503464171-6471-1-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 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 From: Bjorn Helgaas While waiting for a device to become ready (i.e., to return a non-CRS completion to a read of its Vendor ID), if we got a valid response to the very last read before timing out, we printed a warning and gave up on the device even though it was actually ready. For a typical 60s timeout, we wait about 65s (it's not exact because of the exponential backoff), but we treated devices that became ready between 33s and 65s as though they failed. Move the Device ID read later so we check whether the device is ready immediately, before checking for a timeout. Signed-off-by: Bjorn Helgaas [okaya: reorder reads so that we check device presence after sleep] Signed-off-by: Sinan Kaya --- drivers/pci/probe.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index c31310d..2849e0e 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1847,17 +1847,18 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, if (!crs_timeout) return false; - msleep(delay); - delay *= 2; - if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l)) - return false; - /* Card hasn't responded in 60 seconds? Must be stuck. */ if (delay > crs_timeout) { printk(KERN_WARNING "pci %04x:%02x:%02x.%d: not responding\n", pci_domain_nr(bus), bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); return false; } + + msleep(delay); + delay *= 2; + + if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l)) + return false; } return true;