Add 6.13 patches
Some checks failed
PikaOS Package Build Only (amd64-v3) / build (push) Failing after 36s

This commit is contained in:
ferreo 2025-01-20 13:45:45 +00:00
parent 62557d7503
commit 1666dcb0ea
13 changed files with 758 additions and 1 deletions

1
.github/build-nest-v3 vendored Normal file
View File

@ -0,0 +1 @@
1

View File

@ -1,4 +1,4 @@
nvidia-graphics-drivers-565 (565.77-101pika4) pika; urgency=medium nvidia-graphics-drivers-565 (565.77-101pika5) pika; urgency=medium
* New upstream * New upstream

View File

@ -0,0 +1,52 @@
From da9767db1498ab8a679edccb297fa8a8e72ca628 Mon Sep 17 00:00:00 2001
From: Peter Jung <admin@ptr1337.dev>
Date: Fri, 18 Oct 2024 22:40:05 +0200
Subject: [PATCH 1/6] Make modeset and fbdev default enabled
This is generally required for Wayland on NVIDIA support.
NVIDIA is also planing to enable this as default in the future.
Signed-off-by: Peter Jung <admin@ptr1337.dev>
---
nvidia-drm/nvidia-drm-linux.c | 4 ++--
nvidia-drm/nvidia-drm-os-interface.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/nvidia-drm/nvidia-drm-linux.c b/nvidia-drm/nvidia-drm-linux.c
index 78429510..83d40983 100644
--- a/nvidia-drm/nvidia-drm-linux.c
+++ b/nvidia-drm/nvidia-drm-linux.c
@@ -31,13 +31,13 @@
MODULE_PARM_DESC(
modeset,
- "Enable atomic kernel modesetting (1 = enable, 0 = disable (default))");
+ "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_AVAILABLE)
MODULE_PARM_DESC(
fbdev,
- "Create a framebuffer device (1 = enable, 0 = disable (default)) (EXPERIMENTAL)");
+ "Create a framebuffer device (1 = enable (default), 0 = disable) (EXPERIMENTAL)");
module_param_named(fbdev, nv_drm_fbdev_module_param, bool, 0400);
#endif
diff --git a/nvidia-drm/nvidia-drm-os-interface.c b/nvidia-drm/nvidia-drm-os-interface.c
index 473004b5..75fb34b6 100644
--- a/nvidia-drm/nvidia-drm-os-interface.c
+++ b/nvidia-drm/nvidia-drm-os-interface.c
@@ -41,8 +41,8 @@
#include <drm/drmP.h>
#endif
-bool nv_drm_modeset_module_param = false;
-bool nv_drm_fbdev_module_param = false;
+bool nv_drm_modeset_module_param = true;
+bool nv_drm_fbdev_module_param = true;
void *nv_drm_calloc(size_t nmemb, size_t size)
{
--
2.47.0

View File

@ -0,0 +1,37 @@
From c0bf5aa9ab8205c5cf74356c3af6cbeb016765e6 Mon Sep 17 00:00:00 2001
From: Peter Jung <admin@ptr1337.dev>
Date: Fri, 18 Oct 2024 22:40:38 +0200
Subject: [PATCH 2/6] Do not error on unkown CPU Type and add Zen5 support
Currently the Zen 5 CPU is an unknown CPU and prints an error in dmesg. Fix this with adding Zen5 support as well as change the print to a warning.
Signed-off-by: Peter Jung <admin@ptr1337.dev>
---
src/nvidia/src/kernel/platform/cpu.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/nvidia/src/kernel/platform/cpu.c b/src/nvidia/src/kernel/platform/cpu.c
index bb76a9c2..6832e77c 100644
--- a/src/nvidia/src/kernel/platform/cpu.c
+++ b/src/nvidia/src/kernel/platform/cpu.c
@@ -1401,12 +1401,14 @@ static void cpuidInfoAMD(OBJSYS *pSys, PCPUIDINFO pCpuidInfo)
// Zen, Zen+, Zen 2
case 0x0A0:
// Zen 3, Zen 4
+ case 0x0B0:
+ // Zen 5
pSys->cpuInfo.type = NV0000_CTRL_SYSTEM_CPU_TYPE_RYZEN;
break;
default:
- NV_PRINTF(LEVEL_ERROR,
- "Unrecognized AMD processor in cpuidInfoAMD\n");
- pSys->cpuInfo.type = NV0000_CTRL_SYSTEM_CPU_TYPE_K8;
+ NV_PRINTF(LEVEL_NOTICE,
+ "Unrecognized AMD processor 0x%x in cpuidInfoAMD. Assuming new Ryzen\n", pCpuidInfo->Family);
+ pSys->cpuInfo.type = NV0000_CTRL_SYSTEM_CPU_TYPE_RYZEN;
break;
}
}
--
2.47.0

View File

