Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755545AbdLOJhA (ORCPT ); Fri, 15 Dec 2017 04:37:00 -0500 Received: from 9pmail.ess.barracuda.com ([64.235.150.224]:46249 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755222AbdLOJgz (ORCPT ); Fri, 15 Dec 2017 04:36:55 -0500 From: Matt Redfearn To: Ralf Baechle , CC: , Matt Redfearn , Dengcheng Zhu , , Thomas Gleixner , Paul Burton , Mark Rutland Subject: [PATCH 2/2] MIPS: pm-cps: Warn if JTAG presence will block power gating Date: Fri, 15 Dec 2017 09:34:54 +0000 Message-ID: <1513330494-21249-2-git-send-email-matt.redfearn@mips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513330494-21249-1-git-send-email-matt.redfearn@mips.com> References: <1513330494-21249-1-git-send-email-matt.redfearn@mips.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.150.130.83] X-BESS-ID: 1513330597-637138-4364-79173-11 X-BESS-VER: 2017.14-r1710272128 X-BESS-Apparent-Source-IP: 12.201.5.28 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.187999 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2000 Lines: 53 If a JTAG probe is connected to a MIPS cluster, then the CPC detects it and latches the CPC.STAT_CONF.EJTAG_PROBE bit to 1. While set, attempting to send a power-down command to a core will be blocked, and the CPC will instead send the core to clock-off state. This can interfere with systems fully entering a low power state where all cores, CM, GIC, etc are powered down. Detect that a JTAG probe is / has been connected to the cluster and emit a warning that the attempted power down will fail, to aid debugging system suspend where it is not currently obvious that a core has not really powered down and will block a full power down of the cluster. We use a ratelimited pr_warn since this path will also be hit by cpu idle if it attempts to put cores into the powered down state. Signed-off-by: Matt Redfearn --- arch/mips/kernel/pm-cps.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/mips/kernel/pm-cps.c b/arch/mips/kernel/pm-cps.c index 421e06dfee72..45776613a5be 100644 --- a/arch/mips/kernel/pm-cps.c +++ b/arch/mips/kernel/pm-cps.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -143,6 +144,18 @@ int cps_pm_enter_state(enum cps_pm_state state) /* Setup the VPE to run mips_cps_pm_restore when started again */ if (IS_ENABLED(CONFIG_CPU_PM) && state == CPS_PM_POWER_GATED) { + unsigned int stat = read_cpc_cl_stat_conf(); + + if (stat & CPC_Cx_STAT_CONF_EJTAG_PROBE) { + /* + * If we're attempting to gate power to the core, the + * JTAG detect bit indicates that the CPC will instead + * put the core into clock-off state. Emit a warning. + */ + pr_warn_ratelimited("JTAG probe present - core%d will clock off instead of powering down\n", + core); + } + /* Power gating relies upon CPS SMP */ if (!mips_cps_smp_in_use()) return -EINVAL; -- 2.7.4