~ubuntu-branches/ubuntu/edgy/linux-restricted-modules-2.6.15/edgy

« back to all changes in this revision

Viewing changes to nvidia/patches/001_NVIDIA_kernel-1.0-8178-pm_fixes.patch

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2006-04-10 14:51:39 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20060410145139-shki0yqc3z29vgg1
Tags: 2.6.15.8-1
* Update non-legacy NVIDIA driver to 1.0.8756, legacy still at 1.0.7174:
  - Drop patches 001 through 006, all incorporated in the new version.
  - Includes improved power management support, and support for all the
    latest/shiniest NVIDIA hardware, (closes: launchpad.net/{38637,35628})
* Fix whitespace in fglrx rules file (closes: launchpad.net/{32576,23250})
* Stop having nvidia-glx-enable add the nvidia kernel modules to the end
  of /etc/modules, since it is properly autoloaded by the X server.  This
  stops us breaking /etc/modules as a bonus (closes: launchpad.net/27579)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Only in usr/src/nv.1423627: .nv.c.rej.swp
2
 
diff -ru usr/src/nv/Makefile.kbuild usr/src/nv.1423627/Makefile.kbuild
3
 
--- usr/src/nv/Makefile.kbuild  2005-11-23 03:58:01.000000000 +0100
4
 
+++ usr/src/nv.1423627/Makefile.kbuild  2005-12-04 14:56:24.092375500 +0100
5
 
@@ -186,6 +186,14 @@
6
 
   ifeq ($(shell $(CONFTEST) sysctl_max_map_count), 1)
7
 
     EXTRA_CFLAGS += -DNV_SYSCTL_MAX_MAP_COUNT_PRESENT
8
 
   endif
9
 
+
10
 
+  ifeq ($(shell $(CONFTEST) pm_message_t), 1)
11
 
+    EXTRA_CFLAGS += -DNV_PM_MESSAGE_T_PRESENT
12
 
+  endif
13
 
+
14
 
+  ifeq ($(shell $(CONFTEST) pci_choose_state), 1)
15
 
+    EXTRA_CFLAGS += -DNV_PCI_CHOOSE_STATE_PRESENT
16
 
+  endif
17
 
 endif
18
 
 
19
 
 ifeq ($(shell $(CONFTEST) remap_pfn_range), 1)
20
 
diff -ru usr/src/nv/conftest.sh usr/src/nv.1423627/conftest.sh
21
 
--- usr/src/nv/conftest.sh      2005-11-23 03:58:01.000000000 +0100
22
 
+++ usr/src/nv.1423627/conftest.sh      2005-12-04 14:56:24.092375500 +0100
23
 
@@ -643,4 +643,47 @@
24
 
         fi
25
 
     ;;
26
 
 
27
 
+    pm_message_t)
28
 
+        #
29
 
+        # Does linux/pm.h declare the pm_message_t type?
30
 
+        #
31
 
+
32
 
+        echo "#include <linux/pm.h>
33
 
+        void nv_test_pm_message_t(pm_message_t state) {
34
 
+            pm_message_t *p = &state;
35
 
+        }" > conftest$$.c
36
 
+
37
 
+        $CC $CFLAGS -Wno-error -c conftest$$.c > /dev/null 2>&1
38
 
+        rm -f conftest$$.c
39
 
+
40
 
+        if [ -f conftest$$.o ]; then
41
 
+            rm -f conftest$$.o
42
 
+            echo 1
43
 
+        else
44
 
+            echo 0
45
 
+        fi
46
 
+    ;;
47
 
+
48
 
+    pci_choose_state)
49
 
+        #
50
 
+        # Determine if pci_choose_state() is present.
51
 
+        #
52
 
+
53
 
+        echo "#include <linux/pci.h>
54
 
+        pci_power_t
55
 
+        nv_pci_choose_state(struct pci_dev *dev, pm_message_t state) {
56
 
+            return pci_choose_state(dev, state);
57
 
+        }" > conftest$$.c
58
 
