Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1101569ybx; Tue, 5 Nov 2019 10:19:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzKhhnj9CgvLvMkve8vacib0jCLwqGHFA3fn8uMF+nISaP4A6Lic/y2/PnjiRnT6RIiOfBJ X-Received: by 2002:aa7:c303:: with SMTP id l3mr15009733edq.89.1572977968174; Tue, 05 Nov 2019 10:19:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572977968; cv=none; d=google.com; s=arc-20160816; b=V/C3GJE9LrG/c4RXEzRbghLE3h3j/EDshpu89akjjilS3D5GUJca5IkFxJoLGGoIt9 dn4mO152vi3j+7zARA27lHW5B0tkYop0CyKJ5OB6S+iIKaO1+8PN+aiIoHdyhwSA5q+O 5Opuo5qxVruFl9IkZhiASNUtqu1RqWS4SlvY7oPAtBiDnCyFW6QWdEQYg6gY91mCGgeZ dYxHIpGYHzQS984wXaZ+LCWV9ayl9jwyk0R8EQCwv1lYt9OMcQEa26cIuXd/4ma5lBt9 QACJDoITy1ZBnKZzEpBpRfQ6iITOpua2qGJbuZdIZL6GYMMW5Bq0fQx9o0Qff9k94Acr APwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=EI7nBpZegEJXMuMnez7pqS0dTmDTsfE3jTPn2+iYII8=; b=rx2DCb4/f7sui9K6WEwxQFvdr1MPwGSPWWW6c+uSCY+9qztgGvoAkff50T3lynDuMn 0cKXh5gYaJeYXkLtPvzqHdsKGImmGMbdciY//mktiyu2wZcwDg4Zl3Uyqz5h/PltF/pB Mn8oDxA2AQJnTwOGuGloinocQDw2KdfOMV29sZTi2f5RVSNj6YMpnl5nvmnRrkH1enmg YQQNt7Pw7DYnVXnBwOO8uAZ1YYk6xIkdRg1VflQWFZuB4Gvz48wWcscizzArRvz4gNr4 qM3UY8N6inI7rJFNfdn67FDFGHMLCRk7gRyXvmjiuhStVJ+8nXHN7p93mS/1m+8w/b+U horw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o14si3416812ejr.14.2019.11.05.10.19.03; Tue, 05 Nov 2019 10:19: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390694AbfKESSV convert rfc822-to-8bit (ORCPT + 99 others); Tue, 5 Nov 2019 13:18:21 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:55140 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390423AbfKESSV (ORCPT ); Tue, 5 Nov 2019 13:18:21 -0500 Received: from mail-pf1-f198.google.com ([209.85.210.198]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iS3PH-0000IQ-Fl for linux-kernel@vger.kernel.org; Tue, 05 Nov 2019 18:18:19 +0000 Received: by mail-pf1-f198.google.com with SMTP id 20so16812949pfp.19 for ; Tue, 05 Nov 2019 10:18:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=5Wmxaj+BarZSVjtedyoX+TxJZ3eiXoyUdzCwL1PF1ho=; b=omahlsH7EeO1dh8mJpQibtxoDBjACsUpFSzfl5NFlD7oCy52iSu4/8s+BowtSq6g5I AEJNKM3yX118vglgaWK5Mifxn6hH6VUONr+lcOvd4+YKHn3ydzdF/I5gQdeV/jxkSc9N cwlRvAXSJdy8M4e0oTpeKDjfOTyyRnLIxugnnFu/laj1uBZ0w0hvMeJIkrlQ20IsNrTL IHWC1icNxr2j7JhMUq7+BzgG0+CvlaDBcahvym5pMUIZFQEfzwLbLciABdzZIdq2UKaR bB/tk4Nf9X+Qq1xvkMrxqbjy72o8cWzd6Jq967hjZN8dNPWBo/4T0sDGdXeeM9+qVeR8 8eNA== X-Gm-Message-State: APjAAAVQIovKPeL/OIYfLT6eXLHvQNLeLvA8eT86bM6XtnsDtoT88k8O Uypgf56U8ly1ghNN1Xpig5YJ3LsW9G9y/yg/p25SW2bTjQaP0Q+YPhkzpE97WrBPEMRVUliZPD+ G9jXQhIMKbhPXJik0/ylWs5YNab4BAZ6NMxAm/CPQlQ== X-Received: by 2002:a63:fe15:: with SMTP id p21mr37016352pgh.26.1572977898033; Tue, 05 Nov 2019 10:18:18 -0800 (PST) X-Received: by 2002:a63:fe15:: with SMTP id p21mr37016317pgh.26.1572977897645; Tue, 05 Nov 2019 10:18:17 -0800 (PST) Received: from 2001-b011-380f-3c42-8c92-3808-9862-c817.dynamic-ip6.hinet.net (2001-b011-380f-3c42-8c92-3808-9862-c817.dynamic-ip6.hinet.net. [2001:b011:380f:3c42:8c92:3808:9862:c817]) by smtp.gmail.com with ESMTPSA id z1sm93478pju.27.2019.11.05.10.18.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Nov 2019 10:18:17 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3601.0.10\)) Subject: Re: [PATCH] usb: Allow USB device to be warm reset in suspended state From: Kai-Heng Feng In-Reply-To: Date: Wed, 6 Nov 2019 02:18:14 +0800 Cc: Greg Kroah-Hartman , Mathias Nyman , USB list , Kernel development list Content-Transfer-Encoding: 8BIT Message-Id: <325CE337-2467-4DBF-AF23-E4E5E11EAEFB@canonical.com> References: To: Alan Stern X-Mailer: Apple Mail (2.3601.0.10) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Nov 6, 2019, at 02:07, Alan Stern wrote: > > On Wed, 6 Nov 2019, Kai-Heng Feng wrote: > >> On Dell WD15 dock, sometimes USB ethernet cannot be detected after plugging >> cable to the ethernet port, the hub and roothub get runtime resumed and >> runtime suspended immediately: >> ... > >> ... >> >> As Mathias pointed out, the hub enters Cold Attach Status state and >> requires a warm reset. However usb_reset_device() bails out early when >> the device is in suspended state, as its callers port_event() and >> hub_event() don't always resume the device. >> >> Since there's nothing wrong to reset a suspended device, allow >> usb_reset_device() to do so to solve the issue. > > I was sure I remembered reading somewhere that suspended devices were > not allowed to be reset, but now I can't find that requirement anywhere > in the USB spec. I don't find it in the USB spec either. That said, the following usb_autoresume_device() before reset may resume the device. I've also tried using pm_runtime_get_noresume() and it works equally well for my case but I am not sure if we want to change the behavior here. > >> Signed-off-by: Kai-Heng Feng >> --- >> drivers/usb/core/hub.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c >> index 05a2d51bdbe0..f0194fdbc9b8 100644 >> --- a/drivers/usb/core/hub.c >> +++ b/drivers/usb/core/hub.c >> @@ -5877,8 +5877,7 @@ int usb_reset_device(struct usb_device *udev) >> struct usb_host_config *config = udev->actconfig; >> struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); >> >> - if (udev->state == USB_STATE_NOTATTACHED || >> - udev->state == USB_STATE_SUSPENDED) { >> + if (udev->state == USB_STATE_NOTATTACHED) { >> dev_dbg(&udev->dev, "device reset not allowed in state %d\n", >> udev->state); >> return -EINVAL; > > You forgot to update the kerneldoc for this function. Ok, will do that in v2. Kai-Heng > > Alan Stern >