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: 9038131 Return-Path: X-Original-To: patchwork-linux-omap@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 044309F6CD for ; Sat, 7 May 2016 15:24:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21F35200ED for ; Sat, 7 May 2016 15:24:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3588820121 for ; Sat, 7 May 2016 15:24:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751370AbcEGPXw (ORCPT ); Sat, 7 May 2016 11:23:52 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34276 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750886AbcEGPW0 (ORCPT ); Sat, 7 May 2016 11:22:26 -0400 Received: by mail-wm0-f68.google.com with SMTP id n129so13306352wmn.1; 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=PJtpsAYH0LZbs+l7coiO9myWT2z/eiOMOfpS0KapXUgqGI7B8hDD7lQPRaVHvlDp/s 1lHc98eI3Sxqb0+mLIn1rEvFILJQQ0oWCGra3cX6KJvInA97fvD07h9+cvhbQJGa7H59 4rn4XygohSdNkSh1Uo8AqlnFQ+Ht2chx7eZKBNWxlV2gA8WvdzPpU8hzgcHUpVzGjYQ0 mgEBearSeMWvuG7WDCf7X5NHTDTtW/4qFUaoW5XshSx5yfkMm6gypLZ9IXPifBqfF+sk KY6AHH/rmaPQQhAxIZhsNYRQ08d8q7QAp39FZQiOPuIiuIqLID6bBWXlCAkBuN0xeGIO 6qyw== X-Gm-Message-State: AOPr4FUNxHeJ8OuQ2/vdZgxtyvyjeeAa5yWqlDJQRD8M4BgPcQH0SkWAqCY4y8kiawMKZw== 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 Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, sre@kernel.org, pali.rohar@gmail.com, Ivaylo Dimitrov 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> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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;