+
59
 
+        $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
60
 
+        rm -f conftest$$.c
61
 
+
62
 
+        if [ -f conftest$$.o ]; then
63
 
+            rm -f conftest$$.o
64
 
+            echo 1
65
 
+        else
66
 
+            echo 0
67
 
+        fi
68
 
+    ;;
69
 
+
70
 
 esac
71
 
diff -ru usr/src/nv/nv-linux.h usr/src/nv.1423627/nv-linux.h
72
 
--- usr/src/nv/nv-linux.h       2005-11-23 03:58:01.000000000 +0100
73
 
+++ usr/src/nv.1423627/nv-linux.h       2005-12-04 14:56:24.092375500 +0100
74
 
@@ -642,15 +642,49 @@
75
 
 #define NV_PRINT_AT(at)
76
 
 #endif
77
 
 
78
 
-// acpi support has been back-ported to the 2.4 kernel, but the 2.4 driver
79
 
-// model is not sufficient for full acpi support. it may work in some cases,
80
 
-// but not enough for us to officially support this configuration.
81
 
-#if defined(CONFIG_ACPI) && defined(KERNEL_2_6)
82
 
-#define NV_PM_SUPPORT_ACPI
83
 
+/*
84
 
+ * On Linux 2.6, we support both APM and ACPI power management. On Linux
85
 
+ * 2.4, we support APM, only. ACPI support has been back-ported to the
86
 
+ * Linux 2.4 kernel, but the Linux 2.4 driver model is not sufficient for
87
 
+ * full ACPI support: it may work with some systems, but not reliably
88
 
+ * enough for us to officially support this configuration.
89
 
+ *
90
 
+ * We support two Linux kernel power managment interfaces: the original
91
 
+ * pm_register()/pm_unregister() on Linux 2.4 and the device driver model
92
 
+ * backed PCI driver power management callbacks introduced with Linux
93
 
+ * 2.6.
94
 
+ *
95
 
+ * The code below determines which interface to support on this kernel
96
 
+ * version, if any; if built for Linux 2.6, it will also determine if the
97
 
+ * kernel comes with ACPI or APM power management support.
98
 
+ */
99
 
+#if defined(KERNEL_2_6) && (defined(CONFIG_APM) || defined(CONFIG_APM_MODULE) || defined(CONFIG_ACPI))
100
 
+#define NV_PM_SUPPORT_DEVICE_DRIVER_MODEL
101
 
+#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
102
 
+#define NV_PM_SUPPORT_NEW_STYLE_APM
103
 
+#endif
104
 
 #endif
105
 
 
106
 
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
107
 
-#define NV_PM_SUPPORT_APM
108
 
+/*
109
 
+ * On Linux 2.6 kernels >= 2.6.11, the PCI subsystem provides a new 
110
 
+ * interface that allows PCI drivers to determine the correct power state
111
 
+ * for a given system power state; our suspend/resume callbacks now use
112
 
+ * this interface and operate on PCI power state defines.
113
 
+ *
114
 
+ * Define these new PCI power state #define's here for compatibility with
115
 
+ * older Linux 2.6 kernels.
116
 
+ */
117
 
+#if defined(KERNEL_2_6) && !defined(PCI_D0)
118
 
+#define PCI_D0 PM_SUSPEND_ON
119
 
+#define PCI_D3hot PM_SUSPEND_MEM
120
 
+#endif
121
 
+
122
 
+#if defined(KERNEL_2_6) && !defined(NV_PM_MESSAGE_T_PRESENT)
123
 
+typedef u32 pm_message_t;
124
 
+#endif
125
 
+
126
 
+#if defined(KERNEL_2_4) && (defined(CONFIG_APM) || defined(CONFIG_APM_MODULE))
127
 
+#define NV_PM_SUPPORT_OLD_STYLE_APM
128
 
 #endif
129
 
 
130
 
 #ifndef minor
131
 
diff -ru usr/src/nv/nv.c usr/src/nv.1423627/nv.c
132
 
