Gentoo Archives: gentoo-kernel

From: Joshua Kinard <kumba@g.o>
To: "Robin H. Johnson" <robbat2@g.o>, gentoo-kernel@l.g.o
Cc: mips@g.o
Subject: Re: [gentoo-kernel] sys-kernel/mips-firmware: thoughts?
Date: Tue, 31 Mar 2020 02:05:43
Message-Id: c5f3fad7-54a8-2a97-5062-45d8733b7843@gentoo.org
In Reply to: Re: [gentoo-kernel] sys-kernel/mips-firmware: thoughts? by "Robin H. Johnson"
1 On 3/30/2020 19:37, Robin H. Johnson wrote:
2 > On Mon, Mar 30, 2020 at 05:49:20PM -0400, Joshua Kinard wrote:
3 >> For some time now, I've been trying to maintain a patch that kludges the
4 >> external firmware loader and specific firmware blobs back into the kernel
5 >> for sys-kernel/mips-sources. This works fine up until 5.6, which seems to
6 >> have further changed the way that firmware is loaded that breaks my existing
7 >> patch in a not-so-obvious way. I am not terribly inclined to keep debugging
8 >> this, so I think it's time to throw in the towel and use external firmware
9 >> loading.
10 >>
11 >> This brings up the issue that frankly, sys-kernel/linux-firmware is overkill
12 >> for currently-supported MIPS targets. Speaking for just the SGI systems,
13 >> MIPS literally needs only 4 firmware blobs (1 is critical, 1 optional, the
14 >> other two are for the future):
15 >> - acenic/tg2.bin: optional for ACENIC/Tigon II PCI cards
16 >> - qlogic/1040.bin: required for QLA1040 on SGI IP27, IP30
17 >> - qlogic/1280.bin: future use (maybe on SGI IP35?)
18 >> - qlogic/12160.bin: future use (maybe on SGI IP35?)
19 > The 1280 was crucial for SGI Visual Workstation 320, and also
20 > worked as an option on IP32's PCI64 slots (I used it on my O2 R12k).
21 >
22 > Q1)
23 > What distfile would it use? If it's going to be just the same upstream
24 > giant 200+ MiB linux-firmware distfile, then you still have to get that
25 > copied in for the builds, and when you pin it, you're going to keep it
26 > on all Gentoo mirrors.
27
28 I am leaning to a stripped-down distfile containing just those four
29 precompiled *.bin files (versus the ihex variants), plus the necessary
30 license and any redistribution files. Maybe a custom README pointing people
31 to the upstream firmware.git location, etc.
32
33 A quick test of those four bin blobs and two license files + TAR + XZ is
34 ~65K. I //could// get it smaller if I shipped the uncompiled ihex files and
35 then encoded in the ebuild some logic to convert the ihex to binary bobs.
36
37
38 > If you're going to produce a stripped down distfile, how is that going
39 > to interact when you might need a firmware that isn't in the stripped
40 > down package (see further about conflicts). I have used other NICs in my
41 > MIPS gear when I still used it (which I admit was more than a
42 > decade ago now).
43
44 Just add it, add its license file, and revbump the tarball. Even shipping
45 the prebuilt *.bin files, it'll still be extremely small compared to the
46 full-blown linux-firmware package. I've been re-kludging these same four
47 firmware blobs in mips-sources for 2-3 years now as patches and no one's
48 filed any bugs yet, so it shouldn't be an issue. On the off chance things
49 ever got out of control in adding a bunch of more recent firmware files,
50 then this package would be last-rited and we switch to linux-firmware.
51
52
53 >> I wanted to see if there would be any problem with creating a
54 >> sys-kernel/mips-firmware package to contain, at least initially, these four
55 >> firmware files from the linux-firmware repo, and install them to either
56 >> /lib/firmware-mips or /usr/share/mips-firmware (thinking more the latter to
57 >> avoid polluting /lib any further).
58 > Q2)
59 > Do you intend to patch the kernel drivers/base/firmware_loader for these
60 > new paths, or what other way would you pass them?
61 > The firmware_class.path modparam takes only ONE path.
62 >
63 > If you don't patch it to add more paths, then I worry that you can't use
64 > the new paths you propose, and you have to have a blocker against
65 > sys-kernel/linux-firmware.
66
67 This is why I //liked// the in-kernel firmware loader. No messing about
68 with paths or such. I've tested my kludge patch against 5.6_rc7, and while
69 the bin blobs are built and included in the kernel, something has changed
70 somewhere in how it tries to find them in a kernel image. I just don't
71 really care to try and chase that down anymore. Though, the option isn't
72 off the table yet.
73
74 That said, using an external patch with a custom file location, it's more a
75 matter of documentation. Of our supported SGI systems, the only ones that
76 *need* firmware are IP27 and IP30 for enabling the SCSI subsystem. PCI
77 support on both platforms is still in disarray to the point that most other
78 PCI devices are still not going to work well. IP27 lacks code to enable
79 access to its "big windows" PCI alias space, and Octane has issues with >2GB
80 RAM and PCI DMA. It just happens that Acenic 1GB NICs work well on the
81 Octane (especially the SGI-branded version available on eBay)
82
83 Additionally, using a separate install path avoids having to block against
84 linux-firmware, so users can still install that package if they have some
85 esoteric (to MIPS) PCI device that needs firmware to get going, and then
86 just point the firmware loader to linux-firmware's default path. I'm just
87 trying to come up with a workable solution for the *common* case w/ IP27 and
88 IP30.
89
90
91 >> These four blobs have not seen updates in years, so I anticipate there being
92 >> only a single ebuild for sys-kernel/mips-firmware. It'll be versioned like
93 >> the virtual packages (mips-firmware-1, -2, -3, etc), rather than by
94 >> datestamp, as the only times a version bump happens is if the firmware blobs
95 >> ever change or we add/remove a blob.
96 >>
97 >> Thoughts/feedback?
98 >
99 > Can you clarify relative goals in this effort?
100 >
101 > - Avoid packaging effort?
102 > - Save root FS disk space (a limited resource on many MIPS systems)
103 > - Avoid having to build the very large sys-kernel/linux-firmware (even
104 > with savedconfig the download/build takes lots of space, starting with
105 > the 200+ MiB distfile).
106
107 Really, it's just I am tired of kludging in-kernel firmware support back in
108 (that and Makefile syntax is borderline arcane). I get it that the cool kid
109 thing to do these days is build an initramfs into your kernel, but it seems
110 that upstream is either trying to force that home, or they're just restless
111 about where they want firmware support to even live. Stuff keeps moving
112 around and it's a PITA to debug and chase down.
113
114 Long-term, it seems more sensible to just distribute a small tarball of
115 several key prebuilt bin blobs that mips-sources can just reference when
116 needed. I anticipate maybe not more than 2-3 version bumps over the next 5
117 years with this approach.
118
119
120 > I think you SHOULD keep the datestamp method, and have the PV explicitly
121 > match the upstream linux tarballs. I'm not sure about if it should have
122 > it's own smaller distfile or not.
123
124 Datestamp would give the wrong impression that these firmwares are updated.
125 Acenic/tg2.bin hasn't seen an update since 2004, and you can't even get at
126 the original firmware C/asm source code anymore, even via archive.org.
127 Qlogic bins haven't seen updates since 2002 (1040.bin, 1280.bin) and 2003
128 (12160.bin). So I can pick any snapshot of linux-firmware from now until
129 its creation as an external repository, and I am going to wind up with the
130 same firmware. Distributing a tailored package means users won't be forced
131 to download and build new linux-firmware packages for a handful of binary
132 blobs that will likely never ever change again.
133
134 That makes versioning it by single digits, or even a decimal version a bit
135 better because the version will only change with firmware is added/removed
136 from the archive.
137
138 --
139 Joshua Kinard
140 Gentoo/MIPS
141 kumba@g.o
142 rsa6144/5C63F4E3F5C6C943 2015-04-27
143 177C 1972 1FB8 F254 BAD0 3E72 5C63 F4E3 F5C6 C943
144
145 "The past tempts us, the present confuses us, the future frightens us. And
146 our lives slip away, moment by moment, lost in that vast, terrible in-between."
147
148 --Emperor Turhan, Centauri Republic