raspberrypi / linux

Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at https://forums.raspberrypi.com/
Other
11.11k stars 4.97k forks source link

Pi 400 WARNs when shutting down #5680

Open pelwell opened 12 months ago

pelwell commented 12 months ago

Describe the bug

With a serial cable attached reveals that the Pi 400 kernel is emitting a WARN message when shutting down:

[   57.499952] ------------[ cut here ]------------
[   57.504630] Voluntary context switch within RCU read-side critical section!
[   57.504646] WARNING: CPU: 0 PID: 1 at kernel/rcu/tree_plugin.h:320 rcu_note_context_switch+0x4b4/0x5ac
[   57.521154] Modules linked in: rfcomm snd_seq_dummy snd_hrtimer snd_seq snd_seq_device cmac algif_hash aes_arm64 aes_generic algif_skcipher af_alg bnep binfmt_misc brcmfmac brcmutil hci_uart btbcm bluetooth cfg80211 rpivid_hevc(C) bcm2835_codec(C) v4l2_mem2mem bcm2835_isp(C) bcm2835_v4l2(C) ecdh_generic ecc bcm2835_mmal_vchiq(C) videobuf2_dma_contig videobuf2_vmalloc videobuf2_memops libaes raspberrypi_hwmon videobuf2_v4l2 rfkill videobuf2_common videodev raspberrypi_gpiomem vc_sm_cma(C) snd_bcm2835(C) mc nvmem_rmem uio_pdrv_genirq uio i2c_dev fuse dm_mod ip_tables x_tables ipv6 vc4 v3d gpu_sched drm_shmem_helper snd_soc_hdmi_codec drm_display_helper cec drm_dma_helper i2c_brcmstb drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm drm_panel_orientation_quirks snd_soc_core snd_compress snd_pcm_dmaengine snd_pcm snd_timer snd backlight
[   57.597444] CPU: 0 PID: 1 Comm: systemd-shutdow Tainted: G         C         6.1.0-rpi4-rpi-v8 #1  Debian 1:6.1.54-1+rpt2
[   57.608559] Hardware name: Raspberry Pi 400 Rev 1.0 (DT)
[   57.613941] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   57.620999] pc : rcu_note_context_switch+0x4b4/0x5ac
[   57.626031] lr : rcu_note_context_switch+0x4b4/0x5ac
[   57.631064] sp : ffffffc00802b7d0
[   57.634418] x29: ffffffc00802b7d0 x28: ffffff80401e0000 x27: ffffff80409decc0
[   57.641656] x26: 0000000000000000 x25: ffffff80401e0000 x24: ffffff80401e0000
[   57.648895] x23: 0000000000000000 x22: ffffffd845a68d28 x21: ffffff80401e0000
[   57.656132] x20: ffffffd845557f40 x19: ffffff80fb782f40 x18: 0000000000000006
[   57.663370] x17: 0000000000000000 x16: ffffff80fb7d92c0 x15: ffffffc00802b230
[   57.670607] x14: 0000000000000000 x13: 216e6f6974636573 x12: 206c616369746972
[   57.677844] x11: 6320656469732d64 x10: ffffffd8458e77e8 x9 : ffffffd8444fb258
[   57.685080] x8 : 00000000ffffefff x7 : ffffffd8458e4800 x6 : 00000000000001ff
[   57.692319] x5 : 000000000000bff4 x4 : 40000000fffff1ff x3 : 0000000000000000
[   57.699555] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffff80401e0000
[   57.706792] Call trace:
[   57.709266]  rcu_note_context_switch+0x4b4/0x5ac
[   57.713946]  __schedule+0xc4/0xa10
[   57.717397]  schedule+0x60/0x100
[   57.720667]  schedule_timeout+0xa4/0x1c0
[   57.724641]  wait_for_completion_timeout+0x7c/0x150
[   57.729585]  mbox_send_message+0xa8/0x12c
[   57.733651]  rpi_firmware_property_list+0xf8/0x270
[   57.738510]  rpi_firmware_property+0x78/0x114
[   57.742925]  rpi_exp_gpio_get_polarity+0x64/0xec
[   57.747604]  rpi_exp_gpio_dir_out+0x68/0x110
[   57.751930]  gpiod_direction_output_raw_commit+0x64/0x1dc
[   57.757406]  gpiod_direction_output+0xb8/0x134
[   57.761908]  gpio_poweroff_do_poweroff+0x40/0xf0
[   57.766595]  legacy_pm_power_off+0x24/0x40
[   57.770752]  sys_off_notify+0x3c/0x64
[   57.774462]  atomic_notifier_call_chain+0x68/0xa0
[   57.779231]  do_kernel_power_off+0x5c/0x74
[   57.783383]  machine_power_off+0x54/0x60
[   57.787360]  kernel_power_off+0x78/0x84
[   57.791247]  __do_sys_reboot+0x200/0x23c
[   57.795222]  __arm64_sys_reboot+0x2c/0x3c
[   57.799286]  invoke_syscall+0x50/0x120
[   57.803084]  el0_svc_common.constprop.0+0x68/0x124
[   57.807941]  do_el0_svc_compat+0x24/0x4c
[   57.811915]  el0_svc_compat+0x30/0x94
[   57.815625]  el0t_32_sync_handler+0x98/0x140
[   57.819952]  el0t_32_sync+0x190/0x194
[   57.823661] ---[ end trace 0000000000000000 ]---

It then proceeds to power off as expected - I'm just logging this so it doesn't get forgotten.

Steps to reproduce the behaviour

  1. Attach a serial cable.
  2. Enable the UART.
  3. Press the power button to shut it down.
  4. Splat.

Device (s)

Raspberry Pi 400

System

6.1.0-rpi4-rpi-v8 #1 Debian 1:6.1.54-1+rpt2

Logs

No response

Additional context

No response

pelwell commented 12 months ago

The immediate cause of the WARN is the access to the GLOBAL_SHUTDOWN pin during the power-off handling- it's what turns out the lights. Sadly it's on the GPIO expander, which is on the other side of an I2C link. Worse than that, it's an I2C link controlled by the firmware. The "expgpio" driver that controls it expects to be able to sleep while waiting for a response, and the gpio-poweroff driver acknowledges that by using gpiod_set_value_cansleep, but this happens while "within RCU read-side critical section", so I've no idea how that is supposed to work.