linuxPackages_latest.nvidiaPackages.latest: fix fbdev on 6.13

+304
+156
pkgs/os-specific/linux/nvidia-x11/TTM-fbdev-emulation-for-Linux-6.13.patch
··· 1 + From 88b8ae7642ef21e685d51148e8f57c3dfa1323ac Mon Sep 17 00:00:00 2001 2 + From: Bingwu Zhang <xtex@aosc.io> 3 + Date: Sat, 7 Dec 2024 23:56:43 +0800 4 + Subject: [PATCH 10/10] FROM AOSC: TTM fbdev emulation for Linux 6.13+ 5 + 6 + Link: https://github.com/torvalds/linux/commit/1000634477d8d178179b1ad45d92e925fabe3deb 7 + Link: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/749 8 + Signed-off-by: xtex <xtexchooser@duck.com> 9 + Signed-off-by: Eric Naim <dnaim@cachyos.org> 10 + --- 11 + kernel-open/nvidia-drm/nvidia-drm-drv.c | 72 +++++++++++++++++++ 12 + kernel-open/nvidia-drm/nvidia-drm-linux.c | 4 ++ 13 + .../nvidia-drm/nvidia-drm-os-interface.h | 5 ++ 14 + 3 files changed, 81 insertions(+) 15 + 16 + diff --git a/kernel-open/nvidia-drm/nvidia-drm-drv.c b/kernel-open/nvidia-drm/nvidia-drm-drv.c 17 + index 2e4f6404..ab85152f 100644 18 + --- a/kernel-open/nvidia-drm/nvidia-drm-drv.c 19 + +++ b/kernel-open/nvidia-drm/nvidia-drm-drv.c 20 + @@ -1951,7 +1951,60 @@ void nv_drm_update_drm_driver_features(void) 21 + #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */ 22 + } 23 + 24 + +#if !defined(NV_DRM_FBDEV_TTM_AVAILABLE) && \ 25 + + !defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) 26 + +// AOSC OS: Workaround for Linux 6.13+ 27 + 28 + +static const struct drm_fb_helper_funcs nv_drm_fbdev_helper_funcs = { 29 + + .fb_probe = drm_fbdev_ttm_driver_fbdev_probe, 30 + +}; 31 + + 32 + +static void nv_drm_fbdev_client_unregister(struct drm_client_dev *client) 33 + +{ 34 + + struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client); 35 + + if (fb_helper->info) { 36 + + drm_fb_helper_unregister_info(fb_helper); 37 + + } else { 38 + + drm_client_release(&fb_helper->client); 39 + + drm_fb_helper_unprepare(fb_helper); 40 + + kfree(fb_helper); 41 + + } 42 + +} 43 + +static int nv_drm_fbdev_client_restore(struct drm_client_dev *client) 44 + +{ 45 + + drm_fb_helper_lastclose(client->dev); 46 + + return 0; 47 + +} 48 + +static int nv_drm_fbdev_client_hotplug(struct drm_client_dev *client) 49 + +{ 50 + + struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client); 51 + + struct drm_device *dev = client->dev; 52 + + int ret; 53 + + if (dev->fb_helper) 54 + + return drm_fb_helper_hotplug_event(dev->fb_helper); 55 + + ret = drm_fb_helper_init(dev, fb_helper); 56 + + if (ret) 57 + + goto err_drm_err; 58 + + if (!drm_drv_uses_atomic_modeset(dev)) 59 + + drm_helper_disable_unused_functions(dev); 60 + + ret = drm_fb_helper_initial_config(fb_helper); 61 + + if (ret) 62 + + goto err_drm_fb_helper_fini; 63 + + return 0; 64 + +err_drm_fb_helper_fini: 65 + + drm_fb_helper_fini(fb_helper); 66 + +err_drm_err: 67 + + drm_err(dev, "AOSC OS: NV-DRM: fbdev: Failed to setup emulation (ret=%d)\n", ret); 68 + + return ret; 69 + +} 70 + + 71 + +static const struct drm_client_funcs nv_drm_fbdev_client_funcs = { 72 + + .owner = THIS_MODULE, 73 + + .unregister = nv_drm_fbdev_client_unregister, 74 + + .restore = nv_drm_fbdev_client_restore, 75 + + .hotplug = nv_drm_fbdev_client_hotplug, 76 + +}; 77 + +#endif 78 + 79 + /* 80 + * Helper function for allocate/register DRM device for given NVIDIA GPU ID. 81 + @@ -1961,6 +2014,7 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info) 82 + struct nv_drm_device *nv_dev = NULL; 83 + struct drm_device *dev = NULL; 84 + struct device *device = gpu_info->os_device_ptr; 85 + + struct drm_fb_helper *fb_helper = NULL; 86 + bool bus_is_pci; 87 + 88 + DRM_DEBUG( 89 + @@ -2039,6 +2093,20 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info) 90 + drm_fbdev_ttm_setup(dev, 32); 91 + #elif defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) 92 + drm_fbdev_generic_setup(dev, 32); 93 + + #else 94 + + // AOSC OS: Workaround for Linux 6.13+ 95 + + int drm_client_ret; 96 + + fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL); 97 + + if (!fb_helper) 98 + + return; 99 + + drm_fb_helper_prepare(dev, fb_helper, 32, &nv_drm_fbdev_helper_funcs); 100 + + drm_client_ret = drm_client_init(dev, &fb_helper->client, "fbdev", 101 + + &nv_drm_fbdev_client_funcs); 102 + + if (drm_client_ret) { 103 + + drm_err(dev, "AOSC OS: NV-DRM: Failed to register DRM client: %d\n", drm_client_ret); 104 + + goto failed_drm_client_init; 105 + + } 106 + + drm_client_register(&fb_helper->client); 107 + #endif 108 + } 109 + #endif /* defined(NV_DRM_FBDEV_AVAILABLE) */ 110 + @@ -2050,6 +2118,10 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info) 111 + 112 + return; /* Success */ 113 + 114 + +failed_drm_client_init: 115 + + drm_fb_helper_unprepare(fb_helper); 116 + + kfree(fb_helper); 117 + + 118 + failed_drm_register: 119 + 120 + nv_drm_dev_free(dev); 121 + diff --git a/kernel-open/nvidia-drm/nvidia-drm-linux.c b/kernel-open/nvidia-drm/nvidia-drm-linux.c 122 + index 83d40983..ac4fe967 100644 123 + --- a/kernel-open/nvidia-drm/nvidia-drm-linux.c 124 + +++ b/kernel-open/nvidia-drm/nvidia-drm-linux.c 125 + @@ -39,8 +39,12 @@ MODULE_PARM_DESC( 126 + fbdev, 127 + "Create a framebuffer device (1 = enable (default), 0 = disable) (EXPERIMENTAL)"); 128 + module_param_named(fbdev, nv_drm_fbdev_module_param, bool, 0400); 129 + +#else 130 + +#error "nvidia-drm fbdev should always be available." 131 + #endif 132 + 133 + +#else 134 + +#error "nvidia-drm is not available" 135 + #endif /* NV_DRM_AVAILABLE */ 136 + 137 + /************************************************************************* 138 + diff --git a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h 139 + index 71ca5f22..8195af32 100644 140 + --- a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h 141 + +++ b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h 142 + @@ -78,6 +78,11 @@ typedef struct nv_timer nv_drm_timer; 143 + #define NV_DRM_FBDEV_TTM_AVAILABLE 144 + #endif 145 + 146 + +// AOSC OS: Always enable DRM fbdev 147 + +// FIXME: Add config test for drm helper functions. 148 + +// The implementation uses drm_client_register, which is added in v5.2-rc1. 149 + +#define NV_DRM_FBDEV_AVAILABLE 150 + + 151 + struct page; 152 + 153 + /* Set to true when the atomic modeset feature is enabled. */ 154 + -- 155 + 2.47.1 156 +
+146
pkgs/os-specific/linux/nvidia-x11/Use-linux-aperture.c-for-removing-conflict.patch
··· 1 + From 11501d99348a04c608a19330d984188f4766e603 Mon Sep 17 00:00:00 2001 2 + From: Bingwu Zhang <xtex@aosc.io> 3 + Date: Sat, 7 Dec 2024 23:01:26 +0800 4 + Subject: [PATCH 09/10] FROM AOSC: Use linux/aperture.c for removing 5 + conflicting PCI devices on Linux 6.13.0-rc1+ 6 + 7 + Link: https://github.com/torvalds/linux/commit/689274a56c0c088796d359f6c6267323931a2429 8 + Link: https://github.com/torvalds/linux/commit/7283f862bd991c8657e9bf1c02db772fcf018f13 9 + Link: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/749 10 + Signed-off-by: Eric Naim <dnaim@cachyos.org> 11 + --- 12 + kernel-open/conftest.sh | 19 +++++++++++++++++++ 13 + kernel-open/header-presence-tests.mk | 1 + 14 + kernel-open/nvidia-drm/nvidia-drm-drv.c | 15 +++++++++++++++ 15 + .../nvidia-drm/nvidia-drm-os-interface.h | 10 ++++++++++ 16 + kernel-open/nvidia-drm/nvidia-drm-sources.mk | 1 + 17 + 5 files changed, 46 insertions(+) 18 + 19 + diff --git a/kernel-open/conftest.sh b/kernel-open/conftest.sh 20 + index fdceda72..5a0f39e0 100755 21 + --- a/kernel-open/conftest.sh 22 + +++ b/kernel-open/conftest.sh 23 + @@ -6615,6 +6615,8 @@ compile_test() { 24 + # Added by commit 2916059147ea ("drm/aperture: Add infrastructure 25 + # for aperture ownership") in v5.14. 26 + # 27 + + # Removed by commit 689274a56c0c ("drm: Remove DRM aperture helpers") in v6.13. 28 + + # 29 + CODE=" 30 + #if defined(NV_DRM_DRM_APERTURE_H_PRESENT) 31 + #include <drm/drm_aperture.h> 32 + @@ -6626,6 +6628,23 @@ compile_test() { 33 + compile_check_conftest "$CODE" "NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT" "" "functions" 34 + ;; 35 + 36 + + aperture_remove_conflicting_pci_devices) 37 + + # 38 + + # Determine whether aperture_remove_conflicting_pci_devices is present. 39 + + # 40 + + # Added by commit 7283f862bd99 ("drm: Implement DRM aperture helpers under video/") in v6.0. 41 + + # 42 + + CODE=" 43 + + #if defined(NV_LINUX_APERTURE_H_PRESENT) 44 + + #include <linux/aperture.h> 45 + + #endif 46 + + void conftest_aperture_remove_conflicting_pci_devices(void) { 47 + + aperture_remove_conflicting_pci_devices(); 48 + + }" 49 + + 50 + + compile_check_conftest "$CODE" "NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT" "" "functions" 51 + + ;; 52 + + 53 + drm_aperture_remove_conflicting_pci_framebuffers_has_driver_arg) 54 + # 55 + # Determine whether drm_aperture_remove_conflicting_pci_framebuffers 56 + diff --git a/kernel-open/header-presence-tests.mk b/kernel-open/header-presence-tests.mk 57 + index 9d5217a9..b0268541 100644 58 + --- a/kernel-open/header-presence-tests.mk 59 + +++ b/kernel-open/header-presence-tests.mk 60 + @@ -34,6 +34,7 @@ NV_HEADER_PRESENCE_TESTS = \ 61 + generated/autoconf.h \ 62 + generated/compile.h \ 63 + generated/utsrelease.h \ 64 + + linux/aperture.h \ 65 + linux/efi.h \ 66 + linux/kconfig.h \ 67 + linux/platform/tegra/mc_utils.h \ 68 + diff --git a/kernel-open/nvidia-drm/nvidia-drm-drv.c b/kernel-open/nvidia-drm/nvidia-drm-drv.c 69 + index 8f905f82..2e4f6404 100644 70 + --- a/kernel-open/nvidia-drm/nvidia-drm-drv.c 71 + +++ b/kernel-open/nvidia-drm/nvidia-drm-drv.c 72 + @@ -65,7 +65,16 @@ 73 + #endif 74 + 75 + #if defined(NV_DRM_FBDEV_AVAILABLE) 76 + +// Commit 7283f862bd99 ("drm: Implement DRM aperture helpers under video/") 77 + +// moved implementation of drm_aperture_... to linux/aperture.c. 78 + +// Commit 689274a56c0c ("drm: Remove DRM aperture helpers") 79 + +// removed drm/drm_aperture.h. 80 + +#if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT) 81 + #include <drm/drm_aperture.h> 82 + +#endif 83 + +#if defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT) 84 + +#include <linux/aperture.h> 85 + +#endif 86 + #include <drm/drm_fb_helper.h> 87 + #endif 88 + 89 + @@ -2013,10 +2022,16 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info) 90 + if (bus_is_pci) { 91 + struct pci_dev *pdev = to_pci_dev(device); 92 + 93 + +#if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT) 94 + + printk(KERN_INFO "%s: using drm_aperture for old kernels\n", nv_drm_driver.name); 95 + #if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_HAS_DRIVER_ARG) 96 + drm_aperture_remove_conflicting_pci_framebuffers(pdev, &nv_drm_driver); 97 + #else 98 + drm_aperture_remove_conflicting_pci_framebuffers(pdev, nv_drm_driver.name); 99 + +#endif 100 + +#elif defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT) 101 + + printk(KERN_INFO "%s: using linux/aperture workaround for Linux 6.13+\n", nv_drm_driver.name); 102 + + aperture_remove_conflicting_pci_devices(pdev, nv_drm_driver.name); 103 + #endif 104 + nvKms->framebufferConsoleDisabled(nv_dev->pDevice); 105 + } 106 + diff --git a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h 107 + index a6b0f947..71ca5f22 100644 108 + --- a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h 109 + +++ b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h 110 + @@ -63,11 +63,21 @@ typedef struct nv_timer nv_drm_timer; 111 + #define NV_DRM_FBDEV_GENERIC_AVAILABLE 112 + #endif 113 + 114 + +#if defined(NV_DRM_FBDEV_GENERIC_SETUP_PRESENT) && defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT) 115 + +#define NV_DRM_FBDEV_AVAILABLE 116 + +#define NV_DRM_FBDEV_GENERIC_AVAILABLE 117 + +#endif 118 + + 119 + #if defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT) && defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT) 120 + #define NV_DRM_FBDEV_AVAILABLE 121 + #define NV_DRM_FBDEV_TTM_AVAILABLE 122 + #endif 123 + 124 + +#if defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT) && defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT) 125 + +#define NV_DRM_FBDEV_AVAILABLE 126 + +#define NV_DRM_FBDEV_TTM_AVAILABLE 127 + +#endif 128 + + 129 + struct page; 130 + 131 + /* Set to true when the atomic modeset feature is enabled. */ 132 + diff --git a/kernel-open/nvidia-drm/nvidia-drm-sources.mk b/kernel-open/nvidia-drm/nvidia-drm-sources.mk 133 + index 9aaebd04..a4dcad6d 100644 134 + --- a/kernel-open/nvidia-drm/nvidia-drm-sources.mk 135 + +++ b/kernel-open/nvidia-drm/nvidia-drm-sources.mk 136 + @@ -66,6 +66,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += dma_fence_set_error 137 + NV_CONFTEST_FUNCTION_COMPILE_TESTS += fence_set_error 138 + NV_CONFTEST_FUNCTION_COMPILE_TESTS += sync_file_get_fence 139 + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_conflicting_pci_framebuffers 140 + +NV_CONFTEST_FUNCTION_COMPILE_TESTS += aperture_remove_conflicting_pci_devices 141 + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_generic_setup 142 + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_ttm_setup 143 + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_attach_hdr_output_metadata_property 144 + -- 145 + 2.47.1 146 +
+2
pkgs/os-specific/linux/nvidia-x11/default.nix
··· 89 89 patchesOpen = [ 90 90 ./nvidia-nv-Convert-symbol-namespace-to-string-literal.patch 91 91 ./crypto-Add-fix-for-6.13-Module-compilation.patch 92 + ./Use-linux-aperture.c-for-removing-conflict.patch 93 + ./TTM-fbdev-emulation-for-Linux-6.13.patch 92 94 ]; 93 95 }); 94 96