commit 6a6c8b3cc0defed988b7f21991ec2c13514df18f
Author: Vitaly Zaitsev <vitaly(a)easycoding.org>
Date: Sun Oct 30 10:37:54 2022 +0100
Added backported Debian patches for the Linux kernel 6.0.
...rt-get_task_ioprio-changes-from-510.85.02.patch | 78 +++
0021-backport-acpi-changes-from-510.85.02.patch | 622 +++++++++++++++++++++
0022-backport-acpi-changes-from-515.65.01.patch | 153 +++++
...port-drm_frambuffer.h-changes-from-515.76.patch | 36 ++
nvidia-470xx-kmod.spec | 14 +-
5 files changed, 902 insertions(+), 1 deletion(-)
---
diff --git a/0020-backport-get_task_ioprio-changes-from-510.85.02.patch
b/0020-backport-get_task_ioprio-changes-from-510.85.02.patch
new file mode 100644
index 0000000..b7cef40
--- /dev/null
+++ b/0020-backport-get_task_ioprio-changes-from-510.85.02.patch
@@ -0,0 +1,78 @@
+From 41ec8d06eadeaef23d94e8271948e6c48b7e3038 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Wed, 19 Oct 2022 00:14:36 +0200
+Subject: [PATCH] backport get_task_ioprio changes from 510.85.02
+
+---
+ conftest.sh | 17 +++++++++++++++++
+ nvidia/nv.c | 12 ++++++++++++
+ nvidia/nvidia.Kbuild | 1 +
+ 3 files changed, 30 insertions(+)
+
+diff --git a/conftest.sh b/conftest.sh
+index f3fd14b..4789bd5 100755
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -4817,6 +4817,23 @@ compile_test() {
+ compile_check_conftest "$CODE"
"NV_RESERVATION_OBJECT_RESERVE_SHARED_HAS_NUM_FENCES_ARG" ""
"types"
+ ;;
+
++ get_task_ioprio)
++ #
++ # Determine if the __get_task_ioprio() function is present.
++ #
++ # __get_task_ioprio was added by commit 893e5d32d583
++ # ("block: Generalize get_current_ioprio() for any task") for
++ # v5.20 linux-next (2022-06-23).
++ #
++ CODE="
++ #include <linux/ioprio.h>
++ void conftest_get_task_ioprio(void) {
++ __get_task_ioprio();
++ }"
++
++ compile_check_conftest "$CODE"
"NV_GET_TASK_IOPRIO_PRESENT" "" "functions"
++ ;;
++
+ # When adding a new conftest entry, please use the correct format for
+ # specifying the relevant upstream Linux kernel commit.
+ #
+diff --git a/nvidia/nv.c b/nvidia/nv.c
+index 02cc245..2475b96 100644
+--- a/nvidia/nv.c
++++ b/nvidia/nv.c
+@@ -5438,7 +5438,19 @@ NvBool NV_API_CALL nv_s2idle_pm_configured(void)
+ return NV_FALSE;
+ }
+
++ /*
++ * init_sync_kiocb() internally uses GPL licensed __get_task_ioprio() from
++ * v5.20-rc1.
++ */
++#if defined(NV_GET_TASK_IOPRIO_PRESENT)
++ memset(&kiocb, 0, sizeof(kiocb));
++ kiocb.ki_filp = file;
++ kiocb.ki_flags = iocb_flags(file);
++ kiocb.ki_ioprio = IOPRIO_DEFAULT;
++#else
+ init_sync_kiocb(&kiocb, file);
++#endif
++
+ kiocb.ki_pos = 0;
+ iov_iter_kvec(&iter, READ, &iov, 1, sizeof(buf));
+
+diff --git a/nvidia/nvidia.Kbuild b/nvidia/nvidia.Kbuild
+index f1d9b3f..e3c6b1f 100644
+--- a/nvidia/nvidia.Kbuild
++++ b/nvidia/nvidia.Kbuild
+@@ -170,6 +170,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_put_unlocked
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_close_on_exec
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += dma_set_coherent_mask
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_bus_get_device
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_task_ioprio
+
+ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_gpl_of_node_to_nid
+ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_gpl_sme_active
+--
+2.20.1
+
diff --git a/0021-backport-acpi-changes-from-510.85.02.patch
b/0021-backport-acpi-changes-from-510.85.02.patch
new file mode 100644
index 0000000..960567a
--- /dev/null
+++ b/0021-backport-acpi-changes-from-510.85.02.patch
@@ -0,0 +1,622 @@
+From 0d454cca5682eb4fc821299a0cd81b10bc04717a Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Tue, 18 Oct 2022 22:32:41 +0200
+Subject: [PATCH] backport acpi changes from 510.85.02
+
+---
+ common/inc/nv-linux.h | 12 --
+ common/inc/nv-proto.h | 2 -
+ nvidia/nv-acpi.c | 443 ------------------------------------------
+ nvidia/nv.c | 16 --
+ 4 files changed, 473 deletions(-)
+
+diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
+index 51a973b..22b05a0 100644
+--- a/common/inc/nv-linux.h
++++ b/common/inc/nv-linux.h
+@@ -1627,24 +1627,12 @@ extern NvBool nv_ats_supported;
+ * and any other baggage we want to carry along
+ *
+ */
+-#define NV_MAXNUM_DISPLAY_DEVICES 8
+-
+-typedef struct
+-{
+- acpi_handle dev_handle;
+- int dev_id;
+-} nv_video_t;
+-
+ typedef struct
+ {
+ nvidia_stack_t *sp;
+ struct acpi_device *device;
+ struct acpi_handle *handle;
+-
+- nv_video_t pNvVideo[NV_MAXNUM_DISPLAY_DEVICES];
+-
+ int notify_handler_installed;
+- int default_display_mask;
+ } nv_acpi_t;
+
+ #endif
+diff --git a/common/inc/nv-proto.h b/common/inc/nv-proto.h
+index 79cccfa..aa8b285 100644
+--- a/common/inc/nv-proto.h
++++ b/common/inc/nv-proto.h
+@@ -22,8 +22,6 @@ extern nvidia_module_t nv_fops;
+
+ void nv_acpi_register_notifier (nv_linux_state_t *);
+ void nv_acpi_unregister_notifier (nv_linux_state_t *);
+-int nv_acpi_init (void);
+-int nv_acpi_uninit (void);
+
+ NvU8 nv_find_pci_capability (struct pci_dev *, NvU8);
+ void * nv_alloc_file_private (void);
+diff --git a/nvidia/nv-acpi.c b/nvidia/nv-acpi.c
+index 2b7b988..dcad96c 100644
+--- a/nvidia/nv-acpi.c
++++ b/nvidia/nv-acpi.c
+@@ -22,35 +22,13 @@ static NV_STATUS nv_acpi_extract_buffer (const union acpi_object
*, void *, N
+ static NV_STATUS nv_acpi_extract_package (const union acpi_object *, void *, NvU32,
NvU32 *);
+ static NV_STATUS nv_acpi_extract_object (const union acpi_object *, void *, NvU32,
NvU32 *);
+
+-static int nv_acpi_add (struct acpi_device *);
+-
+-#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) ||
(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2)
+-static int nv_acpi_remove_two_args(struct acpi_device *device, int type);
+-#else
+-static int nv_acpi_remove_one_arg(struct acpi_device *device);
+-#endif
+-
+-static void nv_acpi_event (acpi_handle, u32, void *);
+ static void nv_acpi_powersource_hotplug_event(acpi_handle, u32, void *);
+ static acpi_status nv_acpi_find_methods (acpi_handle, u32, void *, void **);
+ static NV_STATUS nv_acpi_nvif_method (NvU32, NvU32, void *, NvU16, NvU32 *, void
*, NvU16 *);
+
+ static NV_STATUS nv_acpi_wmmx_method (NvU32, NvU8 *, NvU16 *);
+
+-static const struct acpi_device_id nv_video_device_ids[] = {
+- {
+- .id = ACPI_VIDEO_HID,
+- .driver_data = 0,
+- },
+- {
+- .id = "",
+- .driver_data = 0,
+- },
+-};
+-
+-static struct acpi_driver *nv_acpi_driver;
+ static acpi_handle nvif_handle = NULL;
+-static acpi_handle nvif_parent_gpu_handle = NULL;
+ static acpi_handle wmmx_handle = NULL;
+
+ // Used for AC Power Source Hotplug Handling
+@@ -74,20 +52,6 @@ static NvBool battery_present = NV_FALSE;
+ #define ACPI_VIDEO_CLASS "video"
+ #endif
+
+-static const struct acpi_driver nv_acpi_driver_template = {
+- .name = "NVIDIA ACPI Video Driver",
+- .class = ACPI_VIDEO_CLASS,
+- .ids = nv_video_device_ids,
+- .ops = {
+- .add = nv_acpi_add,
+-#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) ||
(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2)
+- .remove = nv_acpi_remove_two_args,
+-#else
+- .remove = nv_acpi_remove_one_arg,
+-#endif
+- },
+-};
+-
+ static int nv_acpi_get_device_handle(nv_state_t *nv, acpi_handle *dev_handle)
+ {
+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
+@@ -148,355 +112,6 @@ void nv_acpi_unregister_notifier(nv_linux_state_t *nvl)
+ unregister_acpi_notifier(&nvl->acpi_nb);
+ }
+
+-int nv_acpi_init(void)
+-{
+- /*
+- * This function will register the RM with the Linux
+- * ACPI subsystem.
+- */
+- int status;
+- nvidia_stack_t *sp = NULL;
+- NvU32 acpi_event_config = 0;
+- NV_STATUS rmStatus;
+-
+- status = nv_kmem_cache_alloc_stack(&sp);
+- if (status != 0)
+- {
+- return status;
+- }
+-
+- rmStatus = rm_read_registry_dword(sp, NULL,
+- NV_REG_REGISTER_FOR_ACPI_EVENTS, &acpi_event_config);
+- nv_kmem_cache_free_stack(sp);
+-
+- if ((rmStatus == NV_OK) && (acpi_event_config == 0))
+- return 0;
+-
+- if (nv_acpi_driver != NULL)
+- return -EBUSY;
+-
+- rmStatus = os_alloc_mem((void **)&nv_acpi_driver,
+- sizeof(struct acpi_driver));
+- if (rmStatus != NV_OK)
+- return -ENOMEM;
+-
+- memcpy((void *)nv_acpi_driver, (void *)&nv_acpi_driver_template,
+- sizeof(struct acpi_driver));
+-
+- status = acpi_bus_register_driver(nv_acpi_driver);
+- if (status < 0)
+- {
+- nv_printf(NV_DBG_INFO,
+- "NVRM: nv_acpi_init: acpi_bus_register_driver() failed (%d)!\n",
status);
+- os_free_mem(nv_acpi_driver);
+- nv_acpi_driver = NULL;
+- }
+-
+- return status;
+-}
+-
+-int nv_acpi_uninit(void)
+-{
+- nvidia_stack_t *sp = NULL;
+- NvU32 acpi_event_config = 0;
+- NV_STATUS rmStatus;
+- int rc;
+-
+- rc = nv_kmem_cache_alloc_stack(&sp);
+- if (rc != 0)
+- {
+- return rc;
+- }
+-
+- rmStatus = rm_read_registry_dword(sp, NULL,
+- NV_REG_REGISTER_FOR_ACPI_EVENTS, &acpi_event_config);
+- nv_kmem_cache_free_stack(sp);
+-
+- if ((rmStatus == NV_OK) && (acpi_event_config == 0))
+- return 0;
+-
+- if (nv_acpi_driver == NULL)
+- return -ENXIO;
+-
+- acpi_bus_unregister_driver(nv_acpi_driver);
+- os_free_mem(nv_acpi_driver);
+-
+- nv_acpi_driver = NULL;
+-
+- return 0;
+-}
+-
+-static int nv_acpi_add(struct acpi_device *device)
+-{
+- /*
+- * This function will cause RM to initialize the things it needs for acpi
interaction
+- * on the display device.
+- */
+- int status = -1;
+- NV_STATUS rmStatus = NV_ERR_GENERIC;
+- nv_acpi_t *pNvAcpiObject = NULL;
+- union acpi_object control_argument_0 = { ACPI_TYPE_INTEGER };
+- struct acpi_object_list control_argument_list = { 0, NULL };
+- nvidia_stack_t *sp = NULL;
+- struct list_head *node, *next;
+- unsigned long long device_id = 0;
+- int device_counter = 0;
+-
+- status = nv_kmem_cache_alloc_stack(&sp);
+- if (status != 0)
+- {
+- return status;
+- }
+-
+- // allocate data structure we need
+- rmStatus = os_alloc_mem((void **) &pNvAcpiObject, sizeof(nv_acpi_t));
+- if (rmStatus != NV_OK)
+- {
+- nv_kmem_cache_free_stack(sp);
+- nv_printf(NV_DBG_ERRORS,
+- "NVRM: nv_acpi_add: failed to allocate ACPI device management
data!\n");
+- return -ENOMEM;
+- }
+-
+- os_mem_set((void *)pNvAcpiObject, 0, sizeof(nv_acpi_t));
+-
+- device->driver_data = pNvAcpiObject;
+- pNvAcpiObject->device = device;
+-
+- pNvAcpiObject->sp = sp;
+-
+- // grab handles to all the important nodes representing devices
+-
+- list_for_each_safe(node, next, &device->children)
+- {
+- struct acpi_device *dev =
+- list_entry(node, struct acpi_device, node);
+-
+- if (!dev)
+- continue;
+-
+- 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);
+- break;
+- }
+-
+- status =
+- acpi_evaluate_integer(dev->handle, "_ADR", NULL,
&device_id);
+- if (ACPI_FAILURE(status))
+- /* Couldnt query device_id for this device */
+- continue;
+-
+- 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;
+- break;
+- }
+-
+- pNvAcpiObject->pNvVideo[device_counter].dev_id = device_id;
+- pNvAcpiObject->pNvVideo[device_counter].dev_handle = dev->handle;
+-
+- device_counter++;
+-
+- }
+-
+- // arg 0, bits 1:0, 0 = enable events
+- control_argument_0.integer.type = ACPI_TYPE_INTEGER;
+- control_argument_0.integer.value = 0x0;
+-
+- // listify it
+- control_argument_list.count = 1;
+- control_argument_list.pointer = &control_argument_0;
+-
+- // _DOS method takes 1 argument and returns nothing
+- status = acpi_evaluate_object(device->handle, "_DOS",
&control_argument_list, NULL);
+-
+- if (ACPI_FAILURE(status))
+- {
+- nv_printf(NV_DBG_INFO,
+- "NVRM: nv_acpi_add: failed to enable display switch events
(%d)!\n", status);
+- }
+-
+- status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
+- nv_acpi_event, pNvAcpiObject);
+-
+- if (ACPI_FAILURE(status))
+- {
+- nv_printf(NV_DBG_INFO,
+- "NVRM: nv_acpi_add: failed to install event notification handler
(%d)!\n", status);
+- }
+- else
+- {
+- try_module_get(THIS_MODULE);
+- pNvAcpiObject->notify_handler_installed = 1;
+- }
+-
+- return 0;
+-}
+-
+-#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) ||
(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2)
+-static int nv_acpi_remove_two_args(struct acpi_device *device, int type)
+-#else
+-static int nv_acpi_remove_one_arg(struct acpi_device *device)
+-#endif
+-{
+- /*
+- * This function will cause RM to relinquish control of the VGA ACPI device.
+- */
+- acpi_status status;
+- union acpi_object control_argument_0 = { ACPI_TYPE_INTEGER };
+- struct acpi_object_list control_argument_list = { 0, NULL };
+- nv_acpi_t *pNvAcpiObject = device->driver_data;
+-
+-
+- pNvAcpiObject->default_display_mask = 0;
+-
+- // arg 0, bits 1:0, 1 = disable events
+- control_argument_0.integer.type = ACPI_TYPE_INTEGER;
+- control_argument_0.integer.value = 0x1;
+-
+- // listify it
+- control_argument_list.count = 1;
+- control_argument_list.pointer = &control_argument_0;
+-
+- // _DOS method takes 1 argument and returns nothing
+- status = acpi_evaluate_object(device->handle, "_DOS",
&control_argument_list, NULL);
+-
+- if (ACPI_FAILURE(status))
+- {
+- nv_printf(NV_DBG_INFO,
+- "NVRM: nv_acpi_remove: failed to disable display switch events
(%d)!\n", status);
+- }
+-
+- if (pNvAcpiObject->notify_handler_installed)
+- {
+- // remove event notifier
+- status = acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
nv_acpi_event);
+- }
+-
+- if (pNvAcpiObject->notify_handler_installed &&
+- ACPI_FAILURE(status))
+- {
+- nv_printf(NV_DBG_INFO,
+- "NVRM: nv_acpi_remove: failed to remove event notification handler
(%d)!\n", status);
+- }
+- else
+- {
+- nv_kmem_cache_free_stack(pNvAcpiObject->sp);
+- os_free_mem((void *)pNvAcpiObject);
+- module_put(THIS_MODULE);
+- device->driver_data = NULL;
+- }
+-
+- return status;
+-}
+-
+-/*
+- * The ACPI specification defines IDs for various ACPI video
+- * extension events like display switch events, AC/battery
+- * events, docking events, etc..
+- * Whenever an ACPI event is received by the corresponding
+- * event handler installed within the core NVIDIA driver, the
+- * code can verify the event ID before processing it.
+- */
+-#define ACPI_DISPLAY_DEVICE_CHANGE_EVENT 0x80
+-#define NVIF_NOTIFY_DISPLAY_DETECT 0xCB
+-#define NVIF_DISPLAY_DEVICE_CHANGE_EVENT NVIF_NOTIFY_DISPLAY_DETECT
+-static void nv_acpi_event(acpi_handle handle, u32 event_type, void *data)
+-{
+- /*
+- * This function will handle acpi events from the linux kernel, used
+- * to detect notifications from the VGA device.
+- */
+- nv_acpi_t *pNvAcpiObject = data;
+- u32 event_val = 0;
+- unsigned long long state;
+- int status = 0;
+- int device_counter = 0;
+-
+- if (event_type == NVIF_DISPLAY_DEVICE_CHANGE_EVENT)
+- {
+- /* We are getting NVIF events on this machine. We arent putting a very
+- extensive handling in-place to communicate back with SBIOS, know
+- the next enabled devices, and then do the switch. We just
+- pass a default display switch event, so that X-driver decides
+- the switching policy itself. */
+- rm_system_event(pNvAcpiObject->sp, NV_SYSTEM_ACPI_DISPLAY_SWITCH_EVENT, 0);
+- }
+- if (event_type == ACPI_DISPLAY_DEVICE_CHANGE_EVENT)
+- {
+- if (pNvAcpiObject->default_display_mask != 1)
+- {
+- while ((device_counter < NV_MAXNUM_DISPLAY_DEVICES) &&
+- (pNvAcpiObject->pNvVideo[device_counter].dev_handle))
+- {
+- acpi_handle dev_handle =
pNvAcpiObject->pNvVideo[device_counter].dev_handle;
+- int dev_id = pNvAcpiObject->pNvVideo[device_counter].dev_id;
+-
+- status = acpi_evaluate_integer(dev_handle,
+- "_DGS",
+- NULL,
+- &state);
+- if (ACPI_FAILURE(status))
+- {
+- nv_printf(NV_DBG_INFO,
+- "NVRM: nv_acpi_event: failed to query _DGS method for display
device 0x%x\n",
+- dev_id);
+- }
+- else if (state)
+- {
+- /* Check if the device is a CRT ...*/
+- if (dev_id == 0x0100)
+- {
+- event_val |= NV_HOTKEY_STATUS_DISPLAY_ENABLE_CRT;
+- }
+- /* device-id for a TV */
+- else if (dev_id == 0x0200)
+- {
+- event_val |= NV_HOTKEY_STATUS_DISPLAY_ENABLE_TV;
+- }
+- else if ((dev_id == 0x0110) || /* device id for internal LCD */
+- (dev_id == 0x0118) || /* alternate ACPI ID for the
+- internal LCD */
+- (dev_id == 0x0400)) /* ACPI spec 3.0 specified
+- device id for a internal LCD*/
+- {
+- event_val |= NV_HOTKEY_STATUS_DISPLAY_ENABLE_LCD;
+- }
+- else if ((dev_id == 0x0111) || /* the set
+- of possible device-ids for a DFP */
+- (dev_id == 0x0120) ||
+- (dev_id == 0x0300)) /* ACPI spec 3.0 specified
+- device id for non-LVDS DFP */
+- {
+- event_val |= NV_HOTKEY_STATUS_DISPLAY_ENABLE_DFP;
+- }
+- }
+- device_counter++;
+- }
+- }
+-
+- nv_printf(NV_DBG_INFO,
+- "NVRM: nv_acpi_event: Event-type 0x%x, Event-val 0x%x\n",
+- event_type, event_val);
+-
+- rm_system_event(pNvAcpiObject->sp, NV_SYSTEM_ACPI_DISPLAY_SWITCH_EVENT,
event_val);
+- }
+-
+- // no unsubscription or re-enable necessary. Once DOD has been set, we are go.
+- // once we are subscribed to ACPI events, we don't have to re-subscribe unless
+- // unsubscribe.
+-}
+-
+ NV_STATUS NV_API_CALL nv_acpi_get_powersource(NvU32 *ac_plugged)
+ {
+ unsigned long long val;
+@@ -618,11 +233,6 @@ static void nv_uninstall_notifier(nv_acpi_t *pNvAcpiObject,
acpi_notify_handler
+
+ void NV_API_CALL nv_acpi_methods_init(NvU32 *handlesPresent)
+ {
+-#if defined(NV_ACPI_BUS_GET_DEVICE_PRESENT)
+- struct acpi_device *device = NULL;
+- int retVal = -1;
+-#endif
+-
+ if (!handlesPresent) // Caller passed us invalid pointer.
+ return;
+
+@@ -634,32 +244,6 @@ void NV_API_CALL nv_acpi_methods_init(NvU32 *handlesPresent)
+ if (nvif_handle)
+ {
+ *handlesPresent = NV_ACPI_NVIF_HANDLE_PRESENT;
+-#if defined(NV_ACPI_BUS_GET_DEVICE_PRESENT)
+- do
+- {
+- if (!nvif_parent_gpu_handle) /* unknown error */
+- break;
+-
+- retVal = acpi_bus_get_device(nvif_parent_gpu_handle, &device);
+-
+- if (ACPI_FAILURE(retVal) || !device)
+- break;
+-
+- if (device->driver_data)
+- {
+- nvif_parent_gpu_handle = NULL;
+- break; /* Someone else has already populated this device
+- nodes' structures. So nothing more to be done */
+- }
+-
+- device->driver_data = nv_install_notifier(device->handle,
nv_acpi_event);
+-
+-
+- if (!device->driver_data)
+- nvif_parent_gpu_handle = NULL;
+-
+- } while (0);
+-#endif
+ }
+
+ if (wmmx_handle)
+@@ -691,7 +275,6 @@ acpi_status nv_acpi_find_methods(
+ if (!acpi_get_handle(handle, "NVIF", &method_handle))
+ {
+ nvif_handle = method_handle;
+- nvif_parent_gpu_handle = handle;
+ }
+
+ if (!acpi_get_handle(handle, "WMMX", &method_handle))
+@@ -710,8 +293,6 @@ acpi_status nv_acpi_find_methods(
+
+ void NV_API_CALL nv_acpi_methods_uninit(void)
+ {
+- struct acpi_device *device = NULL;
+-
+ nvif_handle = NULL;
+ wmmx_handle = NULL;
+
+@@ -723,20 +304,6 @@ void NV_API_CALL nv_acpi_methods_uninit(void)
+ psr_device_handle = NULL;
+ psr_nv_acpi_object = NULL;
+ }
+-
+- if (nvif_parent_gpu_handle == NULL)
+- return;
+-
+-#if defined(NV_ACPI_BUS_GET_DEVICE_PRESENT)
+- acpi_bus_get_device(nvif_parent_gpu_handle, &device);
+-
+- nv_uninstall_notifier(device->driver_data, nv_acpi_event);
+-#endif
+-
+- device->driver_data = NULL;
+- nvif_parent_gpu_handle = NULL;
+-
+- return;
+ }
+
+ static NV_STATUS nv_acpi_extract_integer(
+@@ -1734,16 +1301,6 @@ NvBool NV_API_CALL nv_acpi_is_battery_present(void)
+
+ #else // NV_LINUX_ACPI_EVENTS_SUPPORTED
+
+-int nv_acpi_init(void)
+-{
+- return 0;
+-}
+-
+-int nv_acpi_uninit(void)
+-{
+- return 0;
+-}
+-
+ void NV_API_CALL nv_acpi_methods_init(NvU32 *handlePresent)
+ {
+ *handlePresent = 0;
+diff --git a/nvidia/nv.c b/nvidia/nv.c
+index 2475b96..13d2614 100644
+--- a/nvidia/nv.c
++++ b/nvidia/nv.c
+@@ -2694,7 +2694,6 @@ nvidia_ctl_open(
+ nv_linux_state_t *nvl = &nv_ctl_device;
+ nv_state_t *nv = NV_STATE_PTR(nvl);
+ nv_linux_file_private_t *nvlfp = NV_GET_LINUX_FILE_PRIVATE(file);
+- static int count = 0;
+
+ nv_printf(NV_DBG_INFO, "NVRM: nvidia_ctl_open\n");
+
+@@ -2706,13 +2705,6 @@ nvidia_ctl_open(
+ if (NV_ATOMIC_READ(nvl->usage_count) == 0)
+ {
+ nv->flags |= (NV_FLAG_OPEN | NV_FLAG_CONTROL);
+-
+- if ((nv_acpi_init() < 0) &&
+- (count++ < NV_MAX_RECURRING_WARNING_MESSAGES))
+- {
+- nv_printf(NV_DBG_ERRORS,
+- "NVRM: failed to register with the ACPI subsystem!\n");
+- }
+ }
+
+ NV_ATOMIC_INC(nvl->usage_count);
+@@ -2736,7 +2728,6 @@ nvidia_ctl_close(
+ nv_state_t *nv = NV_STATE_PTR(nvl);
+ nv_linux_file_private_t *nvlfp = NV_GET_LINUX_FILE_PRIVATE(file);
+ nvidia_stack_t *sp = nvlfp->sp;
+- static int count = 0;
+ unsigned int i;
+
+ nv_printf(NV_DBG_INFO, "NVRM: nvidia_ctl_close\n");
+@@ -2745,13 +2736,6 @@ nvidia_ctl_close(
+ if (NV_ATOMIC_DEC_AND_TEST(nvl->usage_count))
+ {
+ nv->flags &= ~NV_FLAG_OPEN;
+-
+- if ((nv_acpi_uninit() < 0) &&
+- (count++ < NV_MAX_RECURRING_WARNING_MESSAGES))
+- {
+- nv_printf(NV_DBG_ERRORS,
+- "NVRM: failed to unregister from the ACPI subsystem!\n");
+- }
+ }
+ up(&nvl->ldata_lock);
+
+--
+2.20.1
+
diff --git a/0022-backport-acpi-changes-from-515.65.01.patch
b/0022-backport-acpi-changes-from-515.65.01.patch
new file mode 100644
index 0000000..c1b1590
--- /dev/null
+++ b/0022-backport-acpi-changes-from-515.65.01.patch
@@ -0,0 +1,153 @@
+From 80526de0098cf82afd027e41a57e59e6cafd567c Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Mon, 17 Oct 2022 03:03:00 +0200
+Subject: [PATCH] backport acpi changes from 515.65.01
+
+---
+ nvidia/nv-acpi.c | 65 +++++++++++++-----------------------------------
+ 1 file changed, 17 insertions(+), 48 deletions(-)
+
+diff --git a/nvidia/nv-acpi.c b/nvidia/nv-acpi.c
+index dcad96c..4ec227c 100644
+--- a/nvidia/nv-acpi.c
++++ b/nvidia/nv-acpi.c
+@@ -681,12 +681,11 @@ NV_STATUS NV_API_CALL nv_acpi_ddc_method(
+ )
+ {
+ acpi_status status;
+- struct acpi_device *device = NULL;
+ union acpi_object *ddc = NULL;
+- struct list_head *node, *next;
+ NvU32 i, largestEdidSize;
+ acpi_handle dev_handle = NULL;
+ acpi_handle lcd_dev_handle = NULL;
++ acpi_handle handle = NULL;
+
+ if (!nv_acpi_get_device_handle(nv, &dev_handle))
+ return NV_ERR_NOT_SUPPORTED;
+@@ -694,15 +693,6 @@ NV_STATUS NV_API_CALL nv_acpi_ddc_method(
+ if (!dev_handle)
+ return NV_ERR_INVALID_ARGUMENT;
+
+-#if defined(NV_ACPI_BUS_GET_DEVICE_PRESENT)
+- status = acpi_bus_get_device(dev_handle, &device);
+-#else
+- return NV_ERR_NOT_SUPPORTED;
+-#endif
+-
+- if (ACPI_FAILURE(status) || !device)
+- return NV_ERR_INVALID_ARGUMENT;
+-
+ if (!NV_MAY_SLEEP())
+ {
+ #if defined(DEBUG)
+@@ -713,16 +703,16 @@ NV_STATUS NV_API_CALL nv_acpi_ddc_method(
+ return NV_ERR_NOT_SUPPORTED;
+ }
+
+- list_for_each_safe(node, next, &device->children)
++ while (lcd_dev_handle == NULL)
+ {
+ unsigned long long device_id = 0;
+- struct acpi_device *dev =
+- list_entry(node, struct acpi_device, node);
+
+- if (!dev)
+- continue;
++ status = acpi_get_next_object(ACPI_TYPE_DEVICE, dev_handle,
++ handle, &handle);
++ if (ACPI_FAILURE(status) || (handle == NULL))
++ break;
+
+- status = acpi_evaluate_integer(dev->handle, "_ADR", NULL,
&device_id);
++ status = acpi_evaluate_integer(handle, "_ADR", NULL, &device_id);
+ if (ACPI_FAILURE(status))
+ /* Couldnt query device_id for this device */
+ continue;
+@@ -732,16 +722,13 @@ NV_STATUS NV_API_CALL nv_acpi_ddc_method(
+ case 0x0118:
+ case 0x0400:
+ case 0xA420:
+- lcd_dev_handle = dev->handle;
++ lcd_dev_handle = handle;
+ nv_printf(NV_DBG_INFO, "NVRM: %s Found LCD: %x\n",
+ __FUNCTION__, device_id);
+ break;
+ default:
+ break;
+ }
+-
+- if (lcd_dev_handle != NULL)
+- break;
+ }
+
+ if (lcd_dev_handle == NULL)
+@@ -1091,15 +1078,14 @@ NV_STATUS NV_API_CALL nv_acpi_mux_method(
+ )
+ {
+ acpi_status status;
+- struct acpi_device *device = NULL;
+ struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+ union acpi_object *mux = NULL;
+ union acpi_object mux_arg = { ACPI_TYPE_INTEGER };
+ struct acpi_object_list input = { 1, &mux_arg };
+ acpi_handle dev_handle = NULL;
+ acpi_handle mux_dev_handle = NULL;
++ acpi_handle handle = NULL;
+ unsigned long long device_id = 0;
+- struct list_head *node, *next;
+
+ if ((strcmp(pMethodName, "MXDS") != 0)
+ && (strcmp(pMethodName, "MXDM") != 0))
+@@ -1120,16 +1106,6 @@ NV_STATUS NV_API_CALL nv_acpi_mux_method(
+ if (!dev_handle)
+ return NV_ERR_INVALID_ARGUMENT;
+
+-#if defined(NV_ACPI_BUS_GET_DEVICE_PRESENT)
+- status = acpi_bus_get_device(dev_handle, &device);
+-#else
+- return NV_ERR_NOT_SUPPORTED;
+-#endif
+-
+-
+- if (ACPI_FAILURE(status) || !device)
+- return NV_ERR_INVALID_ARGUMENT;
+-
+ if (!NV_MAY_SLEEP())
+ {
+ #if defined(DEBUG)
+@@ -1138,23 +1114,16 @@ NV_STATUS NV_API_CALL nv_acpi_mux_method(
+ return NV_ERR_NOT_SUPPORTED;
+ }
+
+- list_for_each_safe(node, next, &device->children)
++ while (mux_dev_handle == NULL)
+ {
+- struct acpi_device *dev = list_entry(node, struct acpi_device, node);
+-
+- if (!dev)
+- continue;
+-
+- status = acpi_evaluate_integer(dev->handle, "_ADR", NULL,
&device_id);
+- if (ACPI_FAILURE(status))
+- /* Could not query device_id for this device */
+- continue;
+-
+- if (device_id == muxAcpiId)
+- {
+- mux_dev_handle = dev->handle;
++ status = acpi_get_next_object(ACPI_TYPE_DEVICE, dev_handle,
++ handle, &handle);
++ if (ACPI_FAILURE(status) || (handle == NULL))
+ break;
+- }
++
++ status = acpi_evaluate_integer(handle, "_ADR", NULL, &device_id);
++ if (ACPI_SUCCESS(status) && (device_id == muxAcpiId))
++ mux_dev_handle = handle;
+ }
+
+ if (mux_dev_handle == NULL)
+--
+2.20.1
+
diff --git a/0023-backport-drm_frambuffer.h-changes-from-515.76.patch
b/0023-backport-drm_frambuffer.h-changes-from-515.76.patch
new file mode 100644
index 0000000..402bfcd
--- /dev/null
+++ b/0023-backport-drm_frambuffer.h-changes-from-515.76.patch
@@ -0,0 +1,36 @@
+From 1d8c1a8fc7c278763f93f60e49f16fe9a70a0a6b Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Mon, 17 Oct 2022 03:35:02 +0200
+Subject: [PATCH] backport drm_frambuffer.h changes from 515.76
+
+---
+ nvidia-drm/nvidia-drm-helper.c | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/nvidia-drm/nvidia-drm-helper.c b/nvidia-drm/nvidia-drm-helper.c
+index 3831180..8fc8620 100644
+--- a/nvidia-drm/nvidia-drm-helper.c
++++ b/nvidia-drm/nvidia-drm-helper.c
+@@ -41,6 +41,19 @@
+ #include <drm/drm_atomic_uapi.h>
+ #endif
+
++/*
++ * The inclusion of drm_framebuffer.h was removed from drm_crtc.h by commit
++ * 720cf96d8fecde29b72e1101f8a567a0ce99594f ("drm: Drop drm_framebuffer.h from
++ * drm_crtc.h") in linux-next, expected in v5.19-rc7.
++ *
++ * We only need drm_framebuffer.h for drm_framebuffer_put(), and it is always
++ * present (v4.9+) when drm_framebuffer_{put,get}() is present (v4.12+), so it
++ * is safe to unconditionally include it when drm_framebuffer_get() is present.
++ */
++#if defined(NV_DRM_FRAMEBUFFER_GET_PRESENT)
++#include <drm/drm_framebuffer.h>
++#endif
++
+ static void __nv_drm_framebuffer_put(struct drm_framebuffer *fb)
+ {
+ #if defined(NV_DRM_FRAMEBUFFER_GET_PRESENT)
+--
+2.20.1
+
diff --git a/nvidia-470xx-kmod.spec b/nvidia-470xx-kmod.spec
index 3653176..1d0a7f4 100644
--- a/nvidia-470xx-kmod.spec
+++ b/nvidia-470xx-kmod.spec
@@ -12,7 +12,7 @@ Name: nvidia-470xx-kmod
Epoch: 3
Version: 470.141.03
# Taken over by kmodtool
-Release: 2%{?dist}
+Release: 3%{?dist}
License: Redistributable, no modification permitted
Summary: NVIDIA 470xx display driver kernel module
@@ -20,6 +20,11 @@ URL:
https://www.nvidia.com/
Source11: nvidia-470xx-kmodtool-excludekernel-filterfile
+Patch20: 0020-backport-get_task_ioprio-changes-from-510.85.02.patch
+Patch21: 0021-backport-acpi-changes-from-510.85.02.patch
+Patch22: 0022-backport-acpi-changes-from-515.65.01.patch
+Patch23: 0023-backport-drm_frambuffer.h-changes-from-515.76.patch
+
# needed for plague to make sure it builds for i586 and i686
ExclusiveArch: x86_64
@@ -42,6 +47,10 @@ kmodtool --target %{_target_cpu} --repo rpmfusion --kmodname %{name}
--filterf
%setup -T -c
tar --use-compress-program xz -xf
%{_datadir}/%{name}-%{version}/%{name}-%{version}-%{_target_cpu}.tar.xz
# patch loop
+%patch20 -p1
+%patch21 -p1
+%patch22 -p1
+%patch23 -p1
for kernel_version in %{?kernel_versions} ; do
cp -a kernel _kmod_build_${kernel_version%%___*}
@@ -73,6 +82,9 @@ done
%{?akmod_install}
%changelog
+* Sun Oct 30 2022 Vitaly Zaitsev <vitaly(a)easycoding.org> - 3:470.141.03-3
+- Added backported Debian patches for the Linux kernel 6.0.
+
* Mon Aug 08 2022 RPM Fusion Release Engineering <sergiomb(a)rpmfusion.org> -
3:470.141.03-2
- Rebuilt for
https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild and ffmpeg
5.1