I've done a couple of quick checks.
Setting the period triggers most of the WARNs.
pio_claim_unused_sm is giving me back 0 as the sm, but when we come to use it in pwm_pio_rp1_apply we retrieve 50, which explains why it is out of range.
probe has ppwm as a different pointer to that computed in pwm_pio_rp1_apply.
Comparing to other drivers, I think the start of pwm_pio_rp1_apply actually wants to beotherwise I get an offset of 0x380 in the two pointers.
Creating PWM devices changed between 6.6 and 6.12, and I think this was a bad conversion.
Fixing that gives me a "scheduling while atomic" issue though:I don't immediately see why we're in an atomic context. We've come through pwm_apply_might_sleep which makes the state fairly obvious, and none of __pwm_apply, pwm_pio_rp1_apply, or rp1_pio_sm_set_enabled claim a spinlock which is the normal reason for that.
It has applied all the state though according to /sys/kernel/debug/pwm, but I haven't checked whether the GPIO is actually oscillating.
(Ignore the fact that this is on a 6.15.6 kernel - I was testing something else, and that was my current tree).
Could you create a new issue on https://github.com/raspberrypi/linux/issues referencing back to here? That way Phil can have a look at it with the context when he's back in the office. Forum threads get lost too quickly.
Setting the period triggers most of the WARNs.
pio_claim_unused_sm is giving me back 0 as the sm, but when we come to use it in pwm_pio_rp1_apply we retrieve 50, which explains why it is out of range.
probe has ppwm as a different pointer to that computed in pwm_pio_rp1_apply.
Comparing to other drivers, I think the start of pwm_pio_rp1_apply actually wants to be
Code:
struct pwm_pio_rp1 *ppwm = pwmchip_get_drvdata(chip);Creating PWM devices changed between 6.6 and 6.12, and I think this was a bad conversion.
Fixing that gives me a "scheduling while atomic" issue though:
Code:
[ 42.337433] BUG: scheduling while atomic: bash/972/0x00000002[ 42.337441] Modules linked in: rfcomm snd_seq_dummy snd_hrtimer snd_seq snd_seq_device algif_hash algif_skcipher af_alg bnep binfmt_misc r8153_ecm cdc_ether spidev brcmfmac_wcc hci_uart btbcm bluetooth vc4 aes_ce_blk aes_ce_cipher ghash_ce gf128mul sha2_ce sha256_arm64 snd_soc_hdmi_codec drm_exec sha1_ce sha1_generic drm_display_helper ecdh_generic cec raspberrypi_hwmon ecc drm_dma_helper drm_client_lib snd_soc_core brcmfmac i2c_brcmstb spi_bcm2835 snd_compress brcmutil snd_pcm_dmaengine pwm_pio_rp1 v3d cfg80211 snd_pcm gpio_keys gpu_sched r8152 rpi_hevc_dec pisp_be v4l2_mem2mem videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videodev snd_timer drm_shmem_helper snd rfkill videobuf2_common drm_kms_helper mc rp1_pio raspberrypi_gpiomem rp1_fw rp1_adc rp1_mailbox nvmem_rmem uio_pdrv_genirq uio i2c_dev ledtrig_pattern drm fuse drm_panel_orientation_quirks dm_mod backlight ip_tables x_tables ipv6[ 42.337598] CPU: 3 UID: 0 PID: 972 Comm: bash Not tainted 6.15.6-v8+ #10 PREEMPT [ 42.337602] Hardware name: Raspberry Pi 5 Model B Rev 1.0 (DT)[ 42.337603] Call trace:[ 42.337604] show_stack+0x20/0x38 (C)[ 42.337613] dump_stack_lvl+0x78/0x90[ 42.337617] dump_stack+0x18/0x28[ 42.337618] __schedule_bug+0x58/0x78[ 42.337623] __schedule+0xa90/0xc30[ 42.337626] schedule+0x3c/0x120[ 42.337628] schedule_timeout+0x7c/0x118[ 42.337633] __wait_for_common+0xc0/0x1a8[ 42.337635] wait_for_completion_timeout+0x28/0x40[ 42.337638] rp1_firmware_message+0xac/0x140 [rp1_fw][ 42.337643] rp1_pio_sm_set_enabled+0x54/0x98 [rp1_pio][ 42.337652] pwm_pio_rp1_apply+0xdc/0x378 [pwm_pio_rp1][ 42.337655] __pwm_apply+0x1b4/0x288[ 42.337658] pwm_apply_might_sleep+0x50/0xc0[ 42.337660] period_store+0xb0/0xd8[ 42.337661] dev_attr_store+0x20/0x40[ 42.337665] sysfs_kf_write+0x84/0xa8[ 42.337668] kernfs_fop_write_iter+0x120/0x1b8[ 42.337670] vfs_write+0x2b8/0x370[ 42.337672] ksys_write+0x70/0x110[ 42.337674] __arm64_sys_write+0x24/0x38[ 42.337676] invoke_syscall+0x50/0x120[ 42.337680] el0_svc_common.constprop.0+0x48/0xf8[ 42.337683] do_el0_svc+0x28/0x40[ 42.337686] el0_svc+0x30/0xd0[ 42.337688] el0t_64_sync_handler+0x144/0x168[ 42.337690] el0t_64_sync+0x198/0x1a0[ 42.337912] BUG: scheduling while atomic: bash/972/0x00000000[ 42.337918] Modules linked in: rfcomm snd_seq_dummy snd_hrtimer snd_seq snd_seq_device algif_hash algif_skcipher af_alg bnep binfmt_misc r8153_ecm cdc_ether spidev brcmfmac_wcc hci_uart btbcm bluetooth vc4 aes_ce_blk aes_ce_cipher ghash_ce gf128mul sha2_ce sha256_arm64 snd_soc_hdmi_codec drm_exec sha1_ce sha1_generic drm_display_helper ecdh_generic cec raspberrypi_hwmon ecc drm_dma_helper drm_client_lib snd_soc_core brcmfmac i2c_brcmstb spi_bcm2835 snd_compress brcmutil snd_pcm_dmaengine pwm_pio_rp1 v3d cfg80211 snd_pcm gpio_keys gpu_sched r8152 rpi_hevc_dec pisp_be v4l2_mem2mem videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videodev snd_timer drm_shmem_helper snd rfkill videobuf2_common drm_kms_helper mc rp1_pio raspberrypi_gpiomem rp1_fw rp1_adc rp1_mailbox nvmem_rmem uio_pdrv_genirq uio i2c_dev ledtrig_pattern drm fuse drm_panel_orientation_quirks dm_mod backlight ip_tables x_tables ipv6[ 42.338081] CPU: 3 UID: 0 PID: 972 Comm: bash Tainted: G W 6.15.6-v8+ #10 PREEMPT [ 42.338084] Tainted: [W]=WARN[ 42.338085] Hardware name: Raspberry Pi 5 Model B Rev 1.0 (DT)[ 42.338086] Call trace:[ 42.338086] show_stack+0x20/0x38 (C)[ 42.338090] dump_stack_lvl+0x78/0x90[ 42.338092] dump_stack+0x18/0x28[ 42.338093] __schedule_bug+0x58/0x78[ 42.338096] __schedule+0xa90/0xc30[ 42.338099] schedule+0x3c/0x120[ 42.338101] do_notify_resume+0xdc/0x150[ 42.338104] el0_svc+0xbc/0xd0[ 42.338106] el0t_64_sync_handler+0x144/0x168[ 42.338108] el0t_64_sync+0x198/0x1a0It has applied all the state though according to /sys/kernel/debug/pwm, but I haven't checked whether the GPIO is actually oscillating.
(Ignore the fact that this is on a 6.15.6 kernel - I was testing something else, and that was my current tree).
Could you create a new issue on https://github.com/raspberrypi/linux/issues referencing back to here? That way Phil can have a look at it with the context when he's back in the office. Forum threads get lost too quickly.
Statistics: Posted by 6by9 — Wed Jul 23, 2025 4:51 pm