From: "Vaittinen, Matti" <Matti.Vaittinen@fi.rohmeurope.com>
To: "pmladek@suse.com" <pmladek@suse.com>
Cc: "josef@toxicpanda.com" <josef@toxicpanda.com>,
"keescook@chromium.org" <keescook@chromium.org>,
"rppt@kernel.org" <rppt@kernel.org>,
"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
linux-power <linux-power@fi.rohmeurope.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"bjorn.andersson@linaro.org" <bjorn.andersson@linaro.org>,
"rui.zhang@intel.com" <rui.zhang@intel.com>,
"linux-renesas-soc@vger.kernel.org"
<linux-renesas-soc@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux@roeck-us.net" <linux@roeck-us.net>,
"daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>,
"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"kai.heng.feng@canonical.com" <kai.heng.feng@canonical.com>,
"mcroce@microsoft.com" <mcroce@microsoft.com>,
"amitk@kernel.org" <amitk@kernel.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"andy.shevchenko@gmail.com" <andy.shevchenko@gmail.com>,
"agross@kernel.org" <agross@kernel.org>,
"broonie@kernel.org" <broonie@kernel.org>,
"rafael.j.wysocki@intel.com" <rafael.j.wysocki@intel.com>
Subject: Re: [PATCH v9 02/10] reboot: Add hardware protection power-off
Date: Wed, 12 May 2021 12:00:46 +0000 [thread overview]
Message-ID: <2149df3f542d25ce15d049e81d6188bb7198478c.camel@fi.rohmeurope.com> (raw)
In-Reply-To: <YJuPwAZroVZ/w633@alley>
Hi Petr,
Thanks for the review!
On Wed, 2021-05-12 at 10:20 +0200, Petr Mladek wrote:
> On Mon 2021-05-10 14:28:30, Matti Vaittinen wrote:
> > There can be few cases when we need to shut-down the system in
> > order to
> > protect the hardware. Currently this is done at east by the thermal
> > core
> > when temperature raises over certain limit.
> >
> > Some PMICs can also generate interrupts for example for over-
> > current or
> > over-voltage, voltage drops, short-circuit, ... etc. On some
> > systems
> > these are a sign of hardware failure and only thing to do is try to
> > protect the rest of the hardware by shutting down the system.
> >
> > Add shut-down logic which can be used by all subsystems instead of
> > implementing the shutdown in each subsystem. The logic is stolen
> > from
> > thermal_core with difference of using atomic_t instead of a mutex
> > in
> > order to allow calls directly from IRQ context.
> >
> > Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> >
> > diff --git a/kernel/reboot.c b/kernel/reboot.c
> > index a6ad5eb2fa73..5da8c80a2647 100644
> > --- a/kernel/reboot.c
> > +++ b/kernel/reboot.c
> > @@ -518,6 +519,85 @@ void orderly_reboot(void)
> > }
> > EXPORT_SYMBOL_GPL(orderly_reboot);
> >
> > +/**
> > + * hw_failure_emergency_poweroff_func - emergency poweroff work
> > after a known delay
> > + * @work: work_struct associated with the emergency poweroff
> > function
> > + *
> > + * This function is called in very critical situations to force
> > + * a kernel poweroff after a configurable timeout value.
> > + */
> > +static void hw_failure_emergency_poweroff_func(struct work_struct
> > *work)
> > +{
> > + /*
> > + * We have reached here after the emergency shutdown waiting
> > period has
> > + * expired. This means orderly_poweroff has not been able to
> > shut off
> > + * the system for some reason.
> > + *
> > + * Try to shut down the system immediately using
> > kernel_power_off
> > + * if populated
> > + */
> > + WARN(1, "Hardware protection timed-out. Trying forced
> > poweroff\n");
> > + kernel_power_off();
>
> WARN() look like an overkill here. It prints many lines that are not
> much useful in this case. The function is called from well-known
> context (workqueue worker).
This was the existing code which I stole from the thermal_core. I kind
of think that eye-catching WARN is actually a good choice here. Doing
autonomous power-off without a WARNing does not sound good to me :)
> Also be aware that "panic_on_warn" commandline option will trigger
> panic() here.
Hmm.. If panic() hangs the system that might indeed be a problem. Now
we are (again) on a territory which I don't know well. I'd appreciate
any input from thermal folks and Mark. I don't like the idea of making
extreme things like power-off w/o well visible log-trace. Thus I would
like to have WARN()-like eye-catcher, even if the call-trace was not
too varying. It will at least point to this worker. Any better
suggestions than WARN()?
>
> > + /*
> > + * Worst of the worst case trigger emergency restart
> > + */
> > + WARN(1,
> > + "Hardware protection shutdown failed. Trying emergency
> > restart\n");
> > + emergency_restart();
>
> Two consecutive WARN() calls are even less useful. They are eye
> catching but it is hard to find the only useful line with
> the custom message.
I think you are right. One WARN should be enough to point here. This
last one could be just an additional print.
Best Regards
--Matti Vaittinen
next prev parent reply other threads:[~2021-05-12 12:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-10 11:26 [PATCH v9 00/10] Extend regulator notification support Matti Vaittinen
2021-05-10 11:27 ` [PATCH v9 01/10] dt_bindings: Add protection limit properties Matti Vaittinen
2021-05-10 11:28 ` [PATCH v9 02/10] reboot: Add hardware protection power-off Matti Vaittinen
2021-05-12 8:20 ` Petr Mladek
2021-05-12 12:00 ` Vaittinen, Matti [this message]
2021-05-13 8:34 ` Petr Mladek
2021-05-17 4:57 ` Matti Vaittinen
2021-05-10 11:29 ` [PATCH v9 03/10] thermal: Use generic HW-protection shutdown API Matti Vaittinen
2021-05-10 11:29 ` [PATCH v9 04/10] regulator: add warning flags Matti Vaittinen
2021-05-10 11:29 ` [PATCH v9 05/10] regulator: IRQ based event/error notification helpers Matti Vaittinen
2021-05-10 17:35 ` kernel test robot
2021-05-10 20:15 ` Andy Shevchenko
2021-05-10 19:45 ` kernel test robot
2021-05-10 20:20 ` Andy Shevchenko
2021-05-11 3:24 ` Matti Vaittinen
2021-05-11 4:54 ` Matti Vaittinen
2021-05-10 11:30 ` [PATCH v9 06/10] regulator: add property parsing and callbacks to set protection limits Matti Vaittinen
2021-05-10 11:30 ` [PATCH v9 07/10] dt-bindings: regulator: bd9576 add FET ON-resistance for OCW Matti Vaittinen
2021-05-10 11:30 ` [PATCH v9 08/10] regulator: bd9576: Support error reporting Matti Vaittinen
2021-05-10 11:31 ` [PATCH v9 09/10] regulator: bd9576: Fix the driver name in id table Matti Vaittinen
2021-05-10 11:31 ` [PATCH v9 10/10] MAINTAINERS: Add reviewer for regulator irq_helpers Matti Vaittinen
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=2149df3f542d25ce15d049e81d6188bb7198478c.camel@fi.rohmeurope.com \
--to=matti.vaittinen@fi.rohmeurope.com \
--cc=agross@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=amitk@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=bjorn.andersson@linaro.org \
--cc=broonie@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=josef@toxicpanda.com \
--cc=kai.heng.feng@canonical.com \
--cc=keescook@chromium.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-power@fi.rohmeurope.com \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mcroce@microsoft.com \
--cc=pmladek@suse.com \
--cc=rafael.j.wysocki@intel.com \
--cc=robh+dt@kernel.org \
--cc=rppt@kernel.org \
--cc=rui.zhang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).