Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#72801 - fix `nvidia-dkms` failing to compile against kernel 5.16 due to removed MIGRATE_PFN_LOCKED macro

Attached to Project: Arch Linux
Opened by Scott B (arglebargle) - Saturday, 20 November 2021, 23:33 GMT
Last edited by Antonio Rojas (arojas) - Wednesday, 26 January 2022, 08:02 GMT
Task Type Feature Request
Category Packages: Extra
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Felix Yan (felixonmars)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

`nvidia-dkms` fails to build against kernel 5.16 due to removal of the MIGRATE_PFN_LOCKED macro upstream. If possible could you include a sed call in the PKGBUILD to strip the MIGRATE_PFN_LOCKED macro until nvidia does it themselves? Depending on nvidia's update schedule this might be needed when 5.16 is released anyway, so I figure posting the solution now won't hurt.

This should be nice and safe, the kernel submission that removes the macro notes that the work MIGRATE_PFN_LOCKED does is effectively useless hence the removal, see:20211025041608.289017-1-apopple@nvidia.com/T/"> https://lore.kernel.org/linux-mm/20211025041608.289017-1-apopple@nvidia.com/T/

And here's a thread on the nvidia forums discussing build failure and solution for reference: https://forums.developer.nvidia.com/t/495-44-linux-5-16-rc1-dkms-build-fails-on-linux-5-16-rc1/195126/3

Here's the PKGBUILD change I'm using locally:

```
diff --git a/PKGBUILD b/PKGBUILD
index 2d7472e..b90357f 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -53,6 +53,10 @@ DEST_MODULE_LOCATION[4]="/kernel/drivers/video"' dkms.conf

# Gift for linux-rt guys
sed -i 's/NV_EXCLUDE_BUILD_MODULES/IGNORE_PREEMPT_RT_PRESENCE=1 NV_EXCLUDE_BUILD_MODULES/' dkms.conf
+
+ # fix compilation against 5.16 due to removed MIGRATE_PFN_LOCKED macro
+ # see:20211025041608.289017-1-apopple@nvidia.com/T/"> https://lore.kernel.org/linux-mm/20211025041608.289017-1-apopple@nvidia.com/T/
+ sed -i 's/ | MIGRATE_PFN_LOCKED//g' nvidia-uvm/uvm_migrate_pageable.c
}

package_opencl-nvidia() {
```

Additional info:
* package version(s)
nvidia-dkms 495.44-5

* config and/or log files etc.
compilation errors-
`uvm_migrate_pageable.c:409:55: error: use of undeclared identifier 'MIGRATE_PFN_LOCKED'`

* link to upstream bug report, if any
n/a

Steps to reproduce:

Install nvidia-dkms with a 5.16 kernel present, attempt to build the module.
This task depends upon

Closed by  Antonio Rojas (arojas)
Wednesday, 26 January 2022, 08:02 GMT
Reason for closing:  Fixed
Comment by loqs (loqs) - Saturday, 20 November 2021, 23:53 GMT
Your fix does not include a guard limiting its use to 5.16 or when MIGRATE_PFN_LOCKED is not already defined.
Have you verified this is not an issue on earlier kernels?
Edit:
sed -i '/^#include <linux\/migrate.h>$/a#ifndef MIGRATE_PFN_LOCKED\n#define MIGRATE_PFN_LOCKED 0\n#endif' nvidia-uvm/uvm_migrate_pageable.c
Comment by Scott B (arglebargle) - Sunday, 21 November 2021, 01:45 GMT
Thanks, that's probably a safer change! I've tested the first version pretty extensively on 5.15, I'll go ahead and test your revision this weekend.

Cheers!
Comment by Scott B (arglebargle) - Monday, 22 November 2021, 21:36 GMT
I've been testing @loqs' suggested change the last couple days and it seems to be working fine on my desktop and laptop.
Comment by Bryan (bryan) - Monday, 24 January 2022, 18:11 GMT
Could the fix be applied to nvidia-dkms 470.74-1 too, as it fails too with kernel 5.16.x?
Comment by Doug Newgard (Scimmia) - Monday, 24 January 2022, 18:15 GMT
Arch is on 495.46-2 now, 470.74-1 has nothing to do with it.

Loading...