From patchwork Tue Feb 11 17:10:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 3628601 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E1055BF418 for ; Tue, 11 Feb 2014 17:22:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 09AF9201FE for ; Tue, 11 Feb 2014 17:22:50 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 17E9C20158 for ; Tue, 11 Feb 2014 17:22:49 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDH1y-0000J8-NZ; Tue, 11 Feb 2014 17:21:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDGsH-0002YX-3N; Tue, 11 Feb 2014 17:11:57 +0000 Received: from fw-tnat.austin.arm.com ([217.140.110.23] helo=collaborate-mta1.arm.com) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDGrT-0002OV-JI for linux-arm-kernel@lists.infradead.org; Tue, 11 Feb 2014 17:11:11 +0000 Received: from hornet.Cambridge.Arm.com (hornet.cambridge.arm.com [10.2.201.45]) by collaborate-mta1.arm.com (Postfix) with ESMTP id AD61714005F; Tue, 11 Feb 2014 11:10:43 -0600 (CST) From: Pawel Moll To: arm@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/12] misc: vexpress-syscfg: Add udelay-based delay Date: Tue, 11 Feb 2014 17:10:25 +0000 Message-Id: <1392138636-29240-2-git-send-email-pawel.moll@arm.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392138636-29240-1-git-send-email-pawel.moll@arm.com> References: <1392138636-29240-1-git-send-email-pawel.moll@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140211_121107_799108_C547DCD6 X-CRM114-Status: GOOD ( 13.94 ) X-Spam-Score: -2.5 (--) Cc: Greg Kroah-Hartman , Arnd Bergmann , Pawel Moll X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 It is normally preferable to yield the task waiting for syscfg operations (that can take up to dozens of milliseconds), but when the system is shutting down it may not be possible. This patch adds a udelay-based version of the code to be used in such circumstances. Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Signed-off-by: Pawel Moll --- drivers/misc/vexpress-syscfg.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/misc/vexpress-syscfg.c b/drivers/misc/vexpress-syscfg.c index 4d661ef..82f8229 100644 --- a/drivers/misc/vexpress-syscfg.c +++ b/drivers/misc/vexpress-syscfg.c @@ -53,6 +53,37 @@ struct vexpress_syscfg_func { }; +static int vexpress_syscfg_delay_schedule(unsigned int us) +{ + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(usecs_to_jiffies(us)); + if (signal_pending(current)) + return -EINTR; + + return 0; +} + +static int vexpress_syscfg_delay_loop(unsigned int us) +{ + udelay(us); + + return 0; +} + +static int (*vexpress_syscfg_delay)(unsigned int us) = + vexpress_syscfg_delay_schedule; + +static void vexpress_syscfg_shutdown(void) +{ + /* Can't relay on the scheduler when the system is going down */ + vexpress_syscfg_delay = vexpress_syscfg_delay_loop; +} + +static struct syscore_ops vexpress_syscfg_syscore_ops = { + .shutdown = vexpress_syscfg_shutdown, +}; + + static int vexpress_syscfg_exec(struct vexpress_syscfg_func *func, int index, bool write, u32 *data) { @@ -87,10 +118,9 @@ static int vexpress_syscfg_exec(struct vexpress_syscfg_func *func, tries = 100; timeout = 100; do { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(usecs_to_jiffies(timeout)); - if (signal_pending(current)) - return -EINTR; + int err = vexpress_syscfg_delay(timeout); + if (err) + return err; status = readl(syscfg->base + SYS_CFGSTAT); if (status & SYS_CFGSTAT_ERR) @@ -299,6 +329,8 @@ int vexpress_syscfg_probe(struct platform_device *pdev) if (!pdev->dev.of_node) vexpress_syscfg_bridge = bridge; + register_syscore_ops(&vexpress_syscfg_syscore_ops); + return 0; }