#
…

2021-10-03

00:15tylo has joined #asahi-dev
00:18povik has quit [Quit: Page closed]
00:30tylo1 has joined #asahi-dev
00:30tylo has quit [Read error: No route to host]
00:45tylo1 has quit [Ping timeout: 480 seconds]
01:03riker77_ has joined #asahi-dev
01:07riker77 has quit [Ping timeout: 480 seconds]
01:07riker77_ is now known as riker77
02:29robinp has quit [Ping timeout: 480 seconds]
02:35PhilippvK has joined #asahi-dev
02:38phiologe has quit [Ping timeout: 480 seconds]
04:38robinp has joined #asahi-dev
05:36psykose has quit [Remote host closed the connection]
05:36psykose has joined #asahi-dev
06:10austriancoderHi. I should soon get my hands on an M1 and I am interested if someone started to look at audio on the Air? I have some re experience and might want to help out.
06:15ar has quit [Ping timeout: 480 seconds]
06:28nepeat has quit [Ping timeout: 480 seconds]
06:31nepeat has joined #asahi-dev
06:41tylo1 has joined #asahi-dev
06:55tylo1 has quit [Ping timeout: 480 seconds]
07:12j_eyaustriancoder: povik is looking at audio
07:12j_eyaustriancoder: they started writing a linux driver
07:58ar has joined #asahi-dev
08:02austriancoderj_ey: okay.. thanks.. I think I will find an area to hack on
08:09povik has joined #asahi-dev
08:12poviknitpick: seems it complains about the wrong property
08:13poviklogs gpio-ranges is missing, not apple,npins
08:13povik(had to look up in code why i made the pinctrl driver unhappy)
08:13j_eyah, ty
08:14j_eyI forgot to clean that bit up, I set npins to 512 too, which is a thing i leftover by accident
08:18j_eythe v2 was a bit rushed, wanted to get it out before I went away and lost access to the m1 for a week
08:20poviki also get a strange compile error, that probably has to do with my setup
08:20povik> /include/linux/compiler_types.h:322:38: error: call to ‘__compiletime_assert_370’ declared with attribute error: FIELD_PREP: value too large for the field
08:21poviktriggered on line 297 from apple_gpio_gpio_irq_unmask
08:21povikthe compiler gets confused about the constancy of the field value as i understand it
08:21poviksee no fault in the code itself
08:27poviki replaced it with equivalent shift-and-mask expression, but would like to know how to make it go away properly
08:27j_eywhat compiler?
08:27j_ey#define REG_GPIOx_MODE_MASK GENMASK(3, 1) and irqtype is u32....
08:28povikgcc version 9.3.0 (GCC)
08:28poviksomething nixos gave me for cross-compiling
08:28povikcould be they have some strange patches
08:30povikalso i cherrypicked on top of maz's tree, which is on top of v5.15-rc3
08:30povikcan try to build your tree verbatim and report back
08:31j_eyIm confused now, how can that be a compile time check... it has FIELD_PREP(REG_GPIOx_MODE_MASK, irqtype), where irqtype is runtime
08:31j_eyI wonder if your gcc has a broken '__builtin_constant_p'
08:32j_ey(looking at __BF_FIELD_CHECK in include/linux/bitfield.h)
08:34poviki also wonder
08:34povikit's strange it hasnt triggered anywhere else, if i patch that that particular expression it builds
08:34povikmaybe we are just unlucky
08:36j_eypovik: can you try: BUILD_BUG_ON(__builtin_constant_p(irqtype));
08:37j_eyline 290 or so
08:37poviksure, building
08:37povikand it goes through
08:38* j_eyconfused
08:38povikif i put the FIELD_PREP back it compiles with the BUG_ON :D
08:38povikthis is now a certified compiler bug as i see it
08:39povikyeah, if there's the BUG_ON above the line with FIELD_PREP, it compiles
08:39povikif there's not, it gives the error
08:40j_eywhat about BUG_ON(0);
08:40povikerrors out
08:42tylo1 has joined #asahi-dev
08:44j_eyI use gcc from http://cdn.kernel.org/pub/tools/crosstool/ (actually I use clang now..)
08:49povikok, am updating my compiler, no use spending more time on this
08:49povik(unless it happens again then)
08:50j_eyI still feel I may have done something wrong..
08:50povikif we are looking at the same code i dont know what you could have done
08:51povikalso, the BUG_ON behaviour evades reason
08:51povikspooky action at distance as physics calls it
08:53nepeat has quit [Remote host closed the connection]
08:55aleasto has joined #asahi-dev
08:59tylo1 has quit [Ping timeout: 480 seconds]
09:00povikit also compiles if irqtype is s32, but only if i dont comment out the irqtype<0 return branch
09:01povikbtw you are comparing unsigned type against zero
09:01povikbut thats not what it causes
09:01poviki should restrain myself from poking at this any further
09:01povik(still on the old compiler)
09:03j_eygood catch too, I will make some notes of these
09:04povikcan you still make some minor tweaks if the version on the list is accepted?
09:05* povikis new to the linux process
09:13j_eypovik: I think the person pulling it can, or you'd have to send a new version
09:14j_eyit's fine to just have a final vN with minor things though
09:40nepeat has joined #asahi-dev
09:45povik has quit [Quit: Page closed]
09:52tylo1 has joined #asahi-dev
10:01tylo1 has quit [Ping timeout: 480 seconds]
11:19gabuscus has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
11:19gabuscus has joined #asahi-dev
11:29nico_32 has quit [Ping timeout: 480 seconds]
11:29nico_32 has joined #asahi-dev
12:40alyssathe Corellium wi-fi patch gets a lot less scary if you hit the backspace button a bunch
12:48alyssa(I split it up into separate commits, and dropped the useless commits, and now it's a lot smaller.)
12:49nico_32 has quit [Ping timeout: 480 seconds]
12:51nico_32 has joined #asahi-dev
12:58alyssaOkay, I am not sure where that code came from. But it didn't make sense on the surface, made less sense after thinking about it, and then wifi still works fine after dropping the commit.
12:58alyssamarcan: I see your point.
13:03alyssaMAC address code needs a full rewrite, but that's ok
13:03marcanI'm not saying I don't like their code out of NIH syndrome, you know :p
13:03alyssamarcan: giggle.
13:03alyssa`of_get_mac_address` this is handy :')
13:05alyssabut errrr where does this OF node come from
13:05alyssait's a pcie device
13:05marcanyou add it
13:05marcanbased on pcie port
13:05marcansee how the ethernet mac gets set
13:05marcanit's a child of the pcie bus node
13:05alyssayeah that's what I was looking for. lots of abstractions to chew through but yes
13:06marcanthere's the whole alias dance to set the mac
13:06marcanm1n1 already does that (thanks to the patch by kettenis)
13:06marcanyou just need to set up the right pointer
13:06alyssathe Corellium code ultimately pipes that into an nvram field for the broadcom chip
13:07marcanyeah, I guess it gets presented as a "fake" nvram to the firmware?
13:07alyssaNot sure if this dance is necessary and not sure I want to find out without a Faraday cage :-p
13:07marcanit's all kinda weird
13:07marcanwell, you do need the MAC, but maybe there's an easier way since after all linux can change the mac...
13:07alyssaMaybe? If it is necessary, I'd like to know why the other broadcom chips don't need it
13:07alyssaor, better question - how do mac addrs usually get set with upstream brcmfmac
13:07marcanthis is Apple doing system personalization their own way
13:07marcanremember these things are unbrickable?
13:08marcanso the mac has to come from sysconfig data
13:08marcan(which it pulls from the calls home during DFU restore)
13:08marcanso it can't just be in some EEPROM since that'd add more state
13:08marcan(which is how wifi cards would normally do it)
13:08alyssaso this is a legitimate hardware/firmware difference and not "macOS does it so Corellium does it so we do it"?
13:08aleasto has quit [Quit: Konversation terminated!]
13:08marcanhence this dance to forward the MAC from the ADT to nvram
13:08marcannow the *way* this is being done... I don't know if it's the only/correct way
13:09aleasto has joined #asahi-dev
13:09marcanit stands to reason that since Linux can just outright set the MAC via standard APIs, there might be a way to do it like that without having to add the whole nvram mess
13:09alyssathough we'd still want to respect the one forwarded from the ADT, no?
13:09alyssamaz has a commit to do it for Ethernet, and that was a DT-only change and tg3 just 'magically' worked I think
13:09marcanyes, but what I mean is maybe instead of sticking it in nvram you can just call set_mac() on driver startup
13:09marcanor whatever the api for that is
13:10marcanand that might avoid you a bunch of nvram munging code or whatever
13:10alyssaack. I think there will still be some nvram munging but a heck of a lot less than corellium has.
13:10aleasto has quit [Remote host closed the connection]
13:10marcanand yeah, looking at tg3 to see if it has any special code for this
13:10marcanit might not need it, maybe this is in core stuff already
13:11aleasto has joined #asahi-dev
13:11marcanah, eth_platform_get_mac_address
13:11marcantg3 has that
13:12marcanalyssa: so yes, the driver needs to support it
13:12marcan(that calls of_get_mac_address)
13:15marcanalyssa: see brcmf_c_preinit_dcmds that *gets* the MAC address from the device on startup
13:15marcanwith an analogous API to what brcmf_netdev_set_mac_address uses to set it
13:16marcanthat sounds like a prime place to call eth_platform_get_mac_address and do a *set* instead if that is available
13:16aleasto has quit [Remote host closed the connection]
13:16marcanand then no need to mess with nvram
13:16marcan(plus it works for all brcmfmac devices then, forever)
13:16aleasto has joined #asahi-dev
13:16alyssaalright..
13:17aleasto has quit [Remote host closed the connection]
13:17aleasto has joined #asahi-dev
13:19aleasto has quit [Remote host closed the connection]
13:19aleasto has joined #asahi-dev
13:19marcanbtw, it should be the installer's job to pull the firmware out of osx and into somewhere useful
13:20marcanany ideas? I guess if nowhere else it should go in the FAT32 EFI partition I will (eventually) be setting up
13:20aleasto has quit [Remote host closed the connection]
13:21aleasto has joined #asahi-dev
13:21aleasto has quit []
13:22alyssaFAT is probably the only reasonable answer
13:22alyssasince macOS won't write ext4 and Linux won't read APFS
13:23alyssaThere /is/ a somewhat invovled dance required to /find/ which firmware your hw actually needs, though
13:23alyssat2linux's wiki gives a magic incantation to run in ioreg with wifi enabled.
13:23alyssaI assume you'll be able to do better in the installer but meh
13:29aleasto has joined #asahi-dev
13:35svendon't all m1 machines just have the same chipset?
13:35sventhe t2 people probably need support a few generations of macbooks
13:35sven*need to
13:36jeh[m]All M1 chipsets are same atm (one graphics core disabled on some models iirc)
13:37svenyes, i know. i'm talking about the wifi chipset though
13:38sveni'd expect that to be the same as well but that one's easier to change
13:44jeh[m]Ah! Sorry my bad here! Don't think Apple specifics which chipset they're using but I also assume that should be same across all devices can't say though - they've historically used Broadcom.
13:44jeh[m]I think they're using Broadcom BCM4378 - not sure about that at all though :)
13:48alyssajeh[m]: sven: There are a /lot/ of different firmware files in the 4378 directory on macOS
14:01marcancorellium embedded one in their kernel (did they get a license?) and apparently it worked for people? :')
14:02marcanlet me take a look
14:02alyssa...I see
14:03marcanalso ideally I'd want to pull it from the recovery image, since we install that
14:03marcanin keeping with firmware version consistency
14:03marcanalthough for wifi it matters less
14:03alyssamarcan: If I'm reading the corellium kernel code correctly, I believe they have a pile of hacks in userspace to select the fw, set module parameters to point to it, and then re-load the wifi driver.
14:03marcanwell their first kernel just had one embedded
14:03marcan(which they summarily took down once I pointed it out)
14:03marcan(without a word)
14:04vup2 has quit [Remote host closed the connection]
14:05vup has joined #asahi-dev
14:06alyssaI still dunno what's up with this race condition
14:07alyssalike, it seems like a genuine race we lose every time but if so, why isn't every other brcmfmac user in existence broken
14:07marcanwhat race?
14:07alyssamarcan: brcmfmac does "enable interrupts, then setup driver"
14:08alyssaand their interrupt handler starts off by dereferencing driver intenral stuff
14:08alyssaon BCM4378 at least, we get a very early interrupt => NULL dereference in the IRQ handler
14:09marcanthere are only two BCM4378 firmwares as far as I can tell
14:09marcanwhat they do have is a ton of *config* files
14:09marcanwhich makes sense (things like RF parameters change from platform to platform)
14:09marcanso basically nvrams
14:10marcanlet's see what the adt says about this
14:11marcan module-instance = atlantisb
14:11marcanthat points at the plist
14:13marcan wifi-antenna-sku-info = [0x0000000000000001, 0x0000000000003358]
14:13marcanthat second one is ASCII
14:13alyssameanwhile I'm cranky that I need to build brcmfmac as a module if I don't want to bundle the blob with the kernel ..
14:14marcanyou do not? you can put it in the initramfs
14:14nsklfwiw, i have a 2015 mbp, with arch on it, and both the wifi and bluetooth are under performing. especialy bluetooth. although they both 'technically' work, their signal is very poor. bluetooth i must stand within 1meter of the laptop to have functionning headset, and wifi signal reception is poor too. (it's using brcmfmac.. BCM43602)
14:14marcannskl: sounds like bad configs
14:14alyssa.../me forgot that real initramfs exist
14:14* alyssafeels silly now
14:15nsklmarcan: i tested many distro on it since 2015, it was always like that.. well to be fair, in the beginning it was way worse, and today it's barely usable
14:15jeh[m]nskl: BM4331 here in 2012 MBP - works perfectly fine.
14:16marcannskl: I would not expect any distros to be better than others
14:16nskljeh[m]: even if you compare with macos ? for me the signal reception is quite good in macos and not that great in linux
14:16marcanthat sounds like nobody bothered to make sure the nvram/etc config was done properly
14:17nsklmarcan: my distro of choice is artix (arch without systemd) but i tried plain arch too, and many debian derivatives and tons of other exotic distros
14:17jeh[m]nskl: Yes even compared to macOS! open source broadcom driver is bad that is b43 iirc. broadcom-wl works perfectly fine!
14:18nsklwell, i have good hopes that this time, asahi linux will make it work nicely
14:18marcanalyssa: and there are only two actual *differing* config files for atlantisb
14:18marcan(which are copied and symlinked over and over)
14:18jeh[m]oh my...
14:19marcannow, we do have different instances for each machine
14:20marcanso there are, among all the M1 variants out there so far, 2 actual firmwares (each model symlinks one of those), and then 2 nvram variants for each model
14:21marcanI would just put this info in the devicetree and add some plumbing to brcmfmac to get it from there
14:22marcanalternatively we could just make the installer pull the right variant for *your* machine, but that makes the rootfs nonportable once it gets copied, which is kind of icky
14:26alyssamarcan: symlinks! oh my.
14:29alyssamarcan: ok, stuck the firmware in an initramfs (with nothing else) and passed that to linux.py and built brcmfmac=y and now it's happy
14:29alyssastill stupid that linux can't tell "hmmm I need firmware but have no filesystem maybe I should not try to load that driver before NVMe"
14:32marcanwouldn't help since it needs to mount it anyway
14:32marcanbuilt in module, firmware needs to be in initramfs
14:32marcanthat's just how it is
14:32alyssas/module/kernel/
14:33j_eyoh, didnt know that
14:34marcanalyssa: so it does look like the specific version info is in OTP only, so we need to copy all nvram variants and then have the driver choose one
14:34alyssaso the unused OTP parser in corellium code was secretly used by their userspace?
14:34alyssathanks for volunteering to work on that
14:35marcanand should not be used by userspace, it should be used by the driver
14:35marcanso the way this is normally done, apparently, is
14:35alyssaYeah that's the bigger hack there :-p
14:35marcan-rw-r--r-- 1 root root 1884 Sep 1 06:10 brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt
14:35marcan-rw-r--r-- 1 root root 1883 Sep 1 06:10 brcmfmac43455-sdio.raspberrypi,4-model-b.txt
14:35marcanwe can reformat that however we want
14:36alyssaright, the driver first tries brcmfmac4378-pcie.apple,j274.bin
14:36alyssabut it sounds like there are 2 possible firmwares for J274 depending on... region?
14:37marcanyeah but it's not j274... the devicetree IDs this using a different naming scheme, which is in the ADT, so we ought to follow that unless we want to maintain a mapping table in the installer
14:38alyssabetter in the installer than in the brcmfmac I would think?
14:38marcanalso, slight issue: FAT32 does not support symlinks :')
14:39marcansince we need a script to copy this over anyway, I guess we should dump out the mapping/symlink stuff in a text file anyway
14:43kettenisfwiw, OpenBSD's bwfm(4) uses the same firmware name mapping scheme as the linux driver
14:43marcanactually it looks like the nvrams are the same for every module revision, only there are two vendors
14:44marcanI'm thinking we basically want something like brcmfmac4378-pcie.apple,atlantisb-RASP-m-6.2.txt but with fallback requests
14:44marcanso the driver would try brcmfmac4378-pcie.apple,atlantisb-RASP-m-6.2.txt then brcmfmac4378-pcie.apple,atlantisb-RASP-m.txt then brcmfmac4378-pcie.apple,atlantisb-RASP.txt then brcmfmac4378-pcie.apple,atlantisb.txt
14:44marcanand we can provide the -m since that is where the differences stop
14:45marcanthe installer can check that all the variants are the same to avoid making copies
14:45alyssawhat is RASP btw?
14:45marcan"module"
14:45marcanm is the vendor
14:45marcanthe thing after is the revision
14:45marcandon't ask me what RASP stands for
14:45marcanoh yeah and I forgot, the antenna matters though again this is symlink land
14:46marcanso brcmfmac4378-pcie.apple,atlantisb-RASP-m-6.2-X2.txt first, then everything with X2 but removing components, then without X2
14:46marcan(either this or we throw in a pile of symlinks)
14:54marcankettenis: you mean the corellium driver?
14:55kettenisno, I mean the unmodified driver
14:55kettenisthe way it constructs the name based on the / compatible
14:55marcanyeah, but that doesn't work for us because we have at least two different nvram files per board
14:55marcan(potentially more with versions in the future)
14:57ketteniswell, you could just have the installer install the set of files that you actually need
14:57marcanyeah, but as I said then that makes the rootfs nonportable
14:58marcanwhich is not ideal
14:58kettenisyeah, although the NVMe isn't exactly removable ;)
14:58marcanthe wifi modules are
14:58marcan(at least on some machines)
14:59kettenisanyway, patrick made our driver print the string the corellium driver uses:
14:59kettenisbwfm0: firmware C-4378__s-B1/P-unknown_M-RASP_V-m__m-6.11
14:59kettenisit prints "unknown" because the "atlantisb" bit is missing from the device tree
15:04marcanI wonder how this works on x86
15:04marcanno DT there to tell it the island
15:04marcanif we can get that from OTP too, it would make this whole scheme work for the x86 macs too
15:07kettenisalledgedly on x86 the nvram stuff is provided through an EFI variable
15:08kettenisnot sure if x86 used that same scheme or had a different approach
15:08kettenisI mean x86 macs
15:08kettenisthe EFI variables exist on machines intended to run Windows
15:09kettenisolder chips had just the firmware and the nvram file
15:09marcanhm? my iMac should have it then, pretty sure it can run windows
15:09kettenismore recent chips also have a CLM file
15:09marcanthis has a BCM43602
15:14kettenis# SPDX-License-Identifier: GPL-2.0+
15:14kettenis# (C) Copyright 2018 Linaro Ltd
15:14kettenisSeriously?
15:16kettenis(that's the license somebody put on the .txt file for some ARM board in the Linux firmware repository)
15:19kettenisit's just a bunch of parameters; really shouldn't be copyrightable
15:25kettenisanyway, your challenge is to convince the Linux brcmfmac driver maintainers of the firmware naming scheme ;)
15:32minecrellkettenis: There were long attempts to get Broadcom to clarify the licensing for the NVRAM stuff, of course they didn't. The Linaro copyright is basically some strange way around it, they posted some GPL licensed NVRAM and now everyone seems to copy that with some device-specific values (from the "proprietary" config) adjusted
15:35ketteniswell, the GPL doesn't make sense for this kind of file
16:19kov has joined #asahi-dev
16:26alyssamarcan: "if we can get that from OTP too, it would make this whole scheme work for the x86 macs"
16:26alyssanone of this works on the T2 Macs so yes they would appreciate a proper solution for this :)
16:26alyssaor maybe they enjoy doing the ioreg dance, idk
16:28alyssaminecrell: still not convinced NVRAM is copyrightable at all but y'know
16:31tylo1 has joined #asahi-dev
17:41alyssamarcan: OTOH if we don't care about t2 macs, we could stick all the OTP parsing stuff in m1n1 and just passing the firmware path that way
17:46vup has quit [Ping timeout: 480 seconds]
18:43kettenissigh, I used get_maintainer.pl for v2 of my u-boot upstream diff, but it touches enough code for the list of recipients to get too long for the mailing list :(
19:22confusom1 has joined #asahi-dev
19:51minecrellkettenis: This is mostly get_maintainers.pl being overly verbose though, most of the people you're Cc-ing just added a few lines (e.g. drivers) in the files you're touching (:
19:51minecrellI think I'm on Cc because of doc/board/index.rst and maybe arch/arm/Kconfig
19:53minecrellOh wow your Cc list on v2 is amazing :D
21:10vup has joined #asahi-dev
22:00yrlf has quit [Quit: The Lounge - https://thelounge.chat]
22:02yrlf has joined #asahi-dev
22:55aleasto has quit [Quit: Konversation terminated!]
…