Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4476539ybx; Mon, 4 Nov 2019 14:04:32 -0800 (PST) X-Google-Smtp-Source: APXvYqx2wyc7HbtzCvk/JUTasdfELSU9uwET2eLfiLOQfsf4LmV5FdeUwf8paCC0DamZDjI17OZd X-Received: by 2002:a17:906:cca:: with SMTP id l10mr4664455ejh.161.1572905072474; Mon, 04 Nov 2019 14:04:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905072; cv=none; d=google.com; s=arc-20160816; b=oj6PWMNbMVcO6tu+sqgA6NIj/jHzg3ABSTH+nBOapX66lfJ2x7QF7e7gUJmi1QS/JD ZP2aM7+90o8jXi4MtS4ekXII6zVNZt14cMPCD1YIq4DowGSh3NCz74HqUe0aie6jYW29 jIdGJjwO9hGFdLKWHZ8q1rsUjLT4UYiEYb/kVRhygRqnBd8g8LNizI86EYOfFl/rBypB wFsvZwJsqD9nlIqsOQVF++iGhQvedEpb08BFa9oHhz0RCeioLGd4UAUtZN5KCRYdB/ne X/Az5X7mMi6Tg7/dR2Tahbi5BhEmR5WR6KqXE8RKqbdfhHr5xpfQ1jDzHNtCqxEEYTZF Lnpw== 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=LQPMmTnu1T4U+WVIh6apSDW0+Vr3wGLMx3AMSdLLgZw=; b=KeWcAt4ezHxjzPZMXzjbxYwUMenCAUJotjinj2CMxag7AB/xGb6hC+dLvBEeL1PZ9t dNpN+bngtC0etAMfERNZmqm+NsGFHLyin/0k0G7ah6i0JAih0EjLFI+AMBzlWUAwHlHe uF+8UO6DjUG/VymS9lyOkePHvJmGhUlYC9ySIx+a36ukfWTlW6b7MrtIt0k9PZP8oRw9 ntMJ8mzaJ4fdxeNi3d26Dv0tiEBzixp+6ctMBcUwoo3zMf7buC0TgNYEf+VsV1+LB8ij Rla5KfwowzJ9QhSbRQeKkCRiAdCRNe5m/GnMINjcoYBMoIiksRCpMC/1Ql9NT3geJsev j3Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YZICde0U; 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 uz29si12794125ejb.68.2019.11.04.14.04.09; Mon, 04 Nov 2019 14:04:32 -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=YZICde0U; 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 S2388850AbfKDWAZ (ORCPT + 99 others); Mon, 4 Nov 2019 17:00:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:57986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388512AbfKDWAY (ORCPT ); Mon, 4 Nov 2019 17:00:24 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (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 CF80521744; Mon, 4 Nov 2019 22:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904823; bh=w72zSyvqC/ZsLccUu1t1p4GzejqibTaKWFcIEuyG+0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YZICde0UucqwUzKQWl0NVEMFTd1R0nfYuEHz98fKA9llhu0HV1cRM5nA2uGq/XL+t 5uOt9+EYMpLnmeTDu5GodrLz+B8NKttuUp25B5ATtfs23wVKsOnzT1BCWpp3e/q+ne HzG3RYXfBbSIbHxCkxW8dDklgvhbesuahVupWtEQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan-Marek Glogowski , Alan Stern , Sasha Levin Subject: [PATCH 4.19 041/149] usb: handle warm-reset port requests on hub resume Date: Mon, 4 Nov 2019 22:43:54 +0100 Message-Id: <20191104212138.698719675@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212126.090054740@linuxfoundation.org> References: <20191104212126.090054740@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Jan-Marek Glogowski [ Upstream commit 4fdc1790e6a9ef22399c6bc6e63b80f4609f3b7e ] On plug-in of my USB-C device, its USB_SS_PORT_LS_SS_INACTIVE link state bit is set. Greping all the kernel for this bit shows that the port status requests a warm-reset this way. This just happens, if its the only device on the root hub, the hub therefore resumes and the HCDs status_urb isn't yet available. If a warm-reset request is detected, this sets the hubs event_bits, which will prevent any auto-suspend and allows the hubs workqueue to warm-reset the port later in port_event. Signed-off-by: Jan-Marek Glogowski Acked-by: Alan Stern Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/core/hub.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 8018f813972e0..d5fbd36cf4624 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -107,6 +107,8 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); static void hub_release(struct kref *kref); static int usb_reset_and_verify_device(struct usb_device *udev); static int hub_port_disable(struct usb_hub *hub, int port1, int set_state); +static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1, + u16 portstatus); static inline char *portspeed(struct usb_hub *hub, int portstatus) { @@ -1111,6 +1113,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) USB_PORT_FEAT_ENABLE); } + /* Make sure a warm-reset request is handled by port_event */ + if (type == HUB_RESUME && + hub_port_warm_reset_required(hub, port1, portstatus)) + set_bit(port1, hub->event_bits); + /* * Add debounce if USB3 link is in polling/link training state. * Link will automatically transition to Enabled state after -- 2.20.1