libera/#maemo-leste/ Wednesday, 2024-10-02

buZzmaybe that was what i was hitting with chargers too, prevented with a usbcondom?00:06
siceloWizzup: just as an update regarding my udevadm question/request from yesterday ... the patch in https://paste.debian.net/1331047/ results in https://paste.debian.net/1331046/10:44
sicelo:-)10:44
siceloso we have a kernel event now on the bq2415x charger. problem for now is ... 'online' remains '0', so the event fires a bit too soon, i guess10:45
siceloany ideas? freemangordon perhaps ...10:45
siceloi'm tempted to do power_supply_get_property(...ONLINE..) just before calling power_supply_changed10:50
sicelofeels like a dirty hack, but the function is already getting property of CURRENT_MAX a few lines above where i added power_supply_changed, https://github.com/torvalds/linux/blob/master/drivers/power/supply/bq2415x_charger.c#L830-L83710:51
freemangordonsicelo: I would check how the other drivers use power_supply_changed()11:12
siceloi did, but might have missed something that' not too obvious, at least to me.11:14
freemangordonsicelo: hmm, https://github.com/torvalds/linux/blob/master/drivers/power/supply/bq2415x_charger.c#L84211:17
freemangordonI think wq should call power_supply_changed()11:18
sicelowhat's wq? or you mean bq? or something else?11:19
freemangordonworkqueue11:20
freemangordonbut, seems there is a bug here11:20
freemangordonif wq is already scheduled, that call on L842 will not re-schedule it for immediate execution afaik11:20
siceloyeah i don't understand workqueues at all :p11:22
freemangordonsee https://stackoverflow.com/questions/14965513/what-happens-when-kernel-delayed-work-is-rescheduled11:22
sicelobut will try to learn11:22
siceloi did find that if i insert/remove charger a number of times (or it's when i do it fast?), then ONLINE reporting starts to work11:23
freemangordonsicelo: try instead of calling power_supply_changed, to insert cancel_delayed_work_sync(&bq->work); before line 84211:27
freemangordonso it should look like:11:28
freemangordonschedule_delayed_work(&bq->work, 0);11:28
freemangordonoops, sorry11:28
freemangordonlike:11:28
freemangordoncancel_delayed_work_sync(&bq->work);11:28
freemangordonschedule_delayed_work(&bq->work, 0);11:28
freemangordonor maybe use cancel_delayed_work(), not cancel_delayed_work_sync()11:29
freemangordonwe don;t really want to wait in notifier function, IIRC it is in atomic context11:30
freemangordonso yeah     cancel_delayed_work it is11:30
sicelothanks. will try that11:34
sicelofreemangordon: we definitely need power_supply_changed() somewhere. isn't that what generates the uevent? i guess we should perhaps move it somewhere else ... question would be where?11:46
siceloi.e. we need power_supply_changed() in addition to the cancel_delayed_work()...11:47
siceloLesson #1: freemangordon is always right13:11
sicelommm, back to square 1 ... so i used the suggested way, without power_supply_changed. it worked perfectly for first charger insertion. now it's back to the old behavior (ONLINE property isn't getting updated)13:15
sicelomaybe i should add a small delay to schedule_delayed_work :-/13:22
Wizzupbtw, delta.chat looks kinda neat15:11
freemangordonsicelo: there might be more than one bug17:14
freemangordonalso, do you see a change to OFFLINE on charger disconnect?17:15
freemangordoncould be that some state var is not propery updated17:15
freemangordonalso, do you know what https://github.com/torvalds/linux/blob/master/drivers/power/supply/bq2415x_charger.c#L863 does?17:22
freemangordonwhat is this 'autotimer'?17:23
buZz /* enable/disable auto resetting chip timer */17:26
buZzfeels like a watchdog?17:26
freemangordonsicelo: I assume that ONLINE property is actually "mode" sysfs file, https://github.com/torvalds/linux/blob/master/drivers/power/supply/bq2415x_charger.c#L78017:26
freemangordonbuZz: could be17:26
sicelofreemangordon: so the ONLINE actually does work ... if you look in sysfs it shows online17:31
freemangordonwhich file is that? mode?17:31
siceloonline :-)17:32
freemangordonhmm, and what is this then? https://github.com/torvalds/linux/blob/master/drivers/power/supply/bq2415x_charger.c#L86317:32
sicelothe problem I'm trying to fix is ... when the event fires, it reports wrong online state. however if you manually check online state after the event, it's fine17:33
freemangordonok, with properly re-queuing wq, does it generate event when it shoud?17:33
freemangordon*should17:33
sicelotimer is like watchdog, yes. it's for ensuring the chip doesn't cause overcharging, etc.17:34
freemangordonsorry, I have no leste n900 around17:34
freemangordonyep, got the docs17:34
siceloyes, events are sent at the right time (with your wq change, or my original power supply changed)17:34
sicelojust it doesn't update the properties, so event is effectively useless17:35
freemangordonok, so more than one bug17:35
freemangordonwhich proerties are not updated when you say reading sysfs returns correct values?17:36
sicelothe ONLINE property is new (was added by me a couple of months ago). however, it's also not just ONLINE that's wrong in event, but also the STATUS ... reports Not Charging. so yeah, common cause, just not sure what source17:36
sicelosorry I'm on android phone so my typing is a little erratic ...17:37
freemangordonsure17:37
sicelobut have a look at the udevadm output ... you can see event for isp1704, with ONLINE=1. also event for bq24150a,17:38
sicelostatus says Not charging and ONLiNE=0 ... this is not correct17:39
freemangordonare you sure? shall it start auto charging? with no user interaction?17:39
siceloif you now manually check in syfs, you'll see online=1, and status charging17:39
freemangordonok, then someone is caching values17:40
freemangordonhmm, sec17:40
sicelowe somehow need a way to refresh all properties just before firing the uevent. t17:40
freemangordonmhm17:41
sicelouser interaction is user connecting charger. isp1704 reacts properly, and I'd say it's notifying bq24150 correctly, hence we get bq's uevent. but we seem to report default data in that uevent17:43
buZzmaybe the data was cached from previous queries?17:43
freemangordonmhm17:43
freemangordonand the question is who caches the data17:44
buZzmaybe just 'override data with known good' on the trigger?17:44
buZzso it can settle later17:44
buZzah well, that might bite something later17:44
* freemangordon checks what isp does17:45
siceloisp is the one doing charger detection. ba24 just charges when it sees power17:45
sicelo*bq2417:45
freemangordonI meant - what isp code is doing17:49
freemangordonsicelo: I don't see any cached data in bqxxx code17:51
freemangordonreading the properties reads registers17:51
siceloI don't think bq24's problem is caching, yes (because then it would be correct at some point), the behavior hints at just reporting some (uninitialized?) defaults17:53
freemangordonno, how is that17:53
freemangordonit reports nothing basically17:53
freemangordonlike, power supply core shall call bq2415x_power_supply_get_property() when it needs a value17:54
freemangordonmaybe put printks all over the place to see what happens17:55
sicelowill do17:56
sicelothe ONLINE true does lag by a few milliseconds BTW... so thay could also be it. the uevent fires before it changes17:57
freemangordonok, then schedule_delayed_work(&bq->work,  msecs_to_jiffies(100));18:01
freemangordoninstead of schedule_delayed_work(&bq->work,  0);18:01
freemangordonchange 100 as appropriate18:02
siceloyes, that was the last idea :-) will build in an hour or so and report back18:02
freemangordonok18:03
freemangordonI might not be around though18:03
sicelo[13:22]  sicelo: maybe i should add a small delay to schedule_delayed_work :-/18:03
freemangordonyeah18:04
freemangordonbut that would not work without cancel anyways ;)18:04
sicelothanks for looking into my pet problem :-)18:05
freemangordonnp :)18:05
freemangordonsicelo: see INPUT POWER SOURCE DETECTION in the doc18:10
freemangordonseems input source detection interval is 2 seconds18:14
freemangordonstill try with lower values first18:15

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