-
Notifications
You must be signed in to change notification settings - Fork 1
/
0018-backport-nv_install_notifier-changes-from-418.30.patch
126 lines (108 loc) · 3.9 KB
/
0018-backport-nv_install_notifier-changes-from-418.30.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
From 3c43ce4e0f2406b6411d0c9b29b383e8fb4e9c29 Mon Sep 17 00:00:00 2001
From: Andreas Beckmann <[email protected]>
Date: Wed, 19 Oct 2022 13:49:43 +0200
Subject: [PATCH] backport nv_install_notifier changes from 418.30
---
nvidia/nv-acpi.c | 37 +++++++++++++++----------------------
1 file changed, 15 insertions(+), 22 deletions(-)
diff --git a/nvidia/nv-acpi.c b/nvidia/nv-acpi.c
index 6cfd400..d311e85 100644
--- a/nvidia/nv-acpi.c
+++ b/nvidia/nv-acpi.c
@@ -502,19 +502,19 @@ static int nv_acpi_match(struct acpi_device *device, struct acpi_driver *driver)
#endif
/* Do the necessary allocations and install notifier "handler" on the device-node "device" */
-static NV_STATUS nv_install_notifier(struct acpi_handle *handle, acpi_notify_handler handler)
-{
+static nv_acpi_t* nv_install_notifier(struct acpi_handle *handle, acpi_notify_handler handler)
+{
nvidia_stack_t *sp = NULL;
nv_acpi_t *pNvAcpiObject = NULL;
NV_STATUS rmStatus = NV_ERR_GENERIC;
acpi_status status = -1;
if (!handle)
- return NV_ERR_GENERIC;
+ return NULL;
if (nv_kmem_cache_alloc_stack(&sp) != 0)
{
- return NV_ERR_NO_MEMORY;
+ return NULL;
}
rmStatus = os_alloc_mem((void **) &pNvAcpiObject, sizeof(nv_acpi_t));
@@ -532,32 +532,25 @@ static NV_STATUS nv_install_notifier(struct acpi_handle *handle, acpi_notify_han
if (!ACPI_FAILURE(status))
{
pNvAcpiObject->notify_handler_installed = 1;
- return NV_OK;
+ return pNvAcpiObject;
}
-
return_error:
-
nv_kmem_cache_free_stack(sp);
if (pNvAcpiObject)
os_free_mem((void *)pNvAcpiObject);
- return NV_ERR_GENERIC;
+ return NULL;
}
/* Tear-down and remove whatever nv_install_notifier did */
-static void nv_uninstall_notifier(struct acpi_device *device, acpi_notify_handler handler)
+static void nv_uninstall_notifier(nv_acpi_t *pNvAcpiObject, acpi_notify_handler handler)
{
acpi_status status;
- nv_acpi_t *pNvAcpiObject = NULL;
-
- if (!device)
- return;
- pNvAcpiObject = device->driver_data;
if (pNvAcpiObject && pNvAcpiObject->notify_handler_installed)
{
- status = acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, handler);
+ status = acpi_remove_notify_handler(pNvAcpiObject->handle, ACPI_DEVICE_NOTIFY, handler);
if (ACPI_FAILURE(status))
{
nv_printf(NV_DBG_INFO,
@@ -567,14 +560,12 @@ static void nv_uninstall_notifier(struct acpi_device *device, acpi_notify_handle
{
nv_kmem_cache_free_stack(pNvAcpiObject->sp);
os_free_mem((void *)pNvAcpiObject);
- device->driver_data = NULL;
}
}
-
+
return;
}
-
/*
* acpi methods init function.
* check if the NVIF, _DSM and WMMX methods are present in the acpi namespace.
@@ -585,7 +576,6 @@ void NV_API_CALL nv_acpi_methods_init(NvU32 *handlesPresent)
{
#if defined(NV_ACPI_BUS_GET_DEVICE_PRESENT)
struct acpi_device *device = NULL;
- NV_STATUS rmStatus;
int retVal = -1;
#endif
@@ -618,8 +608,10 @@ void NV_API_CALL nv_acpi_methods_init(NvU32 *handlesPresent)
nodes' structures. So nothing more to be done */
}
- rmStatus = nv_install_notifier(device->handle, nv_acpi_event);
- if (rmStatus != NV_OK)
+ device->driver_data = nv_install_notifier(device->handle, nv_acpi_event);
+
+
+ if (!device->driver_data)
nvif_parent_gpu_handle = NULL;
} while (0);
@@ -684,9 +676,10 @@ void NV_API_CALL nv_acpi_methods_uninit(void)
#if defined(NV_ACPI_BUS_GET_DEVICE_PRESENT)
acpi_bus_get_device(nvif_parent_gpu_handle, &device);
- nv_uninstall_notifier(device, nv_acpi_event);
+ nv_uninstall_notifier(device->driver_data, nv_acpi_event);
#endif
+ device->driver_data = NULL;
nvif_parent_gpu_handle = NULL;
return;
--
2.20.1