Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1563194

Re: [PATCH] power: reset: Add MAX77620 support

From Guenter Roeck <linux@roeck-us.net>
Newsgroups linux.kernel
Subject Re: [PATCH] power: reset: Add MAX77620 support
Date 2017-01-20 00:30 +0100
Message-ID <t1ujv-80E-3@gated-at.bofh.it> (permalink)
References <sYQgz-66R-37@gated-at.bofh.it> <sZ12h-4fJ-7@gated-at.bofh.it> <t1k0O-1tT-7@gated-at.bofh.it> <t1u9P-7WG-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jan 20, 2017 at 12:00:36AM +0100, Sebastian Reichel wrote:
> Hi Thierry,
> 
> > > > [...]
> > >
> > > Please use register_restart_handler() instead. It has support for
> > > priorities, is not arm specific and properly supports unregistering
> > > (some handler with lower priority will take over). You can check
> > > gpio-restart as an example for the API.
> > > 
> > > If you have some other arm_pm_restart handler (those are tried first)
> > > I suggest to convert that to the restart handler framework. Actually
> > > it may be a good idea to convert all of them and drop arm_pm_restart,
> > > since there are only 4 left:
> > > 
> > > $ git grep "arm_pm_restart ="
> > > drivers/firmware/psci.c:        arm_pm_restart = psci_sys_reset;
> > > arch/arm/mach-prima2/rstc.c:    arm_pm_restart = sirfsoc_restart;
> > > arch/arm/xen/enlighten.c:       arm_pm_restart = xen_restart;
> > > arch/arm/kernel/setup.c:                arm_pm_restart = mdesc->restart;
> > > 
> > > The first 3 should be easy to update and the last one could
> > > be solved by registering a wrapper function as restart handler,
> > > which calls mdesc->restart().
> > 
> > I remember this not being the first time that this confuses me. And from
> > looking around a little it seems like I'm not the only one.
> > 
> > Do you know if there's ever been any attempts to formalize all of this
> > by adding some sort of framework for this? That way some of the
> > confusion may be removed and architecture-specific bits could be
> > eliminated more easily.
> 
> We have a framework for restart handlers, which has been written
> by Guenter Roeck [0] in 2014. You just have to call register_restart_handler()
> during probe and unregister_restart_handler() during removal of
> your reboot driver. All reboot drivers in drivers/power/reset use
> that framework.
> 
> The restart handlers are invoked by calling do_kernel_restart()
> based on their configured priority. That function is called by
> the architecture's machine_restart() function. It's currently
> used by mips, ppc, arm & arm64 as far as I can see. ARM's
> implementation looks like this:
> 
> if (arm_pm_restart)
> 	arm_pm_restart()
> else
> 	do_kernel_restart() /* reboot handler framework */
> 
I actually have a set of patches somewhere which transforms the remaining
direct users of arm_pm_restart to use the framework (unless I removed it
from my trees - I don't really recall). I just never got around to submit
it, and then [2] happened and I lost interest.

> No such thing exists for poweroff. Guenter also wrote something for
> that [1], but Linus intervened [2]. Anyways, pm_power_off is at
> least architecture independent.
> 
That was by far the most frustrating kernel development experience
I ever head :-(.

Guenter

> [0] https://lwn.net/Articles/605298/
> [1] https://lwn.net/Articles/617345/
> [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-June/351369.html
> 
> -- Sebastian

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] power: reset: Add MAX77620 support Thierry Reding <thierry.reding@gmail.com> - 2017-01-19 13:30 +0100
  Re: [PATCH] power: reset: Add MAX77620 support Sebastian Reichel <sre@kernel.org> - 2017-01-20 00:20 +0100
    Re: [PATCH] power: reset: Add MAX77620 support Guenter Roeck <linux@roeck-us.net> - 2017-01-20 00:30 +0100
      Re: [PATCH] power: reset: Add MAX77620 support Thierry Reding <thierry.reding@gmail.com> - 2017-01-20 09:40 +0100
        Re: [PATCH] power: reset: Add MAX77620 support Guenter Roeck <linux@roeck-us.net> - 2017-01-20 19:00 +0100
        Re: [PATCH] power: reset: Add MAX77620 support Sebastian Reichel <sre@kernel.org> - 2017-01-29 21:20 +0100
          Re: [PATCH] power: reset: Add MAX77620 support Guenter Roeck <linux@roeck-us.net> - 2017-01-29 21:50 +0100
            Re: [PATCH] power: reset: Add MAX77620 support Sebastian Reichel <sre@kernel.org> - 2017-01-30 00:00 +0100
      Re: [PATCH] power: reset: Add MAX77620 support Sebastian Reichel <sre@kernel.org> - 2017-01-20 13:50 +0100
        Re: [PATCH] power: reset: Add MAX77620 support Thierry Reding <thierry.reding@gmail.com> - 2017-01-20 14:30 +0100
          Re: [PATCH] power: reset: Add MAX77620 support Sebastian Reichel <sre@kernel.org> - 2017-01-20 14:50 +0100
          Re: [PATCH] power: reset: Add MAX77620 support Guenter Roeck <linux@roeck-us.net> - 2017-01-20 15:40 +0100

csiph-web