From patchwork Thu Apr 18 00:13:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10906409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67A9114DB for ; Thu, 18 Apr 2019 00:15:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DAA328BD4 for ; Thu, 18 Apr 2019 00:15:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 419A828BD7; Thu, 18 Apr 2019 00:15:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE40A28BD4 for ; Thu, 18 Apr 2019 00:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ds8D3xXXd8XjA6MDTGfVUiFDYiQqt5i1smEvEebmEF4=; b=kiUWW8ywNVDQTf vDyLjEZHokOuNml7ZH7AtP5/w2HDFMswk1uBUPi18ePTk6PEAycoWYy/ppmo+weUjVwLe9B0ADijd BLXrLvHIdZbsrZbS9w8m9ALd0TE1fuKzLtmM7mtqhxjAAUn5pWKIeyGzMCLaEU9zGlIuTi9qpmRK3 9BpuUWlBd9gDK0q9+jD95u3hw2VY8EqueCps8fUskZaxCOfWYWE+Bs4WfcDNNQ8oe5th0RsSTcaz1 uL4egfP08VaMuK939IXq3/lHnMLShhn/9M6zCIrGYjoxX3Ym+M3FjvDlUWpUx3M0fSsOnIElXwCRN xTbPUBFyJQOF9ueDI2eg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGuhv-00008Z-Az; Thu, 18 Apr 2019 00:15:15 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGuhi-0007Cf-IM for linux-rockchip@lists.infradead.org; Thu, 18 Apr 2019 00:15:06 +0000 Received: by mail-pf1-x441.google.com with SMTP id 8so236882pfr.4 for ; Wed, 17 Apr 2019 17:14:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FEymG5YLHbrDDzFxo52pdSm6cWs0XYbMN/p1plON6hw=; b=IxvwAG/FD+h3vReXVkO8WN6TgoWmn5hmjEDHCWUqYGymihVRS6a5o1mVUT3QNKxtUS s8WcGVHZle2CbosV4XoPgSRF+m5tBlUbQOt2yAkreM99lgKyKUsc0Fkuy3JlX/HFQ/4d bdAJoUwFWOoAEIZttOkK4YpGJT2cIkcGbSuHs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FEymG5YLHbrDDzFxo52pdSm6cWs0XYbMN/p1plON6hw=; b=cCoT1BLaFq1B9q5qbsybBE+8re7L54yUdT2btqlPPjoyhqpLGgAWCT/MkHc2fGRNem vCRH/t+1R2KwtmUJSENQFGrrv3DC92yq//UvNwA9s+nKfOAlfZz0+t6xiTlZ2UnEvRYw J1zgvNcxaHyh2h4XmI9PvRd/TwUBuMK5eZQS3ZdhAUR59BOEc4tmPZqjAh6gGiKBHeq+ qqyw0X9ofZkxoEU1SuUaTTXiFKy7haFt6JYrO19hd7j+QozD2M3Q9pKLz6ZcaeW02FZg yMxTaP8+2GrHmYg6vnZBRDuvtrd/8BYCxLYaCUk7SldYqGjCY8+ZRK94fHaolHHdOvG/ x6pA== X-Gm-Message-State: APjAAAWPI9C/iFawkXmM4KHaw7so98oLgpCg67wZ0cHcL8u4B1Vs3AoK jPlHSDFRBlMo6q9LxUpLv+1tAA== X-Google-Smtp-Source: APXvYqzyMQB6DofPsR3ROmeLa7d3NvmAdljo4RKmr1talzLCVFturW2bHncz7YNf+WhFu2sdhPQ5/g== X-Received: by 2002:a62:aa06:: with SMTP id e6mr2953350pff.254.1555546499283; Wed, 17 Apr 2019 17:14:59 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id q5sm447668pff.97.2019.04.17.17.14.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 17:14:58 -0700 (PDT) From: Douglas Anderson To: Minas Harutyunyan , Felipe Balbi , heiko@sntech.de Subject: [PATCH v2 2/5] USB: Export usb_wakeup_enabled_descendants() Date: Wed, 17 Apr 2019 17:13:53 -0700 Message-Id: <20190418001356.124334-3-dianders@chromium.org> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190418001356.124334-1-dianders@chromium.org> References: <20190418001356.124334-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190417_171502_685818_24B056D1 X-CRM114-Status: GOOD ( 12.66 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amelie Delaunay , linux-kernel@vger.kernel.org, Kai-Heng Feng , zyw@rock-chips.com, Stefan Wahren , Nicolas Boichat , linux-rockchip@lists.infradead.org, mka@chromium.org, Alan Stern , Jon Flatley , Artur Petrosyan , Elaine Zhang , amstan@chromium.org, Randy Li , Mathias Nyman , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Douglas Anderson , ryandcase@chromium.org, William Wu , jwerner@chromium.org, dinguyen@opensource.altera.com, Nicolas Saenz Julienne Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In (e583d9d USB: global suspend and remote wakeup don't mix) we introduced wakeup_enabled_descendants() as a static function. We'd like to use this function in USB controller drivers to know if we should keep the controller on during suspend time, since doing so has a power impact. Signed-off-by: Douglas Anderson --- For relevant prior discussion of this idea, see: https://lkml.kernel.org/r/1436207224-21849-4-git-send-email-dianders@chromium.org If I'm reading all the responses correctly folks were of the opinion that this patch is still the right way to go. Changes in v2: None drivers/usb/core/hub.c | 7 ++++--- include/linux/usb/hcd.h | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 8d4631c81b9f..5e8f3fa7ae5a 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3174,13 +3174,14 @@ static int usb_disable_remote_wakeup(struct usb_device *udev) } /* Count of wakeup-enabled devices at or below udev */ -static unsigned wakeup_enabled_descendants(struct usb_device *udev) +unsigned usb_wakeup_enabled_descendants(struct usb_device *udev) { struct usb_hub *hub = usb_hub_to_struct_hub(udev); return udev->do_remote_wakeup + (hub ? hub->wakeup_enabled_descendants : 0); } +EXPORT_SYMBOL_GPL(usb_wakeup_enabled_descendants); /* * usb_port_suspend - suspend a usb device's upstream port @@ -3282,7 +3283,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) * Therefore we will turn on the suspend feature if udev or any of its * descendants is enabled for remote wakeup. */ - else if (PMSG_IS_AUTO(msg) || wakeup_enabled_descendants(udev) > 0) + else if (PMSG_IS_AUTO(msg) || usb_wakeup_enabled_descendants(udev) > 0) status = set_port_feature(hub->hdev, port1, USB_PORT_FEAT_SUSPEND); else { @@ -3687,7 +3688,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) } if (udev) hub->wakeup_enabled_descendants += - wakeup_enabled_descendants(udev); + usb_wakeup_enabled_descendants(udev); } if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) { diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 695931b03684..ed4fbbd1b35f 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -652,11 +652,16 @@ extern wait_queue_head_t usb_kill_urb_queue; #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) #ifdef CONFIG_PM +extern unsigned usb_wakeup_enabled_descendants(struct usb_device *udev); extern void usb_root_hub_lost_power(struct usb_device *rhdev); extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg); extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg); extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); #else +static inline unsigned usb_wakeup_enabled_descendants(struct usb_device *udev) +{ + return 0; +} static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) { return;