@ -0,0 +1,25 @@
From ca61ee8197185b9db1d1f1d61460c60a0933eeb3 Mon Sep 17 00:00:00 2001
From: Peter Jung <admin@ptr1337.dev>
Date: Fri, 18 Oct 2024 22:40:58 +0200
Subject: [PATCH 3/6] Add IBT support
Signed-off-by: Peter Jung <admin@ptr1337.dev>
---
src/nvidia-modeset/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/nvidia-modeset/Makefile b/src/nvidia-modeset/Makefile
index 2b96f3fa..ed934014 100644
--- a/src/nvidia-modeset/Makefile
+++ b/src/nvidia-modeset/Makefile
@@ -151,6 +151,7 @@ ifeq ($(TARGET_ARCH),x86_64)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -fno-jump-tables)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch=thunk-extern)
CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch-register)
+ CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mharden-sls=all)
endif
CFLAGS += $(CONDITIONAL_CFLAGS)
--
2.47.0

View File

@ -0,0 +1,34 @@
From bc3a3a9b9617c85b259fd1aa2c5ce46f17fb1694 Mon Sep 17 00:00:00 2001
From: Peter Jung <admin@ptr1337.dev>
Date: Fri, 18 Oct 2024 22:44:33 +0200
Subject: [PATCH 4/6] silence-event-assert-until-570
Currently, when playing CS2 it reports a massive spam in the dmesg log. This will be fixed in the 570 driver.
Silence it for now.
Signed-off-by: Peter Jung <admin@ptr1337.dev>
---
src/nvidia/src/kernel/rmapi/event_notification.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/nvidia/src/kernel/rmapi/event_notification.c b/src/nvidia/src/kernel/rmapi/event_notification.c
index cf78eadd..d6937cac 100644
--- a/src/nvidia/src/kernel/rmapi/event_notification.c
+++ b/src/nvidia/src/kernel/rmapi/event_notification.c
@@ -286,11 +286,11 @@ static NV_STATUS _gpuEngineEventNotificationListNotify
portSyncSpinlockAcquire(pEventNotificationList->pSpinlock);
{
// We don't expect this to be called multiple times in parallel
- NV_ASSERT_OR_ELSE(pEventNotificationList->pendingEventNotifyCount == 0,
+ if (pEventNotificationList->pendingEventNotifyCount != 0)
{
portSyncSpinlockRelease(pEventNotificationList->pSpinlock);
return NV_ERR_INVALID_STATE;
- });
+ }
EngineEventNotificationListIter it =
listIterAll(&pEventNotificationList->eventNotificationList);
--
2.47.0

View File

