From nobody Tue Nov 24 12:36:15 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795417541; b=KH2gDAC1x7bI8i/9TkpW56tSBlTuPAa54PAh6rzYnaz7FveD7UuoZqlTTtxtpzeKMmcu mB9xv8GGCbS2GhHAAB2S6hoO91lNZnbGo3WQ0yy5oRSGvJHueYLYihkmBUVNO3cV+lqqI xhltCqlbqRm0344ofVKOWYJDG4zOJawEjBq/AIJSARFQM7iqtmrjtdfzV6BvAohFVMsEX aWVFVfO7nSleH2X4m+GASlCJHweMulDp+RCMRyoG9749CEdCYLnRUNbELGbPWyC04YA8c fFKGuyfZ6dF1Mx84dZw/Q97e3CPCm7SKt99O1ts3/KjqIkyXTSghqOve0lfLFnjgQQw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795417541; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received:From: Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Proofpoint-Reinject:X-QCInternal:X-QCInternal:X-Proofpoint-GUID: X-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Info:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=p6K6BHA8f60tUUn0BXpwoKTl1UjqiSlQvS+aUVZvn0M=; b=aw98yWy1zlV1DeriMCB5PlQu6w9a4ERuYNy7Gq+jwmBaAYP9ru+dq/045jj5mSa+Cgrj 929wC3sF52TrH2f5MwKgMzeByZ9Q7U9LnGUVSeu1MKjHgAQaprxQ2cCOodjcn6yLRyiS3 zeoJo4gklZGSWUnSos1OrqQUOX5bKc+lKl7XXS5ybADW+zfq/RvyJW+YSKqqlkjdhTnhC acFYWCcVkRjlo/7zcOyusKtv/PmNmwSJ62uFcpmJaOtFnQOcri/fWF9VKeCM95qGtDeLK y7f1wWFAXAaJpeJJWTlIxwNCOASEVU+nZMQg7lQepu/UV4vZzbm3k8pXK1J+3aYEqtQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=MKeyK6oU; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4988C606A31A; Mon, 23 Nov 2026 07:05:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4988C606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=MKeyK6oU Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AN6PZP83713062; Mon, 23 Nov 2026 07:05:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= p6K6BHA8f60tUUn0BXpwoKTl1UjqiSlQvS+aUVZvn0M=; b=MKeyK6oU+KNsKJgD I1bakOOX+ujXmshp4r9OcPex82Bdo3u6cX7ydKC8Wk1mX8ceJJDV3TcHGsHX87ar 6dQMfb0r1T82t0kq33/B0Db6zgRe8s/3XWFzvXwBO0DslcnqIHdjcMiRAGXheE20 V9nb/+D3dwPNVIODYbfRJ9vYP4+/YuGBiQSNnlYz5DCUi+rug9vTOwaUL588H2IO 1HzUGoUw6nSo/LaEvpGLBYPx6kkoAkhjAhLOjBEtw92a4xbTYEU0lSZNtVW9L/+4 UZ/pzMxAP61w6+BH8E9BhtbZKJVEBRexNcJlOPaqk+TWOL14gpEz8Frem5OsyMR5 rGv/SQ== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j4g740500-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 23 Nov 2026 07:05:07 +0000 (GMT) Received: from pps.filterd (apblrppmta01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.11/8.18.1.11) with ESMTP id 6AN72cFi4179942; Mon, 23 Nov 2026 07:05:04 GMT Received: from hu-ffaruque-hyd.qualcomm.com (hu-ffaruque-hyd.qualcomm.com [10.147.245.31]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 6AN753Q34185090; Mon, 23 Nov 2026 07:05:04 +0000 (GMT) From: Faruque Ansari Date: Mon, 23 Nov 2026 12:34:53 +0530 Subject: [PATCH v5 1/5] power: reset: pscrr: add kernel panic reason tracking X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-pscrr-reboot-reason-v5-1-fbf3c7c92772@oss.qualcomm.com> References: <20261123-pscrr-reboot-reason-v5-0-fbf3c7c92772@oss.qualcomm.com> In-Reply-To: <20261123-pscrr-reboot-reason-v5-0-fbf3c7c92772@oss.qualcomm.com> To: Sebastian Reichel , Wim Van Sebroeck , Guenter Roeck , Benson Leung , Tzung-Bi Shih , Oleksij Rempel , Srinivas Kandagatla , Daniel Lezcano , Pengutronix Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-arm-msm@vger.kernel.org, kernel@pengutronix.de, Liam Girdwood , Mark Brown , "Rafael J. Wysocki" , Zhang Rui , Lukasz Luba , =?utf-8?q?S=C3=B8ren_Andersen?= , Guenter Roeck , Matti Vaittinen , Ahmad Fatoum , Andrew Morton , avaneesh.dwivedi@oss.qualcomm.com, Umang Chheda , Faruque Ansari , Daniel Lezcano X-Mailer: b4 0.14.3 X-Proofpoint-Reinject: loops=2 maxloops=12 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-GUID: kg99tHVNhU9lTIAZgMBhrsM9W3Mtufw2 X-Proofpoint-ORIG-GUID: kg99tHVNhU9lTIAZgMBhrsM9W3Mtufw2 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDAyNyBTYWx0ZWRfX61+4L7qx1w8C Z0aqJ2v1FvfXoW6lfSs2D5KUz8L6+sH/3SbmGRq3PVJn4+9zKGXeH/j1H14Jp3TwSwI6iEZ7Brp 6BuRX/uujMhiVnXvSF/yCl99xpl7Usc= X-Authority-Analysis: v=2.4 cv=T/cZ3PKQ c=1 sm=1 tr=0 ts=6b03e5a3 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=opvmgqTE--nunqmWsLMA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDAyNyBTYWx0ZWRfX7rMQa4F2/tqz 0s42MnDofvUEhm5HIdh//NbJgExe1qiUrYc4meUcdE+cDFgUb/hJ1cXew53JX9cFkNR/box2mH1 DpXuMesTxorsuVBscJ6iGC9EZcS4nR64p2v0jsjjX+B13g3gIX2TqTjN/HGz71MCnEk9Ub9YQqm LpjHl1I4NjQ476wqAfqEx1KzE5LqLG3R6U4Dnp5kVoUIJ9QtjlE/tdRFXaFNtRg56NeIWlbuhc8 qsNGJcgJzjejcBzszetRqylg82qbkFriFsa+CEEHYi8pk/ReLtw5bVxLTwQD8i/G2tkEtFaxY53 QUQo37oWjoaDGJQIHUsLD8dmw2qxKN39xTZhQ3EHoxu/jVBPTCv5yNgWDDRlnG8WmYBDsOHetu4 qyD4CcUtp4yEu6S3Yhks9dhBtH2nT+lNJGaGFQ4fInikNaxNRNBC8CVngLFMyohg8FZOjXNqkvT +QKcWGLcR1F3WzCpHqg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_01,2026-11-22_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1011 bulkscore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 adultscore=0 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230027 Kernel panic resets are not recorded in NVMEM, causing subsequent boots to report PSCR_UNKNOWN and making post-mortem analysis more difficult. Register a panic notifier to preserve the shutdown reason across panic-triggered resets. Add PSCR_KERNEL_PANIC as a dedicated reset reason code and its corresponding reason string to identify kernel panic resets on subsequent boots. Reviewed-by: Daniel Lezcano Signed-off-by: Faruque Ansari --- drivers/power/reset/pscrr/pscrr.c | 27 +++++++++++++++++++++++++++ include/linux/power/power_on_reason.h | 1 + include/linux/reboot.h | 3 +++ kernel/reboot.c | 1 + 4 files changed, 32 insertions(+) diff --git a/drivers/power/reset/pscrr/pscrr.c b/drivers/power/reset/pscrr/= pscrr.c index 6f23f4c4f590..8c45b84059a9 100644 --- a/drivers/power/reset/pscrr/pscrr.c +++ b/drivers/power/reset/pscrr/pscrr.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -519,6 +520,29 @@ static struct notifier_block pscrr_reboot_nb =3D { .notifier_call =3D pscrr_reboot_notifier, }; =20 +/* + * Panic notifier: record that the machine went down through a kernel pani= c, so + * the cause is visible on the next boot. Runs in atomic panic context, so= the + * provider list is walked without pscrr_lock - providers no longer come o= r go + * once the machine is going down. + */ +static int pscrr_panic_notifier(struct notifier_block *nb, + unsigned long action, void *unused) +{ + struct pscrr_provider_dir *dir; + + set_psc_reason(PSCR_KERNEL_PANIC); + + list_for_each_entry(dir, &pscrr_dirs, node) + pscrr_do_record(dir, get_psc_reason()); + + return NOTIFY_DONE; +} + +static struct notifier_block pscrr_panic_nb =3D { + .notifier_call =3D pscrr_panic_notifier, +}; + /*----------------------------------------------------------------------*/ /* Built-in provider: device-tree /chosen/reset-source */ /*----------------------------------------------------------------------*/ @@ -611,6 +635,8 @@ static int __init pscrr_core_init(void) return ret; } =20 + atomic_notifier_chain_register(&panic_notifier_list, &pscrr_panic_nb); + pscrr_register_reset_source(); =20 return 0; @@ -619,6 +645,7 @@ static int __init pscrr_core_init(void) static void __exit pscrr_core_exit(void) { pscrr_provider_unregister(&pscrr_reset_source_provider); + atomic_notifier_chain_unregister(&panic_notifier_list, &pscrr_panic_nb); unregister_reboot_notifier(&pscrr_reboot_nb); kobject_put(pscrr_root); pscrr_root =3D NULL; diff --git a/include/linux/power/power_on_reason.h b/include/linux/power/po= wer_on_reason.h index 13e61ace14f5..8c99bdd75021 100644 --- a/include/linux/power/power_on_reason.h +++ b/include/linux/power/power_on_reason.h @@ -20,5 +20,6 @@ #define POWER_ON_REASON_OVER_TEMPERATURE "over temperature" #define POWER_ON_REASON_EC_PANIC "EC panic" #define POWER_ON_REASON_EXTERNAL "external reset" +#define POWER_ON_REASON_KERNEL_PANIC "kernel panic" =20 #endif /* POWER_ON_REASON_H */ diff --git a/include/linux/reboot.h b/include/linux/reboot.h index 13f004ad1066..a117dd5eaecd 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -241,6 +241,8 @@ extern void orderly_reboot(void); * * @PSCR_XTAL_FAIL: Reset caused by a crystal oscillator failure. * + * @PSCR_KERNEL_PANIC: Reset that followed a kernel panic. + * * @PSCR_REASON_COUNT: Number of defined power state change reasons. This * value is useful for range checking and potential future extensions * while maintaining compatibility. @@ -264,6 +266,7 @@ enum psc_reason { PSCR_RESET_BUTTON, PSCR_CPU_CLK_FAIL, PSCR_XTAL_FAIL, + PSCR_KERNEL_PANIC, =20 /* Number of reasons */ PSCR_REASON_COUNT, diff --git a/kernel/reboot.c b/kernel/reboot.c index 75af5d763465..979ecf3b093c 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -1109,6 +1109,7 @@ static const struct psc_reason_desc psc_reason_descs[= ] =3D { [PSCR_RESET_BUTTON] =3D { "reset-button", POWER_ON_REASON_RST_BTN }, [PSCR_CPU_CLK_FAIL] =3D { "cpu-clock-failure", POWER_ON_REASON_CPU_CLK_F= AIL }, [PSCR_XTAL_FAIL] =3D { "crystal-failure", POWER_ON_REASON_XTAL_FAIL }, + [PSCR_KERNEL_PANIC] =3D { "kernel-panic", POWER_ON_REASON_KERNEL_PANIC= }, }; =20 /** --=20 2.34.1 From nobody Tue Nov 24 12:36:15 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795417548; b=5KyzZ67cJIlNsz27tVj8feD320giRbDnjHGj743wOCPhYc2/t5bqA6hMuu8Fk4dACsRT JIOZbcNzaOzFMiE3kn3qmisIJtqWlwuXt76hzuYmKNfHEadccEA+J/Pmv6QGTLviMMfaX v2ki8+HEb3IDqmb5Ux3yLKb6xQBTMQbK9oGfi5Gu0OKGwlsRLg84SFcg0VuAhC/1y5KM7 fJG6W2goa+EYuhtSHCHddV1g2mfxYNtioScveQf8f4sYbIOkA6//ZSuus5V1rNqMjoGmb oGZAkS3v8Uy9UQ2L+xsBYc2vw4LchjGGZx2U1sLUaia8MMgftSIUUJBmLvDtXDvJNUw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795417548; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received:From: Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Proofpoint-Reinject:X-QCInternal:X-QCInternal: X-Proofpoint-Spam-Info:X-Proofpoint-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-ORIG-GUID: X-Authority-Analysis:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=W/SQVaOt4hQUDstRSF5z1Q8P4LWhMQSIvuQSidCmHrc=; b=0O/abWlEY+Q9xfE1D4dKbccmkCfUYt94e1hGnPG5aQILTD5KmPNUnR2CkF5jxXErK5n4 yC2IQruX3SjRf9OMtDTqom6L0SJB9K0p+fxdcnLXdH0s5MxieRHgcxDObeBs0ciHILakV zKJRKJNpU+ZL8ddHZNMcG0+41WlunyjSLlUvvzQA2p9qM/RJRFzv4gDNH1KSaMn6yjO+9 A98RcwWeEX8lBjxIKKS57F4pJE119AK1uwspQuj6Lo6Tso1M0BHYI8w5fhk1pPj894MRb j6IiUEY184F+aftwJR+ttfkkyiQepB958Vx2Lvoy2TSExYLLwd0HYmPYo/KIJBvgmBg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=f6AaDQ3n; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 247E4606A686; Mon, 23 Nov 2026 07:05:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 247E4606A686 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=f6AaDQ3n Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AN6Ddpr1490223; Mon, 23 Nov 2026 07:05:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= W/SQVaOt4hQUDstRSF5z1Q8P4LWhMQSIvuQSidCmHrc=; b=f6AaDQ3nrZZXe1Vr L/73gyCjozX1T5NHBzetuNE+8GYARVqs50OMS42KwMKuy7AJDILRz6XECXuR6zD1 tvIA0e969Z6bUJP/nb5RKzvS3zwQBmwz1aQtCByzpbiVqnbIeiAcTWUzraaK7raf wHD4hqLJecj0gqEqThRgM4tqWys/sN6GfMwMEuPXSOF0E6HUXmTNM44YZzbk/Fah xZ6Ad1xaEPb7swVxP67Di1hucw1QOZebYPPg+bnhY82DcWMSvnraW0yDUXY2GZRx U+XyZOXLlr1zFkSjDwtgpw+vJMu+UbvuLY/X4uckXrBNe+wqCDTgpO1O4OHe/op7 pnz9+g== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j4g1k05u7-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 23 Nov 2026 07:05:07 +0000 (GMT) Received: from pps.filterd (apblrppmta01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.11/8.18.1.11) with ESMTP id 6AN755ej4185166; Mon, 23 Nov 2026 07:05:05 GMT Received: from hu-ffaruque-hyd.qualcomm.com (hu-ffaruque-hyd.qualcomm.com [10.147.245.31]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 6AN753Q44185090; Mon, 23 Nov 2026 07:05:04 +0000 (GMT) From: Faruque Ansari Date: Mon, 23 Nov 2026 12:34:54 +0530 Subject: [PATCH v5 2/5] power: reset: pscrr: add watchdog pretimeout reason tracking X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-pscrr-reboot-reason-v5-2-fbf3c7c92772@oss.qualcomm.com> References: <20261123-pscrr-reboot-reason-v5-0-fbf3c7c92772@oss.qualcomm.com> In-Reply-To: <20261123-pscrr-reboot-reason-v5-0-fbf3c7c92772@oss.qualcomm.com> To: Sebastian Reichel , Wim Van Sebroeck , Guenter Roeck , Benson Leung , Tzung-Bi Shih , Oleksij Rempel , Srinivas Kandagatla , Daniel Lezcano , Pengutronix Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-arm-msm@vger.kernel.org, kernel@pengutronix.de, Liam Girdwood , Mark Brown , "Rafael J. Wysocki" , Zhang Rui , Lukasz Luba , =?utf-8?q?S=C3=B8ren_Andersen?= , Guenter Roeck , Matti Vaittinen , Ahmad Fatoum , Andrew Morton , avaneesh.dwivedi@oss.qualcomm.com, Umang Chheda , Faruque Ansari X-Mailer: b4 0.14.3 X-Proofpoint-Reinject: loops=2 maxloops=12 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDAyNyBTYWx0ZWRfX/bu3C30cAFFl yh44MBnx0DYBf6LI+pvhj+c91pJo/7589c4qV0w1tfDWjVbcRIHc6GyC5NxnvSfvUAI4098/ppA FkMVsOUKY9msOdBW0a8L0ZGdHIlgvsU= X-Proofpoint-GUID: eWQ4nhP-YmbG7NRtUREwmiErUQy1WhyR X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDAyNyBTYWx0ZWRfX/30V7i0NyKoC HN/MULWloPXfWpril7A3w+VCZejKFlzkdNVKD82Sd8PMXzMmw7L/j+sF0a7NI7w78jszZSg3D2H Es9XzjnftQduVyqvs4+93I6hsDEDychz4UJmsRKXRRXYZZusMb9JoDOGimcGmJgXyv2e2hVo5py QMr86g+vVvslPuJjbT/2CH7JR7tB1YZwARDFHagCvNR9JIfpWwxRcEUvEnWOi61N99cAMalR7KW NIuUOjZsy8iwIXSObP/6bIzDp4zRfA7T5pVUcPpHYGDmq5iRwNLQDf/X4qjHH1fFTdzLi+XII18 g7mQV+DNn0iU2TqiOC95hZyuDLnAFHSa3CxslsLGXuwjXb1xS5XtaC6O+hkXFgFZZKDnXNa12WG pOg5qCWDiMRPqFQ6PXEsykqkC9RtWueQem+2Q7jlLrIcPPekhC4nU31K/0Kyq3aSu0HsqpBFiF8 V5TBQMlr7Gh+uxDRdsA== X-Proofpoint-ORIG-GUID: eWQ4nhP-YmbG7NRtUREwmiErUQy1WhyR X-Authority-Analysis: v=2.4 cv=cpIOAF4i c=1 sm=1 tr=0 ts=6b03e5a3 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=ynidK1FTdYmqK0Z_2qMA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_01,2026-11-22_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 suspectscore=0 bulkscore=0 spamscore=0 clxscore=1015 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230027 Watchdog pretimeout resets are not recorded with a dedicated reason, causing subsequent boots to report PSCR_UNKNOWN and making it difficult to distinguish them from other unexpected resets. Add PSCR_WATCHDOG_PRETIMEOUT as a dedicated reason code and prevent the panic notifier from overwriting a watchdog pretimeout reason with PSCR_KERNEL_PANIC when the pretimeout governor triggers a panic. Signed-off-by: Faruque Ansari --- drivers/power/reset/pscrr/pscrr.c | 11 +++++++---- include/linux/power/power_on_reason.h | 1 + include/linux/reboot.h | 4 ++++ kernel/reboot.c | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/power/reset/pscrr/pscrr.c b/drivers/power/reset/pscrr/= pscrr.c index 8c45b84059a9..9e6dd3e17382 100644 --- a/drivers/power/reset/pscrr/pscrr.c +++ b/drivers/power/reset/pscrr/pscrr.c @@ -529,12 +529,15 @@ static struct notifier_block pscrr_reboot_nb =3D { static int pscrr_panic_notifier(struct notifier_block *nb, unsigned long action, void *unused) { - struct pscrr_provider_dir *dir; =20 - set_psc_reason(PSCR_KERNEL_PANIC); + /* + * Do not overwrite a watchdog pretimeout reason already set by the + * pretimeout path before it triggered this panic. + */ + if (get_psc_reason() =3D=3D PSCR_UNKNOWN) + set_psc_reason(PSCR_KERNEL_PANIC); =20 - list_for_each_entry(dir, &pscrr_dirs, node) - pscrr_do_record(dir, get_psc_reason()); + pscrr_record_current(); =20 return NOTIFY_DONE; } diff --git a/include/linux/power/power_on_reason.h b/include/linux/power/po= wer_on_reason.h index 8c99bdd75021..8e3889fa43ef 100644 --- a/include/linux/power/power_on_reason.h +++ b/include/linux/power/power_on_reason.h @@ -21,5 +21,6 @@ #define POWER_ON_REASON_EC_PANIC "EC panic" #define POWER_ON_REASON_EXTERNAL "external reset" #define POWER_ON_REASON_KERNEL_PANIC "kernel panic" +#define POWER_ON_REASON_WATCHDOG_PRETIMEOUT "watchdog pretimeout" =20 #endif /* POWER_ON_REASON_H */ diff --git a/include/linux/reboot.h b/include/linux/reboot.h index a117dd5eaecd..6d5ecc6cdc00 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -243,6 +243,9 @@ extern void orderly_reboot(void); * * @PSCR_KERNEL_PANIC: Reset that followed a kernel panic. * + * @PSCR_WATCHDOG_PRETIMEOUT: Recorded when a watchdog pretimeout fires, b= efore + * the pretimeout governor brings the system down. + * * @PSCR_REASON_COUNT: Number of defined power state change reasons. This * value is useful for range checking and potential future extensions * while maintaining compatibility. @@ -267,6 +270,7 @@ enum psc_reason { PSCR_CPU_CLK_FAIL, PSCR_XTAL_FAIL, PSCR_KERNEL_PANIC, + PSCR_WATCHDOG_PRETIMEOUT, =20 /* Number of reasons */ PSCR_REASON_COUNT, diff --git a/kernel/reboot.c b/kernel/reboot.c index 979ecf3b093c..fad4ef9681a6 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -1110,6 +1110,7 @@ static const struct psc_reason_desc psc_reason_descs[= ] =3D { [PSCR_CPU_CLK_FAIL] =3D { "cpu-clock-failure", POWER_ON_REASON_CPU_CLK_F= AIL }, [PSCR_XTAL_FAIL] =3D { "crystal-failure", POWER_ON_REASON_XTAL_FAIL }, [PSCR_KERNEL_PANIC] =3D { "kernel-panic", POWER_ON_REASON_KERNEL_PANIC= }, + [PSCR_WATCHDOG_PRETIMEOUT] =3D { "watchdog-pretimeout", POWER_ON_REASON_W= ATCHDOG_PRETIMEOUT }, }; =20 /** --=20 2.34.1 From nobody Tue Nov 24 12:36:15 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795417548; b=4eI8Y3fBV6HKt+C+Tb/vRw4m1Jtithi8JzoqOq4sY2rKMQjM4VzV4XYAhvKflsWBSGup ZDGnDke3Ht9bcdO8l0B4RAiVFfU59hJ8v6zVjqTYN9iMcDKWQDcQxvhBFXDhmO784iKHN 8szjXAROpFm/WMLMLfEI8/pcYzDeXpxh4zttPGaIEYIFM51D3c0lWkLeTlCTxkh6zkigK NBJ9xomsNQUHNf6IowzBVH2kUhPJ4MhcQuamAfS3VHIZVFx1bu+FVIfq7rIrYMkdX+Maw Jg4ZPrD6ZTXZJkyxuOhjRNqmsfsI4qib+YDQ1L2BcWC2EmA2B0ILwCtAUSNbkZ2qbaw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795417548; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received:From: Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Proofpoint-Reinject:X-QCInternal:X-QCInternal:X-Proofpoint-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Details-Enc:X-Authority-Analysis: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=BkTJNshVqHa3mBbTpFv2gIiMyHVHhJZBrdr/LAVLnz4=; b=XsUqePLdUBiyWmRaY/QRnCHedYZzaLbAcUgwLsVlombZPIHMEHwg3a37wv9AXUTX8VQW hzEB7JY9NnE6pj4UeJaE/iXpaqHlsUE/UXaJDYh7NaxR2ksgpenkJ4ovWpMTn4wxXsYXM q2eJd+iWUkiSCkShJBP+WqmkS1Pocu7OuS/Kt6c2nKNuOBrW0QNLF2V+hFCv+5SS93f2H vvfdX+Ak5CjLYDXy4Rvc7zGY5aR6XWYa+6M/P+YZPkGPLI/8jncOvCAVxHLuxh1MBLFlJ OZzb/EaAr9/Yh9RprdNbtG6EAHNE7tYGtm93sb9JOe8BSdTmuYEexwH/B9FoJq2dK+Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=ob7UHo3y; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3767D606A688; Mon, 23 Nov 2026 07:05:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3767D606A688 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=ob7UHo3y Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AN510JE1961029; Mon, 23 Nov 2026 07:05:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= BkTJNshVqHa3mBbTpFv2gIiMyHVHhJZBrdr/LAVLnz4=; b=ob7UHo3ydyrlnHw9 gmtdgEfUkJmyw7XwqONtcRPZnW/S34lBiH5zlBUaLAPnEITF6jKbB8jJuTKghHBz fBRanLasKe1LBhyYj+7arurqvVap5DodAOtmfXR7nL3yPBVIlGMB09LTJbsJ2i9z EwfylKyXDApXZC7XPKT/Nz7wLVC+bhqP3ZH9FQCltX0Vs510rs7AsUOoBsWxklRq JeBiUynv+CtGwrqZ9FMqjdUzEttHuJ6j0HSUmqY7oBoJcyRTJNXoKWEN+TWwi3m5 lkQ2SD+Gtii+7YgYTExf1NybrHX/KLPQJHHqfOaukHmuznTK8ftHSttekvBxlWST ZwqyvQ== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j32a6npuh-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 23 Nov 2026 07:05:08 +0000 (GMT) Received: from pps.filterd (apblrppmta01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.11/8.18.1.11) with ESMTP id 6AN755q34185176; Mon, 23 Nov 2026 07:05:05 GMT Received: from hu-ffaruque-hyd.qualcomm.com (hu-ffaruque-hyd.qualcomm.com [10.147.245.31]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 6AN753Q54185090; Mon, 23 Nov 2026 07:05:05 +0000 (GMT) From: Faruque Ansari Date: Mon, 23 Nov 2026 12:34:55 +0530 Subject: [PATCH v5 3/5] watchdog: pretimeout: update PSC reason in panic pretimeout governor X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-pscrr-reboot-reason-v5-3-fbf3c7c92772@oss.qualcomm.com> References: <20261123-pscrr-reboot-reason-v5-0-fbf3c7c92772@oss.qualcomm.com> In-Reply-To: <20261123-pscrr-reboot-reason-v5-0-fbf3c7c92772@oss.qualcomm.com> To: Sebastian Reichel , Wim Van Sebroeck , Guenter Roeck , Benson Leung , Tzung-Bi Shih , Oleksij Rempel , Srinivas Kandagatla , Daniel Lezcano , Pengutronix Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-arm-msm@vger.kernel.org, kernel@pengutronix.de, Liam Girdwood , Mark Brown , "Rafael J. Wysocki" , Zhang Rui , Lukasz Luba , =?utf-8?q?S=C3=B8ren_Andersen?= , Guenter Roeck , Matti Vaittinen , Ahmad Fatoum , Andrew Morton , avaneesh.dwivedi@oss.qualcomm.com, Umang Chheda , Faruque Ansari X-Mailer: b4 0.14.3 X-Proofpoint-Reinject: loops=2 maxloops=12 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-GUID: a0xe8MNwU-d8_uWEss5ZoXEDTzB7crM9 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDAyNyBTYWx0ZWRfX2lSvLyiTXPv5 yBGAakKmOFqO0IPqRf5TTDgStPpE5cLgBQdnEW8Q9wjB8iuleG9VjTRuR9G1h8mTEYgkJ1tvEIy PEsFyt9zNLsN4V5WjptRER7y4LD42XY= X-Proofpoint-ORIG-GUID: a0xe8MNwU-d8_uWEss5ZoXEDTzB7crM9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDAyNyBTYWx0ZWRfXzQPtjVx46CBD P85slnrLLkdNWJSoe+npEVxznp800GXFbsbwRfKzWiFIyl69NwyhpDzyafzZScJQO6uNQGHb525 f6muEMWlVxCPrvVLN5p21YyWf2bqgPcPOCxOIs4UxQeajxMrEFZpMocvcMrFdg7hPcWfjejZm7F IZp1HX5Jxu0NjsfWDP1nCOM04nDwEbhiJPGLQLHXdi9sweeAsjmkQFQol7cq/ye4/N94D94Ni5L XuJQVAfoaVFctvLdGLh/fjot8Ncz1nWKb1/0rNn8jXuDY5ltmlWhY9FfG3RHDdQwulTQedqLjbL wrxBkqLUG/omZI+CqUBJ4G6IWZzN5I5TFoSKgVwD/71DuOeUKdXFm0g9vkMnltLrg8QOG4iZzdB eUIZD0EVhLqoscB2BxiDqZ2n9FYkVvyQNIyQlIR40qZ73lpUmykY4Orl0RnS43RzX1z9gz+C9z3 ce9nSCiSsX4cc/1lTJA== X-Authority-Analysis: v=2.4 cv=UbHE26SN c=1 sm=1 tr=0 ts=6b03e5a4 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=_jlGtV7tAAAA:8 a=FYyizyoliohAzulCZuQA:9 a=QEXdDO2ut3YA:10 a=nlm17XC03S6CtCLSeiRr:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_01,2026-11-22_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 phishscore=0 malwarescore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230027 Update the PSC reset reason by invoking set_psc_reason(PSCR_WATCHDOG_PRETIMEOUT) from the panic governor's pretimeout handler before calling panic(), so the reset cause is committed to persistent storage before the system goes down. Signed-off-by: Faruque Ansari Acked-by: Guenter Roeck --- drivers/watchdog/pretimeout_panic.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/watchdog/pretimeout_panic.c b/drivers/watchdog/pretime= out_panic.c index 8c3ac674dc45..819487b5e6fe 100644 --- a/drivers/watchdog/pretimeout_panic.c +++ b/drivers/watchdog/pretimeout_panic.c @@ -5,6 +5,7 @@ =20 #include #include +#include #include =20 #include "watchdog_pretimeout.h" @@ -17,6 +18,7 @@ */ static void pretimeout_panic(struct watchdog_device *wdd) { + set_psc_reason(PSCR_WATCHDOG_PRETIMEOUT); panic("watchdog pretimeout event\n"); } =20 --=20 2.34.1 From nobody Tue Nov 24 12:36:15 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795417550; b=k0cgkKaar2xKipE4JpkSvvs5o8+W3L7lDJbDz+IuwDDGZGGMT7OhxqijrZ/ITFerOvHI 5xM1r/teqCZpcg6SzMnf/TT1z5qxzyZ06/7V2rPsEJuMD3Bd799UTs2cJuRIrKixANXm1 sS6P4qGlLyejUkhExVCbkfDNupp1SFRr8zd/ueyrr3Sn29aGH8llJsjyD1hxOzTqiXUJk 6k9a6u6XP/jDHUkdnl9b+7YWf2BsvU/kYp+Lf6IRpbuyObsAcnlSEo4aWQQ+VL+hgooPo ClfRlSbAQJ3oSJ3u/hhlRSdIRHXbvlA8dXFsHmVIN7nDrK3Agr80H4FG3/ZfGDWyIjA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795417550; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received:From: Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Proofpoint-Reinject:X-QCInternal:X-QCInternal:X-Authority-Analysis: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=73qkdb0vuDKVHImBYvoSDVsRWYaA4I4cYyEBvcpvby8=; b=1tCsd59+ozJEAXSQ6INzENUe831ahdb/+bgHdDwrd7tD3W8wLet8qX42ru9QBQIHjqz/ Qqas8eq3ZZu4gs8ALEZ/8dVl2dmgKq3zk5w+wDYdcvo+qhWIfyGH1wk+qQkD0pqTWqNkl IXn09t5EWnsGinXOU0LPGFuVdiMnfGo+Ot/Yy85N8fP0ptvuqO933ix+o5pQowsf/yrC9 5UN/ztV+wjNufYSBCktIW4Tfq2b35q1uoX2vxQNIluZKhUIg1EQYCxQmfZWEMUXD4fFQ2 NJrumv6cCfXYTF2Uz0/PIWupbyGdkRHL7DpAaXxS5oaUGLxPmfOedlfERMd5rsrG33w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=bKR+HsUd; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CEF3606A681; Mon, 23 Nov 2026 07:05:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5CEF3606A681 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=bKR+HsUd Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AN69FTR1011324; Mon, 23 Nov 2026 07:05:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 73qkdb0vuDKVHImBYvoSDVsRWYaA4I4cYyEBvcpvby8=; b=bKR+HsUdpKaDDy4F m0UN4zPKKtoukMONWmxGWxwaDMtDlJ8xcGXPUxxbtp3WqGzomWlO4+PzkCUFLG6O KMSHirNNQAJzOEvfOpcsPX7Va6mI5WTtgkAnb3aJUuGhZr7yLJ6ohpjEMUOrhJIm GcOWqtXQWeOjQSFRaY92Jl2D3/WME5XHIepXcffALewb1PXTxc0mtIPfwWKyQapB x6JX9hIjjVV0vrjEOMhXwzrqG9OIh68aOybo/iTCzVOoPE7DMiK32Q7EeC6A8ngB pngdUhMyOWNvKRqwlizl7J1xthpP+bQEJic0j/9muVD2edU0+nDAtwwc2X4f2oUN ZfJZoA== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j4fyh063s-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 23 Nov 2026 07:05:09 +0000 (GMT) Received: from pps.filterd (apblrppmta01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.11/8.18.1.11) with ESMTP id 6AN7562Q4185185; Mon, 23 Nov 2026 07:05:06 GMT Received: from hu-ffaruque-hyd.qualcomm.com (hu-ffaruque-hyd.qualcomm.com [10.147.245.31]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 6AN753Q64185090; Mon, 23 Nov 2026 07:05:05 +0000 (GMT) From: Faruque Ansari Date: Mon, 23 Nov 2026 12:34:56 +0530 Subject: [PATCH v5 4/5] power: reset: pscrr: add kernel watchdog reason tracking X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-pscrr-reboot-reason-v5-4-fbf3c7c92772@oss.qualcomm.com> References: <20261123-pscrr-reboot-reason-v5-0-fbf3c7c92772@oss.qualcomm.com> In-Reply-To: <20261123-pscrr-reboot-reason-v5-0-fbf3c7c92772@oss.qualcomm.com> To: Sebastian Reichel , Wim Van Sebroeck , Guenter Roeck , Benson Leung , Tzung-Bi Shih , Oleksij Rempel , Srinivas Kandagatla , Daniel Lezcano , Pengutronix Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-arm-msm@vger.kernel.org, kernel@pengutronix.de, Liam Girdwood , Mark Brown , "Rafael J. Wysocki" , Zhang Rui , Lukasz Luba , =?utf-8?q?S=C3=B8ren_Andersen?= , Guenter Roeck , Matti Vaittinen , Ahmad Fatoum , Andrew Morton , avaneesh.dwivedi@oss.qualcomm.com, Umang Chheda , Faruque Ansari X-Mailer: b4 0.14.3 X-Proofpoint-Reinject: loops=2 maxloops=12 X-QCInternal: smtphost X-QCInternal: smtphost X-Authority-Analysis: v=2.4 cv=NM1AaE6g c=1 sm=1 tr=0 ts=6b03e5a5 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=uGZmaWCuiYb8ISEHsTcA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDAyNyBTYWx0ZWRfX+WXh96U4J1MH /KIOE8RQkLxvHEH3jTVxBgadegXGeQGcnQl8D8w0kEWfn+FU15bCmm4ahc/Lvd8kfWkedQo68D+ icd3G5WYhyw9ERpy01QKQrLwoV6Olmo= X-Proofpoint-ORIG-GUID: tBDg-V36j994N0lxJe0Re5NekDyEILZU X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDAyNyBTYWx0ZWRfX0wsxh8LFO4Dd 23eCO2M0FfQKOyBHvoRLXNTAtTrMHrT06QDomTicfxMAyt9bBYjORFLBnE4DZgP8yzHJue7PPyu Ih7z7D1kWME2A+riWyaB3uLzFO5MAjylRJ+MwuLwVWC9tc4anXjJhvk2EC+dbOwvNhybaOnt0nb s2f5Hi1ct6jXXIJL94/wsEcoSFhmU8Mqsu0ZwpW+7dN6t+vww9ETPtmkUb/bpnmK/V+2TOqq/ZC khdB4TWQAPJnyjfN3ygnkegmwl6eAraOeCW33Ylu3abAb35OmISb7ojY9NTmAdwOvTBIUES2GMY 6ri4Dv+ZzuSCKS1wyrfMUznFYFqMblQoyaFpToaNQUl7cHOCY8p+DA5IwEibP/1KgGkSfvEwLvA gYwfaTBnCmYdz2GQysqr+dBo7ZBsAtMEa4BbQMnAcLojOZHiM6YaRIEIvkBMkBbsESOR40Bziky X5z+ZQCe/1ypRcVob7Q== X-Proofpoint-GUID: tBDg-V36j994N0lxJe0Re5NekDyEILZU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_01,2026-11-22_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 impostorscore=0 phishscore=0 malwarescore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230027 Kernel watchdog events are not recorded with dedicated reset reason codes. Add PSCR_KERNEL_WATCHDOG_HARDLOCKUP and PSCR_KERNEL_WATCHDOG_SOFTLOCKUP as dedicated reason codes to record hard and soft lockup events detected by the kernel watchdog on subsequent boots. Signed-off-by: Faruque Ansari --- include/linux/power/power_on_reason.h | 2 ++ include/linux/reboot.h | 10 ++++++++++ kernel/reboot.c | 2 ++ kernel/watchdog.c | 9 +++++++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/linux/power/power_on_reason.h b/include/linux/power/po= wer_on_reason.h index 8e3889fa43ef..9bcce23c81e9 100644 --- a/include/linux/power/power_on_reason.h +++ b/include/linux/power/power_on_reason.h @@ -22,5 +22,7 @@ #define POWER_ON_REASON_EXTERNAL "external reset" #define POWER_ON_REASON_KERNEL_PANIC "kernel panic" #define POWER_ON_REASON_WATCHDOG_PRETIMEOUT "watchdog pretimeout" +#define POWER_ON_REASON_HARD_LOCKUP "hard lockup" +#define POWER_ON_REASON_SOFT_LOCKUP "soft lockup" =20 #endif /* POWER_ON_REASON_H */ diff --git a/include/linux/reboot.h b/include/linux/reboot.h index 6d5ecc6cdc00..45e64bcad37e 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -246,6 +246,14 @@ extern void orderly_reboot(void); * @PSCR_WATCHDOG_PRETIMEOUT: Recorded when a watchdog pretimeout fires, b= efore * the pretimeout governor brings the system down. * + * @PSCR_KERNEL_WATCHDOG_HARDLOCKUP: Reset that followed a hard lockup det= ected + * by the kernel's NMI watchdog (kernel/watchdog.c), before it escalated to + * panic. + * + * @PSCR_KERNEL_WATCHDOG_SOFTLOCKUP: Reset that followed a soft lockup (hu= ng + * task) detected by the kernel's softlockup watchdog, before it + * escalated to panic. + * * @PSCR_REASON_COUNT: Number of defined power state change reasons. This * value is useful for range checking and potential future extensions * while maintaining compatibility. @@ -271,6 +279,8 @@ enum psc_reason { PSCR_XTAL_FAIL, PSCR_KERNEL_PANIC, PSCR_WATCHDOG_PRETIMEOUT, + PSCR_KERNEL_WATCHDOG_HARDLOCKUP, + PSCR_KERNEL_WATCHDOG_SOFTLOCKUP, =20 /* Number of reasons */ PSCR_REASON_COUNT, diff --git a/kernel/reboot.c b/kernel/reboot.c index fad4ef9681a6..b748153d18cc 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -1111,6 +1111,8 @@ static const struct psc_reason_desc psc_reason_descs[= ] =3D { [PSCR_XTAL_FAIL] =3D { "crystal-failure", POWER_ON_REASON_XTAL_FAIL }, [PSCR_KERNEL_PANIC] =3D { "kernel-panic", POWER_ON_REASON_KERNEL_PANIC= }, [PSCR_WATCHDOG_PRETIMEOUT] =3D { "watchdog-pretimeout", POWER_ON_REASON_W= ATCHDOG_PRETIMEOUT }, + [PSCR_KERNEL_WATCHDOG_HARDLOCKUP] =3D { "hardlockup", POWER_ON_REASON_H= ARD_LOCKUP }, + [PSCR_KERNEL_WATCHDOG_SOFTLOCKUP] =3D { "softlockup", POWER_ON_REASON_S= OFT_LOCKUP }, }; =20 /** diff --git a/kernel/watchdog.c b/kernel/watchdog.c index e5134ad7b663..e05ae3cc583f 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -287,8 +288,10 @@ void watchdog_hardlockup_check(unsigned int cpu, struc= t pt_regs *regs) } =20 sys_info(hardlockup_si_mask & ~SYS_INFO_ALL_BT); - if (hardlockup_panic) + if (hardlockup_panic) { + set_psc_reason(PSCR_KERNEL_WATCHDOG_HARDLOCKUP); nmi_panic(regs, "Hard LOCKUP"); + } =20 per_cpu(watchdog_hardlockup_warned, cpu) =3D true; } @@ -903,8 +906,10 @@ static enum hrtimer_restart watchdog_timer_fn(struct h= rtimer *hrtimer) sys_info(softlockup_si_mask & ~SYS_INFO_ALL_BT); thresh_count =3D duration / get_softlockup_thresh(); =20 - if (softlockup_panic && thresh_count >=3D softlockup_panic) + if (softlockup_panic && thresh_count >=3D softlockup_panic) { + set_psc_reason(PSCR_KERNEL_WATCHDOG_SOFTLOCKUP); panic("softlockup: hung tasks"); + } } =20 return HRTIMER_RESTART; --=20 2.34.1 From nobody Tue Nov 24 12:36:15 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795417546; b=13mrMWPptocKWfgmnyIk5kJlo3t896E0T6qCZ1DdleYQP0Xl4YzOvo/oyfLkiI7M9ZN0 Upolj9JCxSJHnxx35IErQpa+ISHfWhuw5VTJ+RKNahv6er6wNgako66vyNTIloYXGBB+U dSixS+BPdfgrDZhvPF+cTawGvRa85DUfCwQaIjxy803XPaX5EHVC90h9VsCtq3YI+C8vT E0uqxLPIdD8ikRE5hncx4Op+RWNVOz6IA4G6w4zAssyeTWc+dhVVtPAj1VNRaHCGkK2Kc ffTbwrNC3A6yydAyP1fIZdACpF7HVozDFuebvtf/B9MvRb/pt7IUSKxIqCaz8V6LvFA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795417546; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received:From: Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Proofpoint-Reinject:X-QCInternal:X-QCInternal:X-Authority-Analysis: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=mNZ6bZZf33/ujakZ94r0duEndktkggT7gLlZ0Hy4Jlk=; b=EGbHcB6f91bzFMkZld0TTf1VqH2VhIfimSv304YhhTJpVYg6vodlzXZeanmfZwyT56sr 04XlHlhGi20SZTmp5/1VCxhv3m8bubdPfYHnluFJQft4ftqELCqVn8QhHBzsVU1qeSuvg laCkwSi2j6Txv8/l9dPVM/Mp91MqG51fKKG9T/qQRqE+BJuYpW0ppJioQbVvDvLQO7PWY D9CihxnwPL7OL3suIcfGSmzvUe6h/fQFZKTqFFCZFz/ks7C2upv38E7K5y1DnB9wH7/nK +nQEHT34WbOK8QOTWwuUbJFNn90Xl4mgh4/JpWEilMbEoMaVT1+sxlqezQvrr8ZFEBg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=ScdK6bnG; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BFAC606A31F; Mon, 23 Nov 2026 07:05:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0BFAC606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=ScdK6bnG Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AN699sq1011258; Mon, 23 Nov 2026 07:05:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= mNZ6bZZf33/ujakZ94r0duEndktkggT7gLlZ0Hy4Jlk=; b=ScdK6bnGQLdYSEVq Gf6PBQdTmaoey5pyQAaTNaNK2/NXR2IOSoEpD/RomSOFUnME3XO8oMGlKRrGPqzg Edn1SG5hfy6ZJ9dT4I7bXQeBiS2Ce316NioqW9d0D95XNwY2gbNykvg+Tz/7CdA2 wJ+vjpRZsIf+qSY+yTw0ODRgjRKymWk2tgDUVrR2se9K0SQjPnxAnsrZyZ6DP2lm pONlZnjL5OXo8qdS+j/jrHklZB96cNNTDJNCt+Qt7avqki69I833drmLtdlX06oQ I2CWqv2FlKLoJeKz+wPS6io1N/lJGnwuM55fxLPKwLExGv4dXQ3nEjgRK93lR0ra 48ixag== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j4fyh063t-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 23 Nov 2026 07:05:09 +0000 (GMT) Received: from pps.filterd (apblrppmta01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.11/8.18.1.11) with ESMTP id 6AN756wG4185227; Mon, 23 Nov 2026 07:05:06 GMT Received: from hu-ffaruque-hyd.qualcomm.com (hu-ffaruque-hyd.qualcomm.com [10.147.245.31]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 6AN753Q74185090; Mon, 23 Nov 2026 07:05:06 +0000 (GMT) From: Faruque Ansari Date: Mon, 23 Nov 2026 12:34:57 +0530 Subject: [PATCH v5 5/5] power: reset: pscrr: record reason for userspace-initiated reboots X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-pscrr-reboot-reason-v5-5-fbf3c7c92772@oss.qualcomm.com> References: <20261123-pscrr-reboot-reason-v5-0-fbf3c7c92772@oss.qualcomm.com> In-Reply-To: <20261123-pscrr-reboot-reason-v5-0-fbf3c7c92772@oss.qualcomm.com> To: Sebastian Reichel , Wim Van Sebroeck , Guenter Roeck , Benson Leung , Tzung-Bi Shih , Oleksij Rempel , Srinivas Kandagatla , Daniel Lezcano , Pengutronix Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-arm-msm@vger.kernel.org, kernel@pengutronix.de, Liam Girdwood , Mark Brown , "Rafael J. Wysocki" , Zhang Rui , Lukasz Luba , =?utf-8?q?S=C3=B8ren_Andersen?= , Guenter Roeck , Matti Vaittinen , Ahmad Fatoum , Andrew Morton , avaneesh.dwivedi@oss.qualcomm.com, Umang Chheda , Faruque Ansari X-Mailer: b4 0.14.3 X-Proofpoint-Reinject: loops=2 maxloops=12 X-QCInternal: smtphost X-QCInternal: smtphost X-Authority-Analysis: v=2.4 cv=NM1AaE6g c=1 sm=1 tr=0 ts=6b03e5a5 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=y7n2HT4GL4nd4BABNBAA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDAyNyBTYWx0ZWRfX7tW8e+53jAST XtIfZQIrvTZGpZ/pt3gB0WaVgyvYhStXjOwTE2bd0SVcqwrLI+qSlMdrNaFPNFbnJB0EUiU8QNI R2zmEumCqRzXvsjVRbGxSkjUn457560= X-Proofpoint-ORIG-GUID: g5LRt1hhqwD-5yxuCJsTt3Dbn-oqLm17 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDAyNyBTYWx0ZWRfXyglrIFxbW5Po fQYoKArx8jxZbGj6JFV9ZvGBA+sv2KCy14ZNxjE/qwJLPNU8HQjvDi5ostTCPHgVeL8Q0wjlsrU mp55stIPfZgu10QKqLV4PJAwFg/57l1PASAMRuFkWmlY4eqoO0sCsGEwAwxs07PC98JcoeZpl1Q bDFoSMwIAdDwZ8/VJd/46yc+Vj069O0HcSWJNehavm680dmflpkJrdVtra4MN0Ir00yOjoOwhkp 64bVaD8XUG4Raah1GAjsuJHJPQ+adZ7Oa0EP/1uv2zGc/zOgKjPrtv1Zm6HJ6gdsNsUaJ4Lv4uE ycbxjGecbtVQRKFpqKeCB4Phzxr/MDV3t7Fg2sqoSF50D3fKaBwWcTTWoE0vCTys0lPraf8gi9f yMCDAHTb9oPQXcZlAsTU3l7exRY8s23e9Nly13rZLarYihQi8G0rI5mRzVhnEtAoPXKx61pFYYq R5ysZLOxiDnRc2jAGeQ== X-Proofpoint-GUID: g5LRt1hhqwD-5yxuCJsTt3Dbn-oqLm17 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_01,2026-11-22_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 impostorscore=0 phishscore=0 malwarescore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230027 Userspace can request different reboot targets, such as bootloader, recovery, OTA update, EDL and factory reset. Add dedicated reset reason codes for these reboot targets to preserve the requested reboot mode across system resets. Signed-off-by: Faruque Ansari --- drivers/power/reset/pscrr/pscrr.c | 9 ++++---- include/linux/power/power_on_reason.h | 5 +++++ include/linux/reboot.h | 21 ++++++++++++++++++ kernel/reboot.c | 40 +++++++++++++++++++++++++++++++= ++++ 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/drivers/power/reset/pscrr/pscrr.c b/drivers/power/reset/pscrr/= pscrr.c index 9e6dd3e17382..8e345d07269e 100644 --- a/drivers/power/reset/pscrr/pscrr.c +++ b/drivers/power/reset/pscrr/pscrr.c @@ -498,18 +498,19 @@ static void pscrr_record_current(void) } =20 static int pscrr_reboot_notifier(struct notifier_block *nb, - unsigned long action, void *unused) + unsigned long action, void *cmd) { guard(mutex)(&pscrr_lock); =20 /* * 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, + * reason is attributed from the userspace reboot(2) command string + * (e.g. "bootloader", "recovery", "ota-update") when present, or recorde= d as + * software-initiated otherwise. A real cause set earlier (thermal, * under-voltage, ...) is already latched and left untouched. */ if (get_psc_reason() =3D=3D PSCR_UNKNOWN) - set_psc_reason(PSCR_SOFTWARE); + set_psc_reason(psc_reason_from_reboot_cmd(cmd)); =20 pscrr_record_current(); =20 diff --git a/include/linux/power/power_on_reason.h b/include/linux/power/po= wer_on_reason.h index 9bcce23c81e9..9bd903594f41 100644 --- a/include/linux/power/power_on_reason.h +++ b/include/linux/power/power_on_reason.h @@ -24,5 +24,10 @@ #define POWER_ON_REASON_WATCHDOG_PRETIMEOUT "watchdog pretimeout" #define POWER_ON_REASON_HARD_LOCKUP "hard lockup" #define POWER_ON_REASON_SOFT_LOCKUP "soft lockup" +#define POWER_ON_REASON_REBOOT_BOOTLOADER "reboot to bootloader" +#define POWER_ON_REASON_REBOOT_RECOVERY "reboot to recovery" +#define POWER_ON_REASON_REBOOT_OTA "reboot for OTA update" +#define POWER_ON_REASON_EDL "reboot to emergency download mode" +#define POWER_ON_REASON_REBOOT_FACTORY_RESET "reboot to factory reset" =20 #endif /* POWER_ON_REASON_H */ diff --git a/include/linux/reboot.h b/include/linux/reboot.h index 45e64bcad37e..5723852135f2 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -254,6 +254,21 @@ extern void orderly_reboot(void); * task) detected by the kernel's softlockup watchdog, before it * escalated to panic. * + * @PSCR_BOOTLOADER: Userspace-requested reboot into the bootloader + * (e.g. "reboot bootloader" / fastboot). + * + * @PSCR_RECOVERY: Userspace-requested reboot into the recovery image + * (e.g. "reboot recovery"). + * + * @PSCR_OTA: Userspace-requested reboot to apply an OTA update + * (e.g. "reboot ota-update"). + * + * @PSCR_EDL: Userspace-requested reboot into Emergency Download Mode + * (e.g. "reboot edl"). + * + * @PSCR_FACTORY_RESET: Userspace-requested reboot to perform a factory + * reset (e.g. "reboot factory-reset"). + * * @PSCR_REASON_COUNT: Number of defined power state change reasons. This * value is useful for range checking and potential future extensions * while maintaining compatibility. @@ -281,6 +296,11 @@ enum psc_reason { PSCR_WATCHDOG_PRETIMEOUT, PSCR_KERNEL_WATCHDOG_HARDLOCKUP, PSCR_KERNEL_WATCHDOG_SOFTLOCKUP, + PSCR_BOOTLOADER, + PSCR_RECOVERY, + PSCR_OTA, + PSCR_EDL, + PSCR_FACTORY_RESET, =20 /* Number of reasons */ PSCR_REASON_COUNT, @@ -291,6 +311,7 @@ enum psc_reason { const char *psc_reason_to_str(enum psc_reason reason); const char *psc_reason_to_token(enum psc_reason reason); int psc_reason_from_token(const char *token, enum psc_reason *reason); +enum psc_reason psc_reason_from_reboot_cmd(const char *cmd); =20 /** * enum hw_protection_action - Hardware protection action diff --git a/kernel/reboot.c b/kernel/reboot.c index b748153d18cc..73655bd2b02b 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -1113,6 +1113,11 @@ static const struct psc_reason_desc psc_reason_descs= [] =3D { [PSCR_WATCHDOG_PRETIMEOUT] =3D { "watchdog-pretimeout", POWER_ON_REASON_W= ATCHDOG_PRETIMEOUT }, [PSCR_KERNEL_WATCHDOG_HARDLOCKUP] =3D { "hardlockup", POWER_ON_REASON_H= ARD_LOCKUP }, [PSCR_KERNEL_WATCHDOG_SOFTLOCKUP] =3D { "softlockup", POWER_ON_REASON_S= OFT_LOCKUP }, + [PSCR_BOOTLOADER] =3D { "bootloader", POWER_ON_REASON_REBOOT_BOOTLOADE= R }, + [PSCR_RECOVERY] =3D { "recovery", POWER_ON_REASON_REBOOT_RECOVERY }, + [PSCR_OTA] =3D { "ota-update", POWER_ON_REASON_REBOOT_OTA }, + [PSCR_EDL] =3D { "edl", POWER_ON_REASON_EDL }, + [PSCR_FACTORY_RESET] =3D { "factory-reset", POWER_ON_REASON_REBOOT_FAC= TORY_RESET }, }; =20 /** @@ -1168,6 +1173,41 @@ int psc_reason_from_token(const char *token, enum ps= c_reason *reason) } EXPORT_SYMBOL_GPL(psc_reason_from_token); =20 +/** + * psc_reason_from_reboot_cmd - Map a userspace reboot(2) command string t= o a + * power-state-change reason. + * @cmd: Command string passed via LINUX_REBOOT_CMD_RESTART2 (e.g. + * "bootloader", "recovery", "ota-update", "edl", "factory-reset"), or + * NULL. + * + * Return: The specific reason for a recognized command, or PSCR_SOFTWARE = for + * an unrecognized or absent command. + */ +enum psc_reason psc_reason_from_reboot_cmd(const char *cmd) +{ + static const struct { + const char *cmd; + enum psc_reason reason; + } cmd_reasons[] =3D { + { "bootloader", PSCR_BOOTLOADER }, + { "recovery", PSCR_RECOVERY }, + { "ota-update", PSCR_OTA }, + { "edl", PSCR_EDL }, + { "factory-reset", PSCR_FACTORY_RESET }, + }; + int i; + + if (!cmd) + return PSCR_SOFTWARE; + + for (i =3D 0; i < ARRAY_SIZE(cmd_reasons); i++) + if (!strcmp(cmd, cmd_reasons[i].cmd)) + return cmd_reasons[i].reason; + + return PSCR_SOFTWARE; +} +EXPORT_SYMBOL_GPL(psc_reason_from_reboot_cmd); + /** * __hw_protection_trigger - Trigger an emergency system shutdown or reboot * --=20 2.34.1