From 772eaa91e1e79fb0a4a7e9d80abd99db7a0c0b61 Mon Sep 17 00:00:00 2001 From: Peter Jung Date: Thu, 26 Sep 2024 14:52:57 +0200 Subject: [PATCH 4/5] 6.11: Add fix for fbdev --- kernel-open/conftest.sh | 23 ++++++++++++++++++- kernel-open/header-presence-tests.mk | 1 + kernel-open/nvidia-drm/nvidia-drm-drv.c | 22 +++++++++++------- kernel-open/nvidia-drm/nvidia-drm-linux.c | 2 +- .../nvidia-drm/nvidia-drm-os-interface.h | 8 ++++++- kernel-open/nvidia-drm/nvidia-drm-sources.mk | 1 + 6 files changed, 46 insertions(+), 11 deletions(-) diff --git a/kernel-open/conftest.sh b/kernel-open/conftest.sh index 1226cea2..4a239e63 100755 --- a/kernel-open/conftest.sh +++ b/kernel-open/conftest.sh @@ -6596,7 +6596,9 @@ compile_test() { # Determine whether drm_fbdev_generic_setup is present. # # Added by commit 9060d7f49376 ("drm/fb-helper: Finish the - # generic fbdev emulation") in v4.19. + # generic fbdev emulation") in v4.19. Removed by commit + # aae4682e5d66 ("drm/fbdev-generic: Convert to fbdev-ttm") + # in v6.11. # CODE=" #include @@ -6610,6 +6612,25 @@ compile_test() { compile_check_conftest "$CODE" "NV_DRM_FBDEV_GENERIC_SETUP_PRESENT" "" "functions" ;; + drm_fbdev_ttm_setup) + # + # Determine whether drm_fbdev_ttm_setup is present. + # + # Added by commit aae4682e5d66 ("drm/fbdev-generic: + # Convert to fbdev-ttm") in v6.11. + # + CODE=" + #include + #if defined(NV_DRM_DRM_FBDEV_TTM_H_PRESENT) + #include + #endif + void conftest_drm_fbdev_ttm_setup(void) { + drm_fbdev_ttm_setup(); + }" + + compile_check_conftest "$CODE" "NV_DRM_FBDEV_TTM_SETUP_PRESENT" "" "functions" + ;; + drm_aperture_remove_conflicting_pci_framebuffers) # # Determine whether drm_aperture_remove_conflicting_pci_framebuffers is present. diff --git a/kernel-open/header-presence-tests.mk b/kernel-open/header-presence-tests.mk index e8d2e02b..40204ae4 100644 --- a/kernel-open/header-presence-tests.mk +++ b/kernel-open/header-presence-tests.mk @@ -15,6 +15,7 @@ NV_HEADER_PRESENCE_TESTS = \ drm/drm_atomic_uapi.h \ drm/drm_drv.h \ drm/drm_fbdev_generic.h \ + drm/drm_fbdev_ttm.h \ drm/drm_framebuffer.h \ drm/drm_connector.h \ drm/drm_probe_helper.h \ diff --git a/kernel-open/nvidia-drm/nvidia-drm-drv.c b/kernel-open/nvidia-drm/nvidia-drm-drv.c index 359ff0c4..50028c26 100644 --- a/kernel-open/nvidia-drm/nvidia-drm-drv.c +++ b/kernel-open/nvidia-drm/nvidia-drm-drv.c @@ -64,12 +64,14 @@ #include #endif -#if defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) +#if defined(NV_DRM_FBDEV_AVAILABLE) #include #include #endif -#if defined(NV_DRM_DRM_FBDEV_GENERIC_H_PRESENT) +#if defined(NV_DRM_DRM_FBDEV_TTM_H_PRESENT) +#include +#elif defined(NV_DRM_DRM_FBDEV_GENERIC_H_PRESENT) #include #endif @@ -476,7 +478,7 @@ static int nv_drm_load(struct drm_device *dev, unsigned long flags) return -ENODEV; } -#if defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) +#if defined(NV_DRM_FBDEV_AVAILABLE) /* * If fbdev is enabled, take modeset ownership now before other DRM clients * can take master (and thus NVKMS ownership). @@ -610,7 +612,7 @@ static void __nv_drm_unload(struct drm_device *dev) /* Release modeset ownership if fbdev is enabled */ -#if defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) +#if defined(NV_DRM_FBDEV_AVAILABLE) if (nv_dev->hasFramebufferConsole) { drm_atomic_helper_shutdown(dev); nvKms->releaseOwnership(nv_dev->pDevice); @@ -1838,7 +1840,7 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info) goto failed_drm_register; } -#if defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) +#if defined(NV_DRM_FBDEV_AVAILABLE) if (nv_drm_fbdev_module_param && drm_core_check_feature(dev, DRIVER_MODESET)) { @@ -1851,9 +1853,13 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info) drm_aperture_remove_conflicting_pci_framebuffers(pdev, nv_drm_driver.name); #endif } + #if defined(NV_DRM_FBDEV_TTM_AVAILABLE) + drm_fbdev_ttm_setup(dev, 32); + #elif defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) drm_fbdev_generic_setup(dev, 32); + #endif } -#endif /* defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) */ +#endif /* defined(NV_DRM_FBDEV_AVAILABLE) */ /* Add NVIDIA-DRM device into list */ @@ -1995,12 +2001,12 @@ void nv_drm_suspend_resume(NvBool suspend) if (suspend) { drm_kms_helper_poll_disable(dev); -#if defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) +#if defined(NV_DRM_FBDEV_AVAILABLE) drm_fb_helper_set_suspend_unlocked(dev->fb_helper, 1); #endif drm_mode_config_reset(dev); } else { -#if defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) +#if defined(NV_DRM_FBDEV_AVAILABLE) drm_fb_helper_set_suspend_unlocked(dev->fb_helper, 0); #endif drm_kms_helper_poll_enable(dev); diff --git a/kernel-open/nvidia-drm/nvidia-drm-linux.c b/kernel-open/nvidia-drm/nvidia-drm-linux.c index c7f4a239..83d40983 100644 --- a/kernel-open/nvidia-drm/nvidia-drm-linux.c +++ b/kernel-open/nvidia-drm/nvidia-drm-linux.c @@ -34,7 +34,7 @@ MODULE_PARM_DESC( "Enable atomic kernel modesetting (1 = enable (default), 0 = disable)"); module_param_named(modeset, nv_drm_modeset_module_param, bool, 0400); -#if defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) +#if defined(NV_DRM_FBDEV_AVAILABLE) MODULE_PARM_DESC( fbdev, "Create a framebuffer device (1 = enable (default), 0 = disable) (EXPERIMENTAL)"); diff --git a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h index 6f8cfea9..a6b0f947 100644 --- a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h +++ b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h @@ -59,14 +59,20 @@ typedef struct nv_timer nv_drm_timer; #endif #if defined(NV_DRM_FBDEV_GENERIC_SETUP_PRESENT) && defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT) +#define NV_DRM_FBDEV_AVAILABLE #define NV_DRM_FBDEV_GENERIC_AVAILABLE #endif +#if defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT) && defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT) +#define NV_DRM_FBDEV_AVAILABLE +#define NV_DRM_FBDEV_TTM_AVAILABLE +#endif + struct page; /* Set to true when the atomic modeset feature is enabled. */ extern bool nv_drm_modeset_module_param; -#if defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) +#if defined(NV_DRM_FBDEV_AVAILABLE) /* Set to true when the nvidia-drm driver should install a framebuffer device */ extern bool nv_drm_fbdev_module_param; #endif diff --git a/kernel-open/nvidia-drm/nvidia-drm-sources.mk b/kernel-open/nvidia-drm/nvidia-drm-sources.mk index 7ef0c5b8..247096b7 100644 --- a/kernel-open/nvidia-drm/nvidia-drm-sources.mk +++ b/kernel-open/nvidia-drm/nvidia-drm-sources.mk @@ -67,6 +67,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += fence_set_error NV_CONFTEST_FUNCTION_COMPILE_TESTS += sync_file_get_fence NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_conflicting_pci_framebuffers NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_generic_setup +NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_ttm_setup NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_attach_hdr_output_metadata_property NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_helper_crtc_enable_color_mgmt NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_crtc_enable_color_mgmt -- 2.46.2