@ -0,0 +1,51 @@
From e9df998a8915c45aff2f17f80a2711584fba9d5d Mon Sep 17 00:00:00 2001
From: Peter Jung <admin@ptr1337.dev>
Date: Fri, 18 Oct 2024 22:44:59 +0200
Subject: [PATCH 5/6] nvkms: Sanitize & trim ELD product name strings
Signed-off-by: Peter Jung <admin@ptr1337.dev>
---
src/nvidia-modeset/src/nvkms-hdmi.c | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
diff --git a/src/nvidia-modeset/src/nvkms-hdmi.c b/src/nvidia-modeset/src/nvkms-hdmi.c
index 07841ef5..338d2dad 100644
--- a/src/nvidia-modeset/src/nvkms-hdmi.c
+++ b/src/nvidia-modeset/src/nvkms-hdmi.c
@@ -1046,27 +1046,13 @@ static NvBool FillELDBuffer(const NVDpyEvoRec *pDpyEvo,
if (status == NVT_STATUS_SUCCESS) {
/*
- * NvTiming_GetProductName() returns a nul-terminated string, but the
- * string in the EDID is terminated with 0x0A and padded with 0x20.
- * Put back these special characters.
+ * NvTiming_GetProductName returns a nul-terminated string. Figure out
+ * how long it is and copy the bytes up to, but not including, the nul
+ * terminator.
*/
- NvBool pastTerminator = FALSE;
- NvU32 i;
-
- for (i = 0; i < NVT_EDID_LDD_PAYLOAD_SIZE; i++) {
- if (pastTerminator) {
- name[i] = 0x20;
- }
- if (name[i] == '\0') {
- name[i] = 0x0A;
- pastTerminator = TRUE;
- }
- }
-
- monitorNameLen = NVT_EDID_LDD_PAYLOAD_SIZE;
- pEld->buffer[4] |= NVT_EDID_LDD_PAYLOAD_SIZE;
- nvkms_memcpy(&pEld->buffer[20], name,
- NVT_EDID_LDD_PAYLOAD_SIZE);
+ monitorNameLen = nvkms_strlen((char *)name);
+ pEld->buffer[4] |= monitorNameLen;
+ nvkms_memcpy(&pEld->buffer[20], name, monitorNameLen);
}
/* offset 20 + MNL ~ 20 + MNL + (3 * SAD_Count) - 1 : CEA_SADs */
--
2.47.0

View File

@ -0,0 +1,41 @@
From f79e3297278167dbd696677f7c26b82b6622f519 Mon Sep 17 00:00:00 2001
From: Peter Jung <admin@ptr1337.dev>
Date: Tue, 3 Dec 2024 13:01:08 +0100
Subject: [PATCH 06/10] crypto: Add fix for 6.13 Module compilation
This maybe breaks confidental computing
Signed-off-by: Peter Jung <admin@ptr1337.dev>
Signed-off-by: Eric Naim <dnaim@cachyos.org>
---
kernel-open/nvidia/libspdm_ecc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel-open/nvidia/libspdm_ecc.c b/kernel-open/nvidia/libspdm_ecc.c
index 1f8f0100..b31901f6 100644
--- a/kernel-open/nvidia/libspdm_ecc.c
+++ b/kernel-open/nvidia/libspdm_ecc.c
@@ -31,6 +31,8 @@ MODULE_SOFTDEP("pre: ecdh_generic,ecdsa_generic");
#include <crypto/ecdh.h>
#include <crypto/internal/ecc.h>
+#include <linux/version.h>
+
struct ecc_ctx {
unsigned int curve_id;
u64 priv_key[ECC_MAX_DIGITS]; // In big endian
@@ -309,7 +311,11 @@ bool lkca_ecdsa_verify(void *ec_context, size_t hash_nid,
akcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG |
CRYPTO_TFM_REQ_MAY_SLEEP, crypto_req_done, &wait);
akcipher_request_set_crypt(req, &sg, NULL, ber_len, hash_size);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
err = crypto_wait_req(crypto_akcipher_verify(req), &wait);
+#else
+ err = 0;
+#endif
if (err != 0){
pr_info("Verify FAILED %d\n", -err);
--
2.47.1

View File

@ -0,0 +1,40 @@
From 35a25dda24d8f02ca89d53e5975fa7705058c39e Mon Sep 17 00:00:00 2001
From: Eric Naim <dnaim@cachyos.org>
Date: Mon, 9 Dec 2024 19:45:50 +0800
Subject: [PATCH 07/10] nvidia/nv: Convert symbol namespace to string literal
Commit https://github.com/torvalds/linux/commit/cdd30ebb1b9f36159d66f088b61aee264e649d7a ("module: Convert symbol namespace to string literal")
breaks importing symbol namespaces. Apply this change only for 6.13 and higher.
Signed-off-by: Eric Naim <dnaim@cachyos.org>
---
kernel-open/nvidia/nv.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel-open/nvidia/nv.c b/kernel-open/nvidia/nv.c
index 83705a05..1e7de9ea 100644
--- a/kernel-open/nvidia/nv.c
+++ b/kernel-open/nvidia/nv.c
@@ -22,6 +22,7 @@
*/
#include <linux/module.h> // for MODULE_FIRMWARE
+#include <linux/version.h>
// must precede "nv.h" and "nv-firmware.h" includes
#define NV_FIRMWARE_FOR_NAME(name) "nvidia/" NV_VERSION_STRING "/" name ".bin"
@@ -127,7 +128,11 @@ MODULE_ALIAS_CHARDEV_MAJOR(NV_MAJOR_DEVICE_NUMBER);
* DMA_BUF namespace is added by commit id 16b0314aa746
* ("dma-buf: move dma-buf symbols into the DMA_BUF module namespace") in 5.16
*/
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0)
+MODULE_IMPORT_NS("DMA_BUF");
+#else
MODULE_IMPORT_NS(DMA_BUF);
+#endif
#endif // defined(MODULE_IMPORT_NS)
const NvBool nv_is_rm_firmware_supported_os = NV_TRUE;
--
2.47.1

View File

@ -0,0 +1,78 @@
From d0f1f20fb51a82499a9bd6f28d1cfd5b5b504436 Mon Sep 17 00:00:00 2001
From: Eric Naim <dnaim@cachyos.org>
Date: Fri, 20 Dec 2024 20:32:49 +0800
Subject: [PATCH 08/10] Kbuild: Use absolute paths for symbolic links
Command to create a symbolic link, explicitly resolving the symlink target
to an absolute path to abstract away the difference between Linux < 6.13,
where the CWD is the Linux kernel source tree for Kbuild extmod builds, and
Linux >= 6.13, where the CWD is the external module source tree.
This is used to create the nv*-kernel.o -> nv*-kernel.o_binary symlinks for
kernel modules which use precompiled binary object files
Signed-off-by: Eric Naim <dnaim@cachyos.org>
---
kernel-open/Kbuild | 14 ++++++++++++++
kernel-open/nvidia-modeset/nvidia-modeset.Kbuild | 5 +----
kernel-open/nvidia/nvidia.Kbuild | 5 +----
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/kernel-open/Kbuild b/kernel-open/Kbuild
index bda602aa..53e34bd1 100644
--- a/kernel-open/Kbuild
+++ b/kernel-open/Kbuild
@@ -57,6 +57,20 @@ ifeq ($(NV_UNDEF_BEHAVIOR_SANITIZER),1)
UBSAN_SANITIZE := y
endif
+#
+# Command to create a symbolic link, explicitly resolving the symlink target
+# to an absolute path to abstract away the difference between Linux < 6.13,
+# where the CWD is the Linux kernel source tree for Kbuild extmod builds, and
+# Linux >= 6.13, where the CWD is the external module source tree.
+#
+# This is used to create the nv*-kernel.o -> nv*-kernel.o_binary symlinks for
+# kernel modules which use precompiled binary object files.
+#
+
+quiet_cmd_symlink = SYMLINK $@
+ cmd_symlink = ln -sf $(abspath $<) $@
+
+
$(foreach _module, $(NV_KERNEL_MODULES), \
$(eval include $(src)/$(_module)/$(_module).Kbuild))
diff --git a/kernel-open/nvidia-modeset/nvidia-modeset.Kbuild b/kernel-open/nvidia-modeset/nvidia-modeset.Kbuild
index 9698b59e..d5ca07ca 100644
--- a/kernel-open/nvidia-modeset/nvidia-modeset.Kbuild
+++ b/kernel-open/nvidia-modeset/nvidia-modeset.Kbuild
@@ -40,9 +40,6 @@ NV_KERNEL_MODULE_TARGETS += $(NVIDIA_MODESET_KO)
NVIDIA_MODESET_BINARY_OBJECT := $(src)/nvidia-modeset/nv-modeset-kernel.o_binary
NVIDIA_MODESET_BINARY_OBJECT_O := nvidia-modeset/nv-modeset-kernel.o
-quiet_cmd_symlink = SYMLINK $@
-cmd_symlink = ln -sf $< $@
-
targets += $(NVIDIA_MODESET_BINARY_OBJECT_O)
$(obj)/$(NVIDIA_MODESET_BINARY_OBJECT_O): $(NVIDIA_MODESET_BINARY_OBJECT) FORCE
diff --git a/kernel-open/nvidia/nvidia.Kbuild b/kernel-open/nvidia/nvidia.Kbuild
index ea4ef5ba..0a4e68d4 100644
--- a/kernel-open/nvidia/nvidia.Kbuild
+++ b/kernel-open/nvidia/nvidia.Kbuild
@@ -40,9 +40,6 @@ NVIDIA_KO = nvidia/nvidia.ko
NVIDIA_BINARY_OBJECT := $(src)/nvidia/nv-kernel.o_binary
NVIDIA_BINARY_OBJECT_O := nvidia/nv-kernel.o
-quiet_cmd_symlink = SYMLINK $@
- cmd_symlink = ln -sf $< $@
-
targets += $(NVIDIA_BINARY_OBJECT_O)
$(obj)/$(NVIDIA_BINARY_OBJECT_O): $(NVIDIA_BINARY_OBJECT) FORCE
--
2.47.1

View File

@ -0,0 +1,146 @@
From 11501d99348a04c608a19330d984188f4766e603 Mon Sep 17 00:00:00 2001
From: Bingwu Zhang <xtex@aosc.io>
Date: Sat, 7 Dec 2024 23:01:26 +0800
Subject: [PATCH 09/10] FROM AOSC: Use linux/aperture.c for removing
conflicting PCI devices on Linux 6.13.0-rc1+
Link: https://github.com/torvalds/linux/commit/689274a56c0c088796d359f6c6267323931a2429
Link: https://github.com/torvalds/linux/commit/7283f862bd991c8657e9bf1c02db772fcf018f13
Link: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/749
Signed-off-by: Eric Naim <dnaim@cachyos.org>
---
kernel-open/conftest.sh | 19 +++++++++++++++++++
kernel-open/header-presence-tests.mk | 1 +
kernel-open/nvidia-drm/nvidia-drm-drv.c | 15 +++++++++++++++
.../nvidia-drm/nvidia-drm-os-interface.h | 10 ++++++++++
kernel-open/nvidia-drm/nvidia-drm-sources.mk | 1 +
5 files changed, 46 insertions(+)
diff --git a/kernel-open/conftest.sh b/kernel-open/conftest.sh
index fdceda72..5a0f39e0 100755
--- a/kernel-open/conftest.sh
+++ b/kernel-open/conftest.sh
@@ -6615,6 +6615,8 @@ compile_test() {
# Added by commit 2916059147ea ("drm/aperture: Add infrastructure
# for aperture ownership") in v5.14.
#
+ # Removed by commit 689274a56c0c ("drm: Remove DRM aperture helpers") in v6.13.
+ #
CODE="
#if defined(NV_DRM_DRM_APERTURE_H_PRESENT)
#include <drm/drm_aperture.h>
@@ -6626,6 +6628,23 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT" "" "functions"
;;
+ aperture_remove_conflicting_pci_devices)
+ #
+ # Determine whether aperture_remove_conflicting_pci_devices is present.
+ #
+ # Added by commit 7283f862bd99 ("drm: Implement DRM aperture helpers under video/") in v6.0.
+ #
+ CODE="
+ #if defined(NV_LINUX_APERTURE_H_PRESENT)
+ #include <linux/aperture.h>
+ #endif
+ void conftest_aperture_remove_conflicting_pci_devices(void) {
+ aperture_remove_conflicting_pci_devices();
+ }"
+
+ compile_check_conftest "$CODE" "NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT" "" "functions"
+ ;;
+
drm_aperture_remove_conflicting_pci_framebuffers_has_driver_arg)
#
# Determine whether drm_aperture_remove_conflicting_pci_framebuffers
diff --git a/kernel-open/header-presence-tests.mk b/kernel-open/header-presence-tests.mk
index 9d5217a9..b0268541 100644
--- a/kernel-open/header-presence-tests.mk
+++ b/kernel-open/header-presence-tests.mk
@@ -34,6 +34,7 @@ NV_HEADER_PRESENCE_TESTS = \
generated/autoconf.h \
generated/compile.h \
generated/utsrelease.h \
+ linux/aperture.h \
linux/efi.h \
linux/kconfig.h \
linux/platform/tegra/mc_utils.h \
diff --git a/kernel-open/nvidia-drm/nvidia-drm-drv.c b/kernel-open/nvidia-drm/nvidia-drm-drv.c
index 8f905f82..2e4f6404 100644
--- a/kernel-open/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel-open/nvidia-drm/nvidia-drm-drv.c
@@ -65,7 +65,16 @@
#endif
#if defined(NV_DRM_FBDEV_AVAILABLE)
+// Commit 7283f862bd99 ("drm: Implement DRM aperture helpers under video/")
+// moved implementation of drm_aperture_... to linux/aperture.c.
+// Commit 689274a56c0c ("drm: Remove DRM aperture helpers")
+// removed drm/drm_aperture.h.
+#if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT)
#include <drm/drm_aperture.h>
+#endif
+#if defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT)
+#include <linux/aperture.h>
+#endif
#include <drm/drm_fb_helper.h>
#endif
@@ -2013,10 +2022,16 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
if (bus_is_pci) {
struct pci_dev *pdev = to_pci_dev(device);
+#if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT)
+ printk(KERN_INFO "%s: using drm_aperture for old kernels\n", nv_drm_driver.name);
#if defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_HAS_DRIVER_ARG)
drm_aperture_remove_conflicting_pci_framebuffers(pdev, &nv_drm_driver);
#else
drm_aperture_remove_conflicting_pci_framebuffers(pdev, nv_drm_driver.name);
+#endif
+#elif defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_PRESENT)
+ printk(KERN_INFO "%s: using linux/aperture workaround for Linux 6.13+\n", nv_drm_driver.name);
+ aperture_remove_conflicting_pci_devices(pdev, nv_drm_driver.name);
#endif
nvKms->framebufferConsoleDisabled(nv_dev->pDevice);
}
diff --git a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
index a6b0f947..71ca5f22 100644
--- a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
+++ b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
@@ -63,11 +63,21 @@ typedef struct nv_timer nv_drm_timer;
#define NV_DRM_FBDEV_GENERIC_AVAILABLE
#endif
+#if defined(NV_DRM_FBDEV_GENERIC_SETUP_PRESENT) && defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_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
+#if defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT) && defined(NV_APERTURE_REMOVE_CONFLICTING_PCI_DEVICES_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. */
diff --git a/kernel-open/nvidia-drm/nvidia-drm-sources.mk b/kernel-open/nvidia-drm/nvidia-drm-sources.mk
index 9aaebd04..a4dcad6d 100644
--- a/kernel-open/nvidia-drm/nvidia-drm-sources.mk
+++ b/kernel-open/nvidia-drm/nvidia-drm-sources.mk
@@ -66,6 +66,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += dma_fence_set_error
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 += aperture_remove_conflicting_pci_devices
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
--
2.47.1

View File

@ -0,0 +1,156 @@
From 88b8ae7642ef21e685d51148e8f57c3dfa1323ac Mon Sep 17 00:00:00 2001
From: Bingwu Zhang <xtex@aosc.io>
Date: Sat, 7 Dec 2024 23:56:43 +0800
Subject: [PATCH 10/10] FROM AOSC: TTM fbdev emulation for Linux 6.13+
Link: https://github.com/torvalds/linux/commit/1000634477d8d178179b1ad45d92e925fabe3deb
Link: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/749
Signed-off-by: xtex <xtexchooser@duck.com>
Signed-off-by: Eric Naim <dnaim@cachyos.org>
---
kernel-open/nvidia-drm/nvidia-drm-drv.c | 72 +++++++++++++++++++
kernel-open/nvidia-drm/nvidia-drm-linux.c | 4 ++
.../nvidia-drm/nvidia-drm-os-interface.h | 5 ++
3 files changed, 81 insertions(+)
diff --git a/kernel-open/nvidia-drm/nvidia-drm-drv.c b/kernel-open/nvidia-drm/nvidia-drm-drv.c
index 2e4f6404..ab85152f 100644
--- a/kernel-open/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel-open/nvidia-drm/nvidia-drm-drv.c
@@ -1951,7 +1951,60 @@ void nv_drm_update_drm_driver_features(void)
#endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
}
+#if !defined(NV_DRM_FBDEV_TTM_AVAILABLE) && \
+ !defined(NV_DRM_FBDEV_GENERIC_AVAILABLE)
+// AOSC OS: Workaround for Linux 6.13+
+static const struct drm_fb_helper_funcs nv_drm_fbdev_helper_funcs = {
+ .fb_probe = drm_fbdev_ttm_driver_fbdev_probe,
+};
+
+static void nv_drm_fbdev_client_unregister(struct drm_client_dev *client)
+{
+ struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
+ if (fb_helper->info) {
+ drm_fb_helper_unregister_info(fb_helper);
+ } else {
+ drm_client_release(&fb_helper->client);
+ drm_fb_helper_unprepare(fb_helper);
+ kfree(fb_helper);
+ }
+}
+static int nv_drm_fbdev_client_restore(struct drm_client_dev *client)
+{
+ drm_fb_helper_lastclose(client->dev);
+ return 0;
+}
+static int nv_drm_fbdev_client_hotplug(struct drm_client_dev *client)
+{
+ struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
+ struct drm_device *dev = client->dev;
+ int ret;
+ if (dev->fb_helper)
+ return drm_fb_helper_hotplug_event(dev->fb_helper);
+ ret = drm_fb_helper_init(dev, fb_helper);
+ if (ret)
+ goto err_drm_err;
+ if (!drm_drv_uses_atomic_modeset(dev))
+ drm_helper_disable_unused_functions(dev);
+ ret = drm_fb_helper_initial_config(fb_helper);
+ if (ret)
+ goto err_drm_fb_helper_fini;
+ return 0;
+err_drm_fb_helper_fini:
+ drm_fb_helper_fini(fb_helper);
+err_drm_err:
+ drm_err(dev, "AOSC OS: NV-DRM: fbdev: Failed to setup emulation (ret=%d)\n", ret);
+ return ret;
+}
+
+static const struct drm_client_funcs nv_drm_fbdev_client_funcs = {
+ .owner = THIS_MODULE,
+ .unregister = nv_drm_fbdev_client_unregister,
+ .restore = nv_drm_fbdev_client_restore,
+ .hotplug = nv_drm_fbdev_client_hotplug,
+};
+#endif
/*
* Helper function for allocate/register DRM device for given NVIDIA GPU ID.
@@ -1961,6 +2014,7 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
struct nv_drm_device *nv_dev = NULL;
struct drm_device *dev = NULL;
struct device *device = gpu_info->os_device_ptr;
+ struct drm_fb_helper *fb_helper = NULL;
bool bus_is_pci;
DRM_DEBUG(
@@ -2039,6 +2093,20 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
drm_fbdev_ttm_setup(dev, 32);
#elif defined(NV_DRM_FBDEV_GENERIC_AVAILABLE)
drm_fbdev_generic_setup(dev, 32);
+ #else
+ // AOSC OS: Workaround for Linux 6.13+
+ int drm_client_ret;
+ fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL);
+ if (!fb_helper)
+ return;
+ drm_fb_helper_prepare(dev, fb_helper, 32, &nv_drm_fbdev_helper_funcs);
+ drm_client_ret = drm_client_init(dev, &fb_helper->client, "fbdev",
+ &nv_drm_fbdev_client_funcs);
+ if (drm_client_ret) {
+ drm_err(dev, "AOSC OS: NV-DRM: Failed to register DRM client: %d\n", drm_client_ret);
+ goto failed_drm_client_init;
+ }
+ drm_client_register(&fb_helper->client);
#endif
}
#endif /* defined(NV_DRM_FBDEV_AVAILABLE) */
@@ -2050,6 +2118,10 @@ void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
return; /* Success */
+failed_drm_client_init:
+ drm_fb_helper_unprepare(fb_helper);
+ kfree(fb_helper);
+
failed_drm_register:
nv_drm_dev_free(dev);
diff --git a/kernel-open/nvidia-drm/nvidia-drm-linux.c b/kernel-open/nvidia-drm/nvidia-drm-linux.c
index 83d40983..ac4fe967 100644
--- a/kernel-open/nvidia-drm/nvidia-drm-linux.c
+++ b/kernel-open/nvidia-drm/nvidia-drm-linux.c
@@ -39,8 +39,12 @@ MODULE_PARM_DESC(
fbdev,
"Create a framebuffer device (1 = enable (default), 0 = disable) (EXPERIMENTAL)");
module_param_named(fbdev, nv_drm_fbdev_module_param, bool, 0400);
+#else
+#error "nvidia-drm fbdev should always be available."
#endif
+#else
+#error "nvidia-drm is not available"
#endif /* NV_DRM_AVAILABLE */
/*************************************************************************
diff --git a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
index 71ca5f22..8195af32 100644
--- a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
+++ b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h
@@ -78,6 +78,11 @@ typedef struct nv_timer nv_drm_timer;
#define NV_DRM_FBDEV_TTM_AVAILABLE
#endif
+// AOSC OS: Always enable DRM fbdev
+// FIXME: Add config test for drm helper functions.
+// The implementation uses drm_client_register, which is added in v5.2-rc1.
+#define NV_DRM_FBDEV_AVAILABLE
+
struct page;
/* Set to true when the atomic modeset feature is enabled. */
--
2.47.1

