#
✕ nick:marcan
#asahi · 2022-10-24 15:09
marcannormally PSCI would be implemented in an EL3 supervisor, but these chips don't do EL3
#asahi · 2022-10-24 15:09
marcan(since that's how the kernel runs to support KVM)
#asahi · 2022-10-24 15:09
marcanit's hypervisor privilege (EL2)
#asahi · 2022-10-24 15:09
marcanyes, but because the kernel is the same privilege, there is no change
#asahi · 2022-10-24 15:08
marcansince there is no higher privilege to go to that we can use
#asahi · 2022-10-24 15:08
marcani.e. we're making a standard for PSCI that does not involve a privilege change
#asahi · 2022-10-24 15:08
marcanUEFI runtime services -> just jump into UEFI
#asahi · 2022-10-24 15:08
marcanhypervisor -> HVC instruction
#asahi · 2022-10-24 15:08
marcansupervisor -> SMC instruction
#asahi · 2022-10-24 15:07
marcanthe issue is how PSCI calls are made
#asahi · 2022-10-24 15:07
marcanthis does mean cpuidle will only work when booting via u-boot (which is the normal way, but not how I usually boot during development), but that's not a big deal
#asahi · 2022-10-24 15:07
marcanand then u-boot exposes it over UEFI
#asahi · 2022-10-24 15:06
marcanthe plan is to have an ad-hoc hook from u-boot back into m1n1 (linux doesn't have to care about this) so m1n1 can implement the actual PSCI handler
#asahi · 2022-10-24 15:06
marcanu-boot provides the UEFI bit
#asahi · 2022-10-24 15:06
marcanyes
#asahi · 2022-10-24 15:03
marcanand the only way to keep both things is NV
#asahi · 2022-10-24 15:03
marcanwhich is obviously undesirable
#asahi · 2022-10-24 15:03
marcanwe could use normal virtualization but then that would break virtualization in linux
#asahi · 2022-10-24 14:57
marcanm1n1 implements a research hypervisor but I am not adding nested virt to it so people can do crazy stuff like this :p
#asahi · 2022-10-24 14:56
marcanbut it's a terrible idea because first it would have to be M2+ only, and second because nested virt is stupidly complex to implement and has nontrivial overhead
#asahi · 2022-10-24 14:56
marcanPSCI supports hypervisors, that much would just work
#asahi · 2022-10-24 14:54
marcannot sure if something "magic" happens at that point or if it's just a consequence of the design that "S3" isn't much more than deep WFI as far as the CPUs are concerned
#asahi · 2022-10-24 14:53
marcanalso this is part of how to enter "S3" (AIUI you set things up to go into proper sleep, then deep-WFI all cores)
#asahi · 2022-10-24 14:53
marcanlinux probably prefers to control it itself
#asahi · 2022-10-24 14:53
marcanmacos actually just lets the cpus do some heuristic magic and decide what idle state to enter themselves
#asahi · 2022-10-24 14:53
marcanand presumably it has higher latency
#asahi · 2022-10-24 14:52
marcanyes, it's just another idle state, the only difference is it loses the GPR contents except SP/PC, so you need a save/restore around the wfi
#asahi · 2022-10-24 14:52
marcanit just needs a driver for it and the only upstream-approved driver for this on arm64 is psci
#asahi · 2022-10-24 14:52
marcanyes, the kernel already knows how to do idle states
#asahi · 2022-10-24 14:51
marcanbut cooking up such a standard is preferable to an ad-hoc cpuidle driver, since other platforms can use it (I think there's at least one other with a similar problem)
#asahi · 2022-10-24 14:50
marcanso we need a third option, the idea is cooking up a standard for PSCI-over-UEFI-Runtime-Services
#asahi · 2022-10-24 14:50
marcanand doing it in a hypervisor would break KVM since it'd need nested virt which M1 does not support (M2 does) but it's also a terrible idea
#asahi · 2022-10-24 14:50
marcanand M* chips do not support supervisors
#asahi · 2022-10-24 14:50
marcanthe problem is standard PSCI requires the existence of a supervisor or hypervisor
#asahi · 2022-10-24 14:49
marcanno, there is no PSCI
#asahi · 2022-10-24 14:49
marcan(boost meaning 3.2GHz instead of 3GHz, not exactly a massive difference)
#asahi · 2022-10-24 14:49
marcanbut that will automatically work once deep idle works
#asahi · 2022-10-24 14:48
marcanyou don't get boost states as a consequence of the deep idle thing, since they require it
#asahi · 2022-10-24 14:48
marcancpufreq does work fine, I just sent v3 for upstreaming a few hours ago (that has worked fine for like a year now, just not upstream because it took a while to figure out the "right" way to do it)
#asahi · 2022-10-24 14:46
marcansince it's all supposed to use PSCI
#asahi · 2022-10-24 14:46
marcanbecause upstream will reject custom cpuidle implementations on arm64
#asahi · 2022-10-24 14:45
marcanand for technical reasons we need to cook up a custom PSCI interface because these machines can't support standard PSCI
#asahi · 2022-10-24 14:45
marcanimplementing it in Linux is trivial, but not upstreamable
#asahi · 2022-10-24 14:45
marcanit's just the second deep idle state that is not, and the only reason it isn't is bureaucratic
#asahi · 2022-10-24 14:44
marcanall that is supported properly already
#asahi · 2022-10-24 14:44
marcanand the next big improvement will probably be when we get around to implementing the CPU deep idle thing
#asahi · 2022-10-24 14:44
marcanso with that, M1 Air idle time is 18h; with DCP merged in, 30h.
#asahi · 2022-10-24 14:44
marcanyes
#asahi · 2022-10-24 14:43
marcans2idle just means some hardware shuts down and your machine is quiesced into being idle
#asahi · 2022-10-24 14:43
marcan"S3" is technically supported by the hardware but not very useful on modern SoCs because they save power by default

plus ›