--- usr/src/nv/nv.c     2005-11-23 03:58:01.000000000 +0100
133
 
+++ usr/src/nv.1423627/nv.c     2005-12-04 14:57:13.791481500 +0100
134
 
@@ -29,7 +29,7 @@
135
 
 
136
 
 static nv_linux_state_t nv_linux_devices[NV_MAX_DEVICES];
137
 
 
138
 
-#if defined(NV_PM_SUPPORT_APM)
139
 
+#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
140
 
 static struct pm_dev *apm_nv_dev[NV_MAX_DEVICES] = { 0 };
141
 
 #endif
142
 
 
143
 
@@ -244,8 +244,8 @@
144
 
 void          nv_kern_isr_bh(unsigned long);
145
 
 irqreturn_t   nv_kern_isr(int, void *, struct pt_regs *);
146
 
 void          nv_kern_rc_timer(unsigned long);
147
 
-#if defined(NV_PM_SUPPORT_APM)
148
 
-int           nv_kern_apm_event(struct pm_dev *dev, pm_request_t rqst, void *data);
149
 
+#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
150
 
+static int    nv_kern_apm_event(struct pm_dev *, pm_request_t, void *);
151
 
 #endif
152
 
 
153
 
 static int    nv_kern_read_cardinfo(char *, char **, off_t off, int, int *, void *);
154
 
@@ -265,9 +265,10 @@
155
 
 unsigned int  nv_kern_ctl_poll(struct file *, poll_table *);
156
 
 
157
 
 int nv_kern_probe(struct pci_dev *, const struct pci_device_id *);
158
 
-#if defined(NV_PM_SUPPORT_ACPI)
159
 
-int nv_kern_acpi_standby(struct pci_dev *, u32);
160
 
-int nv_kern_acpi_resume(struct pci_dev *);
161
 
+
162
 
+#if defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL)
163
 
+static int    nv_kern_suspend(struct pci_dev *, pm_message_t);
164
 
+static int    nv_kern_resume(struct pci_dev *);
165
 
 #endif
166
 
 
167
 
 /***
168
 
@@ -292,9 +293,9 @@
169
 
     .name     = "nvidia",
170
 
     .id_table = nv_pci_table,
171
 
     .probe    = nv_kern_probe,
172
 
-#if defined(NV_PM_SUPPORT_ACPI)
173
 
-    .suspend  = nv_kern_acpi_standby,
174
 
-    .resume   = nv_kern_acpi_resume,
175
 
+#if defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL)
176
 
+    .suspend  = nv_kern_suspend,
177
 
+    .resume   = nv_kern_resume,
178
 
 #endif
179
 
 };
180
 
 
181
 
@@ -1299,7 +1300,7 @@
182
 
         nv_lock_init_locks(nv_ctl);
183
 
     }
184
 
 
185
 
-#if defined(NV_PM_SUPPORT_APM)
186
 
+#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
187
 
     for (i = 0; i < num_nv_devices; i++)
188
 
     {
189
 
         apm_nv_dev[i] = pm_register(PM_PCI_DEV, PM_SYS_VGA, nv_kern_apm_event);
190
 
@@ -1418,7 +1419,7 @@
191
 
     if (nv_pte_t_cache != NULL)
192
 
         NV_KMEM_CACHE_DESTROY(nv_pte_t_cache);
193
 
 
194
 
-#if defined(NV_PM_SUPPORT_APM)
195
 
+#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
196
 
     for (i = 0; i < num_nv_devices; i++)
197
 
         if (apm_nv_dev[i] != NULL) pm_unregister(apm_nv_dev[i]);
198
 
 #endif
199
 
@@ -1473,10 +1474,10 @@
200
 
     inter_module_unregister("nv_linux_devices");
201
 
 #endif
202
 
 
203
 
-#if defined(NV_PM_SUPPORT_APM)
204
 
+#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
205
 
     for (i = 0; i < num_nv_devices; i++)
206
 
     {
207
 
-        pm_unregister(apm_nv_dev[i]);
208
 
+        if (apm_nv_dev[i] != NULL) pm_unregister(apm_nv_dev[i]);
209
 
     }
210
 
 #endif
211
 
 
212
 
@@ -2429,9 +2430,9 @@
213
 
     mod_timer(&nvl->rc_timer, jiffies + HZ);  /* set another timeout in 1 second */
