added patches up to kernel 6.0 [release 340.108-10mamba;Mon Feb 06 2023]

This commit is contained in:
Silvan Calarco 2024-01-06 07:46:53 +01:00
parent 13c1fa55b5
commit f3487a078d
8 changed files with 798 additions and 17 deletions

View File

@ -1,25 +1,174 @@
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/conftest.sh NVIDIA-Linux-x86_64-340.108-new/kernel/conftest.sh
--- NVIDIA-Linux-x86_64-340.108-old/kernel/conftest.sh 2021-05-24 20:08:18.743742335 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/conftest.sh 2021-05-24 20:13:18.019314390 +0200
@@ -1578,21 +1578,21 @@
#include <drm/drm_drv.h>
#endif
- #if defined(NV_DRM_DRM_PRIME_H_PRESENT)
- #include <drm/drm_prime.h>
- #endif
-
#if !defined(CONFIG_DRM) && !defined(CONFIG_DRM_MODULE)
#error DRM not enabled
#endif
+
void conftest_drm_available(void) {
struct drm_driver drv;
- drv.gem_prime_pin = 0;
- drv.gem_prime_get_sg_table = 0;
- drv.gem_prime_vmap = 0;
- drv.gem_prime_vunmap = 0;
- (void)drm_gem_prime_import;
- (void)drm_gem_prime_export;
+
+ /* 2013-10-02 1bb72532ac260a2d3982b40bdd4c936d779d0d16 */
+ (void)drm_dev_alloc;
+
+ /* 2013-10-02 c22f0ace1926da399d9a16dfaf09174c1b03594c */
+ (void)drm_dev_register;
+
+ /* 2013-10-02 c3a49737ef7db0bdd4fcf6cf0b7140a883e32b2a */
+ (void)drm_dev_unregister;
}"
compile_check_conftest "$CODE" "NV_DRM_AVAILABLE" "" "generic"
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/nv-drm.c NVIDIA-Linux-x86_64-340.108-new/kernel/nv-drm.c
--- NVIDIA-Linux-x86_64-340.108-old/kernel/nv-drm.c 2021-05-24 20:08:18.779739237 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/nv-drm.c 2021-05-24 20:42:13.443288819 +0200
@@ -60,6 +60,8 @@
#else
#include <drm/drm_agpsupport.h>
+#include "linux/dma-buf.h"
+
struct nv_drm_agp_head {
struct agp_kern_info agp_info;
struct list_head memory;
@@ -210,8 +212,10 @@
/* No locking needed since shadow-attach is single-threaded since it may
* only be called from the per-driver module init hook. */
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
if (drm_core_check_feature(dev, DRIVER_LEGACY))
list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
+#endif
return 0;
@@ -239,8 +243,10 @@
if (WARN_ON(!(driver->driver_features & DRIVER_LEGACY)))
return -EINVAL;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
/* If not using KMS, fall back to stealth mode manual scanning. */
INIT_LIST_HEAD(&driver->legacy_dev_list);
+#endif
for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
pid = &pdriver->id_table[i];
@@ -273,11 +279,13 @@
if (!(driver->driver_features & DRIVER_LEGACY)) {
WARN_ON(1);
} else {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
legacy_dev_list) {
list_del(&dev->legacy_dev_list);
drm_put_dev(dev);
}
+#endif
}
DRM_INFO("Module unloaded\n");
}
@@ -402,6 +410,39 @@
.llseek = noop_llseek,
};
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
+struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem)
+{
+ return nv_gem_prime_get_sg_table(gem);
+}
+
+static int nv_drm_gem_vmap(struct drm_gem_object *gem,
+ struct dma_buf_map *map)
+{
+ map->vaddr = nv_gem_prime_vmap(gem);
+ if (map->vaddr == NULL) {
+ return -ENOMEM;
+ }
+ map->is_iomem = true;
+ return 0;
+}
+
+static void nv_drm_gem_vunmap(struct drm_gem_object *gem,
+ struct dma_buf_map *map)
+{
+ nv_gem_prime_vunmap(gem, map->vaddr);
+ map->vaddr = NULL;
+}
+
+static struct drm_gem_object_funcs nv_drm_gem_object_funcs = {
+ .free = nv_gem_free,
+ .export = drm_gem_prime_export,
+ .get_sg_table = nv_drm_gem_prime_get_sg_table,
+ .vmap = nv_drm_gem_vmap,
+ .vunmap = nv_drm_gem_vunmap,
+};
+#endif
+
static struct drm_driver nv_drm_driver = {
.driver_features = DRIVER_GEM
@@ -420,17 +461,19 @@
.set_busid = drm_pci_set_busid,
#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
- .gem_free_object_unlocked = nv_gem_free,
-#else
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0)
.gem_free_object = nv_gem_free,
+#elif LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
+ .gem_free_object_unlocked = nv_gem_free,
#endif
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
.gem_prime_export = drm_gem_prime_export,
.gem_prime_get_sg_table = nv_gem_prime_get_sg_table,
.gem_prime_vmap = nv_gem_prime_vmap,
.gem_prime_vunmap = nv_gem_prime_vunmap,
+#endif
.name = "nvidia-drm",
.desc = "NVIDIA DRM driver",
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/nv-linux.h NVIDIA-Linux-x86_64-340.108-new/kernel/nv-linux.h diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/nv-linux.h NVIDIA-Linux-x86_64-340.108-new/kernel/nv-linux.h
--- NVIDIA-Linux-x86_64-340.108-old/kernel/nv-linux.h 2021-02-23 20:01:52.429999710 +0100 --- NVIDIA-Linux-x86_64-340.108-old/kernel/nv-linux.h 2021-05-24 20:08:18.775739581 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/nv-linux.h 2021-02-23 14:48:00.163333638 +0100 +++ NVIDIA-Linux-x86_64-340.108-new/kernel/nv-linux.h 2021-05-24 20:09:18.748287771 +0200
@@ -119,7 +119,7 @@ @@ -119,7 +119,9 @@
#include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */ #include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */
#include <linux/cpu.h> /* CPU hotplug support */ #include <linux/cpu.h> /* CPU hotplug support */
#endif #endif
-#include <asm/kmap_types.h> /* page table entry lookup */ -#include <asm/kmap_types.h> /* page table entry lookup */
+//#include <asm/kmap_types.h> /* page table entry lookup */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
+ #include <asm/kmap_types.h> /* page table entry lookup */
+#endif
#include <linux/pci.h> /* pci_find_class, etc */ #include <linux/pci.h> /* pci_find_class, etc */
#include <linux/interrupt.h> /* tasklets, interrupt helpers */ #include <linux/interrupt.h> /* tasklets, interrupt helpers */
--- a/kernel/uvm/nvidia_uvm_linux.h 2019-12-11 17:04:24.000000000 -0500 diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/uvm/nvidia_uvm_linux.h NVIDIA-Linux-x86_64-340.108-new/kernel/uvm/nvidia_uvm_linux.h
+++ b/kernel/uvm/nvidia_uvm_linux.h 2021-02-24 06:26:26.237367942 -0500 --- NVIDIA-Linux-x86_64-340.108-old/kernel/uvm/nvidia_uvm_linux.h 2021-05-24 20:08:18.775739581 +0200
@@ -141,7 +141,7 @@ +++ NVIDIA-Linux-x86_64-340.108-new/kernel/uvm/nvidia_uvm_linux.h 2021-05-24 20:09:18.749287739 +0200
@@ -141,7 +141,9 @@
#if !defined(NV_VMWARE) #if !defined(NV_VMWARE)
#include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */ #include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */
#endif #endif
-#include <asm/kmap_types.h> /* page table entry lookup */ -#include <asm/kmap_types.h> /* page table entry lookup */
+//#include <asm/kmap_types.h> /* page table entry lookup */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
+ #include <asm/kmap_types.h> /* page table entry lookup */
+#endif
#include <linux/interrupt.h> /* tasklets, interrupt helpers */ #include <linux/interrupt.h> /* tasklets, interrupt helpers */
#include <linux/timer.h> #include <linux/timer.h>

