Skip to content

Commit

Permalink
vendor-reset: fix build on Linux 6.12
Browse files Browse the repository at this point in the history
`asm/unaligned.h` has been moved to `linux/unaligned.h` since
Linux v. 6.12 [^1]. This has broken the build for `vendor-reset`
on newer versions.

I've opened a PR with the upstream project [^2], but that has been
sitting unmerged on GitHub for a while now, so I decided to add the
fix temporarily using `fetchpatch` in the NixOS module for now.
When it will (hopefully) eventually be merged, we should be able to
remove the patch and just switch to an up-to-date upstream version.

[^1]: torvalds/linux@5f60d5f
[^2]: gnif/vendor-reset#86
  • Loading branch information
mfrischknecht committed Dec 22, 2024
1 parent 55d3dc1 commit 6f402f7
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkgs/os-specific/linux/vendor-reset/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ stdenv.mkDerivation rec {
hash = "sha256-Klu2uysbF5tH7SqVl815DwR7W+Vx6PyVDDLwoMZiqBI=";
};

patches = [
# This is a temporary, vendored version of this upstream PR:
# https://github.com/gnif/vendor-reset/pull/86
# As soon as it is merged, we should be able to update this
# module and remove the patch.
./fix-linux-6.12-build.patch
];

nativeBuildInputs = kernel.moduleBuildDependencies;

hardeningDisable = [ "pic" ];
Expand Down
56 changes: 56 additions & 0 deletions pkgs/os-specific/linux/vendor-reset/fix-linux-6.12-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
From ab1b34848097587aca1f248958358ddb1dc90917 Mon Sep 17 00:00:00 2001
From: mfrischknecht <[email protected]>
Date: Sat, 23 Nov 2024 23:43:53 +0100
Subject: [PATCH 1/2] Import `unaligned.h` from `linux`

`asm/unaligned.h` has been moved to `linux/unaligned.h` since Linux v. 6.12.
C.f. e.g. https://github.com/torvalds/linux/commit/5f60d5f6bbc12e782fac78110b0ee62698f3b576
---
src/amd/amdgpu/atom.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/amd/amdgpu/atom.c b/src/amd/amdgpu/atom.c
index 333961f..d14c849 100644
--- a/src/amd/amdgpu/atom.c
+++ b/src/amd/amdgpu/atom.c
@@ -29,7 +29,7 @@
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/version.h>
-#include <asm/unaligned.h>
+#include <linux/unaligned.h>

//#include <drm/drm_util.h>
//#include <drm/drm_print.h>

From 54ffd6a012e7567b0288bc5fcc3678b545bd5aec Mon Sep 17 00:00:00 2001
From: mfrischknecht <[email protected]>
Date: Wed, 27 Nov 2024 07:09:37 +0100
Subject: [PATCH 2/2] Make new include path conditional
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

…so the module builds for both kernels below 6.12 and above. Thanks, @VoodaGod!

Co-authored-by: Jason Rensburger <[email protected]>
---
src/amd/amdgpu/atom.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/src/amd/amdgpu/atom.c b/src/amd/amdgpu/atom.c
index d14c849..36d45ff 100644
--- a/src/amd/amdgpu/atom.c
+++ b/src/amd/amdgpu/atom.c
@@ -29,7 +29,11 @@
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
+#include <asm/unaligned.h>
+#else
#include <linux/unaligned.h>
+#endif

//#include <drm/drm_util.h>
//#include <drm/drm_print.h>

0 comments on commit 6f402f7

Please sign in to comment.