Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1465188ybf; Thu, 27 Feb 2020 11:30:03 -0800 (PST) X-Google-Smtp-Source: APXvYqxaUY7OnD1j9FG1eWGs5LW7KbEhiMIC0HhPo3X+unL3v7+wFy0yaoNF0dCt5xNVX6GxuoXY X-Received: by 2002:aca:ac86:: with SMTP id v128mr455659oie.178.1582831802926; Thu, 27 Feb 2020 11:30:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582831802; cv=none; d=google.com; s=arc-20160816; b=RB9br0toeH31t0SExP2TuKq9QgBXLhrEVtE/6nV/NJwTXBLANXjiHRO9W4+8jj5Lc0 mcNqxS2Hk+Hx6KOxDhhZ5uDeACMTDHccp2/ZYSbCfSRyPcX2EuHPNSsVEWA5pUUC7JVc uskMtm7Xvk6bJiMfDoE2MgKHTRyp8eXaXzfYP8H1mwc7HzyxFRtdhAl8k1638Xyymsqt Kb5OHcTgSvgiK9V7lTa4GBEhBxcjw1zr+zbc22tt2CBWzlQ34itE3+BqBC+xWocogp00 SVDnlXF8fVw+wAPvQ2JrIBusFELWHhpbdqoNiO9r0KEEhyGgC0/IXdg1vdi+VWQHGM/D wdMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=KklCPD5yxQPZt+Wh7vEGlw+X9omyKLReSLij/hfK1Hg=; b=TmW/wTlur+eh1x6ntFg+Wu17kZ+Rry/euAgXMCTEahHWkQCagnwISYJmW9DomQ1eEe nLjxVj4xUgbI8hXaM9V8/ytNPvBRvkU8+yH/UgFuxismxTu163ZS4R/pBCuGAg6/J3gj zD+3oX/f8uguNlL1E+BerEAOhcDtz5r0Ax/4aC2MD6ZXtY0Tfr1Qc8zbm3Aw4BZmvua8 ouWyl1b9K98P/pUiHQxEDYhVIXVTwp8H4vg/nMYOsmnIa6e57M9uGAoh4NyU/4UZfa61 FPPqLtOV5DZsAUbX+y05IRCmNa99MtHbTC1o3xh+sPVToQjg8NSt/gi+EqaFtlff26+Z Jj5g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l13si127895otq.30.2020.02.27.11.29.46; Thu, 27 Feb 2020 11:30:02 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730073AbgB0T3f (ORCPT + 99 others); Thu, 27 Feb 2020 14:29:35 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:37258 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1729687AbgB0T3f (ORCPT ); Thu, 27 Feb 2020 14:29:35 -0500 Received: (qmail 1906 invoked by uid 2102); 27 Feb 2020 14:29:34 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 27 Feb 2020 14:29:34 -0500 Date: Thu, 27 Feb 2020 14:29:34 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Marco Felsch cc: gregkh@linuxfoundation.org, , , , , , , , , , , , kbuild test robot Subject: Re: [RFC PATCH v2] USB: hub: fix port suspend/resume In-Reply-To: <20200227164142.dsnbrxtk747tnvma@pengutronix.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 27 Feb 2020, Marco Felsch wrote: > On 20-02-27 11:18, Alan Stern wrote: > > > Signed-off-by: Marco Felsch > > > --- > > > Hi, > > > > > > this v2 contains the fixes > > > > > > Reported-by: kbuild test robot > > > > Everything below the "---" line, except the patch itself, gets ignored. > > You need to move this Reported-by: up higher. > > I know, I put it here because the patch isn't part of the kernel. IMHO a > > Signed-off-by: > Reported-by: > > looks a bit strange. Not at all. That sort of thing occurs all the time; just look at a few commits in the kernel or patches on the mailing lists. Especially ones that are bug fixes. > > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > > > index 3405b146edc9..c294484e478d 100644 > > > --- a/drivers/usb/core/hub.c > > > +++ b/drivers/usb/core/hub.c > > > @@ -3323,10 +3323,6 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) > > > usb_set_device_state(udev, USB_STATE_SUSPENDED); > > > } > > > > > > - if (status == 0 && !udev->do_remote_wakeup && udev->persist_enabled > > > - && test_and_clear_bit(port1, hub->child_usage_bits)) > > > - pm_runtime_put_sync(&port_dev->dev); > > > - > > > usb_mark_last_busy(hub->hdev); > > > > > > usb_unlock_port(port_dev); > > > @@ -3514,15 +3510,6 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg) > > > int status; > > > u16 portchange, portstatus; > > > > > > - if (!test_and_set_bit(port1, hub->child_usage_bits)) { > > > - status = pm_runtime_get_sync(&port_dev->dev); > > > - if (status < 0) { > > > - dev_dbg(&udev->dev, "can't resume usb port, status %d\n", > > > - status); > > > - return status; > > > - } > > > - } > > > - > > > > Why do you get rid of these two sections of code? Won't that cause > > runtime PM to stop working properly? > > Both runtime_pm calls are part of the suspend/resume logic so this code > isn't called during runtime PM. I'm not quite sure what you mean by that. In any case, it would be completely wrong to think that usb_port_suspend isn't involved in runtime PM. In fact, usb_port_suspend is _more_ important for runtime suspend than for system sleep. The reason is simple: If you want to put a USB device into runtime suspend, you have to tell its upstream hub's port to enable the suspend feature (i.e., call usb_port_suspend). But if you want to put an entire bus of USB devices to sleep for a system suspend, all you have to do is tell the host controller to stop sending packets; the ports don't need any notification. (Actually the situation is more complicated for USB 3. But you get the idea.) > As far as I understood it correctly the > purpose of those section was to trigger port poweroff if the device > supports it upon a system-suspend. No, the purpose of the sections you removed is to trigger port poweroff when the device goes into any type of suspend, either system or runtime. Of course, as you discovered, during system sleep the code doesn't actually turn off the port power -- that's a bug. But during runtime PM it does. > Therefore I came up with my question: > https://www.spinics.net/lists/linux-usb/msg190537.html. > > Also, try to find better names. Maybe usb_port_sleep and > > usb_port_wake, or usb_port_system_suspend and usb_port_system_resume. > > IMHO usb_port_suspend/resume should be the best ;) Okay, so long as they are static and won't conflict with the functions in hub.c. Alan Stern PS: There's one more thing you need to know -- I completely forgot about it until just now. During system sleep, we have to make sure that the child device gets suspended _before_ and resumed _after_ the port. If it happened the other way, we'd be in trouble. (The proper ordering would be automatic if the child USB device was registered under the port device, but for historical reasons it isn't; it gets registered directly under the parent hub.) This means you'll have to call device_pm_wait_for_dev() at the appropriate places in the suspend and resume pathways.