From patchwork Tue Mar 31 16:14:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6131721 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8E3A2BF4A6 for ; Tue, 31 Mar 2015 16:16:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8EFA02010E for ; Tue, 31 Mar 2015 16:16:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 98F04201B4 for ; Tue, 31 Mar 2015 16:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753180AbbCaQQQ (ORCPT ); Tue, 31 Mar 2015 12:16:16 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:32780 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753084AbbCaQQM (ORCPT ); Tue, 31 Mar 2015 12:16:12 -0400 Received: by wixm2 with SMTP id m2so17747468wix.0; Tue, 31 Mar 2015 09:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=b9gQhmx7HxA9/K17w0SWCgpoOXgbSwlWy6dhj2SeAlc=; b=A9GY8GSwfc35uQ1q/aBerjT8YPQ9WBEjIluWTioPxML2fqqmKziLkxy/osBqBLea3K /DoFlnwswx8DFJH3OhXn9FIob3criqK6hiMqFD+kfCoaAO8SHGAgMB6wdwna1/go3hHB vxpKMoJdMgt0v+Jc3w+OSwzSXPP08LqPweP7dza7mxqrIiI4LlAOiZAxAhTMlzcQDqfN 8wB6ZwoA3KWtL5In3SoI4IJTr6njOyzRihmibKIBdvcz2sW2XqT1skQ6cZ9sGVEdJ87O 4/jT/jWKHVV44O0W9oMPSAhtW1OWRgQTnqPugpao99VbAuIiLoNNxLfgmrepiDKoOCGx 3tRw== X-Received: by 10.180.84.99 with SMTP id x3mr6733492wiy.35.1427818570406; Tue, 31 Mar 2015 09:16:10 -0700 (PDT) Received: from cizrna.lan ([109.72.12.56]) by mx.google.com with ESMTPSA id lx10sm20984796wjb.17.2015.03.31.09.16.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Mar 2015 09:16:09 -0700 (PDT) From: Tomeu Vizoso To: linux-pm@vger.kernel.org Cc: Tomeu Vizoso , Greg Kroah-Hartman , Scot Doyle , Alan Stern , Dan Williams , Julius Werner , "Rafael J. Wysocki" , Pratyush Anand , Sebastian Andrzej Siewior , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] USB / PM: Allow USB devices to remain runtime-suspended when sleeping Date: Tue, 31 Mar 2015 18:14:50 +0200 Message-Id: <1427818501-10201-7-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.3.4 In-Reply-To: <1427818501-10201-1-git-send-email-tomeu.vizoso@collabora.com> References: <1427818501-10201-1-git-send-email-tomeu.vizoso@collabora.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Have dev_pm_ops.prepare return 1 for USB devices, interfaces, endpoints and ports so that USB devices can remain runtime-suspended when the system goes to a sleep state. Also enable runtime PM for endpoints, which is another requirement for the above to work. Signed-off-by: Tomeu Vizoso --- drivers/usb/core/endpoint.c | 17 +++++++++++++++++ drivers/usb/core/message.c | 16 ++++++++++++++++ drivers/usb/core/port.c | 6 ++++++ drivers/usb/core/usb.c | 2 +- 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c index 39a2402..7c82bb7 100644 --- a/drivers/usb/core/endpoint.c +++ b/drivers/usb/core/endpoint.c @@ -160,6 +160,19 @@ static const struct attribute_group *ep_dev_groups[] = { NULL }; +#ifdef CONFIG_PM + +static int usb_ep_device_prepare(struct device *dev) +{ + return 1; +} + +static const struct dev_pm_ops usb_ep_device_pm_ops = { + .prepare = usb_ep_device_prepare, +}; + +#endif /* CONFIG_PM */ + static void ep_device_release(struct device *dev) { struct ep_device *ep_dev = to_ep_device(dev); @@ -170,6 +183,9 @@ static void ep_device_release(struct device *dev) struct device_type usb_ep_device_type = { .name = "usb_endpoint", .release = ep_device_release, +#ifdef CONFIG_PM + .pm = &usb_ep_device_pm_ops, +#endif }; int usb_create_ep_devs(struct device *parent, @@ -197,6 +213,7 @@ int usb_create_ep_devs(struct device *parent, goto error_register; device_enable_async_suspend(&ep_dev->dev); + pm_runtime_enable(&ep_dev->dev); endpoint->ep_dev = ep_dev; return retval; diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index f368d20..9041aee 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1589,10 +1589,26 @@ static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env) return 0; } +#ifdef CONFIG_PM + +static int usb_if_prepare(struct device *dev) +{ + return 1; +} + +static const struct dev_pm_ops usb_if_pm_ops = { + .prepare = usb_if_prepare, +}; + +#endif /* CONFIG_PM */ + struct device_type usb_if_device_type = { .name = "usb_interface", .release = usb_release_interface, .uevent = usb_if_uevent, +#ifdef CONFIG_PM + .pm = &usb_if_pm_ops, +#endif }; static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev, diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index 2106183..f49707d 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -168,12 +168,18 @@ static int usb_port_runtime_suspend(struct device *dev) return retval; } + +static int usb_port_prepare(struct device *dev) +{ + return 1; +} #endif static const struct dev_pm_ops usb_port_pm_ops = { #ifdef CONFIG_PM .runtime_suspend = usb_port_runtime_suspend, .runtime_resume = usb_port_runtime_resume, + .prepare = usb_port_prepare, #endif }; diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index b1fb9ae..1498faa 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -300,7 +300,7 @@ static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env) static int usb_dev_prepare(struct device *dev) { - return 0; /* Implement eventually? */ + return 1; /* Implement eventually? */ } static void usb_dev_complete(struct device *dev)