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
6
ifeq ($(shell $(CONFTEST) sysctl_max_map_count), 1)
7
EXTRA_CFLAGS += -DNV_SYSCTL_MAX_MAP_COUNT_PRESENT
10
+ ifeq ($(shell $(CONFTEST) pm_message_t), 1)
11
+ EXTRA_CFLAGS += -DNV_PM_MESSAGE_T_PRESENT
14
+ ifeq ($(shell $(CONFTEST) pci_choose_state), 1)
15
+ EXTRA_CFLAGS += -DNV_PCI_CHOOSE_STATE_PRESENT
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
29
+ # Does linux/pm.h declare the pm_message_t type?
32
+ echo "#include <linux/pm.h>
33
+ void nv_test_pm_message_t(pm_message_t state) {
34
+ pm_message_t *p = &state;
37
+ $CC $CFLAGS -Wno-error -c conftest$$.c > /dev/null 2>&1
40
+ if [ -f conftest$$.o ]; then
50
+ # Determine if pci_choose_state() is present.
53
+ echo "#include <linux/pci.h>
55
+ nv_pci_choose_state(struct pci_dev *dev, pm_message_t state) {
56
+ return pci_choose_state(dev, state);
59
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
62
+ if [ -f conftest$$.o ]; then
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
75
#define NV_PRINT_AT(at)
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
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.
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
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.
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
106
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
107
-#define NV_PM_SUPPORT_APM
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.
114
+ * Define these new PCI power state #define's here for compatibility with
115
+ * older Linux 2.6 kernels.
117
+#if defined(KERNEL_2_6) && !defined(PCI_D0)
118
+#define PCI_D0 PM_SUSPEND_ON
119
+#define PCI_D3hot PM_SUSPEND_MEM
122
+#if defined(KERNEL_2_6) && !defined(NV_PM_MESSAGE_T_PRESENT)
123
+typedef u32 pm_message_t;
126
+#if defined(KERNEL_2_4) && (defined(CONFIG_APM) || defined(CONFIG_APM_MODULE))
127
+#define NV_PM_SUPPORT_OLD_STYLE_APM
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
136
static nv_linux_state_t nv_linux_devices[NV_MAX_DEVICES];
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 };
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 *);
153
static int nv_kern_read_cardinfo(char *, char **, off_t off, int, int *, void *);
155
unsigned int nv_kern_ctl_poll(struct file *, poll_table *);
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 *);
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 *);
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,
181
@@ -1299,7 +1300,7 @@
182
nv_lock_init_locks(nv_ctl);
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++)
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);
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]);
199
@@ -1473,10 +1474,10 @@
200
inter_module_unregister("nv_linux_devices");
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++)
207
- pm_unregister(apm_nv_dev[i]);
208
+ if (apm_nv_dev[i] != NULL) pm_unregister(apm_nv_dev[i]);
212
@@ -2429,9 +2430,9 @@
213
mod_timer(&nvl->rc_timer, jiffies + HZ); /* set another timeout in 1 second */
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 */
224
@@ -2466,7 +2467,6 @@
228
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
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);
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
247
nv_printf(NV_DBG_WARNINGS, "NVRM: APM: unsupported event: %d\n", rqst);
248
@@ -2496,7 +2493,7 @@
253
+#endif /* defined(NV_PM_SUPPORT_OLD_STYLE_APM) */
257
@@ -3739,6 +3736,7 @@
258
nvl = &nv_linux_devices[num_nv_devices];
259
nv = NV_STATE_PTR(nvl);
261
+ pci_set_drvdata(dev, (void *)nvl);
263
nv->vendor_id = dev->vendor;
264
nv->device_id = dev->device;
265
@@ -3816,11 +3814,10 @@
269
-#if defined(NV_PM_SUPPORT_ACPI)
270
+#if defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL)
276
+nv_power_management(
280
@@ -3828,70 +3825,77 @@
282
nv_linux_state_t *lnv = NULL;
286
- nv_printf(NV_DBG_INFO, "NVRM: nv_acpi_event: %d\n", state);
288
- for (i = 0; i < num_nv_devices; i++)
290
- if (nv_linux_devices[i].dev == dev)
292
- lnv = &nv_linux_devices[i];
296
+ nv_printf(NV_DBG_INFO, "NVRM: nv_power_management: %d\n", state);
297
+ lnv = pci_get_drvdata(dev);
299
if ((!lnv) || (lnv->dev != dev))
301
- nv_printf(NV_DBG_WARNINGS, "NVRM: ACPI: invalid device!\n");
302
+ nv_printf(NV_DBG_WARNINGS, "NVRM: PM: invalid device!\n");
306
nv = NV_STATE_PTR(lnv);
307
+ nv_verify_pci_config(NV_STATE_PTR(lnv), TRUE);
311
- case PM_SUSPEND_MEM:
312
+#if defined(NV_PM_SUPPORT_NEW_STYLE_APM)
314
+ nv_printf(NV_DBG_INFO, "NVRM: APM: received suspend event\n");
315
+ status = rm_power_management(nv, 0, NV_PM_APM_SUSPEND);
319
+ nv_printf(NV_DBG_INFO, "NVRM: APM: received resume event\n");
320
+ status = rm_power_management(nv, 0, NV_PM_APM_RESUME);
324
nv_printf(NV_DBG_INFO, "NVRM: ACPI: received suspend event\n");
325
status = rm_power_management(nv, 0, NV_PM_ACPI_STANDBY);
328
- case PM_SUSPEND_ON:
330
nv_printf(NV_DBG_INFO, "NVRM: ACPI: received resume event\n");
331
status = rm_power_management(nv, 0, NV_PM_ACPI_RESUME);
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);
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);
349
-nv_kern_acpi_standby
351
- struct pci_dev *dev,
353
+static int nv_kern_suspend(
354
+ struct pci_dev *dev,
358
- return nv_acpi_event(dev, state);
359
+ int power_state = -1;
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);
367
+ return nv_power_management(dev, power_state);
373
+static int nv_kern_resume(
377
- return nv_acpi_event(dev, PM_SUSPEND_ON);
378
+ return nv_power_management(dev, PCI_D0);
382
+#endif /* defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL) */
384
void* NV_API_CALL nv_get_adapter_state(