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: 9923991 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 438C260375 for ; Sun, 27 Aug 2017 17:43:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30C32285DE for ; Sun, 27 Aug 2017 17:43:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 234C228623; Sun, 27 Aug 2017 17:43:16 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AAA12285DE for ; Sun, 27 Aug 2017 17:43:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=bB04KXNugWg2Bp7QEPalogkZpuxqk1MB6SeaaUgD9pc=; b=aKZ WI0BUYpSCwKBbCliwDJiHdpu0dCkzduL33xqlyzlwjsE8vAw6zMr+kUTfJZ+cZYALUhyd7vKRITlh loNrmNFCT52muzYZgCnqSzvoMVRwJkQelNT3fOTTer99AP3tJll4IoDwquzC9TX0xGZQTZNZIb7YL EHQFFvv5ifE0zETtaDukexutSsi1pPcH6bXSLiPX/rn9CZgTT+lntofJtjcVNPduRKvL3Okyat9II yn+3rxtoQ7Cg432vOVbZS2mfvLaEDwxTa1Z2Fq413XWzXv9Cv15XGz3nnsp3+Xb4XkstSE1ZTUJ// xi3OfPwcKSPfOQ6TfFZDlRp0Ef5CMPg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dm1aY-0003ID-If; Sun, 27 Aug 2017 17:43:10 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dm1Yo-0002HA-1j for linux-arm-kernel@lists.infradead.org; Sun, 27 Aug 2017 17:41:25 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 27D1D60726; 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170827_104122_185406_E65BE5AF X-CRM114-Status: GOOD ( 10.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bjorn Helgaas , linux-arm-msm@vger.kernel.org, Sinan Kaya , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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;