#
…

2021-08-01

00:16alyssapipcet[m]: I already started thinking through structuring kernel driver
00:23yuyichao has joined #asahi
00:52alyssaHmm if I start working on dcp code am i going to be interrupted before i can get anything done
00:57alyssaohh I have dcplog.txt which gives me references for unit testing the packing code, nice
00:58marcanalyssa: tx/rx are the same, the code is confusing because it plays with the inbuf/outbuf offsets
00:58marcanthe packets are all tag,inlen,outlen,inbuf,outbuf
00:59marcanin the same place
00:59alyssaah, derp, thanks
00:59marcanthe other side will issue an ack packet when the call is complete (no offset in the ack, you need to keep track of the stack and ack the most recent call in that channel) which means outbuf is populated
00:59alyssa(Re offsets advancing forever, I assume a real driver just uses a ringbuffer)
01:00marcanhm? no, it's a stack
01:00alyssagit commit -am wt
01:01marcanall commands are at offset 0 until a callback happens and a command gets issued during the callback
01:01marcanthen that goes after, then gets popped, back to 0
01:01marcanthe other weird thing is the contexts
01:01alyssaohh. wild, ok.
01:01marcanAP->DCP commands issued during a callback use the CB channel in the mailbox, not CMD, even though the *buffer* is still the same as for CMD
01:02marcanso there are, in effect, 3 contexts
01:02marcanplain commands, OOB commands (another thread), and async notifications
01:02* alyssacoughs "overengineered"
01:03marcanplain commands chain like >CMD <CB >CB <CB >CB <CB (and use a pair of buffers, one for each direction)
01:03marcanOOB commands are the same, but different pair of buffers and OOBCMD <OOBCB >OOBCB <OOBCB etc
01:03marcanand then async are just notifications that come in from DCP at any time unsolicited
01:04alyssar00d of it
01:04* alyssaputs up "no soliciting" sign
01:04marcanalso outbuf includes the retval from the call at the end
01:05marcan(if not void)
01:06alyssahow are InPtr and OutPtr encoded?
01:06marcanthose just add a bool nullable flag
01:06marcanInPtr only exists in inbuf, OutPtr only exists in outbuf (null flag only in inbuf)
01:07marcanInOut exists in both
01:07marcanall arrays/etc are fixed length
01:07marcanand the struct is static, so the space is always allocated regardless of whether the pointer is null
01:08marcanthere is also an array-of-inptrs in the swap struct, for the surfaces, which is encoded as 4 buffers and also adds 4 null flags
01:08marcanso it's just an InPtr for each element of the array, with its own null flag
01:08marcan(equivalent to 4 discrete params, which is how I did it before I added support for this a couple streams ago)
01:10marcanthe Ptr thing is a bit of a misnomer, it really should be called Nullable or something, but that's long
01:11marcanby default structs/arrays can be passed without that, which just means no nullable flag
01:11marcanthe python side defaults to in for those, but they can be inout or out too
01:11marcanthen they just can't ever be null
01:11marcanobviously for out args they'd still be a pointer at the prototype level
01:11marcanI assume much like us they have some kind of database with the ABI to generate these bindings and specify what's nullable and in/out beyond the C++ prototype
02:27phiologe has joined #asahi
02:31PhilippvK has quit [Ping timeout: 480 seconds]
03:01skipwich has quit [Remote host closed the connection]
03:03robinp has joined #asahi
03:10alyssamarcan: Ah , got it.
03:10alyssaBetter question, uhm, are there actual DART VA pointers in any of the commands?
03:11alyssaI assumed so by the name pointer but if it's just a m1n1-ism for nullable that's a lot easier :)
03:24alyssadcplog.txt is making a whole lot more sense now :-)
03:24alyssa(Knowing that ptr actually means nullable, and that macOS uses 0xAA for padding instead of 0x00, probably for easier debug)
03:27alyssaEr. Not consistently. Boo.
05:08marcanalyssa: no, there are no meaningful pointers passed anywhere at the dcpep level
05:08marcanI see kernel pointers sometimes, which I assume are just garbage/identifiers and not meaningful to DCP
05:08marcanthe only dva is the shared memory base
05:09marcanwhich is 0xf_00000000 | the DART address
05:09marcandvas seem to all have that form, I presume that range is where the DART gets mapped from an ASC's perspective
05:09marcanactually I think I saw that mapping explicitly defined in the DAPF (the thing after the DART)
05:09marcanalong with direct maps of some MMIO
05:10marcanthe "ptr" was intended to mean pointer at the C++ prototype level, not the IPC level :)
05:10marcanyou could consider the non-nullable ones references instead of pointers, if you're playing the C++ game, and then my naming scheme almost makes sense :p
07:59aleasto has joined #asahi
08:12MTecknologymarcan: How come alyssa hasn't fixed all remaining bugs yet?
08:12MTecknology(ftr - I'm joking, at least half of the backlog is absolute gibberish to me)
08:26Andalu30 has joined #asahi
08:29sveni also kinda expected a fully working linux driver by now
08:29svenmarcan: fwiw, there's a DAPF behind the AES engine that we can configure if you want to play with it and confirm that theory
08:32pipcet[m]alyssa: excellent, thank you very much for working on this. I'll just set myself up right here and ask you "are we done yet" every five minutes or so ;-). Have you decided whether you're going to use the mbox protocol, remoteproc/rpmsg, or roll your own yet?
08:36svenwe briefly talked about that. we'll have to discuss that with someone who knows the kernel much better than we do
08:37svenmailbox certainly makes sense for the very low-level protocol (think send/recv message). the more interesting question is where the common rtkit stuff should be implemented
08:43pipcet[m]can we combine the two approaches? use a mailbox for, uhm, the mailbox, and implement a remoteproc on top of that?
08:46svensure, but remoteproc might still not be a good fit because it does a lot of heavy lifting for loading firmware
08:47sveni've also seen something where mailbox was just the mailbox and then there were just some exported functions in drivers/soc or drivers/firmware for talking to that specific mailbox
08:52pipcet[m]the firmware-loading part seem optional and reasonably independent, to me, and the rest of the API fits very well, I think...
08:54bps has joined #asahi
09:05svenit's a little bit more complex. rpoc_boot e.g. usually really wants to load a firmware, but that can be worked around
09:05svenit's really something we need to discuss with someone who has more experience with these subsystems :)
09:23bps has quit [Ping timeout: 480 seconds]
09:26bps has joined #asahi
09:37kenzie has quit [Quit: The Lounge - https://thelounge.chat]
09:39chadmedpipcet: afaict rproc_boot expects a valid ELF and will return not 0 if it doesnt get one unless the remote has already been initialised and given a handle by the subsystem
09:39chadmedbut like sven said its probably something worth discussing with rproc gurus
09:41pipcet[m]we're not booting the coprocessors, we're just attaching to them :-). If sven has plans to discuss this with the right people that should happen, though.
09:42aleasto has quit [Quit: Konversation terminated!]
09:44chadmedactually yeah true, we can get an rproc handle using the device tree and thus rproc_boot should just return 0 when it sees that the processor is on and ready to go
09:47svenpeter[m]We could just initialize the state to _DETACHED and then it won’t try to boot the thing
09:47svenpeter[m]But yeah, something I need to discuss with people who actually know these subsystems :)
09:48svenpeter[m]Because we need to do something similar to „boot“ (the whole syslog,… stuff)
09:55kenzie has joined #asahi
10:08marcansven/alyssa: I can take a look at the kernel side if you want, or leave it up to you, your choice ;)
10:08marcanif you all want to take it completely off of my hands, I'll go look at the installer and GPU ASC instead :p
10:23bps has quit [Ping timeout: 480 seconds]
10:29svenpeter[m]I’m not gonna touch DCP
10:30svenpeter[m]But the stuff we discussed above kinda applies to everything that runs RTKit
10:32atom1[m] has left #asahi [#asahi]
10:32bps has joined #asahi
10:55Andalu30 has quit [Remote host closed the connection]
10:57svenpeter[m]Happy to get your opinion what should be a mailbox, what should be a remoteproc and what should be something entirely else
11:00Andalu30 has joined #asahi
11:00Andalu30 has quit []
11:01Andalu30 has joined #asahi
11:13bps has quit [Ping timeout: 480 seconds]
11:15bps has joined #asahi
11:21pipcet[m]sven: you can forget about the "persistent bad state" issue, by the way. Not only does your driver continue to work in that state, it actually cures it for the buggy driver, too.
11:23pipcet[m](I think I know what it is but that seems irrelevant now :-) )
11:24marcanlet me guess: not handling syslog messages, which only happen on an unclean shutdown, making it wedge
12:09svenpeter[m]I don’t shut it down cleanly yet either fwiw
12:18bps has quit [Ping timeout: 480 seconds]
12:35Andalu30 has quit [Ping timeout: 480 seconds]
12:51alyssamarcan: If svenpeter[m] finishes the ASC driver I think I can fudge my way through v1 of the DCP driver
12:51alyssawould love to see AGX.kext r/ed in parallel ;-)
12:51alyssa(and that's the linux driver I really want to work on.. dcp is a warmup)
12:57alyssaHmmm, so I have a fair bit of uninterrupted time today
12:57alyssaA) Do my homework
12:57alyssaB) Write a DCP client in one crazed shitting
12:58alyssaC) Write gay fanfiction
12:58chadmedyou shouldnt write drivers on the toilet, no lumber support
12:58frode_0xa has quit [Quit: leaving]
12:58alyssaD) All of the above
12:58alyssaE) None of the above
12:58alyssaF) One of the above
12:58alyssaG) Two of the above
12:58chadmedC, then B, then A
12:58chadmedpriorities are important after all
12:59brentr123[m]I recommended c ;)
12:59chadmedA can be safely omitted
12:59alyssa"oh, DCP, I love you" "my fair AGX, how I love you too" "let's get married!" "agxcp forever!"
13:00alyssa(I don't know what gender DCP and AGX are but I'm pretty sure the ship is gay regardless.)
13:02chadmedcan they send dirty postcards to each others' mailboxes?
13:29alyssasvenpeter[m]: how does the linux kernel not freeze all the time
13:29alyssawith blocking i/o in driver threads
13:36bps has joined #asahi
13:38amwalyssa: Inspired by your tom's hardware article added some details on booting arm64 rootfs to https://github.com/AsahiLinux/docs/wiki/SW:Linux#root-as-usb-drive
13:41alyssaamw: Looks right 👍
13:42alyssaexcept for the fact there's a tom's hardware article about it
13:42alyssatruly baffling.
13:43alyssaif you have an existing arm64 debian machine, it's just `debootstrap buster debinst-buster http://ftp.au.debian.org/debian/`
13:47svenalyssa: atomic vs. process context
13:49alyssasven: 👂
13:49svenso for DCP you'll need to hack the DART driver to make it work with the pagetable apple allocated :(
13:49alyssathanks for volunteering
13:49j_eysven: why?
13:50svenj_ey: because that DART is locked by the time we get control
13:50svenyeah :/
13:53svenalyssa: very short version: in atomic context (e.g. interrupt handles or inside spin_lock_irqsave) you're not allowed to sleep and if you block in there you can easily hang everything. in process context you can sleep while waiting for something and the kernel will schedule something else to run
13:55ketteniswon't the kernel pan^H^H^Hoops when you try to sleep in such a critical section?
13:55svendon't think so. i've done that and it worked
13:55sven(for some value of worked)
13:56sven(but then again, i've also made everything hang from process context so maybe don't list to me too much :-))
13:56sven*listen
13:57svenalyssa: and for the mailbox part: just use the mailbox api for now. whatever ends up the correct solution has to be similar either way.
13:57sveni'm not very happy with the current driver i have for that but it'll work
14:01bps has quit [Ping timeout: 480 seconds]
14:03Andalu30 has joined #asahi
14:06Raqbit8 has joined #asahi
14:12Raqbit has quit [Ping timeout: 481 seconds]
14:12Raqbit8 is now known as Raqbit
14:12pipcet[m]there's CONFIG_DEBUG_ATOMIC_SLEEP
14:19bps has joined #asahi
14:28bps has quit [Remote host closed the connection]
14:28bps has joined #asahi
14:36apetresc has quit [Ping timeout: 480 seconds]
14:40Andalu30 has quit [Remote host closed the connection]
14:42Andalu30 has joined #asahi
14:43bps has quit [Ping timeout: 480 seconds]
14:47Andalu30 has quit [Read error: Connection reset by peer]
15:07bps has joined #asahi
15:39roxfan has quit [Ping timeout: 480 seconds]
15:49alyssasven: 👍
16:10robinp_ has joined #asahi
16:12robinp has quit [Ping timeout: 480 seconds]
16:12bongotrumma has joined #asahi
16:29robinp has joined #asahi
16:34robinp_ has quit [Ping timeout: 480 seconds]
16:35apetresc has joined #asahi
16:52bongotrumma has quit [Ping timeout: 480 seconds]
16:52bps has quit [Ping timeout: 480 seconds]
16:58zimsneexh has joined #asahi
16:58bongotrumma has joined #asahi
17:00zimsneexh has quit []
17:02bps has joined #asahi
17:32bongotrumma has quit [Ping timeout: 480 seconds]
17:33bongotrumma has joined #asahi
17:59bongotrumma has quit [Ping timeout: 480 seconds]
18:14bongotrumma has joined #asahi
18:44bongotrumma has quit [Ping timeout: 480 seconds]
19:01quarkyalice has joined #asahi
19:10apetresc has quit [Ping timeout: 480 seconds]
19:46pinskia has quit [Remote host closed the connection]
19:48pinskia has joined #asahi
20:15bongotrumma has joined #asahi
20:33bongotrumma has quit [Ping timeout: 480 seconds]
20:34bongotrumma has joined #asahi
20:52bongotrumma has quit [Quit: WeeChat 3.2]
21:08norwoodites has joined #asahi
21:13pinskia has quit [Ping timeout: 480 seconds]
21:27quarkyalice has quit [Ping timeout: 480 seconds]
21:28quarkyalice has joined #asahi
21:35apetresc has joined #asahi
21:46norwoodites is now known as pinskia
22:00yrlf has quit [Quit: The Lounge - https://thelounge.chat]
22:01yrlf has joined #asahi
…