mbox series

[v7,0/5] mfd: tps6586x: register restart handler

Message ID 20230327-tegra-pmic-reboot-v7-0-18699d5dcd76@skidata.com
Headers show
Series mfd: tps6586x: register restart handler | expand

Message

Benjamin Bara July 15, 2023, 7:53 a.m. UTC
Hi!

The Tegra20 requires an enabled VDE power domain during startup. As the
VDE is currently not used, it is disabled during runtime.
Since 8f0c714ad9be, there is a workaround for the "normal restart path"
which enables the VDE before doing PMC's warm reboot. This workaround is
not executed in the "emergency restart path", leading to a hang-up
during start.

This series implements and registers a new pmic-based restart handler
for boards with tps6586x. This cold reboot ensures that the VDE power
domain is enabled during startup on tegra20-based boards.

Since bae1d3a05a8b, i2c transfers are non-atomic while preemption is
disabled (which is e.g. done during panic()). This could lead to
warnings ("Voluntary context switch within RCU") in i2c-based restart
handlers during emergency restart. The state of preemption should be
detected by i2c_in_atomic_xfer_mode() to use atomic i2c xfer when
required. Beside the new system_state check, the check is the same as
the one pre v5.2.

---
v7:
- 5/5: drop mode check (suggested by Dmitry)
- Link to v6: https://lore.kernel.org/r/20230327-tegra-pmic-reboot-v6-0-af44a4cd82e9@skidata.com

v6:
- drop 4/6 to abort restart on unexpected failure (suggested by Dmitry)
- 4,5: fix comments in handlers (suggested by Lee)
- 4,5: same delay for both handlers (suggested by Lee)

v5:
- introduce new 3 & 4, therefore 3 -> 5, 4 -> 6
- 3: provide dev to sys_off handler, if it is known
- 4: return NOTIFY_DONE from sys_off_notify, to avoid skipping
- 5: drop Reviewed-by from Dmitry, add poweroff timeout
- 5,6: return notifier value instead of direct errno from handler
- 5,6: use new dev field instead of passing dev as cb_data
- 5,6: increase timeout values based on error observations
- 6: skip unsupported reboot modes in restart handler

---
Benjamin Bara (5):
      kernel/reboot: emergency_restart: set correct system_state
      i2c: core: run atomic i2c xfer when !preemptible
      kernel/reboot: add device to sys_off_handler
      mfd: tps6586x: use devm-based power off handler
      mfd: tps6586x: register restart handler

 drivers/i2c/i2c-core.h |  2 +-
 drivers/mfd/tps6586x.c | 50 ++++++++++++++++++++++++++++++++++++++++++--------
 include/linux/reboot.h |  3 +++
 kernel/reboot.c        |  4 ++++
 4 files changed, 50 insertions(+), 9 deletions(-)
---
base-commit: 197b6b60ae7bc51dd0814953c562833143b292aa
change-id: 20230327-tegra-pmic-reboot-4175ff814a4b

Best regards,

Comments

Lee Jones July 28, 2023, 10:33 a.m. UTC | #1
On Sat, 15 Jul 2023 09:53:22 +0200, Benjamin Bara wrote:
> The Tegra20 requires an enabled VDE power domain during startup. As the
> VDE is currently not used, it is disabled during runtime.
> Since 8f0c714ad9be, there is a workaround for the "normal restart path"
> which enables the VDE before doing PMC's warm reboot. This workaround is
> not executed in the "emergency restart path", leading to a hang-up
> during start.
> 
> [...]

Applied, thanks!

[1/5] kernel/reboot: emergency_restart: set correct system_state
      commit: 60466c067927abbcaff299845abd4b7069963139
[2/5] i2c: core: run atomic i2c xfer when !preemptible
      commit: aa49c90894d06e18a1ee7c095edbd2f37c232d02
[3/5] kernel/reboot: add device to sys_off_handler
      commit: db2d6038c5e795cab4f0a8d3e86b4f7e33338629
[4/5] mfd: tps6586x: use devm-based power off handler
      commit: 8bd141b17cedcbcb7d336df6e0462e4f4a528ab1
[5/5] mfd: tps6586x: register restart handler
      commit: 510f276df2b91efd73f6c53be62b7e692ff533c1

--
Lee Jones [李琼斯]
Lee Jones July 28, 2023, 10:34 a.m. UTC | #2
On Fri, 28 Jul 2023, Lee Jones wrote:

