2022-11-30
00:40tenkuu has joined #asahi-dev
01:27tenkuu has quit [Read error: Connection reset by peer]
01:37cyrozapmarcan: I've finished looking into the ASM3142 firmware loading process, and now have an implementation working in Python (https://github.com/cyrozap/asmedia-xhc-re/blob/836870de1d2584a5716d392b9cce4dfb5134d05f/tools/asm_tool.py). I haven't seen any issues uploading code into the host controller using this program--it seems to just work every time for me, and I've done testing to confirm that the
01:37cyrozapfirmware is in fact running and that the code was all loaded correctly. Based on this research, I have several suggestions for the kernel code:
01:39cyrozap1) Skip the controller reset (https://github.com/AsahiLinux/linux/blob/602fee88eb0603f4d7576797397aff6b33b41765/drivers/usb/host/xhci-pci-asmedia.c#L222-L229), and just do `asmedia_write_reg(hcd, 0x5042, 2);` to halt the controller and hold it in reset (note the "2" to halt instead of "1" for reset).
01:40cyrozap2) Immediately after writing the SRAM address (https://github.com/AsahiLinux/linux/blob/602fee88eb0603f4d7576797397aff6b33b41765/drivers/usb/host/xhci-pci-asmedia.c#L243-L244), read it back in a loop until the value read matches the value that was written.
01:42cyrozap3) Immediately after writing the code to SRAM (https://github.com/AsahiLinux/linux/blob/602fee88eb0603f4d7576797397aff6b33b41765/drivers/usb/host/xhci-pci-asmedia.c#L246), read the SRAM _address_ back in a loop to make sure that it's changed (it should have increased by two).
01:49cyrozap4) As a safety check, after all the SRAM has been written to, the SRAM should be read back and compared with the firmware. Note that unlike when writing to SRAM, reading it back is done in 0x4000-byte/0x2000-word interleaved blocks instead of 0x8000-byte/0x4000-word blocks, and uses two dword registers (0x3018 and 0x301c) for that data instead of just one. And of course bit 6 in PCI config space
01:50cyrozapregister 0xEF needs to be set to enable readback (set it before doing the readback, but after writing has finished).
01:58cyrozap5) Immediately after disabling SRAM write access (`asmedia_write_reg(hcd, 0x500e, 0);`), release the controller from reset with `asmedia_write_reg(hcd, 0x5042, 0);`. Then wait for the controller to initialize--it will reset itself once during this process in order to increase its clock speed from 78.125 MHz to 156.25 MHz, so don't try to talk to it before it's finished. Maybe add a delay of 10 ms or
02:00cyrozapHopefully these suggestions will help you fix the issues you were seeing with the firmware load process!
02:13cyrozapAlso, a small note about the reliability of this process: I was also experimenting with the firmware loading process for an earlier host controller, the ASM1142, and as part of that wrote a small firmware that would simply read itself back to the host. I was very surprised to find that pretty much every time I uploaded firmware to that chip, about 50-60 bytes between 0x0E40 and 0x1090 would get
02:13cyrozapcorrupted. More specifically, the highest bit of the highest byte in each affected 16-bit word would be flipped from either 0 to 1 or 1 to 0--all other bits were unaffected. I'm not sure if this is an issue with only this specific chip, and other ASM1142's are fine, or if it's a more widespread issue with this series of controllers (and maybe the ASM1042A as well, since it also supports the feature),
02:13cyrozapbut regardless of that I think it serves as a good example of how incredibly janky this process is and why it's absolutely necessary to do so many checks at each step.
02:17cyrozapLike, you just can't assume this part of the hardware will always work properly. Since as you've already noted, it was probably originally intended as a debug interface.
02:27r0ni has joined #asahi-dev
02:40user982492 has joined #asahi-dev
02:40tenkuu has joined #asahi-dev
02:42tenkuu has quit []
02:43tenkuu has joined #asahi-dev
03:00ma2 has joined #asahi-dev
03:07ma has quit [Ping timeout: 480 seconds]
03:11tenkuu has quit [Read error: Connection reset by peer]
03:26tenkuu has joined #asahi-dev
03:30nicolas17 has quit [Quit: Konversation terminated!]
03:56tenkuu has quit [Read error: Connection reset by peer]
04:06tenkuu has joined #asahi-dev
04:10tenkuu has quit [Read error: Connection reset by peer]
04:23tenkuu has joined #asahi-dev
04:46marcancyrozap: The failures I saw were all in the reset step, so maybe just skipping that (and possibly adding the MMIO poke readback/check) is all we need?
04:58user982492 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
05:02tenkuu_ has joined #asahi-dev
05:07tenkuu_ has quit []
05:08tenkuu has quit [Ping timeout: 480 seconds]
05:33tenkuu has joined #asahi-dev
05:34tenkuu has quit []
05:38tenkuu has joined #asahi-dev
05:57marcansven: I'll write and send you the t600x DT patch for review if you don't beat me to it :)
06:10grange_c has quit [Quit: Ping timeout (120 seconds)]
06:10grange_c has joined #asahi-dev
06:28hxliew has quit [Quit: WeeChat 3.5]
07:00tenkuu has quit [Quit: WeeChat 3.7.1]
07:59SSJ_GZ has joined #asahi-dev
08:02steven has joined #asahi-dev
08:28mps_ has joined #asahi-dev
08:30mps has quit [Ping timeout: 480 seconds]
08:50capta1nt0ad has quit [Remote host closed the connection]
09:14MajorBiscuit has joined #asahi-dev
09:38bluetail4 has joined #asahi-dev
09:46bluetail has quit [Ping timeout: 480 seconds]
09:46bluetail4 is now known as bluetail
09:54kettenis_ is now known as kettenis
10:00leitao has joined #asahi-dev
10:06svenmaybe we should start sabotaging openbsd efforts instead so that you don't keep beating us with support for almost everything :p
10:14leitao has quit [Ping timeout: 480 seconds]
10:16svenin usb news, i'm also reasonably sure that cd321x is actually more similar to TPS65988DK which also supports USB4 and, according to some public replies by TI employees, is not entirely compatible with the previous tps6598x chips. unfortunately the docs for that one are hidden behind NDAs :(
10:22_jannau_sven: I see the same data sheet / host interface TRM for tps65988 on https://www.ti.com/product/TPS65988 as for the other variants
10:22svenyeah, but if you read the problems people have with the DK variant specifically it very much sounds like the host interface changed
10:23sventhere's also a different host interface datasheet for TPS65987DDH but that also doesn't match up
10:24svenand any questions relating to USB4 and/or the DK variant are stonewalled in that public forum with "just use the reference design or go to the secure site after signing some NDA"
10:25sventhere was e.g. some question about how interrupts were missing/wrong on the DK. that sounds like they moved them around just like on the CD321x
10:43weitcis has joined #asahi-dev
10:57chadmed_ has joined #asahi-dev
11:01chadmed_the alsa-lib rust bindings dont have the methods to change or get current values out of mixer controls hooked up though :/
11:01mazkettenis: no worries. for the few (and hopefully rare) cases where DT becomes a burden, we should consider alternatives...
11:36chadmed_ has quit [Remote host closed the connection]
11:38tim has joined #asahi-dev
11:39tim is now known as Guest442
11:45leitao has joined #asahi-dev
12:35leitao has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
13:02leitao has joined #asahi-dev
13:30leitao has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
13:34leitao has joined #asahi-dev
14:09kujeger has joined #asahi-dev
14:18goldsoultheory has joined #asahi-dev
14:38leitao has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
14:41cyrozapmarcan: No, you should definitely also add the checks for the SRAM address, both before and after writing the SRAM data. Otherwise, data might get written to the wrong address, or the write rate will otherwise just be too fast for the chip to handle. If it works without those checks, then I guess you can skip them, but I'd be worried about the process failing randomly for users. Without proper
14:41cyrozapdocumentation from the manufacturer, I'd be really wary of making any extra optimizations.
14:51leitao has joined #asahi-dev
15:17Guest442 has quit [Quit: Guest442]
16:02leitao has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
16:04leitao has joined #asahi-dev
16:12leitao has quit [Ping timeout: 480 seconds]
16:26jluthra has quit [Remote host closed the connection]
16:26jluthra has joined #asahi-dev
16:56MajorBiscuit has quit [Ping timeout: 480 seconds]
17:03tobhe_ has joined #asahi-dev
17:07tobhe has quit [Ping timeout: 480 seconds]
17:15tobhe has joined #asahi-dev
17:20tobhe_ has quit [Ping timeout: 480 seconds]
17:24blazra has quit [Ping timeout: 480 seconds]
17:49weitcis has quit [Quit: Konversation terminated!]
17:56amarioguy2 has joined #asahi-dev
17:56amarioguy2saw the cpufreq news \o/
17:56amarioguy2when SBSA compliance/ACPI transition /s
18:00amarioguy2(in seriousness - if ACPI support ever becomes/became a seriously considered thing, i'd be more than willing to work on it)
18:01amarioguy2i need acpi or at least some semblance of it for trying to boot [proprietary os] anyways lol
18:01amarioguy2i just thought that for now the "DT vs ACPI" talk would probably be best saved until after the asahi DTs approach anything resembling the term stable, don't want the project to suddenly run into issues with booting because of this kind of change or anything
18:04leitao has joined #asahi-dev
18:18tenkuu has joined #asahi-dev
18:20tenkuu has quit []
18:20tenkuu has joined #asahi-dev
18:35amarioguy2 has quit [Ping timeout: 480 seconds]
18:35ChaosPrincessThe main problem with acpi is aic, acpi standard has a enum of possible interrupt controllers and aic isnt one.
18:36amarioguy2 has joined #asahi-dev
18:40dax has quit [Quit: dax]
18:45amarioguy2 has quit [Ping timeout: 480 seconds]
18:45tenkuu has quit [Ping timeout: 480 seconds]
18:51leitao has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
18:51ChaosPrincessi also was interested in maybe making those systems acpi compatible, and when i reached the interrupt controllers enum, i stopped reading, so there may be more problems
18:53tenkuu has joined #asahi-dev
18:56leitao has joined #asahi-dev
19:08amarioguy2 has joined #asahi-dev
19:09tenkuu has quit [Ping timeout: 480 seconds]
19:12dottedmagWhat's the motivation to make the system ACPI-compatible? Easier installation (probably not), anything else?
19:14___nick___ has joined #asahi-dev
19:14___nick___ has quit []
19:16___nick___ has joined #asahi-dev
19:17tenkuu has joined #asahi-dev
19:29amarioguy2 has quit [Ping timeout: 480 seconds]
19:31riker77 has quit [Quit: Quitting IRC - gone for good...]
19:34ChaosPrincesswinders support
19:42riker77 has joined #asahi-dev
19:45leitao has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
20:04systwi_ has quit [Read error: Connection reset by peer]
20:05systwi has joined #asahi-dev
20:28amarioguy2 has joined #asahi-dev
20:30scardracs has joined #asahi-dev
20:31amarioguy2re acpi - meant it more in a hypothetical sense like if it were to ever happen for whatever reason
20:31amarioguy2obviously i'm not saying that it should happen or even that it will lol
20:32amarioguy2chaosprincess: there *is* the CSRT table
20:33amarioguy2believe that table has an enum for irqchips
20:33amarioguy2again tho definitely no motivation to move away from DT atm so...
20:33* amarioguy2puts that idea on ice
20:52lewurm`` has joined #asahi-dev
20:53lewurm has quit [Ping timeout: 480 seconds]
20:53amarioguy2...side note i really need to stop bringing up ideas that are 99% certain to not ever happen moving forward...
20:54amarioguy2anyways my bad for bringing that up
20:59systwi_ has joined #asahi-dev
21:00tenkuu_ has joined #asahi-dev
21:03systwi has quit [Ping timeout: 480 seconds]
21:05lewurm`` has quit [Ping timeout: 480 seconds]
21:06lewurm has joined #asahi-dev
21:06tenkuu has quit [Ping timeout: 480 seconds]
21:07___nick___ has quit [Ping timeout: 480 seconds]
21:15svenmarcan: https://github.com/AsahiLinux/linux/commits/atcphc-20221130 should fix any conflicts once you rebase on torvald's tree with the dwc3 race and some of the tipd stuff fixed. the old role switch quirk and atcphy stuff won't apply cleanly anymore otherwise
21:18leitao has joined #asahi-dev
21:21lewurm has quit [Ping timeout: 480 seconds]
21:23amarioguy2 has quit [Ping timeout: 480 seconds]
21:24lewurm has joined #asahi-dev
21:29leitao has quit [Ping timeout: 480 seconds]
21:29jannausven: do you have an i2c/smbus tracer? I still have a hack directly integrated in hv.py but I can't remember if it was broken or not
21:31amarioguy2 has joined #asahi-dev
21:31chengsun has joined #asahi-dev
21:32svenjannau: https://f.svpe.de/c3d0e0a630b9e3efca96b58f1c108a73ad54c8023009b38648a56d196433789d_trace_tps.py no idea if that's any better than the hv.py hack
21:33leitao has joined #asahi-dev
21:33leitao has quit [Read error: Connection reset by peer]
21:34lewurm has quit [Read error: Connection reset by peer]
21:34leitao has joined #asahi-dev
21:34lewurm has joined #asahi-dev
21:36tenkuu has joined #asahi-dev
21:38jannauI count at least 3. I think hv/trace_tps6598x.py is written by me but I only a vague recollection of it. maybe author names in copyright notices are useful
21:38svenhrm, i think i tried that I2CRegMapTracer at some point but it wouldn't work correctly for the tps chip and I was too lazy to figure out why
21:40svencouldn't immediately figure out what ADDRESSING means and then just did the raw transactions myself
21:40tenkuu_ has quit [Ping timeout: 480 seconds]
21:41povikfirst number is the number of adress bytes in page register, second the number of address bytes sent with each transactions
21:42tenkuu has quit [Quit: WeeChat 3.7.1]
21:43leitao has quit [Ping timeout: 480 seconds]
21:45svenmaybe we should just use povik's I2CRegMapTracer. that thing seems to have the best chance of working correctly ;)
21:45tenkuu has joined #asahi-dev
21:49amarioguy2sven: have fun dealing with the untracked stuff :D
21:49svenjannau: I think it's just easier to use I2CRegMapTracer tbh. this tree has still all my old very hacky dcpext tracing before I cleaned that up
21:50chengsun_ has joined #asahi-dev
21:51svenjust call it trace_hpm.py because no one ever uses that name. that way we'll get to write another tracer for it half a year from now! :P
21:51chengsun has quit [Ping timeout: 480 seconds]
21:52amarioguy2sven: on a more serious note, the sep tracer i think should probably not go into tree until i decipher how AP side negotiates which "ipc"/communication protocol more in depth, as tracing 12.3 already had unknown SKS messages very early
21:52amarioguy2ventura is likely gonna have even more
21:55amarioguy2fair - tho i do think i want to fix up the tracer still before i commit it to m1n1
21:55amarioguy2or well before you commit it, it was your tracer to start with
21:56amarioguy2alright will do
21:56amarioguy2i'm sorry i'm taking a while on figuring stuff out btw life has been particularly unforgiving lately that hobby time is hard to come by
21:57* amarioguy2thanks irc for being supportive :)
21:58sventhe other much bigger advantage is that you get to increase the release date of $x whenever people ask you about $x!
22:03amarioguy2let's not forget a new challenger, ANE :)
22:10systwi has joined #asahi-dev
22:11systwi_ has quit [Ping timeout: 480 seconds]
22:16nicolas17 has joined #asahi-dev
22:18jannausven: connect and disconnect of the thunderbolt4 dock: https://gist.github.com/jannau/023f2c2a36b880636e037151b84ca626
22:24chengsun_ has quit [Ping timeout: 480 seconds]
22:34amarioguy2 has quit [Ping timeout: 480 seconds]
22:51systwi_ has joined #asahi-dev
22:54systwi__ has joined #asahi-dev
22:57systwi has quit [Ping timeout: 480 seconds]
22:59systwi_ has quit [Ping timeout: 480 seconds]
23:08Dcow has quit [Remote host closed the connection]
23:09Dcow has joined #asahi-dev
23:19user982492 has joined #asahi-dev
23:20Dcow has quit [Ping timeout: 480 seconds]
23:22SSJ_GZ has quit [Ping timeout: 480 seconds]
23:28bluetail1 has joined #asahi-dev
23:30bluetail has quit [Ping timeout: 480 seconds]
23:37mps_ has quit [Remote host closed the connection]
23:37mps has joined #asahi-dev