Use mainline system suspend code / fix gpu and vpu regulator errors
We currently include these hacks: b2066b3e and 2ec68403 that we need to get rid of. Here I test without them. (For 5.18 based kernels I was about to add another similarly bad workaround) So here's the debugging of a kernel close to mainline, in order to get it right:
with hantro disabled (that creates problems, more to that later), I get the following during resume:
[ 2165.739199] Enabling non-boot CPUs ...
[ 2165.744028] Detected VIPT I-cache on CPU1
[ 2165.744078] GICv3: CPU1: found redistributor 1 region 0:0x00000000388a0000
[ 2165.744152] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[ 2165.745124] CPU1 is up
[ 2165.765560] Detected VIPT I-cache on CPU2
[ 2165.765577] GICv3: CPU2: found redistributor 2 region 0:0x00000000388c0000
[ 2165.765601] CPU2: Booted secondary processor 0x0000000002 [0x410fd034]
[ 2165.766022] CPU2 is up
[ 2165.786432] Detected VIPT I-cache on CPU3
[ 2165.786449] GICv3: CPU3: found redistributor 3 region 0:0x00000000388e0000
[ 2165.786473] CPU3: Booted secondary processor 0x0000000003 [0x410fd034]
[ 2165.786996] CPU3 is up
[ 2165.910744] imx-pgc imx-pgc-domain.5: failed to enable regulator: -110
[ 2165.951636] redpine_91x: <==== Interface UP ====>
[ 2165.959107] redpine_91x: rsi_mac80211_bss_info_changed: Change of ERP INFO: 0
[ 2165.966317] redpine_91x: rsi_mac80211_bss_info_changed: Sending vap updates....
[ 2166.466175] usb 1-1: reset high-speed USB device number 2 using xhci-hcd
[ 2166.657911] usb 2-1: reset high-speed USB device number 2 using xhci-hcd
[ 2166.802375] r8152 3-1.4:1.0 enx00e04c684a8a: Stop submitting intr, status -71
[ 2167.055814] usb 1-1.1: reset high-speed USB device number 3 using xhci-hcd
[ 2167.458729] usb 1-1.2: reset high-speed USB device number 4 using xhci-hcd
[ 2167.686886] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
[ 2167.694951] option 1-1.2:1.0: device disconnected
[ 2167.699847] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[ 2167.707903] option 1-1.2:1.1: device disconnected
[ 2167.712793] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
[ 2167.720851] option 1-1.2:1.2: device disconnected
[ 2167.725736] option1 ttyUSB3: GSM modem (1-port) converter now disconnected from ttyUSB3
[ 2167.733792] option 1-1.2:1.3: device disconnected
[ 2167.740410] OOM killer enabled.
[ 2167.740632] option 1-1.2:1.0: GSM modem (1-port) converter detected
[ 2167.743573] Restarting tasks ...
[ 2167.750082] ------------[ cut here ]------------
[ 2167.750152] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB0
[ 2167.755111] unbalanced disables for buck3
[ 2167.759176] done.
[ 2167.765170] WARNING: CPU: 0 PID: 1988 at drivers/regulator/core.c:2852 _regulator_disable+0xdc/0x194
[ 2167.780120] Modules linked in: aes_ce_ccm exfat rfcomm bnep qmi_wwan option cdc_wdm usb_wwan usbserial cdc_ether usbnet uas r8152 usb_storage mii caam_jr caamhash_desc caamalg_desc crypto_engine mousedev usb_f_acm u_serial usb_f_ecm u_ether redpine_sdio aes_ce_blk redpine_91x crct10dif_ce ghash_ce sha2_ce sha1_ce st_lsm6dsx_spi bluetooth snd_soc_simple_card pwm_vibra snd_soc_simple_card_utils mac80211 snd_soc_gtm601 imx7_media_csi(C) cfg80211 vcnl4000 imx_media_common(C) st_lsm6dsx_i2c snd_soc_wm8962 st_lsm6dsx snd_soc_fsl_sai videobuf2_dma_contig industrialio_triggered_buffer imx_pcm_dma imx8mq_mipi_csi2(C) hi846 s5k3l6xx snd_soc_core videobuf2_memops gnss_mtk kfifo_buf leds_lm3560 dw9714 v4l2_fwnode caam videobuf2_v4l2 edt_ft5x06 snd_pcm_dmaengine snd_pcm videobuf2_common v4l2_async gnss_serial gnss error videodev mc snd_timer snd soundcore imx2_wdt watchdog rfkill_hks rfkill libcomposite ledtrig_timer ledtrig_pattern fuse zram ip_tables x_tables ipv6 ofpart xhci_plat_hcd xhci_hcd
[ 2167.780361] spi_nor
[ 2167.803169] option 1-1.2:1.1: GSM modem (1-port) converter detected
[ 2167.867358] mtd usbcore dwc3 ulpi cdns_mhdp_imx cdns_mhdp_drmcore drm_dp_helper udc_core clk_bd718x7 tps6598x imx_dcss usb_common phy_fsl_imx8mq_usb typec bq25890_charger roles imx_sdma snvs_pwrkey virt_dma [last unloaded: v4l2_vp9]
[ 2167.896523] CPU: 0 PID: 1988 Comm: kworker/0:0 Tainted: G C 5.18.1-librem5-00009-g973ddbc80302 #354
[ 2167.906877] Hardware name: Purism Librem 5r4 (DT)
[ 2167.911588] Workqueue: pm genpd_power_off_work_fn
[ 2167.916307] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 2167.918792] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB1
[ 2167.923271] pc : _regulator_disable+0xdc/0x194
[ 2167.923281] lr : _regulator_disable+0xdc/0x194
[ 2167.923287] sp : ffff80000a6ebc60
[ 2167.923290] x29: ffff80000a6ebc60
[ 2167.936095] option 1-1.2:1.2: GSM modem (1-port) converter detected
[ 2167.939123] x28: 0000000000000000 x27: 0000000000000000
[ 2167.939130] x26: ffff000037bf1d74 x25: ffff0000bf945705 x24: ffff000001814c00
[ 2167.939139] x23: 000001f8b7d7c4a3 x22: 000001f8b7e7b273
[ 2167.957779] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB2
[ 2167.964464] x21: ffff0000be862800
[ 2167.964470] x20: ffff0000be8cfd00 x19: ffff0000be8cfd00 x18: 0000000000000000
[ 2167.964479] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000030
[ 2167.964487] x14: 0000000000000035 x13: 0000000000000000 x12: ffff800008f39bd0
[ 2167.964495] x11: ffff800009508aa8 x10: 0000000000000a10 x9 : ffff80000818c54c
[ 2167.964504] x8 : ffff0000038c8a70
[ 2167.970249] option 1-1.2:1.3: GSM modem (1-port) converter detected
[ 2167.976680] x7 : 0000000000000000 x6 : ffff80000816a650
[ 2167.976687] x5 : 0000000000000000 x4 : ffff0000bf930990 x3 : ffff0000bf93ccb0
[ 2167.976695] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000038c8000
[ 2167.981622] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB3
[ 2167.987231]
[ 2167.987235] Call trace:
[ 2167.987238] _regulator_disable+0xdc/0x194
[ 2167.987248] regulator_disable+0x48/0x8c
[ 2167.987254] imx_pgc_power_down+0x1a8/0x304
[ 2167.987264] _genpd_power_off+0xc8/0x164
[ 2167.987272] genpd_power_off.part.0.isra.0+0x130/0x2e0
[ 2167.987281] genpd_power_off_work_fn+0x70/0x90
[ 2167.987288] process_one_work+0x204/0x480
[ 2167.987299] worker_thread+0x154/0x450
[ 2167.987306] kthread+0x118/0x120
[ 2167.987313] ret_from_fork+0x10/0x20
[ 2167.987321] ---[ end trace 0000000000000000 ]---
[ 2167.995509] rfkill: input handler enabled
[ 2168.008929] imx-pgc imx-pgc-domain.5: failed to disable regulator: -5
gpcv2 enables power domains for suspend and "puts" them again for resume. Acceptable workarounds would involve disabling runtime pm before system suspend.
Edited by Martin Kepplinger