[Bug 271359] RPi4: reset after shutdown -h doesn't work.

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 11 May 2023 04:05:19 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271359

            Bug ID: 271359
           Summary: RPi4: reset after shutdown -h doesn't work.
           Product: Base System
           Version: 13.2-STABLE
          Hardware: arm64
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: arm
          Assignee: freebsd-arm@FreeBSD.org
          Reporter: t_uemura@macome.co.jp

Created attachment 242116
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=242116&action=edit
Ugly but reliable way of workaround.

On RPi4B running 13.2-RELEASE official image (or home-brew 13.2-STABLE with
more recent u-boot and firmware), reset after shutdown -h by pressing a key to
"The operating system has halted.\nPlease press any key to reboot." prompt
never works as expected. It simply freezes just after "Rebooting..." message,
and a power cycle is required to restart the operating system.

Precisely, reset after shutdown -h is handled by
sys/kern/kern_shutdown.c:shutdown_reset() but there are two hardware specific
issues here. 

The one is that mtx_lock_spin(&smp_ipi_mtx) never returns. I don't know how
important this lock is and tried to see by commenting it out, and faced another
issue.

If I omitted the lock, then psci_call(PSCI_FNID_SYSTEM_RESET) was subsequently
called from cpu_lock() and it never successfully reset the board. Just stop.
Screen was still on and "Rebooting..." was intact. I don't know whether this
psci_call() failure is caused by the skipped lock.

To workaround, a watchdog firing is good alternative, as did in
sys/arm/broadcom/bcm2835/bcm2835_wdog.c:bcmwd_reboot_system().

I was very reluctant to add machine-dependent code to the file under sys/kern,
but I couldn't think of any other way to get around the lock other than what
was did in the attached patch.

-- 
You are receiving this mail because:
You are the assignee for the bug.