Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3481445imu; Sun, 11 Nov 2018 16:05:28 -0800 (PST) X-Google-Smtp-Source: AJdET5dbZZUj9VotoF8PcDZftBz/YkpqOeHVdG/0RdK0gHm+NyW3RENCJfwaM+/VrX8naU3PmxkJ X-Received: by 2002:a17:902:3a5:: with SMTP id d34-v6mr17832172pld.110.1541981128494; Sun, 11 Nov 2018 16:05:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981128; cv=none; d=google.com; s=arc-20160816; b=g8ZGGHavlsdN19w33G+xyeZPp7VTmbRzkSNe9t0/hwHUPhMh8VLQ1cvLioVD6OckoP ol8zi7T3ra0LlRmb+gspjSoKhEc8H2TmJmFnDblOxrm6k8dO7W2sqCJft5hVjaT47snE o6Nau2BlZ5vrINcIS3NZUjb0GU2Aen+jHPpz6VIubcC5TVBqP4dsxry0oNsjTNAAUCaf CSaptjzWwKB489qIOAcFdclbkoP7uLCfM+84y40RNbi5kP0rInWLauAHL7udqeT98MXd K9vg8RW7eD78v8AsLJB4JxLFbxn2Qd66KUD1A73F7KxDy/BluR/XQd1nXBCcywD85X/j PXbw== 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=PcHcSAOpvmlun8ypdqx2BLBm6Gp0Aar5m2YSIYHP1dk=; b=LQOiOxpYCP9GcMFjjNM0Jqjl9WF/9Qo7u2qtuzQOr3BfUMbevSjbNTAFSvpwc2yho8 mpwBhMB/pPHvHYli1QD0PqgVqUv910Cr8iHiKX2lmym/eHiolNQPVdv0P3Tq9MuiNeZ3 zFpCHJcwnIkp8DrB6dDzuN3uWvjdxWhqwwLC0YIT+9zoxg62Zk+IKukXs4TaeSuM5kW1 lbs2IqE4ZBd5BW1DigFuf7VqO/8qCJhS1OsYuupUi0N3N3pVRGXP5zBY1Qp6VjwVyLAP d6g38JGMrCJDi2a+de7exhw2/EnA2JiQu076Prt01q/8Xjxalbu9wthxGrtuvcmrtDgv rtFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i48DPhzt; 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 d82-v6si17043735pfe.190.2018.11.11.16.05.13; Sun, 11 Nov 2018 16:05:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=i48DPhzt; 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 S1732013AbeKLIRp (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:34236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731952AbeKLIRp (ORCPT ); Mon, 12 Nov 2018 03:17:45 -0500 Received: from localhost (unknown [206.108.79.134]) (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 E93D322360; Sun, 11 Nov 2018 22:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975269; bh=95fGqiKldneHCYHMU3tuNKyIYlEyrLgmvTNwnf1W7YY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i48DPhztyvq71iAxa+KqpllIMsAInTP/qSSvDsjRY9KvG3uLkg9rddBijo0M6EHkA I09STETee2OpmEzmPHBjIEB8hrDFW/ZwveHLcZ2JlqfEgvDe4jA9ephdBCrGCUKKJI sTGKBpYsFJbhgA0uM6mCDM3+Mn1TVhKBUsiBiI8c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anshuman Gupta , Mathias Nyman , Sasha Levin Subject: [PATCH 4.19 165/361] xhci: Avoid USB autosuspend when resuming USB2 ports. Date: Sun, 11 Nov 2018 14:18:32 -0800 Message-Id: <20181111221643.549564876@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anshuman Gupta [ Upstream commit 330e2d61cdd58363eb5e66b2e72f76fe3c5492e0 ] When USB bus host controller root hub resumes from autosuspend, it immediately tries to enter auto-suspend, but there can be a scenario when root hub is resuming its usb2 ports, in that particular case USB host controller auto suspend fails since it is busy to resuming its usb2 ports. This makes multiple failed cycles of auto-suspend until all usb2 ports of host controller root hub do not resume. This patch uses USB core framework usb_hcd_start_port_resume, usb_hcd_end_port_resume API's in order to autoresume/autosuspend root hub properly. Signed-off-by: Anshuman Gupta Signed-off-by: Mathias Nyman Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-hub.c | 5 +++++ drivers/usb/host/xhci-ring.c | 1 + 2 files changed, 6 insertions(+) --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -900,6 +900,7 @@ static u32 xhci_get_port_status(struct u set_bit(wIndex, &bus_state->resuming_ports); bus_state->resume_done[wIndex] = timeout; mod_timer(&hcd->rh_timer, timeout); + usb_hcd_start_port_resume(&hcd->self, wIndex); } /* Has resume been signalled for USB_RESUME_TIME yet? */ } else if (time_after_eq(jiffies, @@ -940,6 +941,7 @@ static u32 xhci_get_port_status(struct u clear_bit(wIndex, &bus_state->rexit_ports); } + usb_hcd_end_port_resume(&hcd->self, wIndex); bus_state->port_c_suspend |= 1 << wIndex; bus_state->suspended_ports &= ~(1 << wIndex); } else { @@ -962,6 +964,7 @@ static u32 xhci_get_port_status(struct u (raw_port_status & PORT_PLS_MASK) != XDEV_RESUME) { bus_state->resume_done[wIndex] = 0; clear_bit(wIndex, &bus_state->resuming_ports); + usb_hcd_end_port_resume(&hcd->self, wIndex); } @@ -1337,6 +1340,7 @@ int xhci_hub_control(struct usb_hcd *hcd goto error; set_bit(wIndex, &bus_state->resuming_ports); + usb_hcd_start_port_resume(&hcd->self, wIndex); xhci_set_link_state(xhci, ports[wIndex], XDEV_RESUME); spin_unlock_irqrestore(&xhci->lock, flags); @@ -1345,6 +1349,7 @@ int xhci_hub_control(struct usb_hcd *hcd xhci_set_link_state(xhci, ports[wIndex], XDEV_U0); clear_bit(wIndex, &bus_state->resuming_ports); + usb_hcd_end_port_resume(&hcd->self, wIndex); } bus_state->port_c_suspend |= 1 << wIndex; --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1602,6 +1602,7 @@ static void handle_port_status(struct xh set_bit(HCD_FLAG_POLL_RH, &hcd->flags); mod_timer(&hcd->rh_timer, bus_state->resume_done[hcd_portnum]); + usb_hcd_start_port_resume(&hcd->self, hcd_portnum); bogus_port_status = true; } }