All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: "Vaittinen, Matti" <Matti.Vaittinen@fi.rohmeurope.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>,
	rostedt@goodmis.org, Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [PATCH v9 02/10] reboot: Add hardware protection power-off
Date: Thu, 13 May 2021 10:34:51 +0200	[thread overview]
Message-ID: <YJzkq+NPW4ZMB8AF@alley> (raw)
In-Reply-To: <2149df3f542d25ce15d049e81d6188bb7198478c.camel@fi.rohmeurope.com>

On Wed 2021-05-12 12:00:46, Vaittinen, Matti wrote:
> 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()?

Heh, it might make sense to create a system wide API for these. I am
sure that WARN() is mis-used this way on many other locations.

There already are two locations that use another eye-catching text.
A common API might help to avoid duplication of the common parts,
see
https://lore.kernel.org/lkml/20210305194206.3165917-2-elver@google.com/

Well, it might be out of scope for this patchset.

Best Regards,
Petr

  reply	other threads:[~2021-05-13  8:35 UTC|newest]

Thread overview: 26+ 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
2021-05-13  8:34       ` Petr Mladek [this message]
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 17:35     ` kernel test robot
2021-05-10 20:15     ` Andy Shevchenko
2021-05-10 20:15       ` Andy Shevchenko
2021-05-10 19:45   ` kernel test robot
2021-05-10 19:45     ` kernel test robot
2021-05-10 20:20     ` Andy Shevchenko
2021-05-10 20:20       ` Andy Shevchenko
2021-05-11  3:24       ` Matti Vaittinen
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=YJzkq+NPW4ZMB8AF@alley \
    --to=pmladek@suse.com \
    --cc=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=geert@linux-m68k.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=rafael.j.wysocki@intel.com \
    --cc=robh+dt@kernel.org \
    --cc=rostedt@goodmis.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 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.