From patchwork Fri May 12 18:13:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 761785 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wPdQd6f4dz9s75 for ; Sat, 13 May 2017 04:14:01 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SEyqSCzE"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758081AbdELSOA (ORCPT ); Fri, 12 May 2017 14:14:00 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35164 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757145AbdELSN7 (ORCPT ); Fri, 12 May 2017 14:13:59 -0400 Received: by mail-pg0-f68.google.com with SMTP id i63so8498617pgd.2 for ; Fri, 12 May 2017 11:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:date:message-id:user-agent:mime-version :content-transfer-encoding; bh=tXOl5L+LOrCBhxTZyaRwO8ANmOiOAZfiMgaSe1h5Wws=; b=SEyqSCzEJe8TW6BEem+ddGYpKNlyQa4UGjXAvKqV072UqhYTrJnWEVmqmzeKl7Z2fE GRZxLM/Gv+tirsnGyW3MJpmzs2QnFhktCsZ+R7jdtWxtM5fDg89A/j3bM8Y2NVqXu5KM W/4RblDuff5uymKMTv8g3qcl81S4T3HLdjn7iD9DhSRgM1ZwO2mNriLxTO3SwYyvQ51J RMiIl0isXXqUHfInfMcbmBzmw5AvExR0F1t7180mcz5jYfMf+erT/1mbC6bJVjG76BBj JXmYK7XnUv2lkuPFna8yFpenvc5MIUcwqmT6uH3X+iK4JhSaW8zkRBumuDmxsy8hKIT4 IKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:date:message-id:user-agent :mime-version:content-transfer-encoding; bh=tXOl5L+LOrCBhxTZyaRwO8ANmOiOAZfiMgaSe1h5Wws=; b=mvoWinhBW+G3X76nvMIoZhuFzQuRjvUB5mOxvWhIHeNL2G5P642aiZBsjRvwTEZCGh wBj5WH/Zw+O3shJRed3w7zStS6U09PPZKIUFSy3sT+lPWMnPDX4FoKeZBjDVxbzOpwyl IOcQHKBzjCm5iSanLIo5sHN3FH0VXhaGZYvwzLOJstOdjPSRXt/hmelCzUjoYb4mw1fL vA4/fY4pYhJkV7ux5+zQWTJq5lLJS+pzGJIMraH+01bRfjcoXxgXmFF5b8pDb+dNXH1b EMEL2do9HE+rTWvAK7dCFbwWBBtAbnMMVf0P6R2Aabm/Ne/1t29MIlpmzfwSEw4fyXTn 7zmw== X-Gm-Message-State: AODbwcARNvELRCRSEpdvv4YAE1MikWLk4rNuDTEHOmSH1KPbgALIL5n8 JXj5Iw/uil/zYQ== X-Received: by 10.84.128.65 with SMTP id 59mr7471494pla.121.1494612839075; Fri, 12 May 2017 11:13:59 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id h21sm6239418pgn.18.2017.05.12.11.13.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 May 2017 11:13:58 -0700 (PDT) Subject: [PATCH] pci: Disable master abort while waiting for an FLR to complete From: Alexander Duyck To: bhelgaas@google.com, linux-pci@vger.kernel.org, alex.williamson@redhat.com, briannorris@chromium.org Date: Fri, 12 May 2017 11:13:57 -0700 Message-ID: <20170512181107.13853.34680.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Alexander Duyck This patch is meant to address issues seen when performing on FLR on some systems as the long wait can result in a master abort when reading a function that is not yet ready. To prevent the master abort from being reported up we should disable reporting for it while waiting on the reset. Once the reset is completed then we can re-enable the master abort for the bus. Fixes: 5adecf817dd6 ("PCI: Wait for up to 1000ms after FLR reset") Reported-by: Brian Norris Signed-off-by: Alexander Duyck --- I haven't been able to test this code as I don't have a system that can reproduce the issue. The fix itself is based on the issue as reported by Brian so I am hoping he can test this on the Samsung Chromebook Plus with RK399 OP1 that this was seen on. drivers/pci/pci.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7904d02ffdb9..acbdbabeaa0e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3758,14 +3758,31 @@ int pci_wait_for_pending_transaction(struct pci_dev *dev) */ static void pci_flr_wait(struct pci_dev *dev) { + struct pci_dev *bridge = dev->bus->self; int i = 0; + u16 bctl; u32 id; + /* + * Disable MasterAbortMode while we are waiting to avoid reporting + * bus errors for reading the command register on a device that is + * not ready (in some architectures) + */ + if (bridge) { + pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, &bctl); + pci_write_config_word(bridge, PCI_BRIDGE_CONTROL, + bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); + } + do { msleep(100); pci_read_config_dword(dev, PCI_COMMAND, &id); } while (i++ < 10 && id == ~0); + /* restore bridge state */ + if (bridge) + pci_write_config_word(bridge, PCI_BRIDGE_CONTROL, bctl); + if (id == ~0) dev_warn(&dev->dev, "Failed to return from FLR\n"); else if (i > 1)