> On Sat, 15 Jul 2023 09:53:22 +0200, Benjamin Bara wrote:
> > The Tegra20 requires an enabled VDE power domain during startup. As the
> > VDE is currently not used, it is disabled during runtime.
> > Since 8f0c714ad9be, there is a workaround for the "normal restart path"
> > which enables the VDE before doing PMC's warm reboot. This workaround is
> > not executed in the "emergency restart path", leading to a hang-up
> > during start.
> > 
> > [...]
> 
> Applied, thanks!
> 
> [1/5] kernel/reboot: emergency_restart: set correct system_state
>       commit: 60466c067927abbcaff299845abd4b7069963139
> [2/5] i2c: core: run atomic i2c xfer when !preemptible
>       commit: aa49c90894d06e18a1ee7c095edbd2f37c232d02
> [3/5] kernel/reboot: add device to sys_off_handler
>       commit: db2d6038c5e795cab4f0a8d3e86b4f7e33338629
> [4/5] mfd: tps6586x: use devm-based power off handler
>       commit: 8bd141b17cedcbcb7d336df6e0462e4f4a528ab1
> [5/5] mfd: tps6586x: register restart handler
>       commit: 510f276df2b91efd73f6c53be62b7e692ff533c1

Pull-request to follow after built tests have completed.
Benjamin Bara Sept. 7, 2023, 8:20 a.m. UTC | #3
Hi Lee,

On Fri, 28 Jul 2023 at 12:34, Lee Jones <lee@kernel.org> wrote:
> On Fri, 28 Jul 2023, Lee Jones wrote:
> > On Sat, 15 Jul 2023 09:53:22 +0200, Benjamin Bara wrote:
> > > The Tegra20 requires an enabled VDE power domain during startup. As the
> > > VDE is currently not used, it is disabled during runtime.
> > > Since 8f0c714ad9be, there is a workaround for the "normal restart path"
> > > which enables the VDE before doing PMC's warm reboot. This workaround is
> > > not executed in the "emergency restart path", leading to a hang-up
> > > during start.
> > >
> > > [...]
> >
> > Applied, thanks!
> >
> > [1/5] kernel/reboot: emergency_restart: set correct system_state
> >       commit: 60466c067927abbcaff299845abd4b7069963139
> > [2/5] i2c: core: run atomic i2c xfer when !preemptible
> >       commit: aa49c90894d06e18a1ee7c095edbd2f37c232d02
> > [3/5] kernel/reboot: add device to sys_off_handler
> >       commit: db2d6038c5e795cab4f0a8d3e86b4f7e33338629
> > [4/5] mfd: tps6586x: use devm-based power off handler
> >       commit: 8bd141b17cedcbcb7d336df6e0462e4f4a528ab1
> > [5/5] mfd: tps6586x: register restart handler
> >       commit: 510f276df2b91efd73f6c53be62b7e692ff533c1
>
> Pull-request to follow after built tests have completed.

What's the current state of this series?

Thanks & regards
Benjamin
Lee Jones Sept. 14, 2023, 10:17 a.m. UTC | #4
On Thu, 07 Sep 2023, Benjamin Bara wrote:

> Hi Lee,
> 
> On Fri, 28 Jul 2023 at 12:34, Lee Jones <lee@kernel.org> wrote:
> > On Fri, 28 Jul 2023, Lee Jones wrote:
> > > On Sat, 15 Jul 2023 09:53:22 +0200, Benjamin Bara wrote:
> > > > The Tegra20 requires an enabled VDE power domain during startup. As the
> > > > VDE is currently not used, it is disabled during runtime.
> > > > Since 8f0c714ad9be, there is a workaround for the "normal restart path"
> > > > which enables the VDE before doing PMC's warm reboot. This workaround is
> > > > not executed in the "emergency restart path", leading to a hang-up
> > > > during start.
> > > >
> > > > [...]
> > >
> > > Applied, thanks!
> > >
> > > [1/5] kernel/reboot: emergency_restart: set correct system_state
> > >       commit: 60466c067927abbcaff299845abd4b7069963139
> > > [2/5] i2c: core: run atomic i2c xfer when !preemptible
> > >       commit: aa49c90894d06e18a1ee7c095edbd2f37c232d02
> > > [3/5] kernel/reboot: add device to sys_off_handler
> > >       commit: db2d6038c5e795cab4f0a8d3e86b4f7e33338629
> > > [4/5] mfd: tps6586x: use devm-based power off handler
> > >       commit: 8bd141b17cedcbcb7d336df6e0462e4f4a528ab1
> > > [5/5] mfd: tps6586x: register restart handler
> > >       commit: 510f276df2b91efd73f6c53be62b7e692ff533c1
> >
> > Pull-request to follow after built tests have completed.
> 
> What's the current state of this series?

Looks like the build-tests didn't complete properly, so they stayed on
one of my development branches.  I'll re-submit them for testing and get
back to you about merging for this cycle.
Wolfram Sang Sept. 19, 2023, 2:58 p.m. UTC | #5
On Tue, Sep 19, 2023 at 03:46:44PM +0100, Lee Jones wrote:
> Enjoy!
> 
> The following changes since commit 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5:
> 
>   Linux 6.5-rc1 (2023-07-09 13:53:13 -0700)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-i2c-reboot-v6.7
> 
> for you to fetch changes up to 510f276df2b91efd73f6c53be62b7e692ff533c1:
> 
>   mfd: tps6586x: Register restart handler (2023-07-28 11:33:20 +0100)

Pulled, thanks!