From 90846d49ccaeaa598011cf626b45ce4725e739b4 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Sun, 3 Aug 2025 17:36:34 +0300 Subject: [PATCH] xfree86: add (optional) ScreenRec padding for legacy Nvidia driver Commit 3cb3024fea187a1292049a0a33200dad53051149 removed pScratchPixmap field in ScreenRec, which broke legacy Nvidia (proprietary) drivers (470.x), thus we should add an empty/dummy field here, to ensure correct padding. But this would break ABI again - can't do that within minor release line. As compromise, adding a *build time* option CONFIG_LEGACY_NVIDIA_PADDING for this, so operators/packagers can opt-in to this change. As it breaks ABI, the option is disabled by default until the next major release and intended for EXPERTS ONLY who need nvidia390 or nvidia470 drivers. Note that ALL DRIVERS should be rebuild if it is applied! This compile-time option, along with the hacks needed to support it in a non-abi-breaking way, should be droppen in the next major release. Co-authored-by: Oleh Nykyforchyn Signed-off-by: Oleh Nykyforchyn Signed-off-by: stefan11111 Signed-off-by: Enrico Weigelt, metux IT consult --- dix/pixmap.c | 4 ++++ hw/xfree86/common/xf86Module.h | 9 ++++++++- include/meson.build | 3 +++ include/scrnintstr.h | 5 +++++ meson.build | 2 ++ meson_options.txt | 3 +++ 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/dix/pixmap.c b/dix/pixmap.c index bc3d83831f..2b1f9e1864 100644 --- a/dix/pixmap.c +++ b/dix/pixmap.c @@ -87,6 +87,10 @@ PixmapScreenInit(ScreenPtr pScreen) pScreen->totalPixmapSize = BitmapBytePad(pixmap_size * 8); +#ifdef CONFIG_LEGACY_NVIDIA_PADDING + /* This field is used by the 470 and 390 proprietary nvidia DDX driver, and should always be NULL */ + pScreen->reserved_for_nvidia_470_and_390 = NULL; +#endif return TRUE; } diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h index b26bdd7bbe..b790c31b9d 100644 --- a/hw/xfree86/common/xf86Module.h +++ b/hw/xfree86/common/xf86Module.h @@ -74,7 +74,14 @@ * mask is 0xFFFF0000. */ #define ABI_ANSIC_VERSION SET_ABI_VERSION(1, 4) -#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(28, 0) + +/* XXX This is a compile-time option that changes abi XXX */ +/* TODO: Remove this toggle in 26.0 */ +#ifdef CONFIG_LEGACY_NVIDIA_PADDING +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(28, 1) +#else +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(28, 0) +#endif #define ABI_XINPUT_VERSION SET_ABI_VERSION(26, 0) #define ABI_EXTENSION_VERSION SET_ABI_VERSION(11, 0) diff --git a/include/meson.build b/include/meson.build index 6c14da6d77..2567caa62f 100644 --- a/include/meson.build +++ b/include/meson.build @@ -210,6 +210,9 @@ conf_data.set('MAXCLIENTS', 2048) # Must be a power of 2 and <= MAXCLIENTS */ conf_data.set('DIX_LIMITCLIENTS', 256) +# Legacy NVidia drivers (390, 470) use an older ABI and expect an additional field in ScreenRec */ +conf_data.set('CONFIG_LEGACY_NVIDIA_PADDING', legacy_nvidia_padding ? '1' : false) + # some drivers (eg. xf86-video-intel) still relying on this symbol being set conf_data.set('COMPOSITE', '1') diff --git a/include/scrnintstr.h b/include/scrnintstr.h index 71ef762ea0..216567d3d3 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -620,6 +620,11 @@ typedef struct _Screen { SetScreenPixmapProcPtr SetScreenPixmap; NameWindowPixmapProcPtr NameWindowPixmap; +#ifdef CONFIG_LEGACY_NVIDIA_PADDING + /* This field is used by the 470 and 390 proprietary nvidia DDX driver, and should always be NULL */ + void* reserved_for_nvidia_470_and_390; +#endif + unsigned int totalPixmapSize; MarkWindowProcPtr MarkWindow; diff --git a/meson.build b/meson.build index 3d2559ae3d..ec0b173488 100644 --- a/meson.build +++ b/meson.build @@ -553,6 +553,8 @@ elif get_option('mitshm') == 'true' build_mitshm = true endif +legacy_nvidia_padding = get_option('legacy_nvidia_padding') + m_dep = cc.find_library('m', required : false) dl_dep = cc.find_library('dl', required : false) diff --git a/meson_options.txt b/meson_options.txt index 6077dca96c..c66e73b695 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -145,3 +145,6 @@ option('devel-docs', type: 'combo', choices: ['true', 'false', 'auto'], value: ' description: 'Build development documentation') option('docs-pdf', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', description: 'Whether to build PDF version of documentation. Setting is ignored if documentation is not built.') + +option('legacy_nvidia_padding', type: 'boolean', value: false, + description: 'EXPERT ONLY: Add a padding to ScreenRec to match an older ABI for legacy NVidia drivers')