Store the state change reason to some black box, for later
investigation.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Mark Brown <broonie@kernel.org>
---
drivers/regulator/core.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 4ddf0efead68..7ccadc7e6d04 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -19,6 +19,7 @@
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>
+#include <linux/pscrr.h>
#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/regulator/of_regulator.h>
@@ -5243,6 +5244,7 @@ EXPORT_SYMBOL_GPL(regulator_bulk_free);
static void regulator_handle_critical(struct regulator_dev *rdev,
unsigned long event)
{
+ enum pscr_reason pscr;
const char *reason = NULL;
if (!rdev->constraints->system_critical)
@@ -5251,17 +5253,21 @@ static void regulator_handle_critical(struct regulator_dev *rdev,
switch (event) {
case REGULATOR_EVENT_UNDER_VOLTAGE:
reason = "System critical regulator: voltage drop detected";
+ pscr = PSCR_UNDER_VOLTAGE;
break;
case REGULATOR_EVENT_OVER_CURRENT:
reason = "System critical regulator: over-current detected";
+ pscr = PSCR_OVER_CURRENT;
break;
case REGULATOR_EVENT_FAIL:
reason = "System critical regulator: unknown error";
+ pscr = PSCR_REGULATOR_FAILURE;
}
if (!reason)
return;
+ set_power_state_change_reason(pscr);
hw_protection_shutdown(reason,
rdev->constraints->uv_less_critical_window_ms);
}
--
2.39.5
Hi Oleksij,
kernel test robot noticed the following build errors:
[auto build test ERROR on sre-power-supply/for-next]
[also build test ERROR on broonie-regulator/for-next rafael-pm/thermal linus/master v6.14-rc7]
[cannot apply to next-20250317]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Oleksij-Rempel/power-Extend-power_on_reason-h-for-upcoming-PSCRR-framework/20250310-184319
base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
patch link: https://lore.kernel.org/r/20250310103732.423542-7-o.rempel%40pengutronix.de
patch subject: [PATCH v5 6/7] regulator: set Power State Change Reason before hw_protection_shutdown()
config: m68k-randconfig-r073-20250314 (https://download.01.org/0day-ci/archive/20250318/202503182046.kOuLXxTn-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250318/202503182046.kOuLXxTn-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503182046.kOuLXxTn-lkp@intel.com/
All errors (new ones prefixed by >>):
m68k-linux-ld: drivers/regulator/core.o: in function `regulator_handle_critical':
>> drivers/regulator/core.c:5270:(.text+0x20c6): undefined reference to `set_power_state_change_reason'
vim +5270 drivers/regulator/core.c
5234
5235 /**
5236 * regulator_handle_critical - Handle events for system-critical regulators.
5237 * @rdev: The regulator device.
5238 * @event: The event being handled.
5239 *
5240 * This function handles critical events such as under-voltage, over-current,
5241 * and unknown errors for regulators deemed system-critical. On detecting such
5242 * events, it triggers a hardware protection shutdown with a defined timeout.
5243 */
5244 static void regulator_handle_critical(struct regulator_dev *rdev,
5245 unsigned long event)
5246 {
5247 enum pscr_reason pscr;
5248 const char *reason = NULL;
5249
5250 if (!rdev->constraints->system_critical)
5251 return;
5252
5253 switch (event) {
5254 case REGULATOR_EVENT_UNDER_VOLTAGE:
5255 reason = "System critical regulator: voltage drop detected";
5256 pscr = PSCR_UNDER_VOLTAGE;
5257 break;
5258 case REGULATOR_EVENT_OVER_CURRENT:
5259 reason = "System critical regulator: over-current detected";
5260 pscr = PSCR_OVER_CURRENT;
5261 break;
5262 case REGULATOR_EVENT_FAIL:
5263 reason = "System critical regulator: unknown error";
5264 pscr = PSCR_REGULATOR_FAILURE;
5265 }
5266
5267 if (!reason)
5268 return;
5269
> 5270 set_power_state_change_reason(pscr);
5271 hw_protection_shutdown(reason,
5272 rdev->constraints->uv_less_critical_window_ms);
5273 }
5274
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Oleksij, kernel test robot noticed the following build errors: [auto build test ERROR on sre-power-supply/for-next] [also build test ERROR on broonie-regulator/for-next rafael-pm/thermal linus/master v6.14-rc6] [cannot apply to next-20250314] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Oleksij-Rempel/power-Extend-power_on_reason-h-for-upcoming-PSCRR-framework/20250310-184319 base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next patch link: https://lore.kernel.org/r/20250310103732.423542-7-o.rempel%40pengutronix.de patch subject: [PATCH v5 6/7] regulator: set Power State Change Reason before hw_protection_shutdown() config: powerpc64-randconfig-r122-20250314 (https://download.01.org/0day-ci/archive/20250314/202503141835.M6AeKZTU-lkp@intel.com/config) compiler: powerpc64-linux-gcc (GCC) 14.2.0 reproduce: (https://download.01.org/0day-ci/archive/20250314/202503141835.M6AeKZTU-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202503141835.M6AeKZTU-lkp@intel.com/ All errors (new ones prefixed by >>): powerpc64-linux-ld: warning: discarding dynamic section .glink powerpc64-linux-ld: warning: discarding dynamic section .plt powerpc64-linux-ld: linkage table error against `set_power_state_change_reason' powerpc64-linux-ld: stubs don't match calculated size powerpc64-linux-ld: can not build stubs: bad value powerpc64-linux-ld: drivers/regulator/core.o: in function `.regulator_notifier_call_chain': >> core.c:(.text+0xc55c): undefined reference to `.set_power_state_change_reason' -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.