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: 24476 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 744F820967 for ; Tue, 11 Feb 2014 17:11:28 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id w20sf17696463vbb.3 for ; Tue, 11 Feb 2014 09:11:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=YLBa2O7h7Qq6N3ECRjQ4MQ3vlxzFbu55cRfxM7sa7CQ=; b=bmGTbY+tCwNvHR4rlV2cyrNOT0uCXeoSWx4pvrZHDuOcgI9gxiABCu6dAB1CIparh9 JbE5/NpQ8ViwqwQYHRRB/uM5qs/2188hvZ3WexkijqgAoMnZTUAyFi+AhXTr5czlsQVr idZESDIWG6CkwyM6XJllXutK5OJjmr35juVDHAHr78BlBO4yP6zTECzsLkwoehI6dBXj uYAQl2Xc6LQDFirxT4yuAsdK0lUUuh0UCHywPOLlujXxqBTzcrX9Twr5fEO2TvjHwanj CfeDN6OJySfyOsBEgBvwarWfut3OKe+qBCICOYr0ls+pRxgbp/seN0EV00wQ45DecAiW wVcQ== X-Gm-Message-State: ALoCoQko91svFL9LrC431ZHMD6/3U7S5dTc6CA1bhR0j+HlPCXVcuw1X4gG5zY6cE1cxJHuH7Pmc X-Received: by 10.58.35.74 with SMTP id f10mr154582vej.23.1392138687579; Tue, 11 Feb 2014 09:11:27 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.48.38 with SMTP id n35ls2625604qga.68.gmail; Tue, 11 Feb 2014 09:11:27 -0800 (PST) X-Received: by 10.220.200.6 with SMTP id eu6mr966519vcb.35.1392138687447; Tue, 11 Feb 2014 09:11:27 -0800 (PST) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id bj3si6133975vcb.139.2014.02.11.09.11.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 09:11:27 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jy13so6290994veb.41 for ; Tue, 11 Feb 2014 09:11:27 -0800 (PST) X-Received: by 10.220.5.8 with SMTP id 8mr171594vct.65.1392138687339; Tue, 11 Feb 2014 09:11:27 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp262246vcz; Tue, 11 Feb 2014 09:11:26 -0800 (PST) X-Received: by 10.66.25.101 with SMTP id b5mr33918294pag.101.1392138678613; Tue, 11 Feb 2014 09:11:18 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bq5si19633709pbb.228.2014.02.11.09.11.16; Tue, 11 Feb 2014 09:11:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752175AbaBKRKu (ORCPT + 27 others); Tue, 11 Feb 2014 12:10:50 -0500 Received: from fw-tnat.austin.arm.com ([217.140.110.23]:25038 "EHLO collaborate-mta1.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752025AbaBKRKo (ORCPT ); Tue, 11 Feb 2014 12:10:44 -0500 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 Cc: Pawel Moll , Arnd Bergmann , Greg Kroah-Hartman 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pawel.moll@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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; }