Linux 6.12 kernel Nvidia G04 - patch
All, Devs, Nvidia G04 (390xx) and G05 (470) drivers will need to be patched for the 6.12 kernel due to removal of drm_mode_config_funcs.output_poll_changed See: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/708 I've prepared a patch for G04 for Arch: diff -ruNb a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c --- a/kernel/nvidia-drm/nvidia-drm-drv.c 2024-07-19 05:21:27.848184261 -0500 +++ b/kernel/nvidia-drm/nvidia-drm-drv.c 2024-11-23 20:07:40.218031132 -0600 @@ -168,7 +168,9 @@ .atomic_check = nv_drm_atomic_check, .atomic_commit = nv_drm_atomic_commit, + #if defined(NV_DRM_OUTPUT_POLL_CHANGED_PRESENT) .output_poll_changed = nv_drm_output_poll_changed, + #endif }; static void nv_drm_event_callback(const struct NvKmsKapiEvent *event) Which can be adapted for openSUSE. The G05 patch will be similar, but I don't have that driver to determine if conftest.sh or nvidia-drm-sources.mk need patching as shown in the link above. -- David C. Rankin, J.D.,P.E.
see here: https://gist.github.com/joanbm Am Sonntag, 24. November 2024, 03:24:23 CET schrieb David C. Rankin:
All, Devs,
Nvidia G04 (390xx) and G05 (470) drivers will need to be patched for the 6.12 kernel due to removal of drm_mode_config_funcs.output_poll_changed
See: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/708
I've prepared a patch for G04 for Arch:
diff -ruNb a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c --- a/kernel/nvidia-drm/nvidia-drm-drv.c 2024-07-19 05:21:27.848184261 -0500 +++ b/kernel/nvidia-drm/nvidia-drm-drv.c 2024-11-23 20:07:40.218031132 -0600 @@ -168,7 +168,9 @@ .atomic_check = nv_drm_atomic_check, .atomic_commit = nv_drm_atomic_commit,
+ #if defined(NV_DRM_OUTPUT_POLL_CHANGED_PRESENT) .output_poll_changed = nv_drm_output_poll_changed, + #endif };
static void nv_drm_event_callback(const struct NvKmsKapiEvent *event)
Which can be adapted for openSUSE. The G05 patch will be similar, but I don't have that driver to determine if conftest.sh or nvidia-drm-sources.mk need patching as shown in the link above.
On 11/24/24 2:05 AM, Stephan Hemeier via openSUSE Users wrote:
see here: https://gist.github.com/joanbm
Am Sonntag, 24. November 2024, 03:24:23 CET schrieb David C. Rankin:
All, Devs,
Nvidia G04 (390xx) and G05 (470) drivers will need to be patched for the 6.12 kernel due to removal of drm_mode_config_funcs.output_poll_changed
See:https://github.com/NVIDIA/open-gpu-kernel-modules/issues/708
Thank you Stephan, It looks like the G05/470 patch has a few more sources that need updating compared to G04/390xx. Interesting they decided to make conditional code inclusion on kernel-version instead of the functionality. I guess that would be a bit more flexible for the 390 driver patch as NV_DRM_OUTPUT_POLL_CHANGED_PRESENT wasn't included in earlier versions of this driver so it would still allows the code: .output_poll_changed = nv_drm_output_poll_changed, to be compiled for kernel versions before 6.12 where it was compiling without problems. -- David C. Rankin, J.D.,P.E.
On 11/24/24 2:05 AM, Stephan Hemeier via openSUSE Users wrote:
see here: https://gist.github.com/joanbm
Thanks Stephan, Redid G04/390 driver patch based on the 470 link above. Applied the same, tested and working fine. diff -ruNb a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c --- a/kernel/nvidia-drm/nvidia-drm-drv.c 2024-07-19 05:21:27.848184261 -0500 +++ b/kernel/nvidia-drm/nvidia-drm-drv.c 2024-11-24 03:10:09.342147481 -0600 @@ -84,6 +84,11 @@ #include <drm/drm_atomic_helper.h> #endif +#include <linux/version.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) +#include <drm/drm_client.h> +#endif + static struct nv_drm_device *dev_list = NULL; #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) @@ -168,7 +173,12 @@ .atomic_check = nv_drm_atomic_check, .atomic_commit = nv_drm_atomic_commit, +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0) + // Rel. commit. "drm: Remove struct drm_mode_config_funcs.output_poll_changed" (Thomas Zimmermann, 12 Aug 2024) + // Replace this callback with a DRM client's hotplug callback. + // This is required for e.g. /sys/class/drm/card*/modes to work. .output_poll_changed = nv_drm_output_poll_changed, +#endif }; static void nv_drm_event_callback(const struct NvKmsKapiEvent *event) @@ -652,6 +662,10 @@ .read = drm_read, .llseek = noop_llseek, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) + // Rel. commit. "fs: move FMODE_UNSIGNED_OFFSET to fop_flags" (Christian Brauner, 9 Aug 2024) + .fop_flags = FOP_UNSIGNED_OFFSET, +#endif }; #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0) @@ -790,7 +804,18 @@ #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */ } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) +static int hotplug_helper_client_hotplug(struct drm_client_dev *client) +{ + nv_drm_output_poll_changed(client->dev); + return 0; +} +static const struct drm_client_funcs nv_hotplug_helper_client_funcs = { + .owner = THIS_MODULE, + .hotplug = hotplug_helper_client_hotplug, +}; +#endif /* * Helper function for allocate/register DRM device for given NVIDIA GPU ID. @@ -844,6 +869,20 @@ goto failed_drm_register; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) + /* Register a DRM client for receiving hotplug events */ + struct drm_client_dev *client = kzalloc(sizeof(*client), GFP_KERNEL); + if (client == NULL || drm_client_init(dev, client, + "nv-hotplug-helper", &nv_hotplug_helper_client_funcs)) { + printk(KERN_WARNING "Failed to initialize the nv-hotplug-helper DRM client" + " (ensure DRM kernel mode setting is enabled via nvidia-drm.modeset=1).\n"); + goto failed_drm_client_init; + } + + drm_client_register(client); + pr_info("Registered the nv-hotplug-helper DRM client.\n"); +#endif + /* Add NVIDIA-DRM device into list */ nv_dev->next = dev_list; @@ -851,6 +890,14 @@ return; /* Success */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) +failed_drm_client_init: + + kfree(client); + drm_dev_unregister(dev); + +#endif + failed_drm_register: nv_drm_dev_free(dev); Applies on top of all current patches. -- David C. Rankin, J.D.,P.E.
The patch was also mentioned by him in the link of the issue posted by you: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/708 I have used his patches to build the driver here on my PC because of the lag of the Nvidia Repo. I also use the patches from Joan Bruguera for the broadcom drivers to build them for Tumbleweed and kernel:stable. Stephan Am Sonntag, 24. November 2024, 10:27:00 CET schrieb David C. Rankin:
Thanks Stephan,
Redid G04/390 driver patch based on the 470 link above. Applied the same, tested and working fine.
On 11/24/24 3:38 AM, Stephan Hemeier via openSUSE Users wrote:
he patch was also mentioned by him in the link of the issue posted by you: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/708
I have used his patches to build the driver here on my PC because of the lag of the Nvidia Repo.
I also use the patches from Joan Bruguera for the broadcom drivers to build them for Tumbleweed and kernel:stable.
Stephan
I've saved the link, it was solid work. Originally, I had worked from the failure log, which resulted in the 1st attempt at the patch -- which built, but didn't automatically register the nvidia card from /sys/class/drm and I had to use nvidia-xconfig to have it load the driver on start. The open-source driver conditioned everything on: #if defined(NV_DRM_OUTPUT_POLL_CHANGED_PRESENT) But the older closed source drivers need the additional patching Joan came up with. Very nicely done. Patches ended up being applied the same, just about 100 lines different as you worked down the nvidia-drm-drv.c source. Glad to have this done for 6.12. Now good until 6.13 on Arch, and hopefully the G04/G05 patches keep up when openSUSE TW moves to 6.12. Thanks again for the link. I updated the Arch/AUR package with it: https://aur.archlinux.org/packages/nvidia-390xx-utils -- David C. Rankin, J.D.,P.E.
On 11/24/24 3:38 AM, Stephan Hemeier via openSUSE Users wrote:
The patch was also mentioned by him in the link of the issue posted by you: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/708
I have used his patches to build the driver here on my PC because of the lag of the Nvidia Repo.
I also use the patches from Joan Bruguera for the broadcom drivers to build them for Tumbleweed and kernel:stable.
Stephan
Am Sonntag, 24. November 2024, 10:27:00 CET schrieb David C. Rankin:
Thanks Stephan,
Redid G04/390 driver patch based on the 470 link above. Applied the same, tested and working fine.
Note to Nvidia users, One of the patched issues for the 6.12 kernel is the kernel removing support for nvidia_drm and patching over with the Linux kernel drm in its place. While most will not notice the change, there are several reports where native resolution for connections over HDMI to say SmartTV are no longer automatically configured correctly. When Tumbleweed updates to the 6.12 kernel, there are troubleshooting steps you can take to restore the correct resolution. One method effective on Arch has been: copy /usr/share/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf to /etc/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf then edit /etc/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf and add the line Option "PrimaryGPU" "yes" The difficulty presented by the kernel removing support used by nvidia_drm is that each of the drivers, G04 (390xx) and G05 (470) and the 535 driver are all separate implementations of dkms drm. So it isn't a single patch or fix for all. All works for normal configs for now on 6.12, but it looks like it will take a driver-by-driver implementation of new kernel drm to attempt to restore full functionality. Oh joy.... -- David C. Rankin, J.D.,P.E.
participants (2)
-
David C. Rankin
-
Stephan Hemeier