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: 9916585 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 7019C602CB for ; Wed, 23 Aug 2017 05:10:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59CA9287AF for ; Wed, 23 Aug 2017 05:10:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E46E28944; Wed, 23 Aug 2017 05:10:20 +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 D81722895B for ; Wed, 23 Aug 2017 05:10:19 +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=ZP3 da33bmZSywRKbw9zQjDPutSA45XZs9mql+lNkDErxEoZLFgBXzxpIdT+dAjE/0tQpcpu727v1cK2X Kfe4As7eiDu7jc4BI4EFM0ZcH3qUL5QVb6n+GA5LIjh2qT/kHx/isn9c5QWYlrO9iNNhfXq62lB2c ncD0Qxh9Y+YZgMP+E+/yuflsYPn11jygk90NwIlC2cMzTQrMF/ETWWe/AmMJ6aEPvWr41Zf8qPhAK gVQEfBdsQ97qgVVAZ8KMq9B3LdoFjXtl41hAjT2r6QwoI2EoUF407SEzzvX2E6+9Ao6DRQwpAZEaE UtHM+bgeTPHh8qOEvCmDI9PPSrxH5Qg==; 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 1dkNvP-0001cr-Kv; Wed, 23 Aug 2017 05:09:55 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dkNiX-0002Gq-Ec for linux-arm-kernel@lists.infradead.org; Wed, 23 Aug 2017 04:56:39 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8B3EA606B7; 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170822_215637_628807_A5F1A6C1 X-CRM114-Status: GOOD ( 10.70 ) 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;