From patchwork Fri Jul 10 06:37:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 6762941 Return-Path: X-Original-To: patchwork-linux-sh@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 B92DC9F536 for ; Fri, 10 Jul 2015 06:40:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E3D6F207F9 for ; Fri, 10 Jul 2015 06:40:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4C0F207F7 for ; Fri, 10 Jul 2015 06:39:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753559AbbGJGhx (ORCPT ); Fri, 10 Jul 2015 02:37:53 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:41871 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753497AbbGJGho (ORCPT ); Fri, 10 Jul 2015 02:37:44 -0400 Received: from ayumi.isobedori.kobe.vergenet.net (p7166-ipbfp1503kobeminato.hyogo.ocn.ne.jp [114.153.234.166]) by kirsty.vergenet.net (Postfix) with ESMTPSA id 090A325B80D; Fri, 10 Jul 2015 16:37:15 +1000 (AEST) Received: by ayumi.isobedori.kobe.vergenet.net (Postfix, from userid 7100) id C8E28EDEB69; Fri, 10 Jul 2015 15:37:13 +0900 (JST) From: Simon Horman To: linux-sh@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Magnus Damm , Geert Uytterhoeven , Simon Horman Subject: [PATCH 3/8] ARM: shmobile: R-Car: Break infinite loop Date: Fri, 10 Jul 2015 15:37:08 +0900 Message-Id: <2f575fcff1fad24e97b8e7d793ad9af9ae5b8a17.1436510166.git.horms+renesas@verge.net.au> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 From: Geert Uytterhoeven rcar_sysc_update() loops (with interrupts disabled and while holding a spinlock) until submitting a power shutoff or resume request fails, or until the submitted request was accepted. If none of these conditions becomes true, this forms an infinite loop. Put a limit on the maximum number of loop iterations, and add a small delay to each iteration, to fix this. Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/pm-rcar.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-shmobile/pm-rcar.c b/arch/arm/mach-shmobile/pm-rcar.c index 56ea82a851cb..a5e4c3a88ec4 100644 --- a/arch/arm/mach-shmobile/pm-rcar.c +++ b/arch/arm/mach-shmobile/pm-rcar.c @@ -42,6 +42,9 @@ #define SYSCSR_RETRIES 100 #define SYSCSR_DELAY_US 1 +#define PWRER_RETRIES 100 +#define PWRER_DELAY_US 1 + #define SYSCISR_RETRIES 1000 #define SYSCISR_DELAY_US 1 @@ -95,14 +98,23 @@ static int rcar_sysc_update(struct rcar_sysc_ch *sysc_ch, iowrite32(isr_mask, rcar_sysc_base + SYSCISCR); /* Submit power shutoff or resume request until it was accepted */ - do { + for (k = 0; k < PWRER_RETRIES; k++) { ret = on_off_fn(sysc_ch); if (ret) goto out; status = ioread32(rcar_sysc_base + sysc_ch->chan_offs + PWRER_OFFS); - } while (status & chan_mask); + if (!(status & chan_mask)) + break; + + udelay(PWRER_DELAY_US); + } + + if (k == PWRER_RETRIES) { + ret = -EIO; + goto out; + } /* Wait until the power shutoff or resume request has completed * */ for (k = 0; k < SYSCISR_RETRIES; k++) {