From patchwork Wed Feb 20 12:20:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Bonn X-Patchwork-Id: 10822015 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 EBA25184E for ; Wed, 20 Feb 2019 12:20:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D57C52D6D6 for ; Wed, 20 Feb 2019 12:20:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9D0F2D8D2; Wed, 20 Feb 2019 12:20:29 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D9EA2D6D6 for ; Wed, 20 Feb 2019 12:20:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727602AbfBTMU2 (ORCPT ); Wed, 20 Feb 2019 07:20:28 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:39490 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727551AbfBTMUV (ORCPT ); Wed, 20 Feb 2019 07:20:21 -0500 Received: by mail-lf1-f68.google.com with SMTP id m11so17397638lfc.6 for ; Wed, 20 Feb 2019 04:20:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FSRWwTVoBrMl78Zf6MgLukE/51IJ1VvujWzWa2NPdSc=; b=fDEUd1Kbd4xOXUo32pDS6RZFh9/z99uqXUrrWCFvE5tCnP8faZpMQiu1QpldIGRr2w PVLaMMYxjlpgpKVMuBBMEuXyjirZg+KEZvFymFzl90msykZoE035PcZm68cvwzc3Mq4U +NQ+BsDl0TcO+GSnyw0909rlIRwfwHLpBakqxF32inxI2PPR4Q8c6NR6XHjWoSkfYs5h 247kaP1lo8gkfO+BMjEnrHiR36ghO/jmmUVVW22vzxm5FvqAkr8bsGtoHRAJauNZgh4A LxLaCaUuJNy3RaESgvLU75qAXrPPS2Hi8inmux7+TqTav+HbXqjgc3R0OZF3mTQQceRd LIMw== 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=FSRWwTVoBrMl78Zf6MgLukE/51IJ1VvujWzWa2NPdSc=; b=bSZ/YgjIQXrNTonHzBm+aNywWIAnzMcO1IfaT8poU/cOOyO0bpAkIi6xsFBjaNazK0 DT3+/OejsUgkkULrqG9lGM0Llqfe+lm3e6KYSD6E4QTVNLacX53g/qSGby9I7Eqe19Us Ep5IKhUX4PB4KhcskEFHaq34mF4SIu0RQEaPbOfvm4/3lq9eMO+mk5vPH30bQsVKfaZ4 5sSgezOx5uI2k47Y+osewR8+LKlBDOoZDEfKlDoTwPJzAbrQ1I77Z6gZnC49uG3mC5pY gnEE/p4UBYr+eUu2cUZrgXkCypRbhtmSJbiu0FO1a2Y53a5+ET+hA709xK//89KydcI/ myzw== X-Gm-Message-State: AHQUAuYxlFK0lUE92VYttShOOHhrXgG6Hv9EuootZ4/FKjDHZ4lo5XIH sBpQEtB5LqkLAu/V08TRQFapIg== X-Google-Smtp-Source: AHgI3IbbedkxmXWV3M9a5yKzldNsxhoImr4snDWLw4L5vmCzdVdnHciIz0cWhZJnqf2SSMtybemGeQ== X-Received: by 2002:ac2:5288:: with SMTP id q8mr21278268lfm.157.1550665218561; Wed, 20 Feb 2019 04:20:18 -0800 (PST) Received: from mimer.lan (h-29-16.A159.priv.bahnhof.se. [79.136.29.16]) by smtp.gmail.com with ESMTPSA id r2-v6sm5270270lja.78.2019.02.20.04.20.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 04:20:17 -0800 (PST) From: Jonas Bonn To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Jonas Bonn , Cristian Birsan , Felipe Balbi , Greg Kroah-Hartman , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] usb: gadget: atmel: tie wake lock to running clock Date: Wed, 20 Feb 2019 13:20:01 +0100 Message-Id: <20190220122001.5713-4-jonas@norrbonn.se> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190220122001.5713-1-jonas@norrbonn.se> References: <20190220122001.5713-1-jonas@norrbonn.se> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the USB device is connected to a host, the CPU cannot be suspended or else the USB device appears to be disconnected from the host's point of view. Only after a "USB suspend" state has been entered (as set by the host) or the host is disconnected can the system safely be suspended: in both these states, the clock is stopped. As such, this patch associates a "wake lock" with the running clock of the UDC to keep the system awake as long as the host maintains the USB connection active. Signed-off-by: Jonas Bonn CC: Cristian Birsan CC: Felipe Balbi CC: Greg Kroah-Hartman CC: Nicolas Ferre CC: Alexandre Belloni CC: Ludovic Desroches CC: linux-arm-kernel@lists.infradead.org CC: linux-usb@vger.kernel.org --- drivers/usb/gadget/udc/atmel_usba_udc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 740cb9308a86..864d03c3c9db 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -1859,6 +1859,8 @@ static int start_clock(struct usba_udc *udc) if (udc->clocked) return 0; + pm_stay_awake(&udc->pdev->dev); + ret = clk_prepare_enable(udc->pclk); if (ret) return ret; @@ -1881,6 +1883,8 @@ static void stop_clock(struct usba_udc *udc) clk_disable_unprepare(udc->pclk); udc->clocked = false; + + pm_relax(&udc->pdev->dev); } static int usba_start(struct usba_udc *udc)