CV-Bowen opened a new pull request, #21765:
URL: https://github.com/apache/nuttx/pull/21765

   ## Summary
   
   Make the peer reset that rptun does on reboot, poweroff and panic
   actually reach the peer and complete.
   
   - drivers/rptun: reset the peers instead of stopping them on reboot
     The reboot notifier stopped the peers; a stopped peer only halts.
     Reset them, so they reboot or power off with this core.
   - drivers/rptun: initialize shmbase and shmlen
     Silence a maybe-uninitialized warning.
   - drivers/rptun: wait for the peer to reset, report poweroff and panic
     Without ops->reset, rptun_dev_reset() set the status bit and returned
     at once, so this core could go down before the peer saw it. Poll the
     peer status until it echoes the bit, up to
     CONFIG_RPTUN_STATUS_TIMEOUT_MS. The reboot notifier passes POWEROFF
     for SYS_POWER_OFF, and a peer asked to power off now powers off.
   - drivers/rptun: call boardctl() from a work queue
     The peer status is handled in the rptun interrupt, and boardctl() runs
     reboot notifiers that may sleep, which asserts there (trace below).
     Queue the reset/poweroff on HPWORK.
   - drivers/rptun: add RPTUN_AUTO_RESET to choose how the peers are reset
     Disable, panic the peers from the panic notifier (default, the
     current behaviour), or do everything from the reboot notifier.
   - drivers/rptun: log the reset reason
   - drivers/rptun: sleep instead of spinning while waiting for the peer
     So a peer that syncs rpmsgfs while going down is still served.
   - drivers/rptun: acknowledge the reset when boardctl cannot do it
     Without BOARDCTL_RESET/POWEROFF the peer waited until timeout.
   - drivers/rptun: run the panic notifier last
     Priority INT_MIN like the reboot notifier, so the coredump runs first.
   - drivers/rptun: use PANIC rather than ASSERT as the halt reason
   
   ## Impact
   
   - New Kconfig choice `RPTUN_AUTO_RESET`, default
     `RPTUN_AUTO_RESET_IN_PANIC_NOTIFIER` which keeps today's behaviour.
   - `rptun_reset()` / `RPTUNIOC_RESET` without `ops->reset` now wait up to
     `CONFIG_RPTUN_STATUS_TIMEOUT_MS` (5 s) for the peer and return
     `-ETIMEDOUT` if it does not answer; before they returned at once.
   - On reboot the peers are reset rather than stopped.
   - No API or ABI change.
   
   ## Testing
   
   Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU 
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
   
   qemu-armv8a:rpserver + qemu-armv8a:rpproxy (rptun over ivshmem), test-only
   overlay `# CONFIG_LIBC_ENVPATH is not set`, `# CONFIG_BINFMT_CHECKEXEC is
   not set`. Each case boots a fresh pair, pings the peer, then runs one
   command on the server and watches the proxy console:
   
   | case (server command) | master | this PR |
   | --- | --- | --- |
   | `rptun reset /dev/rptun/proxy 0` | proxy asserts in `event_wait()` (trace 
below) | proxy `FATAL: Reset by remote core: server reason: 0`, reboots |
   | `reboot` | proxy `Panic by remote core` | proxy `FATAL: Reset by remote 
core: server reason: 0`, reboots |
   | `rptun reset /dev/rptun/proxy 2` | proxy `Panic by remote core` | proxy 
`Panic by remote core` |
   
   On master the reset runs `boardctl()` from the rptun interrupt, and the
   rpmsg_port_uart reboot notifier waits on an event there:
   
   <details><summary>master, proxy, rptun reset 0</summary>
   
   ```
   Assertion failed event != ((void*)0) && !up_interrupt_context() == 0: at 
file: /sched/event/event_wait.c:120 task: Idle_Task process: Kernel 0x404b215c
   Assertion failed panic: at file: /drivers/rptun/rptun.c:918 task: Idle_Task 
process: Kernel 0x404b215c
     sched/event/event_wait.c:120 (discriminator 3)
     sched/event/event_wait.c:279
     drivers/rpmsg/rpmsg_port_uart.c:184
     drivers/rpmsg/rpmsg_port_uart.c:979 (discriminator 3)
     sched/misc/reboot_notifier.c:90 (discriminator 10)
     boards/boardctl.c:448
     drivers/rptun/rptun.c:923
     drivers/rptun/rptun.c:932
     drivers/rptun/rptun_ivshmem.c:429
     sched/wdog/wd_start.c:152
   ```
   </details>
   
   Every commit builds with 0 warnings on sim:rpserver and
   qemu-armv8a:rpserver.
   
   - sim:rpserver + sim:rpproxy: PASS
     - [x] `uname -a` (server)
     - [x] `rpmsg dump all` (server)
     - [x] `rpmsg ping all 10 1024 3 0` (server)
     - [x] `uname -a` (proxy)
     - [x] `rpmsg ping all 10 1024 3 0` (proxy)
     - [x] `mount -t rpmsgfs -o cpu=server,fs=/proc /sp` (proxy)
     - [x] `cat /sp/version` (proxy)
     - [x] `rpmsg dump all` (proxy)
   - qemu-armv8a:rpserver + qemu-armv8a:rpproxy: PASS
     - [x] `uname -a` (server)
     - [x] `uname -a` (proxy)
     - [x] `rpmsg dump all` (server)
     - [x] `rpmsg ping all 10 1024 3 0` (server)
     - [x] `rpmsg ping all 10 1024 3 0` (proxy)
     - [x] `mount -t rpmsgfs -o cpu=server,fs=/proc /sp` (proxy)
     - [x] `cat /sp/version` (proxy)
   
   No regression in rpmsg: sim:rpserver/rpproxy and 
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, 
rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC 
disabled, which current master needs for nxinit to start nsh there; unrelated 
to this change.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] drivers/rptun: complete ... CV-Bowen (via GitHub) via commits

Reply via email to