Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3408015ybz; Mon, 4 May 2020 02:21:49 -0700 (PDT) X-Google-Smtp-Source: APiQypKnyUuUghSv+1+ppBvQ9UPa6kpvre35iiTj0Q6JDg3dksvbhbaJxI+nmN8pZlJmgh+zuMRQ X-Received: by 2002:aa7:d653:: with SMTP id v19mr13398728edr.383.1588584109284; Mon, 04 May 2020 02:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588584109; cv=none; d=google.com; s=arc-20160816; b=cwHPO6O1UR4SkzYXb/3UyQelqAdOD23VufQ84d9gc18l3oh7r/80NR7o0Xn7yfqo1w kce5UNrSwj1KXtcmvYHXazCeQz6AF3bSVC6yOzSCV3vPLkrYyrF6SEpO3wUBm/AmDRLh gTPnOKD/3DVnDMt+uKVfc7Y0ztBHVC/wTDRlE+zNV4Xl7/3DZ2NE1f3xCvDt6aU/dXgO T/qJTNliNCzkyeealPY82mprSFu5qEHKVtxqci8K87JzUo3+ucOeB/yD4FM89FFDJkRE KyxRzvXCkf9Uf/vZyT3s08aMYh2N1cMAND0+RDtyMZYkHBCrwedEXqdqQhAeXqtSqWma Ijqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=V76tD/qhPfuDCLw62sz3uPmzCHoYV5tH9STBMYArvEk=; b=w0c5NkUcX5te9tqR5rJTo3X2zoLY111DiGEHMtI0QuxcaYM/1cixJF/G7ybMB2mpVV yeEjrFOsAUYpkNjMKQkujZMT32j5pM11AAV7ql3qga5PfimP1lfM3W1i3TClODyOB2pH 7JMCTCIhJmDbyCLGnJzfSj94PjG90KN9xYfHAa0CMwee0xmduGsfB0uxKNH+M+Cy3r+9 y0VAbDcDPg2etFDwLo5p8ffRjg1GvslLjXfbd+gjbdMnGMqw6fWOxNghOS2myoxQ7VHM ZBzTfOAkx1KTQ4hNU8Bb9HmrBqI27ViMJu1V167knaMVju3iCQ+3J2D053eg6FIT1hrF q4HA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o15si6153121eju.289.2020.05.04.02.21.24; Mon, 04 May 2020 02:21:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728254AbgEDJUD (ORCPT + 99 others); Mon, 4 May 2020 05:20:03 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:58517 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727930AbgEDJUC (ORCPT ); Mon, 4 May 2020 05:20:02 -0400 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jVXGZ-0006Es-4z; Mon, 04 May 2020 09:19:59 +0000 From: Kai-Heng Feng To: mathias.nyman@intel.com Cc: Kai-Heng Feng , Greg Kroah-Hartman , linux-usb@vger.kernel.org (open list:USB XHCI DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] xhci: Prevent runtime suspend all the time with XHCI_RESET_ON_RESUME quirk Date: Mon, 4 May 2020 17:19:52 +0800 Message-Id: <20200504091952.15820-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Etron EJ168 USB 3.0 Host Controller stops working after S3, if it was runtime suspended previously: [ 370.080359] pci 0000:02:00.0: can't change power state from D3cold to D0 (config space inaccessible) [ 370.080477] xhci_hcd 0000:04:00.0: can't change power state from D3cold to D0 (config space inaccessible) [ 370.080532] pcieport 0000:00:1c.0: DPC: containment event, status:0x1f05 source:0x0200 [ 370.080533] pcieport 0000:00:1c.0: DPC: ERR_FATAL detected [ 370.080536] xhci_hcd 0000:04:00.0: can't change power state from D3hot to D0 (config space inaccessible) [ 370.080552] xhci_hcd 0000:04:00.0: AER: can't recover (no error_detected callback) [ 370.080566] usb usb3: root hub lost power or was reset [ 370.080566] usb usb4: root hub lost power or was reset [ 370.080572] xhci_hcd 0000:04:00.0: Host halt failed, -19 [ 370.080574] xhci_hcd 0000:04:00.0: Host not accessible, reset failed. [ 370.080575] xhci_hcd 0000:04:00.0: PCI post-resume error -19! [ 370.080586] xhci_hcd 0000:04:00.0: HC died; cleaning up This can be fixed by not runtime suspend the controller at all. So instead of conditionally runtime suspend the controller, always prevent runtime suspend with XHCI_RESET_ON_RESUME quirk. Signed-off-by: Kai-Heng Feng --- drivers/usb/host/xhci-pci.c | 3 ++- drivers/usb/host/xhci.c | 19 ------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 766b74723e64..7d2660923dae 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -371,7 +371,8 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) xhci->shared_hcd->can_do_streams = 1; /* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */ - pm_runtime_put_noidle(&dev->dev); + if (!(xhci->quirks & XHCI_RESET_ON_RESUME)) + pm_runtime_put_noidle(&dev->dev); if (xhci->quirks & XHCI_DEFAULT_PM_RUNTIME_ALLOW) pm_runtime_allow(&dev->dev); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index bee5deccc83d..8a1e3172405b 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3860,16 +3860,6 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev) struct xhci_slot_ctx *slot_ctx; int i, ret; -#ifndef CONFIG_USB_DEFAULT_PERSIST - /* - * We called pm_runtime_get_noresume when the device was attached. - * Decrement the counter here to allow controller to runtime suspend - * if no devices remain. - */ - if (xhci->quirks & XHCI_RESET_ON_RESUME) - pm_runtime_put_noidle(hcd->self.controller); -#endif - ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__); /* If the host is halted due to driver unload, we still need to free the * device. @@ -4020,15 +4010,6 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev) xhci_debugfs_create_slot(xhci, slot_id); -#ifndef CONFIG_USB_DEFAULT_PERSIST - /* - * If resetting upon resume, we can't put the controller into runtime - * suspend if there is a device attached. - */ - if (xhci->quirks & XHCI_RESET_ON_RESUME) - pm_runtime_get_noresume(hcd->self.controller); -#endif - /* Is this a LS or FS device under a HS hub? */ /* Hub or peripherial? */ return 1; -- 2.17.1