From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
Cc: Sebastian Reichel <sre@kernel.org>,
Benson Leung <bleung@chromium.org>,
Tzung-Bi Shih <tzungbi@kernel.org>,
Guenter Roeck <groeck@chromium.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Matti Vaittinen <mazziesaccount@gmail.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Oleksij Rempel <o.rempel@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev,
avaneesh.dwivedi@oss.qualcomm.com,
Umang Chheda <umang.chheda@oss.qualcomm.com>,
Francesco Valla <francesco@valla.it>
Subject: Re: [PATCH v15 5/6] power: reset: Introduce PSCR Recording Framework for Non-Volatile Storage
Date: Fri, 2 Oct 2026 11:06:34 +0200 [thread overview]
Message-ID: <ar90GoaxTV8pjonY@mai.linaro.org> (raw)
In-Reply-To: <20260924-pscrr-framework-v15-5-7af87107e0d3@oss.qualcomm.com>
On Thu, Sep 24, 2026 at 12:38:46PM +0530, Faruque Ansari wrote:
> Introduce the Power State Change Reasons Recording (PSCRR) framework: a
> generic mechanism to record why the last power state change (shutdown or
> reboot) happened - under-voltage, thermal, watchdog, software-triggered,
> etc. - so a postmortem reason survives a reboot or an abrupt power loss.
>
> PSCRR is built around providers. A provider is either a hardware reason
> source (a PMIC, SoC reset controller or watchdog exposing a reset cause)
> or a recorder that persists the reason across a power cycle (an NVMEM or
> RTC scratch cell). Each provider gets a directory under
> /sys/kernel/pscrr/providerN/ exposing its name, backing device, the set
> of observed reasons (as tokens), its capabilities, the reasons it
> supports and - for recorders - a record policy. The reason set is
> deliberately not collapsed to a single winning cause, since resets are
> often multi-causal.
>
> Reasons are the numeric enum psc_reason values from reboot.h, shared with
> the POWER_ON_REASON_* vocabulary, so they store compactly in small
> battery-backed cells. The current reason (get/set_psc_reason(), set by
> the thermal/regulator/hw_protection paths) is written to every recorder
> from the reboot notifier.
[ ... ]
> +menuconfig PSCRR
> + bool "Power State Change Reasons Recording (PSCRR) Framework"
> + depends on POWER_RESET
> + help
> + Enables the Power State Change Reasons Recording (PSCRR) framework.
> +
> + PSCRR records why the system last shut down or rebooted into
> + non-volatile storage, so the reason survives the reset and can be
> + read by the bootloader or early user space on the next boot. Reasons
> + come from software (thermal or regulator hardware-protection events,
> + a watchdog pretimeout, a kernel panic, a controlled reboot) or from
> + hardware reset-cause registers (PMIC, SoC reset controller, watchdog).
[ ... ]
> +static int pscrr_reboot_notifier(struct notifier_block *nb,
> + unsigned long action, void *unused)
> +{
> + guard(mutex)(&pscrr_lock);
> +
> + /*
> + * A reboot, halt or power-off that reaches here with no more specific
> + * reason is software-initiated by definition. Record it as such rather
> + * than leaving it unattributed; a real cause set earlier (thermal,
> + * under-voltage, ...) is already latched and left untouched.
> + */
> + if (get_psc_reason() == PSCR_UNKNOWN)
> + set_psc_reason(PSCR_SOFTWARE);
> +
> + pscrr_record_current();
> +
> + return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block pscrr_reboot_nb = {
> + .notifier_call = pscrr_reboot_notifier,
> +};
I'm worried about the mechanism. The call to set_psc_reason() sets a
global variable and pscrr_record_current() write its value to the
NVMEM backend.
That is done from the reboot notifier.
Is this notifier called in all cases, eg. watchdog reset or emergency
reboot ? It sounds possible the reason is set but then the notifier is
not called thus not written in the non-volatile medium, no ?
[ ... ]
next prev parent reply other threads:[~2026-10-02 9:06 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 17:44 [PATCH v14 0/6] power: reset: Introduce the Power State Change Reasons Recording (PSCRR) framework Faruque Ansari
2026-09-21 17:44 ` [PATCH v14 1/6] power: Extend power_on_reason.h for upcoming PSCRR framework Faruque Ansari
2026-09-22 6:02 ` Matti Vaittinen
2026-09-21 17:44 ` [PATCH v14 2/6] reboot: hw_protection_trigger: use standardized numeric shutdown/reboot reasons instead of strings Faruque Ansari
2026-10-02 7:47 ` Daniel Lezcano
2026-10-05 12:27 ` Faruque Ansari
2026-09-21 17:44 ` [PATCH v14 3/6] reboot: add parsable tokens for power state change reasons Faruque Ansari
2026-09-22 7:37 ` Matti Vaittinen
2026-09-23 11:05 ` Faruque Ansari
2026-09-21 17:44 ` [PATCH v14 4/6] reboot: extend psc_reason with power-on and reset causes Faruque Ansari
2026-09-22 7:45 ` Matti Vaittinen
2026-09-23 11:05 ` Faruque Ansari
2026-09-21 17:44 ` [PATCH v14 5/6] power: reset: Introduce PSCR Recording Framework for Non-Volatile Storage Faruque Ansari
2026-09-22 9:03 ` Matti Vaittinen
2026-09-23 11:06 ` Faruque Ansari
2026-09-21 17:44 ` [PATCH v14 6/6] Documentation: Add sysfs documentation for PSCRR Faruque Ansari
2026-09-22 9:12 ` Matti Vaittinen
2026-09-22 6:33 ` [PATCH v14 0/6] power: reset: Introduce the Power State Change Reasons Recording (PSCRR) framework Bradley Morgan
2026-09-22 6:44 ` Faruque Ansari
2026-09-24 7:08 ` [PATCH v15 " Faruque Ansari
2026-09-24 7:08 ` [PATCH v15 1/6] power: Extend power_on_reason.h for upcoming PSCRR framework Faruque Ansari
2026-10-01 20:22 ` Daniel Lezcano
2026-10-02 4:22 ` Oleksij Rempel
2026-10-02 7:07 ` Daniel Lezcano
2026-09-24 7:08 ` [PATCH v15 2/6] reboot: hw_protection_trigger: use standardized numeric shutdown/reboot reasons instead of strings Faruque Ansari
2026-09-24 7:08 ` [PATCH v15 3/6] reboot: add parsable tokens for power state change reasons Faruque Ansari
2026-10-02 7:53 ` Daniel Lezcano
2026-09-24 7:08 ` [PATCH v15 4/6] reboot: extend psc_reason with power-on and reset causes Faruque Ansari
2026-09-24 12:14 ` Matti Vaittinen
2026-09-24 7:08 ` [PATCH v15 5/6] power: reset: Introduce PSCR Recording Framework for Non-Volatile Storage Faruque Ansari
2026-10-02 9:06 ` Daniel Lezcano [this message]
2026-10-05 12:26 ` Faruque Ansari
2026-09-24 7:08 ` [PATCH v15 6/6] Documentation: Add sysfs documentation for PSCRR Faruque Ansari
2026-09-25 17:34 ` [PATCH v14 0/6] power: reset: Introduce the Power State Change Reasons Recording (PSCRR) framework Bradley Morgan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ar90GoaxTV8pjonY@mai.linaro.org \
--to=daniel.lezcano@oss.qualcomm.com \
--cc=avaneesh.dwivedi@oss.qualcomm.com \
--cc=bleung@chromium.org \
--cc=broonie@kernel.org \
--cc=chrome-platform@lists.linux.dev \
--cc=daniel.lezcano@kernel.org \
--cc=faruque.ansari@oss.qualcomm.com \
--cc=francesco@valla.it \
--cc=groeck@chromium.org \
--cc=kernel@pengutronix.de \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=mazziesaccount@gmail.com \
--cc=o.rempel@pengutronix.de \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=sre@kernel.org \
--cc=tzungbi@kernel.org \
--cc=umang.chheda@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.