[RFC,v1,7/7] thermal: core: set Power State Change Reason before hw_protection_shutdown()
Message ID | 20240119132521.3609945-8-o.rempel@pengutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-31192-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp1004307dyb; Fri, 19 Jan 2024 05:27:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHH3+gM1T6B5AlAKiUs9Djt3ZNoHnJ1bGgoBGPzfYe1DCvPU89vBs+Tx3/uJ6rOLi/tNMeB X-Received: by 2002:a05:6870:218c:b0:210:87c2:79d1 with SMTP id l12-20020a056870218c00b0021087c279d1mr2897956oae.57.1705670832296; Fri, 19 Jan 2024 05:27:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705670832; cv=pass; d=google.com; s=arc-20160816; b=EYy9sZj8dvJ/PSyotxcaullh/LYpvvqqcj0FVhKyYM15Bzh+IbWodfsvY5/r9eTgIx EzvgxDuH4sQIaYZ+gAIhP0baVumAbtgzMg4jSa76cp/Ekm/te7kZ2WLTgl+F2kOC1DN5 2TDoTxjk+es+BsuPHAR5j6bbkvt3Ri/qKOQaO7Mf3NFBj7A1KGR7kNlq54QZ1CFACe9Y Bi/7/jfjOg7S1XYba+4XgYBFwKyT2+RkujeonEMepTyiD+65g5trhyfYHfJMgU9A31vK V2jMCjEPMBPA6Z8zu6U1JqnOQxeKMiBJ7o4vqDJEyJvRgHOPd+QUqqxFkzoL128jVRHV PaNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=eHMosafIrihmBRfxcNW5hmD38fZFyPZI9Z5O/m10eEg=; fh=cTOyeHIiotxFveWD397Up69SLR8Dqpy9YboYIfW0A00=; b=o2S83ALHQ57yLf/szfZ0WZpcpCfHArMdUpBOauB6sT7vtBq1zkefJtSk8ylbJ3sBZH qi++fxQu1Bswe4Vfg2ZypwQfA/D8pqJkf1Z4AHLIPOMe6/icT18aQhIQ2SeguM1tuSac DyGXZrtChodYAW0G19j4EMJzRwsuCwkrIx1CsdpUqIbA5fhtxd+UDA+EUVgKy0fwiRpg jqVaPyDAyI0Pfbf98l5IflAhHSBURL2AZhZ4nbG4h94bWrF3drp42B71UWt2vRs/4S9S kCTkI7wuS6j7mHf4LxrD3bvy8AnTNZAdQLo3BJdRSHoBfx7A+gn+KnmWIAzdnYcQutUR GcKw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-31192-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31192-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y16-20020a63e250000000b005c279da45f1si3445609pgj.566.2024.01.19.05.27.12 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 05:27:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31192-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-31192-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31192-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 268E5285AD1 for <ouuuleilei@gmail.com>; Fri, 19 Jan 2024 13:26:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4309653E3F; Fri, 19 Jan 2024 13:25:42 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AAC2524D6 for <linux-kernel@vger.kernel.org>; Fri, 19 Jan 2024 13:25:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705670740; cv=none; b=IsuAVW3mClxcFJqP+yqSqHEEq1dCibsQcegJIOUSQNeqyLBjLcG8OYOVVc++HwSqpBxjNs8tmn/ySCbHYmY3DoFZ9HsS+au0dTPytTT+FIffZ8/QUYRluJASJ12cRSgBcioUzyc5NTCcGFD5DK/fnxbPA4XL2h4JhFL5IvPCFOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705670740; c=relaxed/simple; bh=FG8+XP94f/Ig6ekDFdWhMR1QY436ISnaJd2Qe3LwG1s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DA5v9cl8Ha8ykqX1+A3hKT5tcfFZkAed+x3iVS5srL6za01dVBVzhE4q7vi+T0ZFHMD/1R9kg83Ro/8mwWkn6YMcXXdctHiro/SpuDmDxP7FVoNiMQ14GK9SJgumWzkwej7IEz6W/M/iHKq+dKJKmj/5BTNvy+vchxy80H8ebqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <ore@pengutronix.de>) id 1rQos7-00074L-C1; Fri, 19 Jan 2024 14:25:23 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <ore@pengutronix.de>) id 1rQos6-000viS-AL; Fri, 19 Jan 2024 14:25:22 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from <ore@pengutronix.de>) id 1rQos6-00F98h-0j; Fri, 19 Jan 2024 14:25:22 +0100 From: Oleksij Rempel <o.rempel@pengutronix.de> To: Sebastian Reichel <sre@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Cc: Oleksij Rempel <o.rempel@pengutronix.de>, kernel@pengutronix.de, linux-kernel@vger.kernel.org, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, "Rafael J. Wysocki" <rafael@kernel.org>, Daniel Lezcano <daniel.lezcano@linaro.org>, Zhang Rui <rui.zhang@intel.com>, Lukasz Luba <lukasz.luba@arm.com>, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, =?utf-8?q?S=C3=B8ren_Andersen?= <san@skov.dk> Subject: [RFC PATCH v1 7/7] thermal: core: set Power State Change Reason before hw_protection_shutdown() Date: Fri, 19 Jan 2024 14:25:21 +0100 Message-Id: <20240119132521.3609945-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240119132521.3609945-1-o.rempel@pengutronix.de> References: <20240119132521.3609945-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788525498726055306 X-GMAIL-MSGID: 1788525498726055306 |
Series |
Introduction of PSCR Framework and Related Components
|
|
Commit Message
Oleksij Rempel
Jan. 19, 2024, 1:25 p.m. UTC
Store the state change reason to some black box for later investigation.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
drivers/thermal/thermal_core.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On Fri, Jan 19, 2024 at 2:25 PM Oleksij Rempel <o.rempel@pengutronix.de> wrote: > > Store the state change reason to some black box for later investigation. Seriously? What black box, where, how this is useful and who is going to use it, pretty please. > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> > --- > drivers/thermal/thermal_core.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > index 9c17d35ccbbd..5ee3a59d7a0e 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -16,6 +16,7 @@ > #include <linux/kdev_t.h> > #include <linux/idr.h> > #include <linux/thermal.h> > +#include <linux/pscr.h> > #include <linux/reboot.h> > #include <linux/string.h> > #include <linux/of.h> > @@ -325,6 +326,7 @@ void thermal_zone_device_critical(struct thermal_zone_device *tz) > dev_emerg(&tz->device, "%s: critical temperature reached, " > "shutting down\n", tz->type); > > + set_power_state_change_reason(PSCR_OVERTEMPERATURE); > hw_protection_shutdown("Temperature too high", poweroff_delay_ms); > } > EXPORT_SYMBOL(thermal_zone_device_critical); > -- > 2.39.2 >
On Fri, Jan 19, 2024 at 07:34:26PM +0100, Rafael J. Wysocki wrote: > On Fri, Jan 19, 2024 at 2:25 PM Oleksij Rempel <o.rempel@pengutronix.de> wrote: > > > > Store the state change reason to some black box for later investigation. > > Seriously? > > What black box, where, how this is useful and who is going to use it, > pretty please. The 'black box' refers to a non-volatile memory (NVMEM) cell used by the Power State Change Reasons (PSCR) framework. This cell stores reasons for sudden power state changes, like voltage drops or over-temperature events. This data is invaluable for post-mortem analysis to understand system failures or abrupt shutdowns. It's particularly useful for systems where PMICs or watchdogs cannot record such events. The data can inform recovery routines in the bootloader or early kernel stages during subsequent boots, enhancing system reliability and aiding in debugging and diagnostics. Regards, Oleksij
On Fri, Jan 19, 2024 at 8:34 PM Oleksij Rempel <o.rempel@pengutronix.de> wrote: > > On Fri, Jan 19, 2024 at 07:34:26PM +0100, Rafael J. Wysocki wrote: > > On Fri, Jan 19, 2024 at 2:25 PM Oleksij Rempel <o.rempel@pengutronix.de> wrote: > > > > > > Store the state change reason to some black box for later investigation. > > > > Seriously? > > > > What black box, where, how this is useful and who is going to use it, > > pretty please. > > The 'black box' refers to a non-volatile memory (NVMEM) cell used by the > Power State Change Reasons (PSCR) framework. This cell stores reasons > for sudden power state changes, like voltage drops or over-temperature > events. This data is invaluable for post-mortem analysis to understand > system failures or abrupt shutdowns. It's particularly useful for > systems where PMICs or watchdogs cannot record such events. The data can > inform recovery routines in the bootloader or early kernel stages during > subsequent boots, enhancing system reliability and aiding in debugging > and diagnostics. OK, so please add all of the above to the patch changelog.
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 9c17d35ccbbd..5ee3a59d7a0e 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -16,6 +16,7 @@ #include <linux/kdev_t.h> #include <linux/idr.h> #include <linux/thermal.h> +#include <linux/pscr.h> #include <linux/reboot.h> #include <linux/string.h> #include <linux/of.h> @@ -325,6 +326,7 @@ void thermal_zone_device_critical(struct thermal_zone_device *tz) dev_emerg(&tz->device, "%s: critical temperature reached, " "shutting down\n", tz->type); + set_power_state_change_reason(PSCR_OVERTEMPERATURE); hw_protection_shutdown("Temperature too high", poweroff_delay_ms); } EXPORT_SYMBOL(thermal_zone_device_critical);