From patchwork Fri Jun 5 04:47:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 6550871 Return-Path: X-Original-To: patchwork-linux-rockchip@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 B11AD9F3D1 for ; Fri, 5 Jun 2015 04:48:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B51A120742 for ; Fri, 5 Jun 2015 04:48:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 BA4F720738 for ; Fri, 5 Jun 2015 04:48:41 +0000 (UTC) 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 1Z0jYf-0006ju-Cd; Fri, 05 Jun 2015 04:48:41 +0000 Received: from mail-pa0-f53.google.com ([209.85.220.53]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z0jYU-0006dr-Tm; Fri, 05 Jun 2015 04:48:32 +0000 Received: by padj3 with SMTP id j3so42988877pad.0; Thu, 04 Jun 2015 21:48:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CuxS/oaljqh0ffxEYsrRYw4K50FA3DxlnwDkts0/JJo=; b=S9920YDXe+/Kwu02Crr/FEhz7BBrj3WJay5H2HeBNdN47JupKMrxrWEQ4NJSy8Ymkm SJ+QWJV7c5oMd9B32kNFfNxjC0L/4jqCCGbdpQ1PWMmzAHIXx3y67hAmYcNgm91RnnDv jiSPvWrsF2IFx5YGp6DbBUxq6Z0achArb9LlNJK0j2rt3NlNjDz7PWlqE+KhdK6rr8LA 9747N6Lfy6t4YeoMENFgAhJSGnxrO5H+FPeDG7VzxMpryTHIMdZGHou/NxWMl+EZ3G/5 6nGUlo/7XNxGCxp+dvbyq4sVS4/RjXwZq/cdEFJ+gzDL7elIEdZkO0gd/4LXj7saMsdM ytKw== X-Received: by 10.68.237.105 with SMTP id vb9mr2647474pbc.149.1433479689776; Thu, 04 Jun 2015 21:48:09 -0700 (PDT) Received: from localhost.localdomain ([191.101.57.89]) by mx.google.com with ESMTPSA id c10sm5209803pbu.81.2015.06.04.21.48.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jun 2015 21:48:08 -0700 (PDT) From: Caesar Wang To: Heiko Stuebner Subject: [PATCH 1/3] ARM: rockchip: fix the CPU soft reset Date: Fri, 5 Jun 2015 12:47:55 +0800 Message-Id: <1433479677-18086-2-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433479677-18086-1-git-send-email-wxt@rock-chips.com> References: <1433479677-18086-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150604_214831_008626_499F8FE4 X-CRM114-Status: GOOD ( 11.51 ) X-Spam-Score: -1.8 (-) Cc: Russell King , Dmitry Torokhov , dianders@chromium.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Caesar Wang X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 In general, the correct flow is: cpu off: reset_control_assert regmap_update_bits(pmu, PMU_PWRDN_CON, BIT(pd), BIT(pd)) cpu on: regmap_update_bits(pmu, PMU_PWRDN_CON, BIT(pd), 0) reset_control_deassert You can repro it with bringing CPU up and down. Says:(test scripts) cd /sys/devices/system/cpu/ for i in $(seq 1000); do echo "================= $i ============" for j in $(seq 100); do while [[ "$(cat cpu1/online)$(cat cpu2/online)$(cat cpu3/online)" != "000" ]]; do echo 0 > cpu1/online echo 0 > cpu2/online echo 0 > cpu3/online done while [[ "$(cat cpu1/online)$(cat cpu2/online)$(cat cpu3/online)" != "111" ]]; do echo 1 > cpu1/online echo 1 > cpu2/online echo 1 > cpu3/online done done done The following is reproducile log: [34466.186812] PM: noirq suspend of devices complete after 0.669 msecs [34466.186824] Disabling non-boot CPUs ... [34466.187509] CPU1: shutdown [34466.188672] CPU2: shutdown [34473.736627] Kernel panic - not syncing: Watchdog detected hard LOCKUP on cpu 0 [34473.736646] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 3.14.0 #1 [34473.736687] [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [34473.736711] [] (show_stack) from [] (dump_stack+0x70/0x8c) [34473.736731] [] (dump_stack) from [] (panic+0xa8/0x1fc) [34473.736754] [] (panic) from [] (watchdog_timer_fn+0x234/0x26c) [34473.736777] [] (watchdog_timer_fn) from [] (__run_hrtimer+0x118/0x1e0) [34473.736797] [] (__run_hrtimer) from [] (hrtimer_interrupt+0x148/0x2a0) [34473.736820] [] (hrtimer_interrupt) from [] (arch_timer_handler_phys+0x38/0x48) [34473.736844] [] (arch_timer_handler_phys) from [] (handle_percpu_devid_irq+0xb8/0x124) [34473.736867] [] (handle_percpu_devid_irq) from [] (generic_handle_irq+0x30/0x40) [34473.736887] [] (generic_handle_irq) from [] (__handle_domain_irq+0x8c/0xb0) [34473.736905] [] (__handle_domain_irq) from [] (gic_handle_irq+0x48/0x6c) [34473.736922] [] (gic_handle_irq) from [] (__irq_svc+0x40/0x50) [34473.736936] Exception stack(0xee127f70 to 0xee127fb8) [34473.736948] 7f60: ffffffed 00000000 2dd6d000 00000000 [34473.736964] 7f80: ee126000 00000015 c0b46bac c0b46bac 0000406a 410fc0d1 00000000 ee127fc4 [34473.736979] 7fa0: ee127fb8 ee127fb8 c0107038 c010703c 600f0013 ffffffff [34473.736995] [] (__irq_svc) from [] (arch_cpu_idle+0x40/0x48) [34473.737013] [] (arch_cpu_idle) from [] (cpu_startup_entry+0x170/0x1d0) [34473.737031] [] (cpu_startup_entry) from [] (secondary_start_kernel+0x138/0x160) [34473.737059] [] (secondary_start_kernel) from [<00100464>] (0x100464) [34474.903740] SMP: failed to stop secondary CPUs [34476.099964] SMP: failed to stop secondary CPUs ... Signed-off-by: Caesar Wang --- arch/arm/mach-rockchip/platsmp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-rockchip/platsmp.c b/arch/arm/mach-rockchip/platsmp.c index 5b4ca3c..1230d3d 100644 --- a/arch/arm/mach-rockchip/platsmp.c +++ b/arch/arm/mach-rockchip/platsmp.c @@ -88,20 +88,17 @@ static int pmu_set_power_domain(int pd, bool on) return PTR_ERR(rstc); } - if (on) + if (on) { + regmap_update_bits(pmu, PMU_PWRDN_CON, BIT(pd), val); reset_control_deassert(rstc); - else + } else { reset_control_assert(rstc); + regmap_update_bits(pmu, PMU_PWRDN_CON, BIT(pd), val); + } reset_control_put(rstc); } - ret = regmap_update_bits(pmu, PMU_PWRDN_CON, BIT(pd), val); - if (ret < 0) { - pr_err("%s: could not update power domain\n", __func__); - return ret; - } - ret = -1; while (ret != on) { ret = pmu_power_domain_is_on(pd);