Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp513950imp; Wed, 20 Feb 2019 04:21:09 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib2kUgM1YRQBxOGnfkYbZZLju3DvnjErURywwXLkTZs6X8Ro1vuiBDvRcUFYAQSBbQZ+w6u X-Received: by 2002:a63:a41:: with SMTP id z1mr28779234pgk.117.1550665269049; Wed, 20 Feb 2019 04:21:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550665269; cv=none; d=google.com; s=arc-20160816; b=B4MzVAD66SMK0H2IN616Y69pz12b+KiGIvLJIoz3CaFKS5zvSutyUxtrnNcRlSPE5t S27bpFiwSpZPLxCFwEQDHDPKKpkz7LeB4Abi7e62dmAGvgC949gj9xZ+uw59f+gPfaYt 1anMHLnSNr7rUZRxlVUFmEsBX0igOc0jziHkUU5i0hnwdYtjJQVbkkAWy+TVr/4kqN4t HB3LXAOO5dgfy1WohYVtkOg2vPmGDpX7WCBB0i8kyTVppEUzisbWUOEO4j+9+0hS7Rvr qt/L32WahyFRYZkhBeX10PRQLYo2b2wtyVKAZHcsr0J5I8zcAgTeypBfry+df8qxSfV9 lC9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FSRWwTVoBrMl78Zf6MgLukE/51IJ1VvujWzWa2NPdSc=; b=rjoVGaEafNjIChvEZ+4b8lyGqVet1DUP4myQosXvwugvdZWTXhqIYAGwbevDEbfvQv K9aH+EvP9dggpE5sjptmOtl85LhxT4ph1NsIfWrCqzJ08bsMvP7eE2l+HJs7TgBiLOsq TgFg7vVRiIbotE0Ib9wNKNbidmzHsxfUbGgJpjCR8kikWTdp5PM2DpMSOUqLbUqJMxCq 5Mlo0ndOn0p5KEJWcaTgJt5fxt0E+NALiYKy27z0I234/Iq8Q5Us30PiH+gs59wMeTuy paZE4SRcClI0FYOawgpBC3uDJc4HZBHlDAtmPvUVr5qmeKPZjUVCSDqJz6mQpHQ2Gu/E M5NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@norrbonn-se.20150623.gappssmtp.com header.s=20150623 header.b=fDEUd1Kb; 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 r11si18805930plo.319.2019.02.20.04.20.53; Wed, 20 Feb 2019 04:21:09 -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; dkim=pass header.i=@norrbonn-se.20150623.gappssmtp.com header.s=20150623 header.b=fDEUd1Kb; 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 S1727801AbfBTMUW (ORCPT + 99 others); Wed, 20 Feb 2019 07:20:22 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:36342 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727602AbfBTMUV (ORCPT ); Wed, 20 Feb 2019 07:20:21 -0500 Received: by mail-lf1-f65.google.com with SMTP id q11so17396067lfd.3 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=RPqq6+irpeyYgzI/zqc9Z92N3ICblIYOov59OwhQLqHkOY0MBzd/9v4ACXwBYFIoZr 3dco/zunesjZ4QOio4p6wDTEWFbmkzuvdDZKB9LUP5xYRy50nfmg1RbX+vejt59osKyf cHv9prk4P7L4hTX9rUxQZfkL5VXt6lsy8pGap3oOBaED8QlBdcs3lhltjtPTrtmuse45 PF76Ux8eCAawgmBhemUwjvccydn4Arr8c05Xqupk3NPeKHF/JU8joZHfssWIfbNkDKYF D2wk9wZJnCK1J3QQfRg54fkMVfXdmHTHtzHRF8560kv0y92x+qV6tmy5X221y7DCXWhi qWMQ== X-Gm-Message-State: AHQUAuaVMY07QaUvY25ksVxJQkcGQXbemIBH0hTTMhgU0oKi257sf3fm ce4kwoIH9b6Azems/4O7+6h7bklKC30= 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.19.1