From patchwork Wed Aug 15 10:02:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 1325201 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 3B156DFFED for ; Wed, 15 Aug 2012 10:07:35 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T1aSq-0006wJ-OR; Wed, 15 Aug 2012 10:04:37 +0000 Received: from mail-we0-f177.google.com ([74.125.82.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T1aRZ-0006Uo-PR for linux-arm-kernel@lists.infradead.org; Wed, 15 Aug 2012 10:03:26 +0000 Received: by mail-we0-f177.google.com with SMTP id r3so962134wey.36 for ; Wed, 15 Aug 2012 03:03:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=E3NLVjK1s+rrbQ3huFXyTNG1f21NoOfNzU0hXJTaZQs=; b=FLZWCDt17mX5ueLmkEsM5TxMMAxciujdbFs614EbMRRG0iRFKYEQ7O4GPPen+cmhWZ +QZtLcWrLoaYakd3iHirUHgESkzsNeoT8FY5B0vea2rydQrQzhytOg5V92zZbmfY7cMZ 7JSeH43nvsWFcU8JSB2tveLOO6+yfHlbxC7PWvfqATg6ku3IKKG6HKYa1SXeyLrBPjGR QRLTMBlhebtXGgGGvTsdoD6AEYWweofk3mieZJMUYlLAIetdnGG21+MovDNk2PebVJjJ 7kOCjiwGOcTo0euBjiSzIyNwBtB+imH5gDW5k5NCcBu3CNQ6fIiDjR0XDKB2dqAnmnLu ufPQ== Received: by 10.180.75.209 with SMTP id e17mr41427367wiw.0.1345024997393; Wed, 15 Aug 2012 03:03:17 -0700 (PDT) Received: from localhost.localdomain (49.68-66-87.adsl-dyn.isp.belgacom.be. [87.66.68.49]) by mx.google.com with ESMTPS id q4sm27679093wix.9.2012.08.15.03.03.16 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 15 Aug 2012 03:03:16 -0700 (PDT) From: Jean Pihet To: linux-omap@vger.kernel.org, paul@pwsan.com, linux-arm-kernel@lists.infradead.org, khilman@ti.com, Rajendra Nayak , Santosh Shilimkar , Nishanth Menon Subject: [PATCH 7/8] ARM: OMAP2+: powerdomain: add error logs Date: Wed, 15 Aug 2012 12:02:47 +0200 Message-Id: <1345024968-28951-8-git-send-email-j-pihet@ti.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1345024968-28951-1-git-send-email-j-pihet@ti.com> References: <1345024968-28951-1-git-send-email-j-pihet@ti.com> X-Gm-Message-State: ALoCoQlu1ikVgARMBBTuW3DVP/8/mQ0LN2+GEHnMgjq6fr/jrcGkXz82FGxWBfeRud2dE17hzSGb X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Nishanth Menon Silent failure makes debug hard. So, provide rate limited error messages in functional and oft-used code to prevent spam when something goes wrong.. Signed-off-by: Nishanth Menon --- arch/arm/mach-omap2/powerdomain.c | 72 +++++++++++++++++++++++++++++------- 1 files changed, 58 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c index 06a566b..691247e 100644 --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "cm2xxx_3xxx.h" @@ -146,8 +147,12 @@ static int _pwrdm_state_switch(struct powerdomain *pwrdm, int flag) int prev, next, state, trace_state; - if (pwrdm == NULL) + if (pwrdm == NULL) { + WARN_ONCE(1, "null pwrdm\n"); + pr_err_ratelimited("%s: powerdomain: null pwrdm param\n", + __func__); return -EINVAL; + } state = pwrdm_read_fpwrst(pwrdm); @@ -174,6 +179,8 @@ static int _pwrdm_state_switch(struct powerdomain *pwrdm, int flag) } break; default: + pr_err_ratelimited("%s: powerdomain %s: bad flag %d\n", + __func__, pwrdm->name, flag); return -EINVAL; } @@ -690,7 +697,8 @@ int pwrdm_set_next_fpwrst(struct powerdomain *pwrdm, unsigned long flags; if (!pwrdm || IS_ERR(pwrdm)) { - pr_debug("%s: invalid params: pwrdm=%p\n", __func__, pwrdm); + pr_err_ratelimited("%s: invalid params: pwrdm=%p\n", + __func__, pwrdm); return -EINVAL; } @@ -775,8 +783,11 @@ int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst) if (!pwrdm) return -EINVAL; - if (!(pwrdm->pwrsts & (1 << pwrst))) + if (!(pwrdm->pwrsts & (1 << pwrst))) { + pr_err_ratelimited("%s: powerdomain %s: bad pwrst %d\n", + __func__, pwrdm->name, pwrst); return -EINVAL; + } pr_debug("powerdomain: setting next powerstate for %s to %0x\n", pwrdm->name, pwrst); @@ -924,8 +935,11 @@ int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst) if (!pwrdm) return -EINVAL; - if (!(pwrdm->pwrsts_logic_ret & (1 << pwrst))) + if (!(pwrdm->pwrsts_logic_ret & (1 << pwrst))) { + pr_err_ratelimited("%s: powerdomain %s: bad pwrst %d\n", + __func__, pwrdm->name, pwrst); return -EINVAL; + } pr_debug("powerdomain: setting next logic powerstate for %s to %0x\n", pwrdm->name, pwrst); @@ -958,11 +972,17 @@ int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst) if (!pwrdm) return -EINVAL; - if (pwrdm->banks < (bank + 1)) + if (pwrdm->banks < (bank + 1)) { + pr_err_ratelimited("%s: powerdomain %s: bad bank %d\n", + __func__, pwrdm->name, bank); return -EEXIST; + } - if (!(pwrdm->pwrsts_mem_on[bank] & (1 << pwrst))) + if (!(pwrdm->pwrsts_mem_on[bank] & (1 << pwrst))) { + pr_err_ratelimited("%s: powerdomain %s: bank %d bad pwrst %d\n", + __func__, pwrdm->name, bank, pwrst); return -EINVAL; + } pr_debug("powerdomain: setting next memory powerstate for domain %s " "bank %0x while pwrdm-ON to %0x\n", pwrdm->name, bank, pwrst); @@ -996,11 +1016,17 @@ int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst) if (!pwrdm) return -EINVAL; - if (pwrdm->banks < (bank + 1)) + if (pwrdm->banks < (bank + 1)) { + pr_err_ratelimited("%s: powerdomain %s: bad bank %d\n", + __func__, pwrdm->name, bank); return -EEXIST; + } - if (!(pwrdm->pwrsts_mem_ret[bank] & (1 << pwrst))) + if (!(pwrdm->pwrsts_mem_ret[bank] & (1 << pwrst))) { + pr_err_ratelimited("%s: powerdomain %s: bank %d bad pwrst %d\n", + __func__, pwrdm->name, bank, pwrst); return -EINVAL; + } pr_debug("powerdomain: setting next memory powerstate for domain %s " "bank %0x while pwrdm-RET to %0x\n", pwrdm->name, bank, pwrst); @@ -1092,8 +1118,11 @@ int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank) if (!pwrdm) return ret; - if (pwrdm->banks < (bank + 1)) + if (pwrdm->banks < (bank + 1)) { + pr_err_ratelimited("%s: powerdomain %s: bad bank %d\n", + __func__, pwrdm->name, bank); return ret; + } if (pwrdm->flags & PWRDM_HAS_MPU_QUIRK) bank = 1; @@ -1122,8 +1151,11 @@ int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank) if (!pwrdm) return ret; - if (pwrdm->banks < (bank + 1)) + if (pwrdm->banks < (bank + 1)) { + pr_err_ratelimited("%s: powerdomain %s: bad bank %d\n", + __func__, pwrdm->name, bank); return ret; + } if (pwrdm->flags & PWRDM_HAS_MPU_QUIRK) bank = 1; @@ -1151,8 +1183,11 @@ int pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank) if (!pwrdm) return ret; - if (pwrdm->banks < (bank + 1)) + if (pwrdm->banks < (bank + 1)) { + pr_err_ratelimited("%s: powerdomain %s: bad bank %d\n", + __func__, pwrdm->name, bank); return ret; + } if (arch_pwrdm && arch_pwrdm->pwrdm_read_mem_retst) ret = arch_pwrdm->pwrdm_read_mem_retst(pwrdm, bank); @@ -1208,8 +1243,11 @@ int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm) if (!pwrdm) return ret; - if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR)) + if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR)) { + pr_err_ratelimited("%s: powerdomain %s: no HDSAR in flag %d\n", + __func__, pwrdm->name, pwrdm->flags); return ret; + } pr_debug("powerdomain: %s: setting SAVEANDRESTORE bit\n", pwrdm->name); @@ -1238,8 +1276,11 @@ int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm) if (!pwrdm) return ret; - if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR)) + if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR)) { + pr_err_ratelimited("%s: powerdomain %s: no HDSAR in flag %d\n", + __func__, pwrdm->name, pwrdm->flags); return ret; + } pr_debug("powerdomain: %s: clearing SAVEANDRESTORE bit\n", pwrdm->name); @@ -1279,8 +1320,11 @@ int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm) if (!pwrdm) return -EINVAL; - if (!(pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE)) + if (!(pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE)) { + pr_err_ratelimited("%s: powerdomain %s:no lowpwrch in flag%d\n", + __func__, pwrdm->name, pwrdm->flags); return -EINVAL; + } pr_debug("powerdomain: %s: setting LOWPOWERSTATECHANGE bit\n", pwrdm->name);