#
#asahi-dev · 2022-12-02 05:42
chadmed This is expressed by the driver as a byte array, with rightmost 16
#asahi-dev · 2022-12-02 05:42
chadmedV/ISENSE are 16-bit floats sent in a 32-bit TDM slot by the codec.
#asahi-dev · 2022-12-02 05:42
tpw_ruleshow does macos handle this? if it's just a function of V/ISENSE, why is a (perhaps configurable) model in the kernel not doing the math
#asahi-dev · 2022-12-02 05:39
chadmedim more worried about getting V/ISENSE out of the driver and making sure we can catch over temp situations in a controlled state at the moment
#asahi-dev · 2022-12-02 05:37
chadmedalso we should probably make sure it, yknow, actually does what it says on the tin first
#asahi-dev · 2022-12-02 05:36
chadmedand to me it seems silly to implement something that unorthodox in the kernel to cover a failure mode with such a slim possibility
#asahi-dev · 2022-12-02 05:34
chadmeda quick search hasnt revealed anything similar
#asahi-dev · 2022-12-02 05:34
chadmedi guess with a keepalive signal its just a matter of the implementation difficulty and whether or not such things are tolerated in the kernel
#asahi-dev · 2022-12-02 05:32
dsharshakovI mean running another instance as a child process
#asahi-dev · 2022-12-02 05:32
dsharshakovDoing own daemon-in-daemon supervision can help a bit, but that seems to be hackier than a ping ioctl.
#asahi-dev · 2022-12-02 05:31
dsharshakovSIGKILL cannot be handled rly. Well, then in typical scenario systemd restarts the thing. But there're edge cases...
#asahi-dev · 2022-12-02 05:27
chadmedwe can handle all signals
#asahi-dev · 2022-12-02 05:14
dsharshakovWell, users need to kill it with segkill to avoid proper shutdown, Yes?
#asahi-dev · 2022-12-02 05:14
dsharshakovI see the point
#asahi-dev · 2022-12-02 05:13
dsharshakovYes, oomd and early earlyoom send terminate, but what about kernel
#asahi-dev · 2022-12-02 05:13
chadmedso theres like 0.00000000001% chance that we enter a state where a keepalive would be useful
#asahi-dev · 2022-12-02 05:13
chadmedwe can handle sigterm
#asahi-dev · 2022-12-02 05:13
dsharshakovIdk if kernel oom killer will warn before killing
#asahi-dev · 2022-12-02 05:13
chadmedso the only way that wouldnt happen is if its killed by segfaulting _itself_ or ooming
#asahi-dev · 2022-12-02 05:12
dsharshakovAnd if it ooms oom service likely will send a sigterm first
#asahi-dev · 2022-12-02 05:12
chadmedif the daemon is killed by any means we already have our panic and fail handlers that would theoretically do the IOCTL to put them into safemode
#asahi-dev · 2022-12-02 05:12
dsharshakovYes
#asahi-dev · 2022-12-02 05:12
chadmedhell with the IRs alone the speakers are impossible to blow up, so not only does the daemon have to fail but you have to be accessing it via the raw alsa device AND doing so at sustained full volume
#asahi-dev · 2022-12-02 05:11
dsharshakovWell, not insisting. The overall approach seems quite nice engineered, looking forward to seeing some info about it working
#asahi-dev · 2022-12-02 05:11
chadmedagain though, its a case of this only _ever_ being a possible failure mode in a vanishingly small set of circumstances
#asahi-dev · 2022-12-02 05:10
dsharshakovThe ping is not overengineering imo. This way to destroy the speakers user has to know how to call ping ioctls, that unlikely coexist with stupid actions
#asahi-dev · 2022-12-02 05:09
chadmedand then someone will come along and say "ok but what if they use ssh"
#asahi-dev · 2022-12-02 05:09
chadmedwe could run this treadmill all day and all night and end up with a 30MB binary that has a firewall built into it to stop people breaking in via telnet to run aplay -D hw:0,1
#asahi-dev · 2022-12-02 05:08
chadmedyeah but do you see my point
#asahi-dev · 2022-12-02 05:08
dsharshakovWell, if it's not pinging kernel enters safe mode then
#asahi-dev · 2022-12-02 05:07
chadmedyeah and what if evil ninjas sent by tim apple break into my house and killall speakersafetyd while im not looking? should speakersafetyd have an aperture science turret built in to it?
#asahi-dev · 2022-12-02 05:07
dsharshakovAnd some issues which lead to us getting garbled buffers might exist really if some bug happens in the kernel driver
#asahi-dev · 2022-12-02 05:06
dsharshakov* daemon receiving a signal from layer8 which truly believes you tossed some malware to them. How could speakersafetyd be useful for my computer hmmm
#asahi-dev · 2022-12-02 05:05
chadmedits more a case of how much overengineering do we want to do to prevent an edge case of an edge case of an edge case (someone not using a DE on the laptops -> the daemon crashing -> someone blaring bass boosted amogus trap nightcore remix at full volume)
#asahi-dev · 2022-12-02 05:05
dsharshakovAnd yes, it might be useful to check whether hw doesn't give us obvious nonsense such as high-entropy data or constants (or other failure modes). We mustn't claim it's fine by measurements but raise an alarm
#asahi-dev · 2022-12-02 05:03
chadmedtheres a PR in AsahiLinux/linux that makes power management work for the tas codecs, so we dont have to worry about the hardware doing undefined stuff
#asahi-dev · 2022-12-02 05:03
dsharshakovSuspend can be a corner case for ALSA, btw. In PW we have quite some bugs of hardware not working after resume (some are caused by drivers though). So if daemon is dead after suspend (alsa bugged out, or device resumed badly and only gives 00s or otherwise garbage) it shouldn't be considered adequate
#asahi-dev · 2022-12-02 05:00
dsharshakovchadmed: "how would that play out with suspend etc?" Block immediately after suspend and unlock when daemon thaws and starts working. We shouldn't let 1% chance (likely bc of user's own stupidity) to bite someone
#asahi-dev · 2022-12-02 04:30
chadmedmy main concern apart from that anyway was the maths for the actual safety stuff, but i cant really test any of that until the driver has V/ISENSE support anyway
#asahi-dev · 2022-12-02 04:24
chadmedsomething has gone very wrong if any of the values we get back from the CTL interface are bad, we cant guarantee safety for machines we dont have the config data for, etc
#asahi-dev · 2022-12-02 04:23
chadmedit makes sense to me in this case since (imo) we should put the speakers in safe mode and die if we encounter any error
#asahi-dev · 2022-12-02 04:20
tpw_rulesthere is also the RAII approach. i admit i might be misleading you on the panic hook. i think about it a decent amount in embedded rust but maybe it's not a big thing in desktop rust now that i poke a bit
#asahi-dev · 2022-12-02 04:17
tpw_rulesunwrap_or_else will call a function on None and return that functions value but obviously if it panics or std::process::exit()s then that won't happen
#asahi-dev · 2022-12-02 04:17
chadmedyeah that was the missing piece, didnt realise you could tell panic! to do things
#asahi-dev · 2022-12-02 04:15
tpw_rulesthey do unconditionally panic on failure, but imo that's what you should hook into if you are just going to complain and die
#asahi-dev · 2022-12-02 04:14
chadmedi was under the impression that they just unconditionally panic on failure and i wanted to handle whatever alsa-lib returned in a controlled manner
#asahi-dev · 2022-12-02 04:13
tpw_ruleswhy would you want to avoid them?
#asahi-dev · 2022-12-02 04:13
chadmedah see i was trying to avoid unwrap()s and expect()s thinking it would be better to explicitly handle each Option and Result from the alsa lib bindings but if thats acceptable then that works and is less gross
#asahi-dev · 2022-12-02 04:12
tpw_rulesthe || introduces a lambda which is only called if get_integer returns None to avoid the (likely negligible) cost of formatting the string in the happy path
#asahi-dev · 2022-12-02 04:11
tpw_ruleslooked it up and you would want let val: i32 = self.level.val.get_integer(0).unwrap_or_else(|| panic!("level of {} is readable", self.drv))

plus ›