libera/#maemo-leste/ Thursday, 2024-10-03

freemangordonuvos: I don;t see how was reboot/poweroff ever working08:06
freemangordond4 does poweroff through a gpio, however, a bit in CPCAP_REG_PC1 must be set, I guess08:08
freemangordonfor proper poweroff08:08
freemangordonvendor kernel does a long reboot sequence I can find nowhere in our kernel: https://github.com/NotKit/android_kernel_motorola_omap4-common/blob/hybris-11.0/drivers/mfd/cpcap-core.c#L12508:09
freemangordontmlind_: hi! do you have any idea if there is any poweroff/reboot cpcap code in upstream kernel?08:13
freemangordonuvos: so, I suspect the reason why device reboots when power-off is issued and hangs when reboot is requested is simply that cpcap regs are not properly initied08:14
freemangordon*inited08:14
sicelofreemangordon: believe it or not ... adding the delay in schedule_delayed_wor() caused it to not work at all. no more uevent :-p08:59
sicelobut i'm recompiling just in case i botched it earlier09:00
freemangordonsicelo: do you still have cancel_delayed_work()?13:36
siceloyes13:41
freemangordonsicelo: that does not make sense :)17:26
freemangordonmay I see the exact code?17:28
tmlind_freemangordon: i suspect the system hangs on poweroff and does a watchdog reset, i think it's a serial issue as i recall it works fine without the modem stuff17:40
freemangordontmlind_: so you think if I disable modem poweroff/reboot should work fine?17:41
freemangordonbut why we lack the code that sets cpcap regs then?   CPCAP_REG_PC2 that is17:42
freemangordonalso, I don;t see how modem can hang gpio-poweroff, unless we have oops17:43
freemangordonbut ok, I'll disable modem stuff and check17:43
tmlind_freemangordon: hmm the poweroff gpio is on the soc? but yeah maybe the register configuration on cpcap is incomplete18:30
freemangordongpio-poweroff is on cpcap, like gpio50 is connected to cpcap WDI pin, IIUC19:00
tmlind_i guess i don't follow you.. for mapphone dts has gpio-poweroff as gpios = <&gpio2 18 GPIO_ACTIVE_LOW> so gpio_50 on the soc19:13
tmlind_so that goes to some power pin on the cpcap likely19:14
freemangordonyes, WDI pin should be it19:14
freemangordonbut in order for WDI to function properly, PCEN bit in Power Control 1 register must be set, IIUC19:15
freemangordonat least that's how I read "5.2.5 Turn Off Events"19:15
freemangordon"The phone is powered off upon software initiative based on this interrupt, by pulling WDI low"19:16
tmlind_ok, i recall there was a tiny difference in shutdown power consumption compared to powering off from bootloader or android19:16
freemangordonI wonder how/why powering off/reboot was working at all with 6.119:16
tmlind_from what i recall mainline linux poweroff causes the device to consume about 1mw, while poweroff from android is a bit less19:17
tmlind_sounds like the PCEN might shut down some power supply after poweroff19:17
freemangordonmhm19:18
freemangordonstill, why is poweroff working at all with 6.1? :)19:18
tmlind_why would it not?19:18
freemangordonbecause according to docs nothing should happen if PCEN is 019:19
freemangordonsee MC13783UG.pdf19:19
tmlind_well give it a try without the modem stuff, sounds like PCEN is optional19:19
freemangordon5.2.519:19
freemangordonok19:20
freemangordonthough it is easier to first try with PCEN set19:20
tmlind_possibly having a serial console might also make poweroff behave, don't know, but i suspect something uart related19:20
freemangordonwith serial console it seems to work19:20
tmlind_heh ok19:20
tmlind_serial console keeps the uart from runtime idling19:21
freemangordonmhm19:21
tmlind_anyways worth checking the PCEN, maybe that's the missing extra saving when powered off19:22
freemangordonyep, going to do it19:23
freemangordonwith PCEN on it didn't poweroff, but didn't restart either19:33
tmlind_heh maybe it does powercut when the soc hits idle now..19:34
freemangordondon't follow19:35
tmlind_maybe try unidling the uarts on shutdown to see if that's the issue19:35
freemangordonok19:35
tmlind_looks like the PCEN might be also related to cutting off some regulators during idle depending on the configuration?19:36
freemangordonI doubt19:37
freemangordonsee https://github.com/NotKit/android_kernel_motorola_omap4-common/blob/hybris-11.0/drivers/mfd/cpcap-core.c#L24019:37
tmlind_looking at the "user off power cut" in the mc13783ug19:37
freemangordonthat's the only place this bit is referenced19:37
freemangordonand ofc in default values19:37
freemangordonhttps://github.com/NotKit/android_kernel_motorola_omap4-common/blob/hybris-11.0/arch/arm/mach-omap2/board-mapphone-spi.c#L4719:38
tmlind_hmm is CPCAP_BIT_PC1_PCEN ever set high when system is running?19:40
freemangordonno, it defaults to 0 in our kernel19:41
freemangordon021c: 000019:41
tmlind_also in the stock andriod kernel?19:42
freemangordonon vendor kernel it is set to 0x010A in board file19:42
freemangordonthats PC1 register19:43
freemangordonwhich means PCEN is set to 119:43
freemangordonand power cut timer is set to 0x0A, whatever that means in seconds19:44
freemangordonok, docs say ~32ms steps19:45
freemangordonso ~300 ms19:45
freemangordonlemme set that and try19:45
tmlind_oh interesting19:48
freemangordonsee https://github.com/NotKit/android_kernel_motorola_omap4-common/blob/hybris-11.0/arch/arm/mach-omap2/board-mapphone-spi.c#L4719:49
tmlind_ok19:49
freemangordonwith that set to 010a still no dice, lemme unidle the uarts19:51
tmlind_so i suspect some mctrl call gets called on idle uart(s) and hangs19:53
freemangordonok19:53
freemangordonmctrl?19:53
tmlind_if unidling all the uarts fixes the issue the that's it likely19:53
freemangordontrying it19:53
freemangordonwhat devices are those? ttyS0 etc?19:55
tmlind_yeah ttyS0 to 3 or 419:55
tmlind_git grep mctrl drivers/tty/serial/serial_core.c19:55
freemangordonecho on > 4806a000.serial/power/control20:01
freemangordonand so on for the others, right?20:01
freemangordonyeah, it powered off20:02
freemangordontmlind_: ^^^20:02
freemangordonthanks!20:03
freemangordonso, we shall unidle on poweroff/reboot?20:03
freemangordonor some fix must be implemented?20:04
tmlind_heh ok cool :) i guess that would be a short term workaround20:04
freemangordonin the kernel that is20:04
freemangordonpm_runtime_get?20:04
tmlind_yeah i'll try to fix it when it starts raining more20:04
freemangordonheh :)20:04
tmlind_yeah pm_runtime_get, but i think some drivers may call the mctrl stuff directly too20:05
freemangordonlemme see what that mctll is20:05
tmlind_yeah narrowing it down would help, i would try uart_update_mctrl() first20:06
freemangordonit calls port->ops->set_mctrl()20:06
tmlind_but see also #define uart_set_mctrl and uart_clear_mctrl so pm_runtime_resume_and_get() may not always be the right solution20:07
tmlind_well we can't do it but could return an error possibly20:07
freemangordonsorry, I don't understand that PM stuff, but, if we do the same in uart_update_mctrl() like what is done in __uart_start in regards to calling PM functions, wouln't that fix the issue?20:09
tmlind_hmm yeah worth trying yeah20:10
tmlind_see current mainline kernel though if you're on v6.120:10
freemangordonno, I am on 6.620:11
freemangordonok, checking mainline20:11
tmlind_still behind likely, mainline now has serial core with a struct device hierarchy20:12
freemangordonhow's that related?20:13
tmlind_well the runtime_pm calls propagate to the serial port driver device which is the parent20:13
tmlind_so in theory serial_core.c could eventually handle all runtime pm20:14
freemangordonI have the feeling you are looking for a proper fix :)20:14
tmlind_except that's not exactly clear yet.. see commit 5555980571cc ("serial: core: Fix regression when runtime PM is not enabled")20:15
freemangordonwe still have that in 6.620:17
freemangordonI mean - 5555980571cc is not in 6.620:17
freemangordonso, you mean that if PM runtime cannot be enabled in uart_update_mctrl(), we can't do much but to error out?20:19
tmlind_or maybe what you suggested similar to __uart_start, not sure if they are really called directly though20:24
tmlind_it might be also related to multiple mctrl calls don't know20:25
tmlind_sorry i mean other like uart_port_dtr_rts and carrier_raised20:25
tmlind_maybe see if this helps, this is against v6.12-rc1 http://muru.com/linux/mctrl.patch20:30
tmlind_does not consider the direct calls but worth trying, at least it built and booted for me20:30
tmlind_sounds like v6.6 already has port->port_dev20:32
freemangordonok, lemme check20:32
tmlind_otherwise you could call it on port->dev, but that's not going work in general as you never know what the port->dev runtime_pm configuraion might be..20:33
tmlind_heh disabling runtime_pm with a shutdown call might be the m-l short term fix :)20:35
tmlind_for the uarts i mean20:35
freemangordonI tried it20:35
freemangordonbut it didn;'t work20:35
tmlind_hmm20:35
freemangordonmaybe service does not get stopped20:35
freemangordonor is stopped too late20:35
tmlind_or it happens before shutdown20:36
freemangordonthere is openrc service that idles uarts on bootup20:36
tmlind_the hang might happen before the shutdown calls are run20:36
freemangordonwhen it starts20:36
freemangordonhmm, right20:36
freemangordonok, lemme try your patch20:36
tmlind_ok20:36
tmlind_the alternative i was thinking was adding .shutdown call to 8250_omap20:37
tmlind_so with that poweroff worked for me on d4, still consuming 1 - 3 mw though but seems shut down20:43
freemangordonwhich kernel?20:44
tmlind_i don't have the modem patches applied though, plain v6.12-rc120:44
freemangordonah, ok20:44
freemangordonhow to prevent kernel version being appended with some SHA id?20:45
tmlind_LOCALVERSION_AUTO=n20:45
freemangordonin config?20:46
tmlind_yeah20:47
freemangordonok, thanks20:47
tmlind_need to go offline here, ttyl20:47
freemangordonthanks!20:47
tmlind_thank you20:48
freemangordonI'll play with CPCAP as well20:48
freemangordonok, that patch fixes poweroff on 6.6 as well21:26
freemangordonreboot works as well21:41
freemangordonarno11: ok, now poweroff works on d4, I see similar behaviour in regards to h-s-m21:54
Wizzupwhat behaviour is that?22:43
Wizzup(also: nice!)22:43

Generated by irclog2html.py 2.17.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!