Date: Thu, 29 Aug 2024 12:13:32 +0000 (UTC) From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: FreeBSD wireless mailing list <wireless@FreeBSD.org> Subject: The blocker on MediaTek mt76 drivers - VM changes in LinuxKPI Message-ID: <3pr128oo-q8ro-8o9s-3547-8sq636pnon23@SerrOFQ.bet>
next in thread | raw e-mail | index | archive | help
Hi, a lot of people are asking for the mt76 drivers it seems. They are sitting there and on my branch are compiling (if one flips a switch) but are NOT IN A WORKING STATE YET. In order to make progress a feature called page_pools needs implementation as pi@ has already pointed out on the PR [1]. Before that can happen a 10-15 year old very good but historic shortcut in LinuxKPI needs to be resolved. So far the LinuxKPI 'struct page' is defined to the native 'struct vm_page'. We cannot extend the native struct vm_page with LinuxKPI specific fields. It would both sooner or later become complicated but also penalize the native system massively. But more things (like page_pools) need direct access to fields inside struct page, so it's time to break that historic bit up and enhance our implementation. In my github branch was a start to change that by changing most consumers and macros (some already in main; some that were added since need adjustment) inside LinuxKPI to use a "struct page { }" which no longer ist the native vm_gae. I put an #ifdef PAGE_IS_LKPI_PAGE around that so we can flip from one implementation to the other. I know drm-kmod has at least one workaround in its code for a similar problem that functions want direct access to struct page fields. And drm-kmod will also need to be tested very carefully with the chnage before we do the switch. So what needs doing? To my memory and from a comment in my linux_page.c on github the native page table can be built in at least three ways depending on PMAP_HAS_PAGE_ARRAY and VM_PHYSSEG_SPARSE or VM_PHYSSEG_DENSE. The "shadow copy" of vm_page_array[] which we need in LinuxKPI for struct page needs to be replicated/setup correctly in all cases so that we can do a 1:1 mapping between native pages and LinuxKPI struct page. In the Linux->native direction we could store a pointer to the vm_page for that but in the other direction we need to be able to find the struct page based on the vm_page idx (at least that's what my memory tells me and I am not an expert in that field). This is something which I didn't want to dig deeper into the VM code; I know that a first blunt attempt hadn't work so I figured someone who knows the system can probably do this in a way shorter time and do it right so it can be maintained in the future. I am still looking for someone who can help doing this. [side note: one could argue to change the driver(s) and write these bits as native code but it'll likely end up in a maintainance mess given the amount of churn happening there] Once that logic is there to set this all up, make sure it satisfies all logic to stay in proper synch and that we can (in theory) also properly clean it up, then the next steps folllow, which oversimplified are: 1. Implement page_pools and other missing bits for mt76 in LinuxKPI (some probably as we go) 2. Start testing and debugging the various mt76 driver(s) to load (symbols, module dependencies, ...) 3. Get it to load firmware and register the WiFi interface 4. Take it from there... For any of these steps I'll be more than happy if other people will do them or help; I have some cards for at least two of the chipsets to test and help myself as needed. I hope this clarifies the situation. Lots of health, Bjoern [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264300#c23 -- Bjoern A. Zeeb r15:7
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3pr128oo-q8ro-8o9s-3547-8sq636pnon23>