View File

@ -0,0 +1,213 @@
diff -Naur NVIDIA-Linux-x86_64-340.108-no-compat32.5.13/kernel/nv-drm.c NVIDIA-Linux-x86_64-340.108-no-compat32.5.14/kernel/nv-drm.c
--- NVIDIA-Linux-x86_64-340.108-no-compat32.5.13/kernel/nv-drm.c 2021-07-25 10:29:29.336505688 +0200
+++ NVIDIA-Linux-x86_64-340.108-no-compat32.5.14/kernel/nv-drm.c 2021-09-16 16:49:10.929858547 +0200
@@ -57,8 +57,11 @@
#if defined(NV_DRM_GET_PCI_DEV_PRESENT)
#define nv_drm_get_pci_dev drm_get_pci_dev
#else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
#include <drm/drm_agpsupport.h>
-
+#else
+#include <drm/drm_legacy.h>
+#endif
#include "linux/dma-buf.h"
struct nv_drm_agp_head {
@@ -82,6 +85,11 @@
struct list_head head;
};
+struct nv_drm_extra_priv_data {
+ struct pci_dev *pdev;
+ struct drm_agp_head *agp;
+};
+
/*
* Code from drm_agp_init/nv_drm_{free,unbind}_agp
* Extracted from commit: 5b8b9d0c6d0e0f1993c6c56deaf9646942c49d94, file: drivers/gpu/drm/drm_agpsupport.c
@@ -89,13 +97,14 @@
struct drm_agp_head *nv_drm_agp_init(struct drm_device *dev)
{
struct nv_drm_agp_head *head = NULL;
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
head = kzalloc(sizeof(*head), GFP_KERNEL);
if (!head)
return NULL;
- head->bridge = agp_find_bridge(dev->pdev);
+ head->bridge = agp_find_bridge(extra->pdev);
if (!head->bridge) {
- head->bridge = agp_backend_acquire(dev->pdev);
+ head->bridge = agp_backend_acquire(extra->pdev);
if (!head->bridge) {
kfree(head);
return NULL;
@@ -133,48 +142,71 @@
static void nv_drm_pci_agp_init(struct drm_device *dev)
{
if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
- if (pci_find_capability(dev->pdev, PCI_CAP_ID_AGP))
- dev->agp = nv_drm_agp_init(dev);
- if (dev->agp) {
- dev->agp->agp_mtrr = arch_phys_wc_add(
- dev->agp->agp_info.aper_base,
- dev->agp->agp_info.aper_size *
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
+
+ if (pci_find_capability(extra->pdev, PCI_CAP_ID_AGP))
+ extra->agp = nv_drm_agp_init(dev);
+ if (extra->agp) {
+ extra->agp->agp_mtrr = arch_phys_wc_add(
+ extra->agp->agp_info.aper_base,
+ extra->agp->agp_info.aper_size *
1024 * 1024);
}
}
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
+
+#else
+/* copied from v5.14.5 */
+int nv_drm_legacy_agp_release(struct drm_device *dev)
+{
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
+
+ if (!extra->agp || !extra->agp->acquired)
+ return -EINVAL;
+ agp_backend_release(extra->agp->bridge);
+ extra->agp->acquired = 0;
+ return 0;
+}
+#endif
+
void nv_drm_legacy_agp_clear(struct drm_device *dev)
{
struct nv_drm_agp_mem *entry, *tempe;
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
- if (!dev->agp)
+ if (!extra->agp)
return;
if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return;
- list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
+ list_for_each_entry_safe(entry, tempe, &extra->agp->memory, head) {
if (entry->bound)
nv_drm_unbind_agp(entry->memory);
nv_drm_free_agp(entry->memory, entry->pages);
kfree(entry);
}
- INIT_LIST_HEAD(&dev->agp->memory);
+ INIT_LIST_HEAD(&extra->agp->memory);
- if (dev->agp->acquired)
+ if (extra->agp->acquired)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
drm_agp_release(dev);
-
- dev->agp->acquired = 0;
- dev->agp->enabled = 0;
+#else
+ nv_drm_legacy_agp_release(dev);
+#endif
+ extra->agp->acquired = 0;
+ extra->agp->enabled = 0;
}
void nv_drm_pci_agp_destroy(struct drm_device *dev)
{
- if (dev->agp) {
- arch_phys_wc_del(dev->agp->agp_mtrr);
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
+ if (extra->agp) {
+ arch_phys_wc_del(extra->agp->agp_mtrr);
nv_drm_legacy_agp_clear(dev);
- kfree(dev->agp);
- dev->agp = NULL;
+ kfree(extra->agp);
+ extra->agp = NULL;
}
}
@@ -183,6 +215,7 @@
struct drm_driver *driver)
{
struct drm_device *dev;
+ struct nv_drm_extra_priv_data *extra;
int ret;
DRM_DEBUG("\n");
@@ -191,11 +224,18 @@
if (IS_ERR(dev))
return PTR_ERR(dev);
+ extra = kzalloc(sizeof(*extra), GFP_KERNEL);
+ if (IS_ERR(extra))
+ goto err_free;
+
+ extra->pdev = pdev;
+
ret = pci_enable_device(pdev);
if (ret)
- goto err_free;
+ goto err_free2;
- dev->pdev = pdev;
+ /* use the not used (i hope) dev_private to store deprecated/legacy pointers */
+ dev->dev_private = extra;
#ifdef __alpha__
dev->hose = pdev->sysdata;
#endif
@@ -221,6 +261,8 @@
err_agp:
nv_drm_pci_agp_destroy(dev);
pci_disable_device(pdev);
+err_free2:
+ kfree(extra);
err_free:
drm_dev_put(dev);
return ret;
@@ -303,10 +345,11 @@
)
{
nv_linux_state_t *nvl;
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next)
{
- if (nvl->dev == dev->pdev)
+ if (nvl->dev == extra->pdev)
{
nvl->drm = dev;
return 0;
@@ -327,10 +370,11 @@
)
{
nv_linux_state_t *nvl;
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next)
{
- if (nvl->dev == dev->pdev)
+ if (nvl->dev == extra->pdev)
{
BUG_ON(nvl->drm != dev);
nvl->drm = NULL;
diff -Naur NVIDIA-Linux-x86_64-340.108-no-compat32.5.13/kernel/os-interface.c NVIDIA-Linux-x86_64-340.108-no-compat32.5.14/kernel/os-interface.c
--- NVIDIA-Linux-x86_64-340.108-no-compat32.5.13/kernel/os-interface.c 2021-07-25 10:29:29.083168593 +0200
+++ NVIDIA-Linux-x86_64-340.108-no-compat32.5.14/kernel/os-interface.c 2021-09-16 13:17:43.345906445 +0200
@@ -549,7 +549,11 @@
// the requested timeout has expired, loop until less
// than a jiffie of the desired delay remains.
//
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)
+ current->__state = TASK_INTERRUPTIBLE;
+#else
current->state = TASK_INTERRUPTIBLE;
+#endif
do
{
schedule_timeout(jiffies);

View File

@ -0,0 +1,14 @@
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/nv-drm.c NVIDIA-Linux-x86_64-340.108-new/kernel/nv-drm.c
--- NVIDIA-Linux-x86_64-340.108-old/kernel/nv-drm.c 2021-11-06 20:08:18.779739237 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/nv-drm.c 2021-11-06 20:42:13.443288819 +0200
@@ -529,7 +529,9 @@ RM_STATUS NV_API_CALL nv_alloc_os_descri
#if defined(NV_DRM_GEM_OBJECT_PUT_UNLOCKED_PRESENT)
drm_gem_object_put_unlocked(&nv_obj->base);
#else
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
+ drm_gem_object_put(&nv_obj->base);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
drm_gem_object_put_locked(&nv_obj->base);
#else
drm_gem_object_unreference_unlocked(&nv_obj->base);

View File

@ -0,0 +1,30 @@
--- a/kernel/os-interface.h 2019-12-11 22:04:24.000000000 +0000
+++ b/kernel/os-interface.h 2022-01-10 02:04:26.740899810 +0000
@@ -24,7 +24,12 @@
* *
\***************************************************************************/
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
+#include <linux/stdarg.h>
+#else
#include <stdarg.h>
+#endif
/*
* Define away Microsoft compiler extensions when possible
--- a/kernel/nv.h 2019-12-11 22:04:24.000000000 +0000
+++ b/kernel/nv.h 2022-01-10 02:29:07.828733372 +0000
@@ -13,7 +13,12 @@
#define _NV_H_
#include <nvtypes.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
+#include <linux/stdarg.h>
+#else
#include <stdarg.h>
+#endif
#if !defined(NV_MIN)
#define NV_MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))

View File

@ -0,0 +1,57 @@
diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
--- a/kernel/conftest.sh 2022-04-02 10:27:54.463179319 +0000
+++ b/kernel/conftest.sh 2022-04-02 10:27:54.553179467 +0000
@@ -1619,7 +1619,11 @@
CODE="
#include <linux/proc_fs.h>
void conftest_PDE_DATA(void) {
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
+ pde_data();
+ #else
PDE_DATA();
+ #endif
}"
compile_check_conftest "$CODE" "NV_PDE_DATA_PRESENT" "" "functions"
diff -Naur a/kernel/nv-linux.h b/kernel/nv-linux.h
--- a/kernel/nv-linux.h 2022-04-02 10:27:54.463179319 +0000
+++ b/kernel/nv-linux.h 2022-04-02 10:27:54.556512806 +0000
@@ -266,9 +266,9 @@
#endif
#ifdef CONFIG_PROC_FS
-#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#endif
+#include <linux/proc_fs.h>
#ifdef CONFIG_KDB
#include <linux/kdb.h>
@@ -2052,8 +2052,12 @@
})
#if defined(NV_PDE_DATA_PRESENT)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)
# define NV_PDE_DATA(inode) PDE_DATA(inode)
#else
+# define NV_PDE_DATA(inode) pde_data(inode)
+#endif
+#else
# define NV_PDE_DATA(inode) PDE(inode)->data
#endif
diff -Naur a/kernel/uvm/conftest.sh b/kernel/uvm/conftest.sh
--- a/kernel/uvm/conftest.sh 2022-04-02 10:27:54.456512642 +0000
+++ b/kernel/uvm/conftest.sh 2022-04-02 10:27:54.556512806 +0000
@@ -1578,7 +1578,11 @@
CODE="
#include <linux/proc_fs.h>
void conftest_PDE_DATA(void) {
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
+ pde_data();
+ #else
PDE_DATA();
+ #endif
}"
compile_check_conftest "$CODE" "NV_PDE_DATA_PRESENT" "" "functions"

View File

@ -0,0 +1,151 @@
diff -Naur a/kernel/nv-acpi.c b/kernel/nv-acpi.c
--- a/kernel/nv-acpi.c 2019-12-12 06:04:24.000000000 +0800
+++ b/kernel/nv-acpi.c 2022-05-29 20:00:00.000000000 +0800
@@ -577,9 +577,13 @@
{
if (!nvif_parent_gpu_handle) /* unknown error */
break;
-
- retVal = acpi_bus_get_device(nvif_parent_gpu_handle, &device);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ device = acpi_fetch_acpi_dev(nvif_parent_gpu_handle);
+ retVal = 0;
+#else
+ retVal = acpi_bus_get_device(nvif_parent_gpu_handle, &device);
+#endif
if (ACPI_FAILURE(retVal) || !device)
break;
@@ -652,8 +656,11 @@
if (nvif_parent_gpu_handle == NULL)
return;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ device = acpi_fetch_acpi_dev(nvif_parent_gpu_handle);
+#else
acpi_bus_get_device(nvif_parent_gpu_handle, &device);
-
+#endif
nv_uninstall_notifier(device, nv_acpi_event);
nvif_parent_gpu_handle = NULL;
@@ -1212,7 +1219,12 @@
if (!dev_handle)
return RM_ERR_INVALID_ARGUMENT;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ device = acpi_fetch_acpi_dev(dev_handle);
+ status = 0;
+#else
status = acpi_bus_get_device(dev_handle, &device);
+#endif
if (ACPI_FAILURE(status) || !device)
return RM_ERR_INVALID_ARGUMENT;
diff -Naur a/kernel/nv-dma.c b/kernel/nv-dma.c
--- a/kernel/nv-dma.c 2019-12-12 06:04:24.000000000 +0800
+++ b/kernel/nv-dma.c 2022-05-29 20:00:00.000000000 +0800
@@ -136,10 +136,17 @@
return status;
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ dma_map->sg_map_count = dma_map_sg(&dma_map->dev->dev,
+ NV_DMA_MAP_SCATTERLIST(dma_map),
+ NV_DMA_MAP_SCATTERLIST_LENGTH(dma_map),
+ DMA_BIDIRECTIONAL);
+#else
dma_map->sg_map_count = pci_map_sg(dma_map->dev,
NV_DMA_MAP_SCATTERLIST(dma_map),
NV_DMA_MAP_SCATTERLIST_LENGTH(dma_map),
PCI_DMA_BIDIRECTIONAL);
+#endif
if (dma_map->sg_map_count == 0)
{
nv_printf(NV_DBG_ERRORS,
@@ -211,8 +218,13 @@
if (dma_map->sg_map_count != 0)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ dma_unmap_sg(&dma_map->dev->dev, NV_DMA_MAP_SCATTERLIST(dma_map),
+ NV_DMA_MAP_SCATTERLIST_LENGTH(dma_map), DMA_BIDIRECTIONAL);
+#else
pci_unmap_sg(dma_map->dev, NV_DMA_MAP_SCATTERLIST(dma_map),
NV_DMA_MAP_SCATTERLIST_LENGTH(dma_map), PCI_DMA_BIDIRECTIONAL);
+#endif
}
*priv = dma_map->user_pages;
diff -Naur a/kernel/nv-drm.c b/kernel/nv-drm.c
--- a/kernel/nv-drm.c 2022-05-29 21:57:55.203782383 +0800
+++ b/kernel/nv-drm.c 2022-05-29 20:00:00.000000000 +0800
@@ -458,9 +458,15 @@
return nv_gem_prime_get_sg_table(gem);
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+static int nv_drm_gem_vmap(struct drm_gem_object *gem,
+ struct iosys_map *map)
+{
+#else
static int nv_drm_gem_vmap(struct drm_gem_object *gem,
struct dma_buf_map *map)
{
+#endif
map->vaddr = nv_gem_prime_vmap(gem);
if (map->vaddr == NULL) {
return -ENOMEM;
@@ -469,9 +475,15 @@
return 0;
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+static void nv_drm_gem_vunmap(struct drm_gem_object *gem,
+ struct iosys_map *map)
+{
+#else
static void nv_drm_gem_vunmap(struct drm_gem_object *gem,
struct dma_buf_map *map)
{
+#endif
nv_gem_prime_vunmap(gem, map->vaddr);
map->vaddr = NULL;
}
diff -Naur a/kernel/nv-vm.c b/kernel/nv-vm.c
--- a/kernel/nv-vm.c 2019-12-12 06:04:24.000000000 +0800
+++ b/kernel/nv-vm.c 2022-05-29 20:00:00.000000000 +0800
@@ -169,12 +169,20 @@
static inline int nv_map_sg(struct pci_dev *dev, struct scatterlist *sg)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ return dma_map_sg(&dev->dev, sg, 1, DMA_BIDIRECTIONAL);
+#else
return pci_map_sg(dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
+#endif
}
static inline void nv_unmap_sg(struct pci_dev *dev, struct scatterlist *sg)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ dma_unmap_sg(&dev->dev, sg, 1, DMA_BIDIRECTIONAL);
+#else
pci_unmap_sg(dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
+#endif
}
#define NV_MAP_SG_MAX_RETRIES 16
diff -Naur a/kernel/nv-frontend.c b/kernel/nv-frontend.c
--- a/kernel/nv-frontend.c 2019-12-12 06:04:24.000000000 +0800
+++ b/kernel/nv-frontend.c 2022-05-29 20:00:00.000000000 +0800
@@ -15,7 +15,7 @@
#include "nv-frontend.h"
#if defined(MODULE_LICENSE)
-MODULE_LICENSE("NVIDIA");
+MODULE_LICENSE("GPL");
#endif
#if defined(MODULE_INFO)
MODULE_INFO(supported, "external");

View File

@ -0,0 +1,151 @@
diff -Naur a/kernel/nv-acpi.c b/kernel/nv-acpi.c
--- a/kernel/nv-acpi.c 2022-10-14 02:26:04.379601051 +0000
+++ b/kernel/nv-acpi.c 2022-10-14 02:28:07.309332369 +0000
@@ -178,6 +178,53 @@
return 0;
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
+static struct nv_acpi_add_enumerated_data {
+ nv_acpi_t *object;
+ int *counter;
+};
+static int nv_acpi_add_enumerated(struct acpi_device *dev, void *data)
+{
+ struct nv_acpi_add_enumerated_data *rcvd_data = data;
+ nv_acpi_t *pNvAcpiObject = rcvd_data->object;
+ int *device_counter = rcvd_data->counter;
+ acpi_status status = -1;
+ nv_acpi_integer_t device_id = 0;
+ if (!dev)
+ return 0;
+ if (*device_counter == NV_MAXNUM_DISPLAY_DEVICES) {
+ nv_printf(NV_DBG_ERRORS,
+ "NVRM: nv_acpi_add: Total number of devices cannot exceed %d\n",
+ NV_MAXNUM_DISPLAY_DEVICES);
+ return 1;
+ }
+ status =
+ acpi_evaluate_integer(dev->handle, "_ADR", NULL, &device_id);
+ if (ACPI_FAILURE(status))
+ /* Couldnt query device_id for this device */
+ return 0;
+
+ device_id = (device_id & 0xffff);
+
+ if ((device_id != 0x100) && /* Not a known CRT device-id */
+ (device_id != 0x200) && /* Not a known TV device-id */
+ (device_id != 0x0110) && (device_id != 0x0118) && (device_id != 0x0400) && /* Not an LCD*/
+ (device_id != 0x0111) && (device_id != 0x0120) && (device_id != 0x0300)) /* Not a known DVI device-id */
+ {
+ /* This isnt a known device Id.
+ Do default switching on this system. */
+ pNvAcpiObject->default_display_mask = 1;
+ return 1;
+ }
+
+ pNvAcpiObject->pNvVideo[*device_counter].dev_id = device_id;
+ pNvAcpiObject->pNvVideo[*device_counter].dev_handle = dev->handle;
+
+ (*device_counter)++;
+ return 0;
+}
+#endif
+
static int nv_acpi_add(struct acpi_device *device)
{
/*
@@ -190,8 +237,10 @@
union acpi_object control_argument_0 = { ACPI_TYPE_INTEGER };
struct acpi_object_list control_argument_list = { 0, NULL };
nv_stack_t *sp = NULL;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
struct list_head *node, *next;
nv_acpi_integer_t device_id = 0;
+#endif
int device_counter = 0;
NV_KMEM_CACHE_ALLOC_STACK(sp);
@@ -220,6 +269,7 @@
// grab handles to all the important nodes representing devices
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
list_for_each_safe(node, next, &device->children)
{
struct acpi_device *dev =
@@ -261,6 +311,13 @@
device_counter++;
}
+#else
+ struct nv_acpi_add_enumerated_data data = {
+ .object = pNvAcpiObject,
+ .counter = &device_counter,
+ };
+ acpi_dev_for_each_child(device, nv_acpi_add_enumerated, &data);
+#endif
// arg 0, bits 1:0, 0 = enable events
control_argument_0.integer.type = ACPI_TYPE_INTEGER;
@@ -1192,6 +1249,31 @@
return status;
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
+static int nv_acpi_ddc_method_enumerated(struct acpi_device *dev, void *data)
+{
+ acpi_handle *lcd_dev_handle = data;
+ acpi_status status;
+ nv_acpi_integer_t device_id = 0;
+ if (!dev)
+ return 0;
+ status = acpi_evaluate_integer(dev->handle, "_ADR", NULL, &device_id);
+ if (ACPI_FAILURE(status))
+ /* Couldnt query device_id for this device */
+ return 0;
+
+ device_id = (device_id & 0xffff);
+
+ if ((device_id == 0x0110) || (device_id == 0x0118) || (device_id == 0x0400)) /* Only for an LCD*/
+ {
+ *lcd_dev_handle = dev->handle;
+ nv_printf(NV_DBG_INFO, "NVRM: %s Found LCD: %x\n", __FUNCTION__, device_id);
+ return 1;
+ }
+ return 0;
+}
+#endif
+
/*
* This function executes a _DDC ACPI method.
*/
@@ -1207,8 +1289,10 @@
union acpi_object *ddc;
union acpi_object ddc_arg0 = { ACPI_TYPE_INTEGER };
struct acpi_object_list input = { 1, &ddc_arg0 };
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
struct list_head *node, *next;
nv_acpi_integer_t device_id = 0;
+#endif
NvU32 i;
acpi_handle dev_handle = NULL;
acpi_handle lcd_dev_handle = NULL;
@@ -1239,6 +1323,7 @@
return RM_ERR_NOT_SUPPORTED;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
list_for_each_safe(node, next, &device->children)
{
struct acpi_device *dev =
@@ -1262,6 +1347,9 @@
}
}
+#else
+ acpi_dev_for_each_child(device, nv_acpi_ddc_method_enumerated, &lcd_dev_handle);
+#endif
if (lcd_dev_handle == NULL)
{

View File

@ -2,13 +2,13 @@
Name: nvidia_340 Name: nvidia_340
Version: 340.108 Version: 340.108
Epoch: 1 Epoch: 1
Release: 9mamba Release: 10mamba
Summary: NVIDIA proprietary accelerated drivers for the Linux Kernel Summary: NVIDIA proprietary accelerated drivers for the Linux Kernel
Group: System/Kernel and Hardware Group: System/Kernel and Hardware
Vendor: openmamba Vendor: openmamba
Distribution: openmamba Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@mambasoft.it> Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: http://www.nvidia.com/object/unix.html URL: https://www.nvidia.com/en-us/drivers/unix/
Source0: http://us.download.nvidia.com/XFree86/Linux-x86/%{version}/NVIDIA-Linux-x86-%{version}.run Source0: http://us.download.nvidia.com/XFree86/Linux-x86/%{version}/NVIDIA-Linux-x86-%{version}.run
Source1: http://us.download.nvidia.com/XFree86/Linux-x86_64/%{version}/NVIDIA-Linux-x86_64-%{version}.run Source1: http://us.download.nvidia.com/XFree86/Linux-x86_64/%{version}/NVIDIA-Linux-x86_64-%{version}.run
Source2: nvidia_340.sysusers Source2: nvidia_340.sysusers
@ -21,12 +21,18 @@ Patch5: nvidia_340-340.108-kernel-5.8.patch
Patch6: nvidia_340-340.108-kernel-5.9.patch Patch6: nvidia_340-340.108-kernel-5.9.patch
Patch7: nvidia_340-340.108-kernel-5.10.patch Patch7: nvidia_340-340.108-kernel-5.10.patch
Patch8: nvidia_340-340.108-kernel-5.11.patch Patch8: nvidia_340-340.108-kernel-5.11.patch
Patch9: nvidia_340-340.108-kernel-5.14.patch
Patch10: nvidia_340-340.108-kernel-5.15.patch
Patch11: nvidia_340-340.108-kernel-5.16.patch
Patch12: nvidia_340-340.108-kernel-5.17.patch
Patch13: nvidia_340-340.108-kernel-5.18.patch
Patch14: nvidia_340-340.108-kernel-6.0.patch
License: no OSI Approved License: no OSI Approved
## AUTOBUILDREQ-BEGIN ## AUTOBUILDREQ-BEGIN
BuildRequires: glibc-devel BuildRequires: glibc-devel
BuildRequires: libX11-devel BuildRequires: libX11-devel
BuildRequires: libXext-devel BuildRequires: libXext-devel
BuildRequires: libatk-devel BuildRequires: libat-spi2-core-devel
BuildRequires: libgdk-pixbuf-devel BuildRequires: libgdk-pixbuf-devel
BuildRequires: libglib-devel BuildRequires: libglib-devel
BuildRequires: libglvnd-devel BuildRequires: libglvnd-devel
@ -88,7 +94,7 @@ This package contains the HTML documentation.
%setup -q -c -n %{name}-%{version} -T %setup -q -c -n %{name}-%{version} -T
%global __provides_exclude ^(libGL\\.so.*|libEGL\\.so.*|libGLESv1_CM\\.so.*|libGLESv2\\.so.*|libOpenCL\\.so.*)$ %global __provides_exclude ^(libGL\\.so.*|libEGL\\.so.*|libGLESv1_CM\\.so.*|libGLESv2\\.so.*|libOpenCL\\.so.*)$
%define _default_patch_fuzz 2
# #
# unpack NVIDIA files # unpack NVIDIA files
# #
@ -105,14 +111,21 @@ sed -i "s|__UTILS_PATH__|%{_bindir}|;s|__PIXMAP_PATH__|%{_datadir}/pixmaps|" \
cd current cd current
#%patch0 -p1 #%patch0 -p1
%patch1 -p1 #%patch1 -p1
#%patch2 -p1 ##%patch2 -p1
%patch3 -p1 #%patch3 -p1
%patch4 -p1 %patch4 -p1
%patch5 -p1 %patch5 -p1
%patch6 -p1 %patch6 -p1
%patch7 -p1 %patch7 -p1
%patch8 -p1 %patch8 -p1
%patch9 -p1 -b .kernel-5.14
%patch10 -p1 -b .kernel-5.15
%patch11 -p1 -b .kernel-5.16
%patch12 -p1 -b .kernel-5.17
%patch13 -p1 -b .kernel-5.18
%patch14 -p1 -b .kernel-6.0
tar xf nvidia-persistenced-init.tar.bz2 tar xf nvidia-persistenced-init.tar.bz2
cd .. cd ..
@ -311,6 +324,9 @@ fi
%doc current/{NVIDIA_Changelog,README.txt} current/html %doc current/{NVIDIA_Changelog,README.txt} current/html
%changelog %changelog
* Mon Feb 06 2023 Silvan Calarco <silvan.calarco@mambasoft.it> 340.108-10mamba
- added patches up to kernel 6.0
* Sun Apr 25 2021 Silvan Calarco <silvan.calarco@mambasoft.it> 340.108-9mamba * Sun Apr 25 2021 Silvan Calarco <silvan.calarco@mambasoft.it> 340.108-9mamba
- need to rename libGL etc. as libGL_nvidia or ldconfig will overwrite libglvnd library - need to rename libGL etc. as libGL_nvidia or ldconfig will overwrite libglvnd library