From patchwork Thu Apr 24 16:40:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 28999 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 67DF72036A for ; Thu, 24 Apr 2014 16:42:44 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id lh14sf9699201vcb.6 for ; Thu, 24 Apr 2014 09:42:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=fP1emuv3wndSguRcdbThWy+NrV6y2g3u63msZRm6DM0=; b=gpV1K373TVK8AAKK35MSLW1hpVjQQaDq0vpudZOjuQSc2JPKv/5xPyvnittBdGBadO Aiwr/wOTnHmPUXKlt+RjJjeHBZOWzpcTYUreGCjdaybBIXs4mGGMQS4sEp9F1kzjeKdc 2G9IsKMef16xC36y4pP4QSv32OEaHt07bcEhbnOBGMeFZJmoPnRJYKeeKJOddU39lHf3 B2Y5vaQr++9UwS7un17VTPJErKKRp4YYqkFJMglBPcVmXp7r/DlCNvOX2lLYuvHD40ED DvWYTV8utOwzETTXQPmN7dpq4EB2yPoALUP+VWppWkIQrXEbX+5RwSZdbgB1vcjpzdeW 8Ydw== X-Gm-Message-State: ALoCoQkCdC7USC2ZFA2L//QKHeielCJe277A5QNbgfZTNBvR7LQY5ghEGLrFfIa+xnYwtmDMyrlL X-Received: by 10.52.112.163 with SMTP id ir3mr1456065vdb.5.1398357764160; Thu, 24 Apr 2014 09:42:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.4 with SMTP id t4ls1159359qge.1.gmail; Thu, 24 Apr 2014 09:42:44 -0700 (PDT) X-Received: by 10.58.31.136 with SMTP id a8mr1942668vei.20.1398357764042; Thu, 24 Apr 2014 09:42:44 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id b7si1049094vev.202.2014.04.24.09.42.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Apr 2014 09:42:44 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id id10so3335708vcb.12 for ; Thu, 24 Apr 2014 09:42:44 -0700 (PDT) X-Received: by 10.220.12.66 with SMTP id w2mr1846699vcw.15.1398357763944; Thu, 24 Apr 2014 09:42:43 -0700 (PDT) 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.221.72 with SMTP id ib8csp30583vcb; Thu, 24 Apr 2014 09:42:34 -0700 (PDT) X-Received: by 10.224.169.6 with SMTP id w6mr4359194qay.102.1398357754537; Thu, 24 Apr 2014 09:42:34 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id s39si2480936qgs.184.2014.04.24.09.42.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Apr 2014 09:42:34 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WdMi2-0000lc-LJ; Thu, 24 Apr 2014 16:41:14 +0000 Received: from fw-tnat.austin.arm.com ([217.140.110.23] helo=collaborate-mta1.arm.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WdMhb-0000ST-NO for linux-arm-kernel@lists.infradead.org; Thu, 24 Apr 2014 16:40:48 +0000 Received: from hornet.Cambridge.Arm.com (hornet.cambridge.arm.com [10.2.201.45]) by collaborate-mta1.arm.com (Postfix) with ESMTP id 6397313FC94; Thu, 24 Apr 2014 11:40:22 -0500 (CDT) From: Pawel Moll To: arm@kernel.org Subject: [PATCH 3/4] power/reset: vexpress: Fix restart/power off operation Date: Thu, 24 Apr 2014 17:40:17 +0100 Message-Id: <1398357618-11050-4-git-send-email-pawel.moll@arm.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398357618-11050-1-git-send-email-pawel.moll@arm.com> References: <1398357618-11050-1-git-send-email-pawel.moll@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140424_094047_810887_836AC948 X-CRM114-Status: GOOD ( 12.78 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record Cc: Pawel Moll , linux-arm-kernel@lists.infradead.org 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+patch=linaro.org@lists.infradead.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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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 The restart/power off implementation in the vexpress driver used to obtain the config function when necessary. This was wrong in two respects: 1. It required memory allocation with disabled interrupts (it worked, but lockdep - when enabled - reported warnings). 2. Used jiffies-based timeout, while jiffies are not running at this stage of system shutdown (therefore a config transaction error - if happened - would have never be reported). Fixed by pre-allocating the config function per device and using mdelay for timeout. Signed-off-by: Pawel Moll --- drivers/power/reset/vexpress-poweroff.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c index 476aa49..b95cf71 100644 --- a/drivers/power/reset/vexpress-poweroff.c +++ b/drivers/power/reset/vexpress-poweroff.c @@ -11,7 +11,7 @@ * Copyright (C) 2012 ARM Limited */ -#include +#include #include #include #include @@ -23,17 +23,12 @@ static void vexpress_reset_do(struct device *dev, const char *what) { int err = -ENOENT; - struct vexpress_config_func *func = - vexpress_config_func_get_by_dev(dev); + struct vexpress_config_func *func = dev_get_drvdata(dev); if (func) { - unsigned long timeout; - err = vexpress_config_write(func, 0, 0); - - timeout = jiffies + HZ; - while (time_before(jiffies, timeout)) - cpu_relax(); + if (!err) + mdelay(1000); } dev_emerg(dev, "Unable to %s (%d)\n", what, err); @@ -96,12 +91,18 @@ static int vexpress_reset_probe(struct platform_device *pdev) enum vexpress_reset_func func; const struct of_device_id *match = of_match_device(vexpress_reset_of_match, &pdev->dev); + struct vexpress_config_func *config_func; if (match) func = (enum vexpress_reset_func)match->data; else func = pdev->id_entry->driver_data; + config_func = vexpress_config_func_get_by_dev(&pdev->dev); + if (!config_func) + return -EINVAL; + dev_set_drvdata(&pdev->dev, config_func); + switch (func) { case FUNC_SHUTDOWN: vexpress_power_off_device = &pdev->dev;