Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1077536rdb; Wed, 24 Jan 2024 04:23:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUjkRRcelv5kReIf9EIsFDnfSLtQcOjwyf7DU/Re/OL73tH4iT7L8SUXH/P6EuGKqESMFH X-Received: by 2002:a92:c687:0:b0:361:add8:21e4 with SMTP id o7-20020a92c687000000b00361add821e4mr1466167ilg.2.1706098992752; Wed, 24 Jan 2024 04:23:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706098992; cv=pass; d=google.com; s=arc-20160816; b=w8hWYvfL931eP0KScgdpJ46YmFHSAf39mKN53KBBy1XiZWzcIm1rtjHXjriRW5yNt5 M99RxRYToe1HWQcVj3lan+FvEq/HWqNAqPGaj1mlwWPYuCOx4KDGG3PlfMsg/YkrnQPt marGzbdyG32vwenio/3I2UgaMUcS+KzF9Z9a1A/usZ+kBZftOBeHtNhnyHk0JmorCFRl eDC0RnUxAnMnrSjLKGLQkI3pTMUJzZBcHhd3DdNYFzotXJj9WgkgsK+MmCie08yGhXZn 5/jDAQTCgisF8z0gYJFj9RhzNm+BECerVu+ub2IQDBkeheAO9cmiKXOuZo2z3dghCcWm lxJw== 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=I8r/edMx+iyEZ6fKQoBaay9p1ypCo1S2jGAadaPff+M=; fh=cTOyeHIiotxFveWD397Up69SLR8Dqpy9YboYIfW0A00=; b=mrJx50+aYaYLG+webOsnm4SAjyYyIQy6DvBcBbNHz+IQ0GO8VtiebiBIgiJLGA8dxc peb6wkOOwt6Udw4z/uBR9W/xVXOcTEQOQHV2aOYhm6siPCoZ93/zHFOjCgiU21T0xytD bk7NS7DlBE1wv8/KleRADL/XEJy0iwN/6xMSOwJaRnnHE/kk4Q4N95r6jYUhP2q/AtwF 0C6Qk4aW/X5/YHYtEWuWIOPtVe6cd7lroMZ7zc6gDarazJDFpn3zAGFffObp9BvVRj1B f4qB1rPlVqEnBmU6betQLtGKMw0mJ4UrN8ru/AOhEYpBoNySbzf5ox5Dwd1ekYQIHmjl tJ0g== 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-36962-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36962-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h27-20020a63f91b000000b005ce05e6f59bsi11350964pgi.877.2024.01.24.04.23.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 04:23:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36962-linux.lists.archive=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-36962-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36962-linux.lists.archive=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 B218D285BEC for ; Wed, 24 Jan 2024 12:22:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0AD7363134; Wed, 24 Jan 2024 12:22:28 +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 F04DC6310E for ; Wed, 24 Jan 2024 12:22:25 +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=1706098947; cv=none; b=eQ9XMdL6PCby9xLFmm0y9+GfV8xYsjlkfWBELxS0TAHzi5dfm0dRfSeELXjPPy5MbuWUIawFKOpAptpgQlViGP6QW/Erq2eC5+I5bbos+PpSKoJIGH2BtPjwY2xmVgaTeE4qXS8utdDDYHcJ9FbKQ2YhXG863J0GhCPbp5NcHvE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706098947; c=relaxed/simple; bh=HDAeY4bWfoe9Y+7OHDYHhF+4G8dpj+H9p3pWeswLx5k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ImzcrxLrU4IBo5LPlndz3y7d+IUFI9MZ5hbe6/JR88Q1JrxpIKfCxTt9jXSlDpybh+3OFRnOwzWVYJcZMSnU4ZrU8td73T6Y+8tGDmG68XxhbDAeLzrOXPsiWpwFrpYQFXxlRGildlvgFsZIo+YtOkcm3su+m08bYi6TlHPPoyw= 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 ) id 1rScGd-0007oC-1C; Wed, 24 Jan 2024 13:22:07 +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 ) id 1rScGc-0023Zn-46; Wed, 24 Jan 2024 13:22:06 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rScGc-003424-03; Wed, 24 Jan 2024 13:22:06 +0100 From: Oleksij Rempel To: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Srinivas Kandagatla Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, Liam Girdwood , Mark Brown , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, =?UTF-8?q?S=C3=B8ren=20Andersen?= Subject: [PATCH v2 8/8] thermal: core: Record PSCR before hw_protection_shutdown() Date: Wed, 24 Jan 2024 13:22:04 +0100 Message-Id: <20240124122204.730370-9-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240124122204.730370-1-o.rempel@pengutronix.de> References: <20240124122204.730370-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Enhance the thermal core to record the Power State Change Reason (PSCR) prior to invoking hw_protection_shutdown(). This change integrates the PSCR framework with the thermal subsystem, ensuring that reasons for power state changes, such as overtemperature events, are stored in a dedicated non-volatile memory (NVMEM) cell. This 'black box' recording is crucial for post-mortem analysis, enabling a deeper understanding of system failures and abrupt shutdowns, especially in scenarios where PMICs or watchdog timers are incapable of logging such events. The recorded data can be utilized during system recovery routines in the bootloader or early kernel stages of subsequent boots, significantly enhancing system diagnostics, reliability, and debugging capabilities. Signed-off-by: Oleksij Rempel --- drivers/thermal/thermal_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index dfaa6341694a..0511d82351c5 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -329,6 +330,8 @@ static void thermal_zone_device_halt(struct thermal_zone_device *tz, bool shutdo dev_emerg(&tz->device, "%s: critical temperature reached\n", tz->type); + set_power_state_change_reason(PSCR_OVERTEMPERATURE); + if (shutdown) hw_protection_shutdown(msg, poweroff_delay_ms); else -- 2.39.2