View File

@ -17,6 +17,54 @@ ifeq (amd64,$(DEB_HOST_ARCH))
rm -rf debian/tmp/32 rm -rf debian/tmp/32
# Extract all manpages # Extract all manpages
gunzip debian/tmp/*.1.gz -k gunzip debian/tmp/*.1.gz -k
# Enable modeset and fbdev as default
# This avoids various issue, when Simplefb is used
# https://gitlab.archlinux.org/archlinux/packaging/packages/nvidia-utils/-/issues/14
# https://github.com/rpmfusion/nvidia-kmod/blob/master/make_modeset_default.patch
patch -Np2 -i $(CURDIR)/debian/patches/0001-Make-modeset-and-fbdev-default-enabled.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0001-Make-modeset-and-fbdev-default-enabled.patch -d $(CURDIR)/debian/tmp/kernel-open
# Dont error, when Zen5 CPU is in the system
patch -Np2 -i $(CURDIR)/debian/patches/0002-Do-not-error-on-unkown-CPU-Type-and-add-Zen5-support.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0002-Do-not-error-on-unkown-CPU-Type-and-add-Zen5-support.patch -d $(CURDIR)/debian/tmp/kernel-open
# Fix for https://bugs.archlinux.org/task/74886
patch -Np2 -i $(CURDIR)/debian/patches/0003-Add-IBT-support.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0003-Add-IBT-support.patch -d $(CURDIR)/debian/tmp/kernel-open
# Patch by Nvidia to silence error messages until a real fix drops in 570.xx
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/716#issuecomment-2391898884
patch -Np2 -i $(CURDIR)/debian/patches/0004-silence-event-assert-until-570.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0004-silence-event-assert-until-570.patch -d $(CURDIR)/debian/tmp/kernel-open
# Patch by Nvidia to fix HDMI names which are otherwise broken in the /proc/asound/NVidia/* ELD files
# Should hopefully ship with 570.xx
# https://github.com/NVIDIA/open-gpu-kernel-modules/pull/715
patch -Np2 -i $(CURDIR)/debian/patches/0005-nvkms-Sanitize-trim-ELD-product-name-strings.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0005-nvkms-Sanitize-trim-ELD-product-name-strings.patch -d $(CURDIR)/debian/tmp/kernel-open
# Fix build errors on 6.13+
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/746
patch -Np2 -i $(CURDIR)/debian/patches/0006-crypto-Add-fix-for-6.13-Module-compilation.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0006-crypto-Add-fix-for-6.13-Module-compilation.patch -d $(CURDIR)/debian/tmp/kernel-open
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/751
patch -Np2 -i $(CURDIR)/debian/patches/0007-nvidia-nv-Convert-symbol-namespace-to-string-literal.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0007-nvidia-nv-Convert-symbol-namespace-to-string-literal.patch -d $(CURDIR)/debian/tmp/kernel-open
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/747
patch -Np2 -i $(CURDIR)/debian/patches/0008-Kbuild-Use-absolute-paths-for-symbolic-links.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0008-Kbuild-Use-absolute-paths-for-symbolic-links.patch -d $(CURDIR)/debian/tmp/kernel-open
# Fixes fbdev on 6.13+
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/749
# https://gist.github.com/xtexChooser/da92d9df902788b75f746f348552ae80
patch -Np2 -i $(CURDIR)/debian/patches/0009-FROM-AOSC-Use-linux-aperture.c-for-removing-conflict.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0009-FROM-AOSC-Use-linux-aperture.c-for-removing-conflict.patch -d $(CURDIR)/debian/tmp/kernel-open
patch -Np2 -i $(CURDIR)/debian/patches/0010-FROM-AOSC-TTM-fbdev-emulation-for-Linux-6.13.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0010-FROM-AOSC-TTM-fbdev-emulation-for-Linux-6.13.patch -d $(CURDIR)/debian/tmp/kernel-open
# NVENC/NvFBC # NVENC/NvFBC
sed -i 's/\xe8\x35\x3e\xfe\xff\x85\xc0\x41\x89\xc4/\xe8\x35\x3e\xfe\xff\x29\xc0\x41\x89\xc4/g' "debian/tmp/libnvidia-encode.so.565.77" sed -i 's/\xe8\x35\x3e\xfe\xff\x85\xc0\x41\x89\xc4/\xe8\x35\x3e\xfe\xff\x29\xc0\x41\x89\xc4/g' "debian/tmp/libnvidia-encode.so.565.77"
sed -i 's/\x85\xc0\x0f\x84\x9b\x00\x00\x00\x48/\x85\xc0\x90\x90\x90\x90\x90\x90\x48/g' "debian/tmp/libnvidia-fbc.so.565.77" sed -i 's/\x85\xc0\x0f\x84\x9b\x00\x00\x00\x48/\x85\xc0\x90\x90\x90\x90\x90\x90\x48/g' "debian/tmp/libnvidia-fbc.so.565.77"
@ -29,6 +77,54 @@ ifeq (i386,$(DEB_HOST_ARCH))
mkdir -p debian/tmp mkdir -p debian/tmp
# Copy installer contents into debian temp dir # Copy installer contents into debian temp dir
cp -rf ./NVIDIA-Linux-*/* debian/tmp cp -rf ./NVIDIA-Linux-*/* debian/tmp
# Enable modeset and fbdev as default
# This avoids various issue, when Simplefb is used
# https://gitlab.archlinux.org/archlinux/packaging/packages/nvidia-utils/-/issues/14
# https://github.com/rpmfusion/nvidia-kmod/blob/master/make_modeset_default.patch
patch -Np2 -i $(CURDIR)/debian/patches/0001-Make-modeset-and-fbdev-default-enabled.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0001-Make-modeset-and-fbdev-default-enabled.patch -d $(CURDIR)/debian/tmp/kernel-open
# Dont error, when Zen5 CPU is in the system
patch -Np2 -i $(CURDIR)/debian/patches/0002-Do-not-error-on-unkown-CPU-Type-and-add-Zen5-support.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0002-Do-not-error-on-unkown-CPU-Type-and-add-Zen5-support.patch -d $(CURDIR)/debian/tmp/kernel-open
# Fix for https://bugs.archlinux.org/task/74886
patch -Np2 -i $(CURDIR)/debian/patches/0003-Add-IBT-support.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0003-Add-IBT-support.patch -d $(CURDIR)/debian/tmp/kernel-open
# Patch by Nvidia to silence error messages until a real fix drops in 570.xx
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/716#issuecomment-2391898884
patch -Np2 -i $(CURDIR)/debian/patches/0004-silence-event-assert-until-570.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0004-silence-event-assert-until-570.patch -d $(CURDIR)/debian/tmp/kernel-open
# Patch by Nvidia to fix HDMI names which are otherwise broken in the /proc/asound/NVidia/* ELD files
# Should hopefully ship with 570.xx
# https://github.com/NVIDIA/open-gpu-kernel-modules/pull/715
patch -Np2 -i $(CURDIR)/debian/patches/0005-nvkms-Sanitize-trim-ELD-product-name-strings.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0005-nvkms-Sanitize-trim-ELD-product-name-strings.patch -d $(CURDIR)/debian/tmp/kernel-open
# Fix build errors on 6.13+
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/746
patch -Np2 -i $(CURDIR)/debian/patches/0006-crypto-Add-fix-for-6.13-Module-compilation.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0006-crypto-Add-fix-for-6.13-Module-compilation.patch -d $(CURDIR)/debian/tmp/kernel-open
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/751
patch -Np2 -i $(CURDIR)/debian/patches/0007-nvidia-nv-Convert-symbol-namespace-to-string-literal.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0007-nvidia-nv-Convert-symbol-namespace-to-string-literal.patch -d $(CURDIR)/debian/tmp/kernel-open
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/747
patch -Np2 -i $(CURDIR)/debian/patches/0008-Kbuild-Use-absolute-paths-for-symbolic-links.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0008-Kbuild-Use-absolute-paths-for-symbolic-links.patch -d $(CURDIR)/debian/tmp/kernel-open
# Fixes fbdev on 6.13+
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/749
# https://gist.github.com/xtexChooser/da92d9df902788b75f746f348552ae80
patch -Np2 -i $(CURDIR)/debian/patches/0009-FROM-AOSC-Use-linux-aperture.c-for-removing-conflict.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0009-FROM-AOSC-Use-linux-aperture.c-for-removing-conflict.patch -d $(CURDIR)/debian/tmp/kernel-open
patch -Np2 -i $(CURDIR)/debian/patches/0010-FROM-AOSC-TTM-fbdev-emulation-for-Linux-6.13.patch -d $(CURDIR)/debian/tmp/kernel
patch -Np2 -i $(CURDIR)/debian/patches/0010-FROM-AOSC-TTM-fbdev-emulation-for-Linux-6.13.patch -d $(CURDIR)/debian/tmp/kernel-open
# Replace libs with 32 bit # Replace libs with 32 bit
rm -rf debian/tmp/*.so* rm -rf debian/tmp/*.so*
cp -rf ./NVIDIA-Linux-*/32/* debian/tmp cp -rf ./NVIDIA-Linux-*/32/* debian/tmp