#
✕ nick:marcan
#asahi · 2021-04-06 13:31
marcankettenis_: right?
#asahi · 2021-04-06 13:31
marcanarnd: apparently these need to be applied after PCIe reset, so doing it in m1n1 means the kernel isn't allowed to do a reset
#asahi · 2021-04-06 13:30
marcanbut if we need model-specifity there is probably some saner way of describing that than a blob of pokes
#asahi · 2021-04-06 13:29
marcanI need to check all 3 models and compare
#asahi · 2021-04-06 13:29
marcanit depends on what they do
#asahi · 2021-04-06 13:29
marcansuspend-to-ram will be a whole separate can of worms, but I don't want to think about that until we have most drivers working to begin with and I can start testing real power consumption
#asahi · 2021-04-06 13:28
marcanbut, I want to know how to approach this if it comes up again
#asahi · 2021-04-06 13:28
marcanit's init stuff; right now one fairly short set is the PCIe root port configs that need to be set after a PCIe reset, and I think for *that* one we can turn it into higher-level driver logic
#asahi · 2021-04-06 13:26
marcanit might be possible to just hardcode this stuff in the kernel like AMD for some cases, but that loses generality (and means upstreaming, to some extent, blobs; copyright-wise I don't think register lists have an issue, but it seems a waste not to use the ones in the Apple device tree, which would be more general and avoid the distribution question entirely)
#asahi · 2021-04-06 13:25
marcanI want to avoid most of it by initializing in m1n1, but I think some of it will have to happen in the kernel
#asahi · 2021-04-06 13:25
marcanbasically we have data like this to pass through: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/amdgpu/cik.c#n180
#asahi · 2021-04-06 13:25
marcanrobher: how do you handle things like bootloader-trained memory timing configs? that's a similar kind of issue
#asahi · 2021-04-05 16:48
marcanand e.g. I would *love* to understand anything related to axi, memory transactions, etc since I bet we might end up having to fix bugs by tweaking stuff there
#asahi · 2021-04-05 16:46
marcanheck, for all I know some of this stuff might already have sensible DT bindings in linux; configuring root port settings sounds like something a lot of socs would need
#asahi · 2021-04-05 16:45
marcantrying to prevent a situation where we end up passing tunable nonsense in the DT that then in the future can go away as we understand things better, if at all possible
#asahi · 2021-04-05 16:45
marcansince m1n1 gets the tunables from iBoot anyway, we can just apply them; but I'll be very happy if whatever we need to pass on to the kernel is understood more properly
#asahi · 2021-04-05 16:44
marcanbut I bet for stuff above that level we can, with enough effort, work out what's going on
#asahi · 2021-04-05 16:44
marcanof course some stuff will be magic (e.g. almost certainly the fused bits), anything touching the PHY especially
#asahi · 2021-04-05 16:44
marcanthings that do very specific, sensible things, that we might even want to configure or drive at a higher level
#asahi · 2021-04-05 16:43
marcannot actual "magic" stuff
#asahi · 2021-04-05 16:43
marcanI get the feeling Apple is using this whole "tunables" business, in part, as a lazy "eh, this is the init sequence, and we can't be arsed to put it in xnu"
#asahi · 2021-04-05 16:43
marcanand drop that tunable entirely
#asahi · 2021-04-05 16:43
marcanit might be something completely bog standard or representable at a higher level, that we can turn into sensible driver logic
#asahi · 2021-04-05 16:43
marcankettenis_: if you have time, you can see if the ones that don't stick can be described in terms of standard caps, and what they do exactly
#asahi · 2021-04-05 15:24
marcanthough for config space, some of it might be totally bog standard stuff we can reverse engineer and handle at a high level sanely
#asahi · 2021-04-05 15:24
marcanone issue is that we don't know what most of these registers are, so we can't come up with nice symbolic names for them
#asahi · 2021-04-05 15:24
marcanI'm not sure if this is common; I know nvidia used to do hideous stuff along these lines in their L4T tree
#asahi · 2021-04-05 15:23
marcanrobher: how do you want to handle this kind of thing? tl;dr Apple passes lists of register addr/mask/values in their devicetree. so far the ones we care about seem to be static for any given device, not sure about if they change between devices using the same soc (hopefully not? should check that)
#asahi · 2021-04-05 15:07
marcanso there is also the option of just embedding them in the kernel driver, which is how most other drivers do this, though obviously that is less flexible
#asahi · 2021-04-05 15:07
marcanthough those aren't the fuse ones, right?
#asahi · 2021-04-05 15:07
marcansounds like we're going to have to put at least *some* tunables in the DT then
#asahi · 2021-04-05 14:57
marcanright
#asahi · 2021-04-05 14:48
marcangoing to look at PRs now :)
#asahi · 2021-04-05 14:47
marcanit's nontrivial driver logic where I start worrying
#asahi · 2021-04-05 14:47
marcanand yeah, that's basically fine; I'm not too worried about general poke-bits stuff and the clocks (which sven is also looking at) seem pretty simple afaik?
#asahi · 2021-04-05 14:46
marcankettenis_: this is for m1n1, right?
#asahi · 2021-04-05 07:05
marcansince they are not interacting with the community, and we cannot get any feedback on their code, it seems best to just work on it from scratch with an upstreaming mentality
#asahi · 2021-04-05 07:04
marcana lot of their code doesn't meet upstreaming standards, and I also don't know how it was developed; I would like some answers about their development methodology before using any of it directly, but all we've gotten so far is silence
#asahi · 2021-04-05 07:04
marcanour goal is to upstream support for the M1 into the official kernel, but corellium doesn't seem to be interested in that. they haven't replied to any of the upstreaming e-mail threads.
#asahi · 2021-04-05 06:59
marcanwe've been working on defining the base support, bindings, etc and upstreaming that first; expect a lot of drivers to follow very quickly now that that's almost done :)
#asahi · 2021-04-05 06:59
marcannvme is coming soon
#asahi · 2021-04-05 06:48
marcankettenis_: re those fuse tunables, it's just reading some fields and poking them into registers, right? I think it's fine to use the table corellium has for that as a reference
#asahi · 2021-04-05 06:41
marcan(e.g. some stuff about counters 8/9)
#asahi · 2021-04-05 06:41
marcanwith some details added by me by poking around that were missing
#asahi · 2021-04-05 06:41
marcanthat info is actually from the XNU source code
#asahi · 2021-04-05 06:28
marcanthe details are still fairly unknown
#asahi · 2021-04-05 06:27
marcanwe have documented some registers: https://github.com/AsahiLinux/docs/wiki/HW:ARM-System-Registers#performance-counter-registers
#asahi · 2021-04-05 05:59
marcan*unfortunately
#asahi · 2021-04-05 05:59
marcanJaehyuk[m]: M1 implements apple-proprietary PMCs, not the standard ARM PMU, unfortunatelty
#asahi · 2021-04-05 03:00
marcanhttps://mrcn.st/p/QC01QNKq that should do it

plus ›