From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Lezcano Subject: Re: [PATCH v9 09/17] arm: tegra20: cpuidle: Handle case where secondary CPU hangs on entering LP2 Date: Fri, 21 Feb 2020 15:55:22 +0100 Message-ID: <20200221145522.GG10516@linaro.org> References: <20200212235134.12638-1-digetx@gmail.com> <20200212235134.12638-10-digetx@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Content-Disposition: inline In-Reply-To: <20200212235134.12638-10-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Sender: linux-tegra-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Dmitry Osipenko Cc: Thierry Reding , Jonathan Hunter , Peter De Schrijver , "Rafael J. Wysocki" , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Jasper Korten , David Heidelberg , Peter Geis , linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-tegra@vger.kernel.org On Thu, Feb 13, 2020 at 02:51:26AM +0300, Dmitry Osipenko wrote: > It is possible that something may go wrong with the secondary CPU, in that > case it is much nicer to get a dump of the flow-controller state before > hanging machine. > > Acked-by: Peter De Schrijver > Tested-by: Peter Geis > Tested-by: Jasper Korten > Tested-by: David Heidelberg > Signed-off-by: Dmitry Osipenko Acked-by: Daniel Lezcano > --- > arch/arm/mach-tegra/cpuidle-tegra20.c | 47 +++++++++++++++++++++++++-- > 1 file changed, 45 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c > index 9672c619f4bc..bcc158b72e67 100644 > --- a/arch/arm/mach-tegra/cpuidle-tegra20.c > +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c > @@ -83,14 +83,57 @@ static inline void tegra20_wake_cpu1_from_reset(void) > } > #endif > > +static void tegra20_report_cpus_state(void) > +{ > + unsigned long cpu, lcpu, csr; > + > + for_each_cpu(lcpu, cpu_possible_mask) { > + cpu = cpu_logical_map(lcpu); > + csr = flowctrl_read_cpu_csr(cpu); > + > + pr_err("cpu%lu: online=%d flowctrl_csr=0x%08lx\n", > + cpu, cpu_online(lcpu), csr); > + } > +} > + > +static int tegra20_wait_for_secondary_cpu_parking(void) > +{ > + unsigned int retries = 3; > + > + while (retries--) { > + ktime_t timeout = ktime_add_ms(ktime_get(), 500); > + > + /* > + * The primary CPU0 core shall wait for the secondaries > + * shutdown in order to power-off CPU's cluster safely. > + * The timeout value depends on the current CPU frequency, > + * it takes about 40-150us in average and over 1000us in > + * a worst case scenario. > + */ > + do { > + if (tegra_cpu_rail_off_ready()) > + return 0; > + > + } while (ktime_before(ktime_get(), timeout)); > + > + pr_err("secondary CPU taking too long to park\n"); > + > + tegra20_report_cpus_state(); > + } > + > + pr_err("timed out waiting secondaries to park\n"); > + > + return -ETIMEDOUT; > +} > + > static bool tegra20_cpu_cluster_power_down(struct cpuidle_device *dev, > struct cpuidle_driver *drv, > int index) > { > bool ret; > > - while (!tegra_cpu_rail_off_ready()) > - cpu_relax(); > + if (tegra20_wait_for_secondary_cpu_parking()) > + return false; > > ret = !tegra_pm_enter_lp2(); > > -- > 2.24.0 > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog