Repository navigation
Integrate out-of-tree DKMS modules into the kernel at build time - #54
Conversation
1d842df to
916da65
Compare
The Debian Debusine build path now needs kgsl-dkms as a build dependency (via PR #54 against qcom/debian/latest). The package is published in the qli Debusine workspace, so the build step must expose qli as an extra build-dependency source when invoking debusine-action/lib/build. Set EXTRA_BUILD_DEP_WORKSPACES=qli in Build in Debusine and pass DEBUSINE_USER, which lib/build currently requires to apply its extra_repositories compatibility workaround.
The Debian Debusine build path now needs kgsl-dkms as a build dependency (via PR #54 against qcom/debian/latest). The package is published in the qli Debusine workspace, so the build step must expose qli as an extra build-dependency source when invoking debusine-action/lib/build. Set EXTRA_BUILD_DEP_WORKSPACES=qli in Build in Debusine and pass DEBUSINE_USER, which lib/build currently requires to apply its extra_repositories compatibility workaround. Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
9917688 to
916da65
Compare
|
Bjordis Collaku (@bjordiscollaku) what is the status of this PR? would be great to get it in :-) |
Hi Christopher Obbard (@obbardc), technically, status is READY :) It's been ready for a while from my end, it's gonne through iteration of improvements, and also been validated as part of pkg-linux-qcom build with pkg-kgsl enabled (please check PR description on validation), both for ubuntu resolute and debian trixie. One note, as specified at the end of PR " hardware validation, owned by the device team." --> so in this case we would want gfx team to confirm this on target device. Since this is a big chunk of change though, it'd be good to get the mechanism in, and if any incremental changes/improvements arise, we can take care in subsequent PRs. Why it's not merged yet? We switched primary focus to #62 AND #63. I'd say we get #62 and #63 in (they've been validated in I'd appreciate your review on all 3 if/when you get a chance! Thanks in advance, and happy to work together! |
Christopher Obbard (obbardc)
left a comment
There was a problem hiding this comment.
Starting to look great, but some minor thoughts attached. I think you can squash a few commits, I'd like this to build camx-dkms and iris-vpu-dkms to prove the logic, but we can look at that separately if you wish.
|
Thanks a lot for going through this commit by commit Christopher Obbard (@obbardc), really appreciate the detailed review. Replies inline. Short version: I'll squash the noisy intermediate commits into the extraction, split the deps commit, and drop the version pin. Will ping you once it's pushed. |
916da65 to
c496305
Compare
debian/scripts/bundle-dkms-modules.sh (added in a follow-up commit) invokes dkms build unconditionally once any module is listed in debian/dkms-modules. Declare dkms itself here, separately from any specific module's own -dkms package, so the generic build-time prerequisite for the mechanism doesn't get tangled with per-module additions. Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
…rnel image Compile out-of-tree kernel modules from their DKMS source packages and bundle them into linux-image-<KVER>-qcom at dpkg-buildpackage time, in the same run that builds the kernel. The device receives one self-contained kernel package: the module is present and pinned to the exact kernel it was built against, with no DKMS, compiler, or headers required on the target. The mechanism is module-agnostic and driven by debian/dkms-modules, a plain-text manifest of module names (one per line; comments and blank lines ignored). Onboarding a module is a two-line change: append its name to the manifest, and add <name>-dkms to Build-Depends. Neither debian/rules nor debian/scripts/bundle-dkms-modules.sh changes. The logic lives in debian/scripts/bundle-dkms-modules.sh, a standalone, documented tool that debian/rules' override_dh_auto_install delegates to once the kernel image, modules, headers, and debug packages are staged. It can also be invoked directly by a developer who has already staged those trees, without re-running the full dpkg-buildpackage. For each manifest module, the tool: - Resolves the installed <name>-dkms package's source directory via dpkg -L (authoritative; no /usr/src globbing), and reads PACKAGE_NAME/PACKAGE_VERSION from the package's own dkms.conf. - Runs dkms build against the kernel headers staged earlier in this same run, in a private --dkmstree (mktemp), so the module matches the exact kernel and the build stays rootless under fakeroot. - Judges the outcome by produced .ko artifact, not dkms exit code: dkms exit-code conventions vary across versions, and a BUILD_EXCLUSIVE skip can exit 0. A manifest entry is a presence contract, so a module that produces nothing hard-fails the build with precise diagnostics (the make.log tail for a build failure, or the BUILD_EXCLUSIVE gates evaluated against the staged kernel .config for a silent skip). - Guards against name collisions: duplicate manifest entries resolving to the same dkms module, two modules bundling to the same .ko basename, and a bundled module's name clashing with an in-tree module (which would make depmod's search order ambiguous on the device). - Installs the module under lib/modules/<KVER>/extra/, handling it exactly like an in-tree module: objcopy --only-keep-debug routes its debug symbols to the -dbg package before strip --strip-debug strips the shipped copy (--strip-debug, not a full strip, since kernel modules need their symtab and relocations to be loadable by the module loader). On the device, the existing postinst depmod call indexes extra/, so modprobe and autoload resolve the module with no other changes required. kgsl is wired in as the reference module (declared in a follow-up commit, separately from this generic mechanism), validated end to end on both the Ubuntu/resolute (Docker) and Debian/trixie (Debusine) build paths. Document the mechanism, the manifest format, and standalone developer use in README.md. Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
The Debian Debusine build path now needs kgsl-dkms as a build dependency (via PR #54 against qcom/debian/latest). The package is published in the qli Debusine workspace, so the build step must expose qli as an extra build-dependency source when invoking debusine-action/lib/build. Set EXTRA_BUILD_DEP_WORKSPACES=qli in Build in Debusine. DEBUSINE_USER, which lib/build requires for its extra_repositories compatibility workaround, is already set on this step (added independently for the build signing key), so no change is needed for it here. Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
c496305 to
3a9983c
Compare
The Debian Debusine build path now needs kgsl-dkms as a build dependency (via PR #54 against qcom/debian/latest). The package is published in the qli Debusine workspace, so the build step must expose qli as an extra build-dependency source when invoking debusine-action/lib/build. Set EXTRA_BUILD_DEP_WORKSPACES=qli in Build in Debusine. DEBUSINE_USER, which lib/build requires for its extra_repositories compatibility workaround, is already set on this step (added independently for the build signing key), so no change is needed for it here. Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
kgsl is the reference module wired into debian/dkms-modules, validated end to end on both the Ubuntu/resolute (Docker) and Debian/trixie (Debusine) build paths. Declare its -dkms package as a build-time-only dependency, separately from the generic dkms tooling dependency, so future per-module additions (camx-dkms, iris-vpu-dkms) each land as their own commit alongside the manifest line they require, with no change to debian/rules or the bundling tool itself. No version floor: kgsl 1.0.4 is in qli and 1.0.10 is in qli-staging, well past any earlier pin. No package relationship is declared against the -dkms packages here. Deciding whether the kernel image should Conflict with, Break, or Provide them needs its own discussion: the kernel image ships a built module for one kernel while a -dkms package serves every installed kernel, and the -dkms package also ships runtime configuration that the kernel image does not. Left for a follow-up so it does not hold up the mechanism. Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
3a9983c to
a9dc634
Compare
e07dd41
into
qcom/debian/latest
Summary
This adds a build-time mechanism that compiles out-of-tree kernel modules from
their DKMS source packages and bundles them into the kernel package, in the same
run that builds the kernel. The device receives one self-contained kernel
package: the module is present and pinned to the exact kernel it was built
against, with no DKMS, compiler, or headers required on the target.
The mechanism is module-agnostic. It is implemented as a standalone, documented
tool (
debian/scripts/bundle-dkms-modules.sh) thatdebian/rulesinvokes duringthe build, and it is driven by a manifest, so onboarding any out-of-tree module
is a two-line change with no change to the build logic.
Design history and rationale: #44.
How it works, in order
flowchart TD P["module DKMS source package<br/>(from the distro apt source)"] K["1. Build kernel + headers<br/>in one packaging run"] H["2. Stage headers in the build tree"] R["3. debian/rules calls<br/>bundle-dkms-modules.sh"] RES["4. Resolve source + tokens<br/>via dpkg -L and dkms.conf"] D["5. dkms build against the<br/>staged headers (private tree)"] J{"6. Built a .ko?"} X["Fail the build<br/>with precise diagnostics"] S["7. Extract debug to -dbg,<br/>strip the shipped copy"] B["8. Bundle into the kernel image<br/>under lib/modules/KVER/extra"] O["9. On device: depmod indexes it,<br/>modprobe + autoload work"] P -. "Build-Depends" .-> RES K --> H --> R --> RES --> D --> J J -- "no" --> X J -- "yes" --> S --> B --> O*-dkmspackage is installed viaBuild-Depends(build-timeonly; it never enters any binary package's runtime dependencies).
debian/rules(override_dh_auto_install) invokes the bundling tool once thetrees are staged.
name/version tokens from
dpkg -Land the shippeddkms.conf.dkms buildagainst the staged headers in a private DKMS tree, so themodule matches the exact kernel and the build stays rootless under
fakeroot.build with precise diagnostics if a listed module produces nothing.
-dbgpackage and strips the shippedcopy, the same two-stage handling an in-tree module gets.
lib/modules/<KVER>/extra/,guarding against duplicate and in-tree name collisions.
depmodindexesextra/, somodprobeand autoload resolve the module.
The tool:
debian/scripts/bundle-dkms-modules.shThe bundling logic is a single standalone tool with a documented CLI, so
debian/rulesstays a thin call, future changes (a new guard, signing,compression) touch one file, and a developer can re-run just the bundling step
against already-staged trees.
The tool resolves each module authoritatively (no path globbing), judges
outcomes by artifacts, hard-fails when a declared module produces nothing, prints actionable diagnostics on failure
(the
make.logtail for a build failure, or thedkms.confgates evaluatedagainst the kernel config for a skip), and guards against name collisions.
CI path:
debian/rulescalls the tooloverride_dh_auto_installinvokes the tool with explicit, absolute paths afterthe kernel, headers, and debug trees are staged:
$(CURDIR)/debian/scripts/bundle-dkms-modules.sh \ --kver "$$BASE" \ --headers-dir "$(CURDIR)/debian/linux-headers-$$BASE-qcom/usr/src/linux-headers-$$BASE" \ --image-pkg-dir "$(CURDIR)/$$PKG" \ --dbg-pkg-dir "$(CURDIR)/$$DBG_PKG" \ --arch "$(DKMS_ARCH)" \ --objcopy "$(OBJCOPY)" \ --modules-manifest "$(CURDIR)/debian/dkms-modules"dh_installmodules(called inoverride_dh_installdeb) wires the postinstdepmodthat indexesextra/on the device.Developer path: run the tool standalone
A developer who has already staged the kernel trees can re-run just the bundling
step, without re-running the whole
dpkg-buildpackage:--helpdocuments the full CLI, prerequisites, and a host-arch note (the toolbuilds with the host toolchain and is intended to run on a native arm64 host).
The manifest:
debian/dkms-modulesA plain-text list of module names, one per line. Comments, blank lines, and CRLF
endings are tolerated. This is the single place that decides which modules are
built and bundled; the tool and
debian/rulesare untouched when it changes.Adding a module is two lines:
debian/dkms-modules.dkmsand<name>-dkms (>= x.y.z)toBuild-Dependsindebian/control.in.Module load policy
Blacklisting and load policy are orthogonal to this change. The bundled module is
installed under
/lib/modules/<KVER>/extra/and indexed by the standarddepmod,so to the loader it is an ordinary module: the usual controls apply by module name,
unchanged (a
blacklistorinstallline inmodprobe.d, ormodprobe.blacklist=or
module_blacklist=on the kernel command line). The kernel package intentionallyships no load policy of its own, because a blacklist is board and policy specific
while this package is shared across boards; that decision stays external to this
mechanism, at the image build stage.
Validation
Both runs below were built from this branch's packaging
(
pkg-linux-qcom-ref: feat/dkms-build-time-module-integration) after the rebaseonto the multi-variant packaging from #62, against kernel
7.2.0-qcom-next-20260826andkgsl-dkms 1.0.12.CI (Ubuntu, resolute). Run
33023768993.
kgsl-dkms 1.0.12-0qli1is pulled in throughBuild-Depends, and the module isbuilt against the headers staged earlier in the same run rather than against
anything on the build host:
The contents of the built packages confirm the two-stage handling landed in the
right places:
All six packages build (image, headers, their debug companions, and both
metapackages) at
7.2.0+20260826-0qli~26.04.1~, and the run is green through theS3 upload.
CI (Debian, trixie). Run
33023767189.
The source package is submitted to Debusine, both work requests complete
successfully, and the same six packages are produced at
7.2.0+20260826-0qli~bpo13+1~, retrieved from the workspace and published to S3.The binary build runs on Debusine, so its
sbuildlog is not streamed back intothe GitHub log; the bundling output visible above for Ubuntu is therefore not
reproduced here. The build completing is itself the signal:
kgslis listed indebian/dkms-modules, and a listed module that yields no.kofails the buildrather than shipping an image without it. For a byte-level check, the
.debcanbe pulled from S3 and inspected with
dpkg -c.Local (standalone tool, 18 of 18). The tool was exercised through its CLI
against shimmed leaf tools, so its real control flow, resolution, outcome
judgment, collision guards, and path layout all run:
extra/, debug written to the-dbgtree, strip ran on the shipped copydkms.conf, missingPACKAGE_NAMEmake.logtail; gated skip with config set, with config unset, and with no gates declared; compressed output reportedRequirements (R1 to R7)
Build-Dependson the DKMS source packages. DKMS is a build-time tool, not a runtime mechanism.Depends,Recommends, orSuggestsof any binary package.*-dkmspackage. The kernel CI only consumes it.-dbgpackage.Design decisions
debian/rulesis a thin call, future changes touch one place, and the step is independently re-runnable.make.logand thedkms.confgates.dpkg -Lnames the onedkms.confthe package ships; itsPACKAGE_NAME/PACKAGE_VERSIONare the tokens dkms keys on. No path globbing.fakeroot, away from the root-owned/var/lib/dkms.-dbgpackage viaobjcopy --only-keep-debug, then strip the shipped copy viastrip --strip-debug.Commits (3)
Reorganized per review: the generic
dkmsbuild-dependency, the mechanismitself, and the
kgsl-specific build-dependency (now unpinned) are separatecommits. The mechanism lands directly as the generic tool, with the
incremental bring-up-then-extract history squashed away.
No package relationship (
Conflicts,Breaks,Provides,Replaces) isdeclared against the
-dkmspackages in this PR. That question is deferredto a follow-up so it does not hold up the mechanism.
Not in this PR
module loads and functions (
modprobe, autoload). Hardware validation, owned bythe device team.
Notes
qcom/debian/latest.