214
 
 }
215
 
 
216
 
-#if defined(NV_PM_SUPPORT_APM)
217
 
+#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
218
 
 /* kernel calls us with a power management event */
219
 
-int
220
 
+static int
221
 
 nv_kern_apm_event(
222
 
     struct pm_dev *dev,
223
 
     pm_request_t rqst,
224
 
@@ -2466,7 +2467,6 @@
225
 
 
226
 
     switch (rqst)
227
 
     {
228
 
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
229
 
         case PM_RESUME:
230
 
             nv_printf(NV_DBG_INFO, "NVRM: APM: received resume event\n");
231
 
             status = rm_power_management(nv, 0, NV_PM_APM_RESUME);
232
 
@@ -2476,15 +2476,12 @@
233
 
             nv_printf(NV_DBG_INFO, "NVRM: APM: received suspend event\n");
234
 
             status = rm_power_management(nv, 0, NV_PM_APM_SUSPEND);
235
 
             break;
236
 
-#endif
237
 
 
238
 
-#if defined(KERNEL_2_4)
239
 
         // 2.4 kernels sent a PM_SAVE_STATE request when powering down via
240
 
         // ACPI. just ignore it and return success so the power down works
241
 
         case PM_SAVE_STATE:
242
 
             status = RM_OK;
243
 
             break;
244
 
-#endif
245
 
 
246
 
         default:
247
 
             nv_printf(NV_DBG_WARNINGS, "NVRM: APM: unsupported event: %d\n", rqst);
248
 
@@ -2496,7 +2493,7 @@
249
 
 
250
 
     return status;
251
 
 }
252
 
-#endif
253
 
+#endif /* defined(NV_PM_SUPPORT_OLD_STYLE_APM) */
254
 
 
255
 
 /*
256
 
 ** nv_kern_ctl_open
257
 
@@ -3739,6 +3736,7 @@
258
 
     nvl = &nv_linux_devices[num_nv_devices];
259
 
     nv  = NV_STATE_PTR(nvl);
260
 
 
261
 
+    pci_set_drvdata(dev, (void *)nvl);
262
 
     nvl->dev          = dev;
263
 
     nv->vendor_id     = dev->vendor;
264
 
     nv->device_id     = dev->device;
265
 
@@ -3816,11 +3814,10 @@
266
 
 #endif
267
 
 }
268
 
 
269
 
-#if defined(NV_PM_SUPPORT_ACPI)
270
 
+#if defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL)
271
 
 
272
 
-int
273
 
-nv_acpi_event
274
 
-(
275
 
+static int
276
 
+nv_power_management(
277
 
     struct pci_dev *dev, 
278
 
     u32 state
279
 
 )
280
 
@@ -3828,70 +3825,77 @@
281
 
     nv_state_t *nv;
282
 
     nv_linux_state_t *lnv = NULL;
283
 
     int status = RM_OK;
284
 
-    U032 i;
285
 
-
286
 
-    nv_printf(NV_DBG_INFO, "NVRM: nv_acpi_event: %d\n", state);
287
 
 
288
 
-    for (i = 0; i < num_nv_devices; i++)
289
 
-    {
290
 
-        if (nv_linux_devices[i].dev == dev)
291
 
-        {
292
 
-            lnv = &nv_linux_devices[i];
293
 
-            break;
294
 
-        }
295
 
-    }
296
 
+    nv_printf(NV_DBG_INFO, "NVRM: nv_power_management: %d\n", state);
297
 
+    lnv = pci_get_drvdata(dev);
298
 
 
299
 
     if ((!lnv) || (lnv->dev != dev))
300
 
     {
301
 
-        nv_printf(NV_DBG_WARNINGS, "NVRM: ACPI: invalid device!\n");
302
 
+        nv_printf(NV_DBG_WARNINGS, "NVRM: PM: invalid device!\n");
303
 
         return -1;
304
 
     }
305
 
 
306
 
     nv = NV_STATE_PTR(lnv);
307
 
+    nv_verify_pci_config(NV_STATE_PTR(lnv), TRUE);
308
 
 
309
 
     switch (state)
310
 
     {
311
 
-        case PM_SUSPEND_MEM:
312
 
+#if defined(NV_PM_SUPPORT_NEW_STYLE_APM)
313
 
+        case PCI_D3hot:
314
 
+            nv_printf(NV_DBG_INFO, "NVRM: APM: received suspend event\n");
315
 
+            status = rm_power_management(nv, 0, NV_PM_APM_SUSPEND);
316
 
+            break;
317
 
+
318
 
+        case PCI_D0:
319
 
+            nv_printf(NV_DBG_INFO, "NVRM: APM: received resume event\n");
320
 
+            status = rm_power_management(nv, 0, NV_PM_APM_RESUME);
321
 
+            break;
322
 
+#else
323
 
+        case PCI_D3hot:
324
 
             nv_printf(NV_DBG_INFO, "NVRM: ACPI: received suspend event\n");
325
 
             status = rm_power_management(nv, 0, NV_PM_ACPI_STANDBY);
326
 
             break;
327
 
 
328
 
-        case PM_SUSPEND_ON:
329
 
+        case PCI_D0:
330
 
             nv_printf(NV_DBG_INFO, "NVRM: ACPI: received resume event\n");
331
 
             status = rm_power_management(nv, 0, NV_PM_ACPI_RESUME);
332
 
             break;
333
 
-
334
 
+#endif
335
 
         default:
336
 
-            nv_printf(NV_DBG_WARNINGS, "NVRM: ACPI: unsupported event: %d\n", state);
337
 
+            nv_printf(NV_DBG_WARNINGS, "NVRM: PM: unsupported event: %d\n", state);
338
 
             return -1;
339
 
     }
340
 
 
341
 
     if (status != RM_OK)
342
 
-        nv_printf(NV_DBG_ERRORS, "NVRM: ACPI: failed event: %d\n", state);
343
 
+        nv_printf(NV_DBG_ERRORS, "NVRM: PM: failed event: %d\n", state);
344
 
 
345
 
     return status;
346
 
 }
347
 
 
348
 
-int
349
 
-nv_kern_acpi_standby
350
 
-(
351
 
-    struct pci_dev *dev, 
352
 
-    u32 state
353
 
+static int nv_kern_suspend(
354
 
+    struct pci_dev *dev,
355
 
+    pm_message_t state
356
 
 )
357
 
 {
358
 
-    return nv_acpi_event(dev, state);
359
 
+    int power_state = -1;
360
 
+
361
 
+#if !defined(NV_PM_MESSAGE_T_PRESENT)
362
 
+    power_state = state;
363
 
+#elif defined(NV_PCI_CHOOSE_STATE_PRESENT)
364
 
+    power_state = pci_choose_state(dev, state);
365
 
+#endif
366
 
+
367
 
+    return nv_power_management(dev, power_state);
368
 
 }
369
 
 
370
 
-int
371
 
-nv_kern_acpi_resume
372
 
-(
373
 
+static int nv_kern_resume(
374
 
     struct pci_dev *dev
375
 
 )
376
 
 {
377
 
-    return nv_acpi_event(dev, PM_SUSPEND_ON);
378
 
+    return nv_power_management(dev, PCI_D0);
379
 
 }
380
 
 
381
 
-#endif
382
 
+#endif /* defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL) */
383
 
 
384
 
 void* NV_API_CALL nv_get_adapter_state(
385
 
     U016 bus,