From patchwork Sun Aug 27 17:40:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9923977 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 A277260375 for ; Sun, 27 Aug 2017 17:42:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CC4C28640 for ; Sun, 27 Aug 2017 17:42:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 795522863F; Sun, 27 Aug 2017 17:42:46 +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 10B6728623 for ; Sun, 27 Aug 2017 17:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751252AbdH0RlC (ORCPT ); Sun, 27 Aug 2017 13:41:02 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:42528 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751146AbdH0RlB (ORCPT ); Sun, 27 Aug 2017 13:41:01 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 446CD60725; Sun, 27 Aug 2017 17:41:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503855661; bh=K70AuNQZATZbVji4X69+sUcnX7fd/Jf8kcDV5r57vwE=; h=From:To:Cc:Subject:Date:From; b=dY1qU9mi8/M7QwJpVqT8djkPO+3vJU4iRd01R2hruU5LmTVVB7pjSyO0+X2cnOCR4 5NFM2SKrrHEHh8siXWuww/lDg4CvuH7UccSwjCJ0n7QEavZwlerwTs3lbSonc1/gn9 xJBI3KfE7zc9Btib5azRzH8wDUVlFraSSZFKKUzw= 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 BC5C16070A; Sun, 27 Aug 2017 17:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503855660; bh=K70AuNQZATZbVji4X69+sUcnX7fd/Jf8kcDV5r57vwE=; h=From:To:Cc:Subject:Date:From; b=DuDF4BvUEU09AGJAbvKP+pjCPZtzmu6UUuhG53k2HOdYshyrMLyuNPNslw7ePQvvZ SGWCj4A3G9jXUqREsKkbz3iv3uNMKSBUh5o45nMQztPzIfuHh8nAAw+ZRs9BvJF4ym lZGO2JkJd9/B6ml1K1n4HWv41LKKVXdu0oiy6tOk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BC5C16070A 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 V13 1/4] PCI: Don't ignore valid response before CRS timeout Date: Sun, 27 Aug 2017 13:40:48 -0400 Message-Id: <1503855651-17409-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;