From patchwork Fri Feb 12 23:51:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 8298551 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 198BFC02AA for ; Fri, 12 Feb 2016 23:51:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41CDD202FE for ; Fri, 12 Feb 2016 23:51:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B75BB201CD for ; Fri, 12 Feb 2016 23:51:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751965AbcBLXvK (ORCPT ); Fri, 12 Feb 2016 18:51:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57392 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751320AbcBLXvJ (ORCPT ); Fri, 12 Feb 2016 18:51:09 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 4A88CC0C2356; Fri, 12 Feb 2016 23:51:09 +0000 (UTC) Received: from gimli.home (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1CNp8ba008072; Fri, 12 Feb 2016 18:51:08 -0500 Subject: [PATCH] pci: Wait for up to an additional 1000ms after FLR reset From: Alex Williamson To: linux-pci@vger.kernel.org Cc: allen.m.kay@intel.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Date: Fri, 12 Feb 2016 16:51:08 -0700 Message-ID: <20160212235013.16862.53910.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some devices take longer than the spec indicates to return from FLR reset, a notable case of this is Intel integrated graphics (IGD), which can often take an additional 300ms powering down an attached LCD panel as part of the FLR. Allow devices up to an additional 1000ms, testing every 100ms whether the first dword of config space is read as -1. Signed-off-by: Alex Williamson --- Copying KVM list as this patch is required for IGD assignment. drivers/pci/pci.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 602eb42..3b90a42 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3414,6 +3414,25 @@ int pci_wait_for_pending_transaction(struct pci_dev *dev) } EXPORT_SYMBOL(pci_wait_for_pending_transaction); +static void pci_wait_alive(struct pci_dev *dev) +{ + int i; + u32 id; + + for (i = 0; i < 10; i++) { + pci_read_config_dword(dev, PCI_VENDOR_ID, &id); + if (~id != 0) { + if (i > 0) + dev_info(&dev->dev, "Required additional %d" + "ms to return from reset\n", i * 100); + return; + } + msleep(100); + } + + dev_warn(&dev->dev, "Failed to return from reset\n"); +} + static int pcie_flr(struct pci_dev *dev, int probe) { u32 cap; @@ -3430,6 +3449,7 @@ static int pcie_flr(struct pci_dev *dev, int probe) pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); msleep(100); + pci_wait_alive(dev); return 0; } @@ -3460,6 +3480,7 @@ static int pci_af_flr(struct pci_dev *dev, int probe) pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR); msleep(100); + pci_wait_alive(dev); return 0; }