From patchwork Sun Jul 26 23:24:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ruffell X-Patchwork-Id: 1336568 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BFJvJ3sWLz9sRX; Mon, 27 Jul 2020 09:25:16 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jzq12-0002Ag-EN; Sun, 26 Jul 2020 23:25:12 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jzq0z-0002A4-65 for kernel-team@lists.ubuntu.com; Sun, 26 Jul 2020 23:25:09 +0000 Received: from mail-pj1-f72.google.com ([209.85.216.72]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jzq0y-00017D-Pq for kernel-team@lists.ubuntu.com; Sun, 26 Jul 2020 23:25:09 +0000 Received: by mail-pj1-f72.google.com with SMTP id t3so3468635pjo.2 for ; Sun, 26 Jul 2020 16:25:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZpHa4UDXHScuH7HrxgSNClV9Uv/LFlA3wU7FAm27V/M=; b=iQPnCEl65y4dQc2TcQ8NBPYmXfUbDwEN/ks8O3eEe0xuZM+rZlDQkfNHfGWzyaDZ5S DC5pEKzBwjL5JMxkLrA9RtAScmpXF9NVrpGCRPQApU+nXpbTgHSoeVNoubX2GvU5dctU nNjpf2U171zP7oZ0d9fFd1sLaqtIcAg9da2q8wn4060DqselHPHb1pccj2vZnxVNglsu cbejbBSIHt9V3lTYA6mnBc7zFGb9q+O/SyWBSPobNMY3vg+ilpqTNdvKZhI78BkuPTBU MiIVelHOQYe55qJM3Vx/P//QZ9yBhWKZjfBRhZc4mmbWr1ZesLROjGNjPIiG85J/sxfP DzDQ== X-Gm-Message-State: AOAM532yEG2A8WiSJYaDa0vphQ0yGQYWOeroQiAXapNmoct6trbJFkYR hrTINLi3OYarE30oChJzICSrldm96FVbETzdXFtJjkIMLGJmJl69eqRq4tRC6NABvghst0xJuTj ST21MhhvS+JnEPMbz11Boz4cBE6bHAR8NZOAhzuvJvw== X-Received: by 2002:a17:90a:be06:: with SMTP id a6mr16104625pjs.136.1595805907381; Sun, 26 Jul 2020 16:25:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypd1fgIsVhbneyDB0kdzEsL/vU6yAImv6/JbJOp+vMqh8evCBK7A0LWi6SRLQ9Nia8gzoHug== X-Received: by 2002:a17:90a:be06:: with SMTP id a6mr16104614pjs.136.1595805907175; Sun, 26 Jul 2020 16:25:07 -0700 (PDT) Received: from localhost.localdomain (222-152-178-139-fibre.sparkbb.co.nz. [222.152.178.139]) by smtp.gmail.com with ESMTPSA id w18sm12267138pgj.31.2020.07.26.16.25.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2020 16:25:06 -0700 (PDT) From: Matthew Ruffell To: kernel-team@lists.ubuntu.com Subject: [SRU][B][E][PATCH 1/1] usb: handle warm-reset port requests on hub resume Date: Mon, 27 Jul 2020 11:24:57 +1200 Message-Id: <20200726232457.9107-2-matthew.ruffell@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200726232457.9107-1-matthew.ruffell@canonical.com> References: <20200726232457.9107-1-matthew.ruffell@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jan-Marek Glogowski BugLink: https://bugs.launchpad.net/bugs/1859873 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 (cherry picked from commit 4fdc1790e6a9ef22399c6bc6e63b80f4609f3b7e) Signed-off-by: Matthew Ruffell Acked-by: Stefan Bader Acked-by: Kleber Sacilotto de Souza --- 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 b99602789ca2..7a27237f6b67 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) { @@ -1117,6 +1119,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