Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2568176imm; Thu, 11 Oct 2018 12:21:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV62PB4mp4/FW+6tagZvzlz7KE8wibtrpuCw71AeOyhdyURTjjWAxM7X8pqJ7v8s6SqvQTPna X-Received: by 2002:a17:902:7785:: with SMTP id o5-v6mr2685045pll.200.1539285708154; Thu, 11 Oct 2018 12:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539285708; cv=none; d=google.com; s=arc-20160816; b=VTS8af1G4+K8dtE//KP/sri7WFYdR4N+ks4gyU8P8xtCmFF6Y41829mSqWHKSTHTsm NKBZ/S5Lzmwep1YCsBef6pyQaygaYGil9GPaA2z738YHum3zMydK7Odchxl/tv3D4mUZ bOkycubjELR07VaRZuHmDfjH7AJjU7T3aBWoasLPkY4kubd2xwlU4xi0oYVqIU/m+KLo XXVWczEOrnRZS+IN/TtcOlqJNhDIAWq3SVig2VK8cPjeKQ2DS7gO6kxTaNNLKtgXFfwB gBaSIsbgsPoKJL1exhseaO2WNsra0O27JE8Y/qTDdseUkXCo1OqHLzZr1Gp5ifuNTcdc 7rAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YtgL2eIbHRYJhUJBdRNt/U/qN0KcGxRaJSmuY3lvORY=; b=dn/W5KcUpM56OPn6dqLKAqQWLTwKU83N0xKxVi2tg6DynnF1xW7euyZiavr8kGGtB6 4N8KyWq6OjxlI2KzQcV7qqEMlIOc2YR1QkFeksLra9/U0jJKQ8GBtWiw2r0pzYKl93Ph 7Dk2mvSj8IUIQovhGqFwlWVdpMsZSn8BryKXn6/rSNUXkz3hl3xsJYlSIxVhqeVSSnUu 4qzHT/riOiDCkQdTpfWf9cWKhKLUD6Bef3BXOFlEWAdSbrneuhIFTB527MdFo1T23YjB 6VWLX6z9/T/5sGCVKMpuOVMyfcoZ5mpNZ0ggWCfcO16/0pFgEvCHNgNI3Vjlxi7wDIUf VYkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k5oesu9g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4-v6si32914511pfg.90.2018.10.11.12.21.32; Thu, 11 Oct 2018 12:21:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k5oesu9g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730738AbeJKXKU (ORCPT + 99 others); Thu, 11 Oct 2018 19:10:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:41576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726700AbeJKXKT (ORCPT ); Thu, 11 Oct 2018 19:10:19 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B8BA620652; Thu, 11 Oct 2018 15:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539272555; bh=Xs1jnEjH2UJRwqM0UWL+SP1bGdcBy4qxPuzUsyytnPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k5oesu9gT5Svm+woj0NrlGKIHKfTLhZyuWa6HbE2WJpnztFaT8LnAQkHnqKElZ7NG fvpX0+SIuCqzbZuf7uX9B/O5LQHVMoVZGdLBkkLoVy0J+trqD70Qr/v+8V3OrF/Fv4 4I5pLAN+VlEsyIa/7rZOy6y5gwXAcmMIpJLIizbs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Drake , Bjorn Helgaas , "Rafael J. Wysocki" , Peter Wu Subject: [PATCH 4.4 05/27] PCI: Reprogram bridge prefetch registers on resume Date: Thu, 11 Oct 2018 17:34:52 +0200 Message-Id: <20181011152534.273102382@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181011152534.014964888@linuxfoundation.org> References: <20181011152534.014964888@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Drake commit 083874549fdfefa629dfa752785e20427dde1511 upstream. On 38+ Intel-based ASUS products, the NVIDIA GPU becomes unusable after S3 suspend/resume. The affected products include multiple generations of NVIDIA GPUs and Intel SoCs. After resume, nouveau logs many errors such as: fifo: fault 00 [READ] at 0000005555555000 engine 00 [GR] client 04 [HUB/FE] reason 4a [] on channel -1 [007fa91000 unknown] DRM: failed to idle channel 0 [DRM] Similarly, the NVIDIA proprietary driver also fails after resume (black screen, 100% CPU usage in Xorg process). We shipped a sample to NVIDIA for diagnosis, and their response indicated that it's a problem with the parent PCI bridge (on the Intel SoC), not the GPU. Runtime suspend/resume works fine, only S3 suspend is affected. We found a workaround: on resume, rewrite the Intel PCI bridge 'Prefetchable Base Upper 32 Bits' register (PCI_PREF_BASE_UPPER32). In the cases that I checked, this register has value 0 and we just have to rewrite that value. Linux already saves and restores PCI config space during suspend/resume, but this register was being skipped because upon resume, it already has value 0 (the correct, pre-suspend value). Intel appear to have previously acknowledged this behaviour and the requirement to rewrite this register: https://bugzilla.kernel.org/show_bug.cgi?id=116851#c23 Based on that, rewrite the prefetch register values even when that appears unnecessary. We have confirmed this solution on all the affected models we have in-hands (X542UQ, UX533FD, X530UN, V272UN). Additionally, this solves an issue where r8169 MSI-X interrupts were broken after S3 suspend/resume on ASUS X441UAR. This issue was recently worked around in commit 7bb05b85bc2d ("r8169: don't use MSI-X on RTL8106e"). It also fixes the same issue on RTL6186evl/8111evl on an Aimfor-tech laptop that we had not yet patched. I suspect it will also fix the issue that was worked around in commit 7c53a722459c ("r8169: don't use MSI-X on RTL8168g"). Thomas Martitz reports that this change also solves an issue where the AMD Radeon Polaris 10 GPU on the HP Zbook 14u G5 is unresponsive after S3 suspend/resume. Link: https://bugzilla.kernel.org/show_bug.cgi?id=201069 Signed-off-by: Daniel Drake Signed-off-by: Bjorn Helgaas Reviewed-by: Rafael J. Wysocki Reviewed-By: Peter Wu CC: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1064,12 +1064,12 @@ int pci_save_state(struct pci_dev *dev) EXPORT_SYMBOL(pci_save_state); static void pci_restore_config_dword(struct pci_dev *pdev, int offset, - u32 saved_val, int retry) + u32 saved_val, int retry, bool force) { u32 val; pci_read_config_dword(pdev, offset, &val); - if (val == saved_val) + if (!force && val == saved_val) return; for (;;) { @@ -1088,25 +1088,36 @@ static void pci_restore_config_dword(str } static void pci_restore_config_space_range(struct pci_dev *pdev, - int start, int end, int retry) + int start, int end, int retry, + bool force) { int index; for (index = end; index >= start; index--) pci_restore_config_dword(pdev, 4 * index, pdev->saved_config_space[index], - retry); + retry, force); } static void pci_restore_config_space(struct pci_dev *pdev) { if (pdev->hdr_type == PCI_HEADER_TYPE_NORMAL) { - pci_restore_config_space_range(pdev, 10, 15, 0); + pci_restore_config_space_range(pdev, 10, 15, 0, false); /* Restore BARs before the command register. */ - pci_restore_config_space_range(pdev, 4, 9, 10); - pci_restore_config_space_range(pdev, 0, 3, 0); + pci_restore_config_space_range(pdev, 4, 9, 10, false); + pci_restore_config_space_range(pdev, 0, 3, 0, false); + } else if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { + pci_restore_config_space_range(pdev, 12, 15, 0, false); + + /* + * Force rewriting of prefetch registers to avoid S3 resume + * issues on Intel PCI bridges that occur when these + * registers are not explicitly written. + */ + pci_restore_config_space_range(pdev, 9, 11, 0, true); + pci_restore_config_space_range(pdev, 0, 8, 0, false); } else { - pci_restore_config_space_range(pdev, 0, 15, 0); + pci_restore_config_space_range(pdev, 0, 15, 0, false); } }