File 0021-kernel-5.18-opensusedit.patch of Package x11-video-nvidiaG02
diff -ruN NVIDIA-Linux-x86_64-304.137p1/kernel/nv-acpi.c NVIDIA-Linux-x86_64-304.137p2/kernel/nv-acpi.c
--- NVIDIA-Linux-x86_64-304.137p1/nv-acpi.c 2017-09-14 17:51:09.000000000 -0300
+++ NVIDIA-Linux-x86_64-304.137p2/nv-acpi.c 2022-06-25 21:35:03.106678042 -0300
@@ -14,6 +14,7 @@
#include "os-interface.h"
#include "nv-linux.h"
#include "nv-reg.h"
+#include <linux/version.h>
#if defined(NV_LINUX_ACPI_EVENTS_SUPPORTED)
@@ -574,7 +575,12 @@
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;
@@ -648,8 +654,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;
@@ -1137,8 +1146,13 @@
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 -ruN NVIDIA-Linux-x86_64-304.137p1/kernel/nv.c NVIDIA-Linux-x86_64-304.137p2/kernel/nv.c
--- NVIDIA-Linux-x86_64-304.137p1/nv.c 2022-06-25 19:31:10.540509042 -0300
+++ NVIDIA-Linux-x86_64-304.137p2/nv.c 2022-06-25 23:14:04.196971200 -0300
@@ -20,8 +20,12 @@
#include <linux/version.h>
#if defined(MODULE_LICENSE)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)
+MODULE_LICENSE("GPL");
+#else
MODULE_LICENSE("NVIDIA");
#endif
+#endif
#if defined(MODULE_INFO)
MODULE_INFO(supported, "external");
#endif
diff -ruN NVIDIA-Linux-x86_64-304.137p1/kernel/nv-linux.h NVIDIA-Linux-x86_64-304.137p2/kernel/nv-linux.h
--- NVIDIA-Linux-x86_64-304.137p1/nv-linux.h 2022-06-25 19:31:29.893412239 -0300
+++ NVIDIA-Linux-x86_64-304.137p2/nv-linux.h 2022-06-25 22:04:11.236764184 -0300
@@ -338,8 +338,13 @@
#if defined(NV_PCI_DMA_MAPPING_ERROR_PRESENT)
#if (NV_PCI_DMA_MAPPING_ERROR_ARGUMENT_COUNT == 2)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+#define NV_PCI_DMA_MAPPING_ERROR(dev, addr) \
+ dma_mapping_error(dev, addr)
+#else
#define NV_PCI_DMA_MAPPING_ERROR(dev, addr) \
pci_dma_mapping_error(dev, addr)
+#endif
#elif (NV_PCI_DMA_MAPPING_ERROR_ARGUMENT_COUNT == 1)
#define NV_PCI_DMA_MAPPING_ERROR(dev, addr) \
pci_dma_mapping_error(addr)
diff -ruN NVIDIA-Linux-x86_64-304.137p1/kernel/nv-mlock.c NVIDIA-Linux-x86_64-304.137p2/kernel/nv-mlock.c
--- NVIDIA-Linux-x86_64-304.137p1/nv-mlock.c 2022-06-25 19:31:08.052392389 -0300
+++ NVIDIA-Linux-x86_64-304.137p2/nv-mlock.c 2022-06-25 23:01:54.616935166 -0300
@@ -13,6 +13,7 @@
#include "os-interface.h"
#include "nv-linux.h"
+#include <linux/version.h>
RM_STATUS NV_API_CALL nv_lock_user_pages(
nv_state_t *nv,
@@ -76,6 +77,21 @@
for (i = 0; i < page_count; i++)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ pte_array[i] = dma_map_page(&dev->dev, user_pages[i], 0,
+ PAGE_SIZE,
+ DMA_BIDIRECTIONAL);
+ if (NV_PCI_DMA_MAPPING_ERROR(&dev->dev, pte_array[i]))
+ {
+ nv_printf(NV_DBG_ERRORS,
+ "NVRM: failed to create a DMA mapping!\n");
+ for (j = 0; j < i; j++)
+ {
+ dma_unmap_page(&dev->dev, pte_array[j],
+ PAGE_SIZE, DMA_BIDIRECTIONAL);
+ put_page(user_pages[j]);
+ }
+#else
pte_array[i] = pci_map_page(dev, user_pages[i], 0,
PAGE_SIZE,
PCI_DMA_BIDIRECTIONAL);
@@ -89,6 +105,7 @@
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
put_page(user_pages[j]);
}
+#endif
os_free_mem(user_pages);
return RM_ERR_OPERATING_SYSTEM;
}
@@ -117,8 +134,13 @@
for (i = 0; i < page_count; i++)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ dma_unmap_page(&dev->dev, pte_array[i],
+ PAGE_SIZE, DMA_BIDIRECTIONAL);
+#else
pci_unmap_page(dev, pte_array[i],
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
+#endif
if (write)
set_page_dirty_lock(user_pages[i]);
put_page(user_pages[i]);
diff -ruN NVIDIA-Linux-x86_64-304.137p1/kernel/nv-vm.c NVIDIA-Linux-x86_64-304.137p2/kernel/nv-vm.c
--- NVIDIA-Linux-x86_64-304.137p1/nv-vm.c 2017-09-14 17:51:09.000000000 -0300
+++ NVIDIA-Linux-x86_64-304.137p2/nv-vm.c 2022-06-25 21:36:04.876681090 -0300
@@ -12,6 +12,7 @@
#include "os-interface.h"
#include "nv.h"
#include "nv-linux.h"
+#include <linux/version.h>
#define NV_DEFAULT_LIST_PAGE_COUNT 10
@@ -205,7 +206,11 @@
ret = swiotlb_map_sg(&dev->dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
else
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ ret = dma_map_sg(&dev->dev, sg, 1, DMA_BIDIRECTIONAL);
+#else
ret = pci_map_sg(dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
+#endif
return ret;
}
@@ -216,7 +221,11 @@
swiotlb_unmap_sg(&dev->dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
else
#endif
+#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