From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lr2-f12.google.com (mail-lr2-f12.google.com [74.125.230.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A283B387590 for ; Thu, 24 Sep 2026 12:14:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.230.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790252047; cv=none; b=g6172YQPbuE6uwXhISf88KpGJnf9OKdMm24ykqljhq0WYE10N3fTT2PDE243/8RHWyZq3cBi83WnYxJjwsV4tQzZ2mHQu6tno3Yr4mo87qmmnsMY0OxZ915shALZ80gU+gPx4UxuFmHVr7XYjBjngYp4TLpphNxvBdn69Ky1Vtc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790252047; c=relaxed/simple; bh=otGD8El/usb5+EdYLvRCSLCI0HhgOOwUewbzGHi4nw4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rKMIHvp6Tun1jFOQ2Knk1MOR6NY+nZYBDQS8hJtX3C4S2PuWHRKQ3NFtsnJC0SKsjqufkxk+xQW3j0ySDg6SEkrGvDUjVeOl4pi+aCm6sLbmF/8fDVmqD6lsi4V0fINeWF1WIdvuAZfPmvnZf6ytAbwqnx5OVEF1P9aVdwlPwiM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pTu+qwoD; arc=none smtp.client-ip=74.125.230.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pTu+qwoD" Received: by mail-lr2-f12.google.com with SMTP id 38308e7fff4ca-3a2ff17443dso20788371fa.1 for ; Thu, 24 Sep 2026 05:14:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790252043; x=1790856843; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rhr+KJXZzXoDkRQD5ZZRVZfYL8tC8NnQwJ47gS6L1EQ=; b=pTu+qwoDcb3s9ihKFMqI7NQwOEHuFvOgNt7q+p5D/awpOw5+FjgkvdixZVTTLXU0PF s88/18pigY/hzhXLLrYcXOYfG0pCf5yfkiyhaOorgFVae6OyxtA46VfatZz9gVjZ9kg1 0CTb4JIL1kShApBn82ezMjYSZXrafXw1gCsUfo1KfZ+A9ADhs3h/aiBf/6qrhW5wCc1d 5vWFJR65yTGqRFcLVs+85xlr01Nota2p0ZWGSeoa697oC4AZ3ArhGfG6UM5uEo9JkgaB nxi2NCfs2NE8XksrTnEMIq8peRXVaDWk20NOGdZZVRw0h5IOqScWcc/IOWyRi+2CNb7v 1xVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790252043; x=1790856843; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rhr+KJXZzXoDkRQD5ZZRVZfYL8tC8NnQwJ47gS6L1EQ=; b=qnaT+zbHFqbjJkMm5n2oZevzC1oJdgLKcEAlC60iSQ095VyqJzwxZwtSCxwcE4QsVe jwS32D67YuWrBh3s8i4iq6APl9gnuSoqrsZi3JyrX29hfDbDvQ5TB/d6d5ntvlGQHsL0 mC/CYF587+yqWszO85juyTYZ0bcprFh6LszTKVq78vNmL/GuC3nJrkW7rhoxc7LGSSNw tKx8G0hH3XPDoIasj6cGvjtHip7NCgYdEAAlJ6wLEozBwFPQUXCrNxN5a0V55MSLckZm TmPPfTcfBWVsBxht2dm7IYckPsbwkp4wIi33jfRynHbfct5sNkoE9vayKt1/b+dBHk+b hJew== X-Forwarded-Encrypted: i=1; AKwUvBy68cx7jEvSARJfPd3xhMe18HPXydflhdsVWvO++s6sZISppdRt8yv/9DohSEg6GJHrpXnQQVuocsZDJyA=@vger.kernel.org X-Gm-Message-State: AFuF++nA4ObvlzFWpn7ri73XI+HUOlG7gSLbKLRHSJk6VEggRMZFGBSF uSxYvRPNiLY6fxO9pFH+kxenYzQ7Ye2g/gFGHp2YR0m0eXDPN2aWzI8E X-Gm-Gg: AYBFou2IxpbcR7NBejHDTtFFN5tDk7QnOq+QIn8AeSEaQpxExccoqDSXYlEVyTUlbAL FBMkUmWyQ2rPJstT9kqxGdLcpCJVqXymqfk+boFveZipGFYj8DDSUGXzn6OAGXz64kiT2rBOi90 2DNPhFQZmMzY49iijm004iILW7nuaRr1NvpMPk/bO4sCw+MJhWBDC0NFOCfTqWwqHlzuzPLYCbl AJQAd5PnEMn60sw5cEho7pzorRw1jJtpOhgyU2yIBQ/TBoIZIWXn/Izn7lh3WS4yyh79w1pvAHd fcaC5KpiY0STbI2nsrNvVF4sPey+YsI9ZErlFdtWbKhb9Otx/Eu4PEhiDGjihfH0YYOW2/gIMwY rpewD9Mtx4RlHCQQihTb3X9h5r3rnV+6qCm59jqUsc0CLpYaWiZsdca+gSkiH8GgFUNO4fHf0oR edlZCdruavt+rNl9h+dpb+pI7Hp2eFV0sDDi2bjxQtEAvD6vLkRo0VR5udxn9XfeoyK5lsSh6k5 zI8ZnGpxkXfBdrxH+aL/ypZhG07mHDc2nHTc35UQi64b7r0rYg9ApY= X-Received: by 2002:a05:651c:2107:b0:3a5:d0ad:7df2 with SMTP id 38308e7fff4ca-3a63c06d2d1mr5437961fa.6.1790252042323; Thu, 24 Sep 2026 05:14:02 -0700 (PDT) Received: from ?IPV6:2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703? ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3a63bf2c113sm7362221fa.11.2026.09.24.05.14.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Sep 2026 05:14:01 -0700 (PDT) Message-ID: <8a08809f-a276-4c5b-9734-1bb6aca4f51c@gmail.com> Date: Thu, 24 Sep 2026 15:14:00 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v15 4/6] reboot: extend psc_reason with power-on and reset causes To: Faruque Ansari , Sebastian Reichel , Benson Leung , Tzung-Bi Shih , Guenter Roeck , Liam Girdwood , Mark Brown , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Oleksij Rempel , Pengutronix Kernel Team Cc: 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 References: <20260924-pscrr-framework-v15-0-7af87107e0d3@oss.qualcomm.com> <20260924-pscrr-framework-v15-4-7af87107e0d3@oss.qualcomm.com> Content-Language: en-US, en-AU, en-GB, en-BW From: Matti Vaittinen In-Reply-To: <20260924-pscrr-framework-v15-4-7af87107e0d3@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 24/09/2026 10:08, Faruque Ansari wrote: > psc_reason covered only the protection reasons. Extend it to mirror the > full POWER_ON_REASON_* vocabulary - power-on, watchdog, software, > external, RTC, reset button, CPU clock and crystal failures - so a > provider can report why the system last powered on, not only why it was > shut down. New values are appended to keep the existing numeric ABI. > > Co-developed-by: Oleksij Rempel > Signed-off-by: Oleksij Rempel > Signed-off-by: Faruque Ansari > Reviewed-by: Matti Vaittinen > > changes v15: > - add a static_assert() tying ARRAY_SIZE(psc_reason_descs) to > PSCR_REASON_COUNT, so a future enum addition without a matching > table entry fails the build instead of silently reading a hole > (Matti Vaittinen) > - Add Reviewed-by tags from Matti Vaittinen. > changes v12: > - new patch > --- > include/linux/reboot.h | 28 ++++++++++++++++++++++++++++ > kernel/reboot.c | 12 ++++++++++++ > 2 files changed, 40 insertions(+) > > diff --git a/include/linux/reboot.h b/include/linux/reboot.h > index 4c5327dd7645..13f004ad1066 100644 > --- a/include/linux/reboot.h > +++ b/include/linux/reboot.h > @@ -225,9 +225,28 @@ extern void orderly_reboot(void); > * management errors, or an unrecoverable hardware fault requiring > * immediate response. > * > + * @PSCR_POWER_ON: Regular cold power-on (e.g. via a PMIC power-on request). > + * > + * @PSCR_WATCHDOG: Reset caused by a watchdog timeout. > + * > + * @PSCR_SOFTWARE: Software-initiated reset or reboot. > + * > + * @PSCR_EXTERNAL: Reset asserted through an external pin or reset input. > + * > + * @PSCR_RTC: Wake-up or power-on triggered by the RTC. > + * > + * @PSCR_RESET_BUTTON: Reset triggered by a user reset button. > + * > + * @PSCR_CPU_CLK_FAIL: Reset caused by a CPU clock failure. > + * > + * @PSCR_XTAL_FAIL: Reset caused by a crystal oscillator failure. > + * > * @PSCR_REASON_COUNT: Number of defined power state change reasons. This > * value is useful for range checking and potential future extensions > * while maintaining compatibility. > + * > + * The reasons mirror the POWER_ON_REASON_* strings in > + * ; keep the two in sync when extending. > */ > enum psc_reason { > PSCR_UNKNOWN, > @@ -236,6 +255,15 @@ enum psc_reason { > PSCR_REGULATOR_FAILURE, > PSCR_OVER_TEMPERATURE, > PSCR_EC_PANIC, > + /* Append new reasons here; the numeric order is ABI. */ > + PSCR_POWER_ON, > + PSCR_WATCHDOG, > + PSCR_SOFTWARE, > + PSCR_EXTERNAL, > + PSCR_RTC, > + PSCR_RESET_BUTTON, > + PSCR_CPU_CLK_FAIL, > + PSCR_XTAL_FAIL, > > /* Number of reasons */ > PSCR_REASON_COUNT, > diff --git a/kernel/reboot.c b/kernel/reboot.c > index e53fb31bad06..7094c7a8f315 100644 > --- a/kernel/reboot.c > +++ b/kernel/reboot.c > @@ -7,7 +7,9 @@ > > #define pr_fmt(fmt) "reboot: " fmt > > +#include > #include > +#include > #include > #include > #include > @@ -1102,7 +1104,17 @@ static const struct psc_reason_desc psc_reason_descs[] = { > [PSCR_REGULATOR_FAILURE] = { "regulator-failure", POWER_ON_REASON_REGULATOR_FAILURE }, > [PSCR_OVER_TEMPERATURE] = { "over-temperature", POWER_ON_REASON_OVER_TEMPERATURE }, > [PSCR_EC_PANIC] = { "ec-panic", POWER_ON_REASON_EC_PANIC }, > + [PSCR_POWER_ON] = { "power-on", POWER_ON_REASON_REGULAR }, > + [PSCR_WATCHDOG] = { "watchdog", POWER_ON_REASON_WATCHDOG }, > + [PSCR_SOFTWARE] = { "software", POWER_ON_REASON_SOFTWARE }, > + [PSCR_EXTERNAL] = { "external", POWER_ON_REASON_EXTERNAL }, > + [PSCR_RTC] = { "rtc", POWER_ON_REASON_RTC }, > + [PSCR_RESET_BUTTON] = { "reset-button", POWER_ON_REASON_RST_BTN }, > + [PSCR_CPU_CLK_FAIL] = { "cpu-clock-failure", POWER_ON_REASON_CPU_CLK_FAIL }, > + [PSCR_XTAL_FAIL] = { "crystal-failure", POWER_ON_REASON_XTAL_FAIL }, > }; > +static_assert(ARRAY_SIZE(psc_reason_descs) == PSCR_REASON_COUNT, > + "psc_reason_descs[] must have an entry for every psc_reason"); Thanks Faruque. This is better than nothing, but if I read it right, it won't still catch missing initializations when last item is initialized (but not all items). Eg: enum { PSCR_REGULATOR_FAILURE, PSCR_OVER_TEMPERATURE, PSCR_EC_PANIC, ... PSCR_REASON_COUNT }; static const struct psc_reason_desc psc_reason_descs[] = { [ PSCR_REASON_COUNT - 1] = { "foo", BAR } }; static_assert(ARRAY_SIZE(psc_reason_descs) == PSCR_REASON_COUNT, "psc_reason_descs[] must have an entry for every psc_reason"); would pass the check, but accessors would crash to uninitialized entries. Hence, I would still prefer the run-time NULL checks. Oh, and I just noticed there is comma following the 'PSCR_REASON_COUNT' in the enum. Since 'PSCR_REASON_COUNT' should always be kept as the last enum value, the comma should be omitted. Other than this - I like the changes you implemented this series. Won't reply to other patches, but I think this is a very nice series! Yours, -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~