From patchwork Sat May 7 15:21:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Dimitrov X-Patchwork-Id: 9038191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D35629F30C for ; Sat, 7 May 2016 15:25:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E434620149 for ; Sat, 7 May 2016 15:24:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C11420121 for ; Sat, 7 May 2016 15:24:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1az44V-0004AR-SV; Sat, 07 May 2016 15:23:11 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1az442-00042n-TU for linux-arm-kernel@lists.infradead.org; Sat, 07 May 2016 15:22:44 +0000 Received: by mail-wm0-x244.google.com with SMTP id e201so13349410wme.2 for ; Sat, 07 May 2016 08:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=O5KY0dX3icRMF7fOYcVNw5UJFH9R7a/Gg1JVsW0+jdA=; b=RsjxTNjEU6s6OI7n+xN9R6Tzlyav1oqKtpxFhuiMMpk/iiRVYHEjR31G0otrRbCDGj F6JfHGQjvCxtXKkcpCjsVSJj8i8EBx3QEjDuRkYTjFdJpI87x3f0oKpbCPxXCbO3abpR BZSlYYxknx+mX3Rtn7ew5UFpU6G2reLQignoCUIB4JujOhIg5RPM1dWd2Csh2HLYNzr6 dedQ4CUq0TO8iwsWHZSil7/qDIYpATvYIVl1f9mQUhI/mJa+0avqvM+SfwnLU8Sb6OGn pTuWbu57upfYvJQA9jcmQXWMAC+JnAmcLUQoclOx0lrUF1f/rHV4gH+dI5a2EYPNRjTd cHXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=O5KY0dX3icRMF7fOYcVNw5UJFH9R7a/Gg1JVsW0+jdA=; b=ReBDy+4qU/96OLGuQaa5/xtwYdL4z6OmanlkT/nlh0Rbzr19TIEFIjylwWS7XdlaHZ DeNMlMGKlPzEd+mzYe/vSzH9NqEGVFtQh0cU9AOi7m88zPCVzveJxpR169vUgYEhAdek 2aDbnhhQGsV2hdTsznnuiAiS9zalQfPrCisj4LHiWDOTDifKvX/QtTRARhT+nAJcm9He OIV79fZNaf7CS+f0TPb++k6MmnOrJgCRRWOJiT55Cc11BpSnR53GrRqhvHDKn8xCQylH Eii2idzA5kU9fLT87fSXAf6uyekwU7T9LWgRTEURG64V4DoDslEFGcWDOSU52I00Shq1 c3NA== X-Gm-Message-State: AOPr4FWJnoCC1tM/vGoH3mSGeUaX2ARKgb75Fa2X+rrD16iMfFgec74TAyJ2pbD9Z9i5Ng== X-Received: by 10.28.126.145 with SMTP id z139mr2649080wmc.81.1462634544557; Sat, 07 May 2016 08:22:24 -0700 (PDT) Received: from localhost.localdomain ([46.249.74.23]) by smtp.gmail.com with ESMTPSA id jq1sm20737835wjc.28.2016.05.07.08.22.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 07 May 2016 08:22:24 -0700 (PDT) From: Ivaylo Dimitrov To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, thierry.reding@gmail.com, bcousson@baylibre.com, tony@atomide.com, linux@arm.linux.org.uk, mchehab@osg.samsung.com Subject: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed. Date: Sat, 7 May 2016 18:21:46 +0300 Message-Id: <1462634508-24961-6-git-send-email-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462634508-24961-1-git-send-email-ivo.g.dimitrov.75@gmail.com> References: <1462634508-24961-1-git-send-email-ivo.g.dimitrov.75@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160507_082243_222364_F5FA1343 X-CRM114-Status: GOOD ( 13.47 ) X-Spam-Score: -2.5 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Ivaylo Dimitrov , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, sre@kernel.org, pali.rohar@gmail.com, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 once omap_dm_timer_start() is called, which calls omap_dm_timer_enable() and thus pm_runtime_get_sync(), it doesn't make sense to call PM runtime functions again before omap_dm_timer_stop is called(). Otherwise PM runtime functions called in omap_dm_timer_enable/disable lead to long and unneeded delays. Fix that by implementing an "enabled" counter, so the PM runtime functions get called only when really needed. Without that patch Nokia N900 IR TX driver (ir-rx51) does not function. Signed-off-by: Ivaylo Dimitrov --- arch/arm/plat-omap/dmtimer.c | 9 ++++++++- arch/arm/plat-omap/include/plat/dmtimer.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c index 7a327bd..f35a78c 100644 --- a/arch/arm/plat-omap/dmtimer.c +++ b/arch/arm/plat-omap/dmtimer.c @@ -365,6 +365,9 @@ void omap_dm_timer_enable(struct omap_dm_timer *timer) { int c; + if (timer->enabled++) + return; + pm_runtime_get_sync(&timer->pdev->dev); if (!(timer->capability & OMAP_TIMER_ALWON)) { @@ -383,7 +386,11 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_enable); void omap_dm_timer_disable(struct omap_dm_timer *timer) { - pm_runtime_put_sync(&timer->pdev->dev); + if (timer->enabled == 1) + pm_runtime_put_sync(&timer->pdev->dev); + + if (timer->enabled) + timer->enabled--; } EXPORT_SYMBOL_GPL(omap_dm_timer_disable); diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h index dd79f30..fc984e1 100644 --- a/arch/arm/plat-omap/include/plat/dmtimer.h +++ b/arch/arm/plat-omap/include/plat/dmtimer.h @@ -114,6 +114,7 @@ struct omap_dm_timer { unsigned long rate; unsigned reserved:1; unsigned posted:1; + u32 enabled; struct timer_regs context; int (*get_context_loss_count)(struct device *); int ctx_loss_count;