From patchwork Wed Jun 20 22:47:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 9517 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9A45A23E1B for ; Wed, 20 Jun 2012 22:48:11 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 53353A18290 for ; Wed, 20 Jun 2012 22:48:11 +0000 (UTC) Received: by ggnf1 with SMTP id f1so6697768ggn.11 for ; Wed, 20 Jun 2012 15:48:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding :x-content-scanned:x-cbid:x-gm-message-state; bh=t7s9vqq17BurKv7w+P3q8kkS6gzRv4rbOQL+9T8vAmk=; b=M3NdKVAtz2kDh2CbhnkzJEw3w8hMtjikaMkQFTj+3vCaRNjwyQycOzxhKYafqCq/OS t91OFtlEMW7e9mgh89Jf4euk+PoLv46QILdxqpHuxBrCxMcABhetW1iZx0tnVGBDVC+u 8kcWjARmKNnchLM08+caoukfv5Zr+hPOjqEWWbDLezYS27Yk0confIq4/2katZu67IOv R0jYosxt7VJLQ2KUSwEnEGX0OAMMjdv9QhTsjHp5TmLzsjeXMoDZQeFE6KE23uqt86GJ om0WmYDN//4sUcrMhbLHsfkjXkEq9ZSN0Su9p0y2843I1lMOwTnh3eyoG0F5MIi3suOe MQTw== Received: by 10.50.46.232 with SMTP id y8mr5969378igm.57.1340232490721; Wed, 20 Jun 2012 15:48:10 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp204144ibb; Wed, 20 Jun 2012 15:48:10 -0700 (PDT) Received: by 10.236.186.103 with SMTP id v67mr31163414yhm.6.1340232489621; Wed, 20 Jun 2012 15:48:09 -0700 (PDT) Received: from e36.co.us.ibm.com (e36.co.us.ibm.com. [32.97.110.154]) by mx.google.com with ESMTPS id f3si439542anb.32.2012.06.20.15.48.09 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Jun 2012 15:48:09 -0700 (PDT) Received-SPF: neutral (google.com: 32.97.110.154 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=32.97.110.154; Authentication-Results: mx.google.com; spf=neutral (google.com: 32.97.110.154 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Jun 2012 16:48:08 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 20 Jun 2012 16:48:07 -0600 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id CB58919D805E; Wed, 20 Jun 2012 22:48:03 +0000 (WET) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5KMm5ba241394; Wed, 20 Jun 2012 16:48:05 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5KMm4GH029450; Wed, 20 Jun 2012 16:48:05 -0600 Received: from kernel.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5KMls26028868; Wed, 20 Jun 2012 16:48:04 -0600 From: John Stultz To: LKML Cc: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Russell King , Paul Gortmaker , Alexander Shishkin , John Stultz Subject: [PATCH 10/15] ARM: etm: Wait for etm/ptm(s) to stop before requesting PowerDown Date: Wed, 20 Jun 2012 18:47:42 -0400 Message-Id: <1340232467-6023-11-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1340232467-6023-1-git-send-email-john.stultz@linaro.org> References: <1340232467-6023-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12062022-7606-0000-0000-00000151F6CB X-Gm-Message-State: ALoCoQlvZh501juc8w65R8d5AnSosXtbXQeiFhRiOVFlhD4wgAisgAct5/6wusZFqDlwzXla0PQu From: Arve Hjønnevåg When PowerDown was requested at the same time as ProgBit, the formatter flush command that follows could get stuck. CC: Russell King CC: Paul Gortmaker CC: Alexander Shishkin Acked-by: Alexander Shishkin Signed-off-by: Arve Hjønnevåg Signed-off-by: John Stultz --- arch/arm/kernel/etm.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/arch/arm/kernel/etm.c b/arch/arm/kernel/etm.c index 66bf592..bad28de 100644 --- a/arch/arm/kernel/etm.c +++ b/arch/arm/kernel/etm.c @@ -200,11 +200,13 @@ static int trace_stop_etm(struct tracectx *t, int id) etm_unlock(t, id); - etm_writel(t, id, 0x441, ETMR_CTRL); + etm_writel(t, id, 0x440, ETMR_CTRL); while (!(etm_readl(t, id, ETMR_CTRL) & ETMCTRL_PROGRAM) && --timeout) ; if (!timeout) { - dev_dbg(t->dev, "Waiting for progbit to assert timed out\n"); + dev_err(t->dev, + "etm%d: Waiting for progbit to assert timed out\n", + id); etm_lock(t, id); return -EFAULT; } @@ -213,18 +215,36 @@ static int trace_stop_etm(struct tracectx *t, int id) return 0; } +static int trace_power_down_etm(struct tracectx *t, int id) +{ + unsigned long timeout = TRACER_TIMEOUT; + etm_unlock(t, id); + while (!(etm_readl(t, id, ETMR_STATUS) & ETMST_PROGBIT) && --timeout) + ; + if (!timeout) { + dev_err(t->dev, "etm%d: Waiting for status progbit to assert timed out\n", + id); + etm_lock(t, id); + return -EFAULT; + } + + etm_writel(t, id, 0x441, ETMR_CTRL); + + etm_lock(t, id); + return 0; +} + static int trace_stop(struct tracectx *t) { int id; - int ret; unsigned long timeout = TRACER_TIMEOUT; u32 etb_fc = t->etb_fc; - for (id = 0; id < t->etm_regs_count; id++) { - ret = trace_stop_etm(t, id); - if (ret) - return ret; - } + for (id = 0; id < t->etm_regs_count; id++) + trace_stop_etm(t, id); + + for (id = 0; id < t->etm_regs_count; id++) + trace_power_down_etm(t, id); etb_unlock(t); if (etb_fc) {