From patchwork Wed Nov 27 05:38:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 11263473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB5CA13A4 for ; Wed, 27 Nov 2019 05:38:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA7AB2075C for ; Wed, 27 Nov 2019 05:38:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=endlessm-com.20150623.gappssmtp.com header.i=@endlessm-com.20150623.gappssmtp.com header.b="eQHCrbNn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726558AbfK0Fin (ORCPT ); Wed, 27 Nov 2019 00:38:43 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38412 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbfK0Fin (ORCPT ); Wed, 27 Nov 2019 00:38:43 -0500 Received: by mail-pf1-f194.google.com with SMTP id c13so10392558pfp.5 for ; Tue, 26 Nov 2019 21:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NYfy1OGYsmHuR36W7MzFL9PBKNRJbvSfEwDa+a4Yg3I=; b=eQHCrbNnB5S/Vsv4VaieHevHPmhY9piE14RhEqo4eyUuYbcmeRI/GIyn9U76ow/97G FqEbs/wEG5R2bimSNtRjlUcpNEqf68UqPZI0/B2RCdNRzfyArrDo2cvTC6Xo5kT1gnSb Q9pzd+BKdPc0JS40hEuyBIFscmOLPzqq+6JcQ6L97e9JaZ7PalzRJpDT/c5nEfQKM9H8 ILFaAFITWcJ01KO1JK/1NtZ9E48Mnhs7DcWRkdVMbBYaZAzQSurQqVXJXiUC9YjLaJGL aJXrkhw1z6ODMkfMwIS8HeILrnlxTICSja6UW37jIFPH4AqScrTRdx6AiK8vkhr1tjRy yr7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NYfy1OGYsmHuR36W7MzFL9PBKNRJbvSfEwDa+a4Yg3I=; b=uU8wFc1qiwUwaccr0ZlNUE5N4SEafJKyMsBXGDMnDwRbBjm9X8Lqpwgcg93EYiGKld Tm0NomI60H3bzmai5ejFi27lL6XchfZCM5h606B5Aw8eikUMWC/8rxox8GN0uXgWYIpb CKm8kUyHKnZRUKggulSfxZo/uGar/OlSM/mQBPvUY+SjdswQeJR/ybgRwMsbb3M5ghxu JhiXEPppPsKh0plSXg6LF6Evp6+ktF6u44Odzd9+y3t5gXjAZSJSfzOXQjD5//PBZoyV hiZJZJ/IK5O5PALdvtbUnjGMdw60DxbDC7uyX8W0HjKt3ropjThsdVArRRjS8lKD/02g 1FWg== X-Gm-Message-State: APjAAAVU0wlFtmbqltc0tOdl6RtLY4JTAISEFfn34tBL7l5Mz4Rop+oE iymtPCbLelT/8/HCUu6frgSa7g== X-Google-Smtp-Source: APXvYqwkIc1tIyZp/lCw1pjR+6d5K/sfpjcR2fpqPtdQSCf/JXdaMAJ1a/B4Quf/UWy1UT4dIWQE2A== X-Received: by 2002:a63:6dcf:: with SMTP id i198mr2741882pgc.86.1574833121503; Tue, 26 Nov 2019 21:38:41 -0800 (PST) Received: from limbo.local (123-204-46-122.static.seed.net.tw. [123.204.46.122]) by smtp.gmail.com with ESMTPSA id y8sm14088008pfl.8.2019.11.26.21.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2019 21:38:40 -0800 (PST) From: Daniel Drake To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, rafael.j.wysocki@intel.com, linux@endlessm.com, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, mika.westerberg@linux.intel.com Subject: [PATCH v2 1/2] PCI: add generic quirk function for increasing D3hot delay Date: Wed, 27 Nov 2019 13:38:35 +0800 Message-Id: <20191127053836.31624-1-drake@endlessm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Separate the D3 delay increase functionality out of quirk_radeon_pm() into its own function so that it can be shared with other quirks, including the AMD Ryzen XHCI quirk that will be introduced in a followup commit. Tweak the function name and message to indicate more clearly that the delay relates to a D3hot-to-D0 transition. Signed-off-by: Daniel Drake Reviewed-by: Mika Westerberg --- drivers/pci/quirks.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) v2: tweaked function name and message to emphasize D3hot state diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 320255e5e8f89..3b4021e719530 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -1871,16 +1871,21 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2609, quirk_intel_pcie_pm); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260a, quirk_intel_pcie_pm); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260b, quirk_intel_pcie_pm); +static void quirk_d3hot_delay(struct pci_dev *dev, unsigned int delay) +{ + if (dev->d3_delay >= delay) + return; + + dev->d3_delay = delay; + pci_info(dev, "extending delay after power-on from D3hot to %d msec\n", + dev->d3_delay); +} + static void quirk_radeon_pm(struct pci_dev *dev) { if (dev->subsystem_vendor == PCI_VENDOR_ID_APPLE && - dev->subsystem_device == 0x00e2) { - if (dev->d3_delay < 20) { - dev->d3_delay = 20; - pci_info(dev, "extending delay after power-on from D3 to %d msec\n", - dev->d3_delay); - } - } + dev->subsystem_device == 0x00e2) + quirk_d3hot_delay(dev, 20); } DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6741, quirk_radeon_pm); From patchwork Wed Nov 27 05:38:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 11263479 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A23E015AB for ; Wed, 27 Nov 2019 05:38:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8045920665 for ; Wed, 27 Nov 2019 05:38:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=endlessm-com.20150623.gappssmtp.com header.i=@endlessm-com.20150623.gappssmtp.com header.b="03QmaYAq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726634AbfK0Fip (ORCPT ); Wed, 27 Nov 2019 00:38:45 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37864 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbfK0Fio (ORCPT ); Wed, 27 Nov 2019 00:38:44 -0500 Received: by mail-pl1-f196.google.com with SMTP id bb5so9235688plb.4 for ; Tue, 26 Nov 2019 21:38:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A1crt5ZX5/o6tqZ8uQeAgWxnW6il/kNy0inAaXVelWg=; b=03QmaYAqqV7p+2/P0ek7syQoGHcAgOXji2fJRE13ydAmBy/qMCG4aBhnyp/RnL1MEg HngVDerDsYPHadSYiO2t4A6vPf3vU5YfWkQDy5yL4v1TI3qCgXvSaj4y5WRLv+tfioR3 P6kREx5Mc4tkwL8LHBfqCxMBlBtAGowVmk05raMfkzNZVAarD7Thw/yPmXlH8TrCYhGQ Sw+AiR0DHihdJZk+CYuI5j4FcWDUzeS462dvKaGpvi8lRY428rEUO96BPQ1NfRBcU06h qQXH+ROoIhA8KeSWq5lQQAw7bgUdUd4foBxqPnL182bs9eam/JqCS9bXC3bCIaEyNcrW y59Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A1crt5ZX5/o6tqZ8uQeAgWxnW6il/kNy0inAaXVelWg=; b=DwHWBoMHVPaZqp8+V9sose8N0sKVVoo5PesjiJ1WOw7WvcU3KU+oLUJDT5E4mHZC9w egvWAWGkK+0K08QDDJtF04BwxzZ8IWpunq6Fyv9J4ruqh7+6ML7MMvZRKCn0pOWCZXah ALrNeXrb3xdPe7Wa9DzF03EjJapfNbOmuPfK7EztmAUpZgfyYv+zOH8Lx4odAt712eUl eUxkJv9ZtBZyzUXOWjllMpyHRZ+L6w5V/Am87b4r5t+HHHZEbT9kCwX22K2BB+XPU0rg dReplK6lpWZ+FK+sh9uN2gqeC8L+gWWHt1J1o6NvEyfx0dtc14TEKrHhgeS4QMn/DH6D lS3g== X-Gm-Message-State: APjAAAW+N/XjAR2g1W6u7bKbA95w7fr/Xg+ALuAQyfD13kWENRAmqXvm 3ul5UCARsUwXV/Dl2Rj2BstGXg== X-Google-Smtp-Source: APXvYqwaICaiIi2qlVP9oI/G9SEz3ACyQkNtE5h1JyLUsyrXggjU2y9sZVHDzZcDGoCT3MoOKaOHAw== X-Received: by 2002:a17:902:5a04:: with SMTP id q4mr2318041pli.34.1574833124051; Tue, 26 Nov 2019 21:38:44 -0800 (PST) Received: from limbo.local (123-204-46-122.static.seed.net.tw. [123.204.46.122]) by smtp.gmail.com with ESMTPSA id y8sm14088008pfl.8.2019.11.26.21.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2019 21:38:43 -0800 (PST) From: Daniel Drake To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, rafael.j.wysocki@intel.com, linux@endlessm.com, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, mika.westerberg@linux.intel.com Subject: [PATCH v2 2/2] PCI: increase D3 delay for AMD Ryzen5/7 XHCI controllers Date: Wed, 27 Nov 2019 13:38:36 +0800 Message-Id: <20191127053836.31624-2-drake@endlessm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191127053836.31624-1-drake@endlessm.com> References: <20191127053836.31624-1-drake@endlessm.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Asus UX434DA (AMD Ryzen7 3700U) and Asus X512DK (AMD Ryzen5 3500U), the XHCI controller fails to resume from runtime suspend or s2idle, and USB becomes unusable from that point. xhci_hcd 0000:03:00.4: Refused to change power state, currently in D3 xhci_hcd 0000:03:00.4: enabling device (0000 -> 0002) xhci_hcd 0000:03:00.4: WARN: xHC restore state timeout xhci_hcd 0000:03:00.4: PCI post-resume error -110! xhci_hcd 0000:03:00.4: HC died; cleaning up During suspend, a transition to D3cold is attempted, however the affected platforms do not seem to cut the power to the PCI device when in this state, so the device stays in D3hot. Upon resume, the D3hot-to-D0 transition is successful only if the D3 delay is increased to 20ms. The transition failure does not appear to be detectable as a CRS condition. Add a PCI quirk to increase the delay on the affected hardware. Link: https://bugzilla.kernel.org/show_bug.cgi?id=205587 Link: http://lkml.kernel.org/r/CAD8Lp47Vh69gQjROYG69=waJgL7hs1PwnLonL9+27S_TcRhixA@mail.gmail.com Signed-off-by: Daniel Drake Reviewed-by: Mika Westerberg --- drivers/pci/quirks.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) v2: split out the creation of quirk_d3hot_delay() into its own patch diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 3b4021e719530..222108f1a602e 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -1889,6 +1889,22 @@ static void quirk_radeon_pm(struct pci_dev *dev) } DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6741, quirk_radeon_pm); +/* + * Ryzen5/7 XHCI controllers fail upon resume from runtime suspend or s2idle. + * https://bugzilla.kernel.org/show_bug.cgi?id=205587 + * + * The kernel attempts to transition these devices to D3cold, but that seems + * to be ineffective on the platforms in question; the PCI device appears to + * remain on in D3hot state. The D3hot-to-D0 transition then requires an + * extended delay in order to succeed. + */ +static void quirk_ryzen_xhci_d3hot(struct pci_dev *dev) +{ + quirk_d3hot_delay(dev, 20); +} +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15e0, quirk_ryzen_xhci_d3hot); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15e1, quirk_ryzen_xhci_d3hot); + #ifdef CONFIG_X86_IO_APIC static int dmi_disable_ioapicreroute(const struct dmi_system_id *d) {