Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2974779imu; Sun, 9 Dec 2018 14:04:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/UaeARHykOhT5Dcq6LUoD6NFyXznahwNoCeTTCHJOA5AlzgXC6h4EQdkskwxTAqTGVB9hMU X-Received: by 2002:a63:7154:: with SMTP id b20mr8786072pgn.342.1544393069165; Sun, 09 Dec 2018 14:04:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544393069; cv=none; d=google.com; s=arc-20160816; b=QAbIS+o6F0chYA6zrVNsu10b22aeNiNxIPNm6jcZie7BLr9LsB96ZRPtGwLwzf9reg bbZ/Ullyg6qDudxFlbIVc5k1tKb9+ItQI0fNXtlzzeouQLCjWcpjHwbUmaV557k5wr4J qAb2gQdlRUf9X4/1quNzvEv69OiM86SlC6le2LNXsQjzD0urPoeuPuBhpIj1zh70EMx5 3vF2N3crDjnMWoztE5xR//eNpkz+xW7I2DPB3Y14fC2sGaDZSdI19JD/aj4MXzZpykpY ay3lAH6+YrKsoxj3SnVN2UVRv50jU8MQmRg1bRaaRIFHxqmjJdRq4zMPazjL2MSeLa2B 90TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=LK0JkxruPkB06RKiSndHM2trH4dNfJf8SemApjp98PQ=; b=YCkBTQCqEJObyDEctShxRbrM4yOjrmKwe6HqF5tq/wajCDsvb0tkyxcnw+V2yGX/lH ZOMCX+4FBQelKgn+uNMPf7EhfD9f74fyMO20NrcohrhQACpG8crQxFEjHiKpJoCR0eiC yHVUi6GUNu1K+9gnBlVfsO/Z22ROFZkmkxfYWrMFLWIyKd1EX/qpjvcoUNRD1uwhZQYK eNreyHS/v+X/ZgclV9j2rmAnYMaIn9MapGopvJo7X6uyXBtkJ/VS2LHZ8nFFa1diFNSP DyC+RS2y773SaWqMIOeyOL/fTazMETsFU1AcFqdGolgfaq5xWo2M2SHhRMA8bVFotJX0 9Uvw== ARC-Authentication-Results: i=1; mx.google.com; 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 g9si9058549plb.54.2018.12.09.14.04.14; Sun, 09 Dec 2018 14:04:29 -0800 (PST) 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; 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 S1727253AbeLIWBm (ORCPT + 99 others); Sun, 9 Dec 2018 17:01:42 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35942 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726676AbeLIVzd (ORCPT ); Sun, 9 Dec 2018 16:55:33 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW72w-0002ic-PO; Sun, 09 Dec 2018 21:55:31 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72j-0003c1-Gf; Sun, 09 Dec 2018 21:55:17 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Peter Wu" , "Bjorn Helgaas" , "Rafael J. Wysocki" , "Daniel Drake" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 270/328] PCI: Reprogram bridge prefetch registers on resume In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 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 Signed-off-by: Ben Hutchings --- drivers/pci/pci.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1014,12 +1014,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 (;;) { @@ -1038,25 +1038,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); } }