#
…

2021-11-28

00:33squags has quit [Ping timeout: 480 seconds]
00:45opticron has joined #asahi-dev
00:59squags has joined #asahi-dev
03:10PhilippvK has joined #asahi-dev
03:13phiologe has quit [Ping timeout: 480 seconds]
03:17squags has quit [Ping timeout: 480 seconds]
03:21squags has joined #asahi-dev
03:50kov has quit [Quit: Coyote finally caught me]
07:18user982492_ has joined #asahi-dev
07:18user982492 has quit [Read error: Connection reset by peer]
07:29the_lanetly_052___ has quit [Remote host closed the connection]
07:29the_lanetly_052 has joined #asahi-dev
07:43uartman_ has joined #asahi-dev
07:45uartman_ has quit []
07:47kov has joined #asahi-dev
08:13user982492_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
10:01the_lanetly_052 has quit [Remote host closed the connection]
10:01the_lanetly_052 has joined #asahi-dev
11:01Dcow has joined #asahi-dev
11:05Dcow_ has quit [Ping timeout: 480 seconds]
13:23j_eyso I put a branch here with my new SPI driver, if anyone is using the keyboard patches and wants to test it out https://gitlab.arm.com/linux-arm/jg-open/-/commits/spi/dev/
13:26j_eyjannau: would be nice if you could try it out at some point. I seem to still get data from the tracpkad even after pressing capslock. (I dont have x11 or anything, but I put a pr_err in applespi_got_data and im at least getting prints when using the tracpkad)
14:39svenj_ey: it's a bit weird that the irq is started by setting REG_CONFIG_IE_TXEMPTY but never stopped. does that happen automatically?
14:39svenand do you know why you need to read and then write REG_STATUS? does that ack an irq or something?
14:43j_eythe status thing is cargo culted from corellium, will add it to the list of things to check
14:43svenah.. true
14:43svendidn't see that
14:44j_ey(but i assumed it was an ack, so left it in)
14:44svenit might be. if it is i'd just add a comment about that
14:44j_eyI found that I don't even need to set: config |= REG_CONFIG_IE_RXRDY;, seems to work fine without it
14:45j_eysven: thanks, I had a local TODO for that, just didnt get round to it
14:46svenyou can probably even get rid of spi->clk then completely
14:47svenmaybe also add a check to apple_spimc_irq to ensure there actually is an xfer in progress and return IRQ_NONE otherwise
14:48svenlooks good otherwise!
14:49the_lanetly_052__ has joined #asahi-dev
14:49j_eyI had some IRQ_NONE stuff in a previous revision, will try bring it back
14:49the_lanetly_052 has quit [Read error: Connection reset by peer]
14:52j_eyneed bindings and runtime-pm, and I guess I can send it out..
14:53svenhrm, spi is also technically full duplex but i dunno how that works with the spi subssytem or that driver
14:53svenlooks like it always first receives everything before writing everything?
14:54j_eyif you mean the calls inside apple_spimc_transfer_one to apple_spimc_drain_rx and apple_spimc_fill_tx
14:54j_eyI think those can go in either order? maybe not even have to be there at all!
14:55svenSPI always sends and receives data at the same time
14:55j_eyright, but this fills the FIFO for rx and tx, i assume the controller then takes data from the FIFO and does the right thing
14:55svenbut how can it do that when you read first?
14:56sventhe controller needs to know what to send before it can receive anything
14:56svenit maybe works because at first the RX fifo will always be empty but then the call to apple_spimc_drain_rx is probably not required?
14:57sveni'd expect something like "fill TX fifo, start xfer, read from RX fifo"
14:57j_eyI see what you mean now
14:59the_lanetly_052__ has quit [Read error: Connection reset by peer]
14:59the_lanetly_052 has joined #asahi-dev
15:00j_eythe packets from the keyboard/touchpad are 256 bytes, so we know theyre never going to be sent in one go..
15:01sveni dunno how this hardware works but SPI is probably slow i'd expect that at first you just fill the TX fifo, start the xfer and then wait for an interrupt
15:02svenand then in the interrupt probably first see if you can read from the RX fifo and then try to fill the TX fifo again
15:02svenand the xfer would be complete if you read from the RX fifo and don't have any more bytes to send
15:03j_eythis seems to match up what I learnt about SPI from watching one Ben Eater video about it lol
15:04j_eyso yes, ive had a 30min video primer on SPI, I have no idea what Im doing :-)
15:08j_eythere is this bit REG_STATUS_COMPL.. but I think because I disable the interrurpts.. it seems to be set at the start of every new transfer
15:08j_ey*because I disable the interrupts after I know the transfer is complete
15:09kettenisI've defenitely seen that bit get set when the transfer is complete
15:10kettenisbut if you don't clear it, it will still be set at the start of the next transfer
15:11j_eyI think I can just ignore it, since Im keeping track of when the transfer is going to be cmplete anyway
15:13svendoes it not keep firing the interrupt if you keep that bit enabled?
15:14svenoh, no
15:14svenbecause you write to STATUS anyway in the irq handler and just ack everything
15:15j_eyi started to try write a spi.py.. but realised I didnt want to deal with getting the actual HID protocol right to properly get packets
15:16sventhat's why i never wrote nvme.py :D
15:17sventhough at this point it actually wouldn't have been that bad. for some reason i assumed that nvme was going to be much more complex than it actually is
15:17j_eysven: how is the rewrite going?
15:18svenworking on the rtkit part right now
15:18sventwo more weeks of work and my xmas vacation starts. i should be able to just get it done then :-)
15:19j_eyI have 3 more weeks left, although I guess it might get quite quiet
15:34jannauj_ey: I get "applespi spi0.0: Received corrupted packet (invalid message length 0 - expected 4294967286)" every second
15:34j_eyjannau: after the caps lock thing or?
15:34j_eyor just with my driver? :|
15:35jannaujust with your driver. no working keyboard
15:35j_eyoh yikes
15:36jannaujust with spi-apple-mc2 on top of my tree and the Makefile pointed to it
15:36jannauapplespi.c is identical
15:56j_eythe only way I could think of figuring it out is to just slowly add back in some of the register that corellium set, that I didnt
16:07j_eyjannau: are you willing to try figure out whats missing, if not maybe marcan or someone else can help
16:09marcanif I'm allowed to just rewrite everything... :>
16:11j_eyI just want to try get it upstream!
16:11j_ey(I mean, have any spi driver for it upstream)
16:12marcanspi seems to fit the "so simple figuring it out from scratch is probably easier than figuring out what corellium did wrong" bill so...
16:12j_eymarcan: also as long as you stream it :P
16:13marcanand it might give me an excuse to disassemble that second Mini if I need to pull out the scope
16:14marcanand besides, I'm twiddling my thumbs waiting for the PMGR/DT stuff reviews anyway
16:15j_eyits 1am japan, you can probably do it before 3am
16:15marcan(at least in this context; in global context I just came back from band practice today, I promise I'm not *literally* wasting my time :p)
16:15j_eylol sorry, I shouldn't encourage you
16:15marcanI'm tired enough after 4h of playing that I don't think that would happen today :p
16:17j_eynerdsnipe failed
16:24marcanooh, speaking of PMGR reviews... robh email spotted :)
16:25j_eyoverall it's pretty simple to have a basic SPI driver, you just need a to provide a transfer_one, and you return 0 from that if the transfer finished and 1 if there is more to send
16:25j_eyand in the irq hanlder once you sent everything you call spi_finalize_current_transfer
16:26marcanmakes sense
16:27j_eyyou also want master->use_gpio_descriptors = true;, so the core gets the cs from the DT for you
16:56ethanr has joined #asahi-dev
17:37jannauj_ey: sure, do you a suspicion to what it might be? just to be sure, it should work with an unchanged dtb?
17:37aleasto has joined #asahi-dev
17:39j_eyjannau: no I dont have any real suspicions.. but it seems like markan might take over, so Im just going to park it for now
17:39ethanr_ has joined #asahi-dev
17:42svenmy first bet is the rx/tx fifo handling
17:42svenit should really be fill N bytes to tx fifo, trigger xfer, read N bytes from rx fifo
17:45ethanr has quit [Ping timeout: 480 seconds]
17:45svenspi cannot receive without also transmitting something
17:46svenI don’t know what the hw does in this case
17:47j_eyjannau: you could try comment out the `apple_spimc_drain_rx` in apple_spimc_transfer_one
17:47svenbsd also doesn’t seem to use interrupts there and doing it that way might just work out
17:48kettenisit reads the fifo level register and the rx level should be 0 at the start of a transfer
17:50j_eyjannau: you could also try: writel_relaxed(0, spi->base + REG_CLKIDLE);, just before the writel_relaxed(REG_CLKCFG_ENABLE, spi->base + REG_CLKCFG);
17:50j_eyYou'd also need "#define REG_CLKIDLE 0x38"
17:51svenor maybe first start with a driver that polls and only add interrupts later
17:51jannaucommenting apple_spimc_drain_rx doesn't help, all adding all the register writes in _prepare/_clock except the draining doesn't fisx it either
17:53marcanI highly encourage everyone to work out how the hardware works first, over stumbling over drivers written by people who haven't done so :-)
17:53svenwhat bad does looks good fwiw. I’d start from there and get that working first
17:53svenalso what marcan said
17:54sven*bsd instead of bad :D
17:54marcanremember, Corellium do VMs that run *one* OS; they don't need to understand how the hardware works, they just need to make that OS happy. you can get away with a ton of nonsense/misunderstandings when you only need to make one piece of code work.
17:54j_eykettenis: im guessing the openbsd one hasnt been tested on pro/max?
17:55marcanit's been evident throughout this entire thing that they have never sat down and actually poked at any of this hardware to understand how it works; they just read macOS drivers
17:55j_eysven: I do have an older version w/o interrupts, but what marcan says etc :P
17:56svengetting polling to work is literally the first step in understanding how the hw works
17:56marcan(this is also why getting a m1n1 driver up first is a very good idea)
17:57marcan(that entire thing is *designed* as a testing and understanding framework precisely for this purpose!)
17:58marcanyou should be able to "single-step" through the hardware handling and observe the registers change and exactly what effect each action has (RegMonitor is your friend etc)
18:00marcanand yes, IRQ support should follow naturally from a polled implementation; the only thing that should need working out for IRQs to work is the flags/masks/whatever, everything else should come from an existing understanding of the hardware
18:00marcanthe rest of the IRQ complexity is in the kernel/driver side to handle things properly asynchronously, not in hardware understanding
18:01kettenisFWIW, I spent quite some time poking at the hardware writing that driver
18:01marcan^^ good reason to use the BSD driver as a reference to write a new Linux one then :)
18:01marcan(which is what I plan to do with WiFi btw)
18:02kettenismy understanding of how it works is still incomplete, but heck of a lot better than whoever write the corellium driver ;)
18:02marcanthere will always be gaps, but it's important to get the core concepts right or else the thing will fall apart even if it appears to work at first
18:02j_eyI mean, if someone wants to try the bsd driver on max/pro..
18:02marcanI would be very surprised if any of this changed on t6000
18:03marcanthey all have the same compatible and I think this probably also dates to the dark ages of iPhones
18:07kettenisOpenBSD won't run on the M1 pro/max until I have a working u-boot and a driver for the new AIC version
18:09kettenisspeaking about u-boot, its power domains framework is a bit dumb
18:09kettenisit is unaware of multiple devices depending on a power domain
18:10kettenisi'm considering to simply avoid turning off power domains in u-boot
18:11marcanas long as you don't create dependency issues, linux will power down everything that needs powering down anyway
18:11marcanand in general the default state is/should be things powered up (which is why driver probe functions are called after domains are powered up)
18:11marcanso it makes sense for a bootloader not to shut things down
18:12j_eykettenis: how come you re-read AVAIL inside the rx loop, but not the tx one?
18:15marcankettenis: is there much to do for u-boot on t6000? does it even use IRQs?
18:15marcanI imagine the DART/SART changes should be ~all it takes
18:15kettenisj_ey: I think I came to the conclusion that it would be pointless
18:16the_lanetly_052 has quit [Ping timeout: 480 seconds]
18:16marcanonce I catch up on getting decent versions of all these kernel bits and pieces merged, I want to finally put together a shippable boot stack, and I definitely want it to work on t6000 :)
18:17kettenismarcan: I need to add a t6000-specific memory map
18:17marcanoh, is that hardcoded?
18:17marcanaw, that's a shame
18:17kettenisbut we can have multiple memory maps
18:18kettenisand we might actually be able to build one from the DT
18:18marcanthat would be ideal
18:19kettenisthere are also some hardcoded memory addresses in the u-boot environment
18:19kettenisI think those are only used for the legacy boot path
18:19marcanhm, like where to load raw kernels and such?
18:20marcanwe could make m1n1 fill some of that stuff in if needed
18:20kettenisdon't think that'll help
18:22kettenisI'm focussing on upstreaming the missing drivers first
18:22marcansgtm, I imagine if I get to this point and you haven't gotten around to it yet, it shouldn't be a huge issue to take a crack at :)
18:38Dcow has quit [Ping timeout: 480 seconds]
18:53user982492 has joined #asahi-dev
19:15ethanr_ has quit [Quit: Leaving]
19:20loki_val has quit [Ping timeout: 480 seconds]
19:23squags has quit [Ping timeout: 480 seconds]
19:32squags has joined #asahi-dev
19:40squags has quit [Ping timeout: 480 seconds]
19:48squags has joined #asahi-dev
20:35aleasto has quit [Remote host closed the connection]
21:14ethanr has joined #asahi-dev
21:16ethanrDoes the m1n1 bootloader work with btrfs?
21:16ethanr has quit []
21:17ethanr has joined #asahi-dev
21:20j_eyethanr: m1n1 doesnt do any file system stuff
21:25DarkShadow44 has quit [Quit: ZNC - https://znc.in]
21:26DarkShadow44 has joined #asahi-dev
21:28Mary has quit [Quit: Ping timeout (120 seconds)]
21:28Mary has joined #asahi-dev
21:54alonetogether[m] has joined #asahi-dev
21:58ethanr has quit [Quit: Leaving]
22:00alonetogether[m] is now known as petermlyon[m]
22:05kettenisu-boot supports btrfs though
22:07jannauj_ey: the problem seems to be that RXDATA is always 0x00
22:08squags has quit [Ping timeout: 480 seconds]
22:10jannauexcept for reads and writebacks of 0x150, 0x154, 0x160, and 0x168 I don't see a difference in the register writes
22:11jannauI'll check next if cs is actually asserted
22:16squags has joined #asahi-dev
22:24squags has quit [Ping timeout: 480 seconds]
22:33squags has joined #asahi-dev
22:41squags has quit [Ping timeout: 480 seconds]
22:44kenzie41 has quit []
22:44kenzie41 has joined #asahi-dev
22:47kenzie41 has quit []
22:49squags has joined #asahi-dev
22:59Dcow has joined #asahi-dev
23:00yrlf has quit [Quit: The Lounge - https://thelounge.chat]
23:01jannauseems ok, although the common spi code actually does extra cs deassrt/assert requested by applespi
23:03jannaumaybe the clock programming between transfers vs. once per message and with cs already low causes problems
23:14user982492 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
23:16yrlf has joined #asahi-dev
23:18kettenisnot unlikely that the applespi driver needs some adjustments
23:18kettenisthe chip needs a delay after asserting cs
23:19kettenisand the corellium applespi diff is full of hacks to achieve that
23:21mrbatmanface[m] has joined #asahi-dev
23:22j_eythe spi core code has some code for delays after asserting cs
23:23j_ey(cs_hold, cs_active, cs_inactive)
23:24j_eyjannau: thanks again for looking into it more (if nothing else, will be useful info if markan ends up redoing the driver)
23:30ethanr has joined #asahi-dev
23:58ethanr has quit [Ping timeout: 480 seconds]
23:58squags has quit [Ping timeout: 480 seconds]
…