Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp171242imd; Wed, 31 Oct 2018 16:45:24 -0700 (PDT) X-Google-Smtp-Source: AJdET5d29FDuTYgIgmxJnhymIx3AnADHLM1VBe+STPPZGYh9kwx6O6xa7Cv2fGcPfwReskwaNaRd X-Received: by 2002:a17:902:5a8b:: with SMTP id r11-v6mr5479582pli.305.1541029524594; Wed, 31 Oct 2018 16:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029524; cv=none; d=google.com; s=arc-20160816; b=xNxaEZ/APRLo5o0F/hVJ8DECqDMQx6hSaphOagrsM3i8bvYXbjB/g/L9hstdEcQCLH jBExxGQnoEq+TwgY6jMjiAA15tK2gY8te7pXt2typnF5U2LzKFttgikDo2E04Bro07TW qbhP8xTwOCTsYNs8/4uXF4gDhM9xUMVNBcZg3WSfP3d46C5QVh+KqUUnUDwASXh3p0Bw 6gXF1inNLGUxZgRe++QVKC7ss8tYmc6xIqEg2Es6Atzz7uPZ97bbNXZKc0V0VtxfZYOZ 7Yec9ft76tH01eHGGPAdcdRDD8yZ5G0zicvAzyaQPx9qP8yeFHFVAt5Ibp9585+8wkZv CzLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=cjkflDmhiXUv+fnNcBlitWNFNW4ylO9qi5+v4iabUVI=; b=i/lt1C7KuaZlzeZWjkGVTRkm0bFftP4/dmr8IRzBjujcUotO7Du+kR0f9subvZQYFO JGWgvX2H0V3SF+cy1ww0ZpurANY85myOcYOVAUO2oNqqk9nt68ZDPxU/M2FxIegx2q4i j5YhlejlytvJGEjLg+/CkqNjXfhptjfQsc6Cfp8ZtFCMyM9RuUeONIGB6TJw/LcU6EyU Yms2J3Z6WWVV4k5gBpEhBQFej0N5/548husYZsEUE436v5AXVtTz6b0i78nLtlN9yV9k qZ3h9WQnlhG0P6tbbrgExiPkvCy5k6jH8GfFemD4JPKSagL+RWpFyCDs6Il+JUgrH23s SSkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="W/sDDSiI"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p6-v6si28251727pgd.312.2018.10.31.16.45.09; Wed, 31 Oct 2018 16:45:24 -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="W/sDDSiI"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729112AbeKAIHn (ORCPT + 99 others); Thu, 1 Nov 2018 04:07:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:55696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727308AbeKAIHm (ORCPT ); Thu, 1 Nov 2018 04:07:42 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B73832064C; Wed, 31 Oct 2018 23:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027251; bh=L2Otf0USOLk05QKnSlvJM8QHbwdM1pnJno8WqednS+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W/sDDSiIulYOxxDAMEic/KiJthT1vsiCeNfDJIpRY7kX6VG0gDxfViucr40S90btI ZbSKbxpbK4mwvq/cJlozt7Fd7PyVFXxhB7ceiqG+jp993nVf8Z05Yb9+id5WAlKiZX HZyXkg7+iz2gzsKYkcCtc30nQ7hp9Qt/tSLdQSVI= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Anshuman Gupta , Mathias Nyman , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.19 121/146] xhci: Avoid USB autosuspend when resuming USB2 ports. Date: Wed, 31 Oct 2018 19:05:16 -0400 Message-Id: <20181031230541.28822-121-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/usb/host/xhci-hub.c | 5 +++++ drivers/usb/host/xhci-ring.c | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 7e2a531ba321..12eea73d9f20 100644 --- 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 usb_hcd *hcd, 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 usb_hcd *hcd, 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 usb_hcd *hcd, (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, u16 typeReq, u16 wValue, 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, u16 typeReq, u16 wValue, 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; diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index f0a99aa0ac58..cd4659703647 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1602,6 +1602,7 @@ static void handle_port_status(struct xhci_hcd *xhci, 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; } } -- 2.17.1