Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 510020 | Differences between
and this patch

Collapse All | Expand All

(-)usr-patched1.orig/src/nv/Makefile.kbuild (-1 / +5 lines)
Lines 189-195 Link Here
189
	agp_memory \
189
	agp_memory \
190
	scatterlist \
190
	scatterlist \
191
	file_operations \
191
	file_operations \
192
	sg_init_table
192
	sg_init_table \
193
	proc_create_data \
194
	pde_data \
195
	proc_remove \
196
	get_num_physpages
193
else
197
else
194
 COMPILE_TESTS = \
198
 COMPILE_TESTS = \
195
	remap_page_range \
199
	remap_page_range \
(-)usr-patched1.orig/src/nv/Makefile.kbuild.orig (+333 lines)
Line 0 Link Here
1
# This Makefile is automatically generated; do not edit
2
# Generated on 'swio-display-x86-rh72-02.nvidia.com' on Fri Aug 31 14:52:31 PDT 2012
3
4
# to use this file, rename or delete the default Makefile, then rename or
5
# link this file to Makefile. then type 'make'
6
7
#
8
# KBUILD Makefile for the NVIDIA Linux kernel module.
9
#
10
# The motivation for replacing the original Makefile is the hope that this
11
# version will simplify the build and installation process. In the past,
12
# many architectural and cosmetic changes to the Linux kernel have made it
13
# difficult to maintain compatibility or required duplication of logic.
14
#
15
# Linux 2.6 introduces numerous such changes, many of which impact modules.
16
# Relying on KBUILD, some aspects of the build system otherwise difficult
17
# to support (for example, module versioning) are abstracted away and dealt
18
# with elsewhere, making life significantly easier here.
19
#
20
# The new approach currently has its own share of problems, some of which
21
# are architectural difficulties with KBUILD, others minor annoyances. For
22
# this reason, an improved version of the NVIDIA Makefile is available to
23
# those experiencing difficulties.
24
#
25
# kbuild Makefile originally developed by:
26
#
27
# Alistair J Strachan (alistair@devzero.co.uk) (first pass, enhancements)
28
# Christian Zander (zander@mail.minion.de) (enhancements)
29
#
30
31
all: install
32
install: package-install
33
34
#
35
# The NVIDIA kernel module base name and static file names. KBUILD will go
36
# ahead and append ".o" or ".ko" to form the final module name.
37
#
38
39
MODULE_NAME := nvidia
40
VERSION_HEADER := nv_compiler.h
41
42
#
43
# List of object files to link into NVIDIA kernel module; make sure KBUILD
44
# understands that we want a module.
45
#
46
47
CORE_OBJS := nv-kernel.o
48
RESMAN_GLUE_OBJS := nv.o nv-vm.o os-agp.o os-interface.o os-registry.o nv-i2c.o
49
50
$(MODULE_NAME)-objs := $(CORE_OBJS) $(RESMAN_GLUE_OBJS)
51
52
#
53
# The precompiled kernel module build process requires a separation of the
54
# closed source and open source object files.
55
#
56
57
KERNEL_GLUE_NAME := nv-linux.o
58
KERNEL_GLUE_OBJS := $(RESMAN_GLUE_OBJS) $(MODULE_NAME).mod.o
59
60
#
61
# A bug in KBUILD 2.4 means that leaving obj-m set in top-level context
62
# will cause Rules.make to call pathdown.sh, which is wrong. So, we only
63
# set this conditional of a kernel-level instance.
64
#
65
66
TOPDIR ?= $(srctree)
67
68
ifdef TOPDIR
69
obj-m := $(MODULE_NAME).o
70
endif
71
72
#
73
# Include local source directory in $(CC)'s include path and set disable any
74
# warning types that are of little interest to us.
75
#
76
77
EXTRA_CFLAGS += -I$(src)
78
EXTRA_CFLAGS += -Wall -Wimplicit -Wreturn-type -Wswitch -Wformat -Wchar-subscripts -Wparentheses  -Wno-multichar -Werror -MD $(DEFINES) $(INCLUDES)  -Wno-cast-qual -Wno-error
79
80
#
81
# We rely on these two definitions below; if they aren't set, we set them to
82
# reasonable defaults (Linux 2.4's KBUILD, and top-level passes will not set
83
# these).
84
#
85
86
src ?= .
87
obj ?= .
88
89
#
90
# Determine location of the Linux kernel source tree. Allow users to override
91
# the default (i.e. automatically determined) kernel source location with the
92
# SYSSRC directive; this new directive replaces NVIDIA's SYSINCLUDE.
93
#
94
95
KERNEL_MODLIB := /lib/modules/$(shell uname -r)
96
97
ifdef SYSSRC
98
 KERNEL_SOURCES := $(SYSSRC)
99
 KERNEL_HEADERS := $(KERNEL_SOURCES)/include
100
else
101
 KERNEL_UNAME := $(shell uname -r)
102
 KERNEL_SOURCES := $(shell test -d $(KERNEL_MODLIB)/source && echo $(KERNEL_MODLIB)/source || echo $(KERNEL_MODLIB)/build)
103
 KERNEL_HEADERS := $(KERNEL_SOURCES)/include
104
endif
105
106
KERNEL_OUTPUT := $(KERNEL_SOURCES)
107
KBUILD_PARAMS :=
108
109
ifdef SYSOUT
110
 ifneq ($(SYSOUT), $(KERNEL_SOURCES))
111
 KERNEL_OUTPUT := $(SYSOUT)
112
 KBUILD_PARAMS := KBUILD_OUTPUT=$(KERNEL_OUTPUT)
113
 endif
114
else
115
 ifeq ($(KERNEL_SOURCES), $(KERNEL_MODLIB)/source)
116
 KERNEL_OUTPUT := $(KERNEL_MODLIB)/build
117
 KBUILD_PARAMS := KBUILD_OUTPUT=$(KERNEL_OUTPUT)
118
 endif
119
endif
120
121
CC ?= cc
122
HOST_CC ?= $(CC)
123
OBJDUMP ?= objdump
124
CONFTEST := /bin/sh $(src)/conftest.sh "$(CC)" "$(HOST_CC)" $(KERNEL_SOURCES) $(KERNEL_OUTPUT)
125
126
KERNEL_UNAME ?= $(shell $(CONFTEST) get_uname)
127
MODULE_ROOT := /lib/modules/$(KERNEL_UNAME)/kernel/drivers
128
129
#
130
# Sets any internal variables left unset by KBUILD (e.g. this happens during
131
# a top-level run).
132
#
133
134
TOPDIR ?= $(KERNEL_SOURCES)
135
PATCHLEVEL ?= $(shell $(CONFTEST) kernel_patch_level)
136
137
#
138
# Linux 2.4 uses the .o module extension. Linux 2.6, however, uses the .ko
139
# module extension. Handle these gracefully.
140
#
141
142
ifeq ($(PATCHLEVEL), 4)
143
 MODULE_OBJECT := $(MODULE_NAME).o
144
else
145
 MODULE_OBJECT := $(MODULE_NAME).ko
146
endif
147
148
#
149
# NVIDIA specific CFLAGS and #define's. The remap_page_range check has become
150
# necessary with the introduction of the five argument version to Linux 2.4
151
# distribution kernels; this conflicting change cannot be detected at compile
152
# time.
153
#
154
155
EXTRA_CFLAGS += -D_LOOSE_KERNEL_NAMES -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"96.43.23\" -UDEBUG -U_DEBUG -DNDEBUG
156
157
ifeq ($(shell echo $(NVDEBUG)),1)
158
 ifeq ($(shell test -z $(RMDEBUG) && echo yes),yes)
159
 RMDEBUG=1
160
 endif
161
endif
162
163
ifeq ($(shell echo $(RMDEBUG)),1)
164
 EXTRA_CFLAGS += -DDEBUG -g 
165
endif
166
167
ifneq ($(PATCHLEVEL), 4)
168
 COMPILE_TESTS = \
169
	remap_page_range \
170
	remap_pfn_range \
171
	vmap \
172
	agp_backend_acquire \
173
	set_pages_uc \
174
	change_page_attr \
175
	i2c_adapter \
176
	pci_get_class \
177
	pm_message_t \
178
	irq_handler_t \
179
	pci_choose_state \
180
	vm_insert_page \
181
	acquire_console_sem \
182
	kmem_cache_create \
183
	on_each_cpu \
184
	smp_call_function \
185
	ioremap_cache \
186
	ioremap_wc \
187
	proc_dir_entry \
188
	acpi_walk_namespace \
189
	agp_memory \
190
	scatterlist \
191
	file_operations \
192
	sg_init_table
193
else
194
 COMPILE_TESTS = \
195
	remap_page_range \
196
	vmap \
197
	change_page_attr \
198
	i2c_adapter \
199
	smp_call_function \
200
	proc_dir_entry \
201
	scatterlist
202
endif
203
204
#
205
# Miscellaneous NVIDIA kernel module build support targets. They are needed
206
# to satisfy KBUILD requirements and to support NVIDIA specifics.
207
#
208
209
$(obj)/$(CORE_OBJS):
210
	cp $(src)/$(CORE_OBJS) $(obj)/$(CORE_OBJS)
211
212
$(obj)/$(VERSION_HEADER):
213
	@ echo \#define NV_COMPILER \"`$(CC) -v 2>&1 | tail -n 1`\" > $@
214
215
$(obj)/conftest.h:
216
	@if ! $(CONFTEST) compile_tests $(COMPILE_TESTS); then exit 1; fi
217
218
$(obj)/patches.h:
219
	@if ! $(CONFTEST) patch_check; then exit 1; fi
220
221
RESMAN_GLUE_TARGETS = $(addprefix $(obj)/,$(RESMAN_GLUE_OBJS))
222
223
$(RESMAN_GLUE_TARGETS): $(obj)/conftest.h $(obj)/patches.h
224
225
$(obj)/nv.o: $(obj)/$(VERSION_HEADER)
226
227
#
228
# More quirks for Linux 2.4 KBUILD, which doesn't link automatically.
229
#
230
231
ifeq ($(PATCHLEVEL), 4)
232
$(obj)/$(MODULE_NAME).o: $($(MODULE_NAME)-objs)
233
	$(LD) $(EXTRA_LDFLAGS) -r -o $@ $($(MODULE_NAME)-objs)
234
endif
235
236
#
237
# KBUILD build parameters.
238
#
239
240
KBUILD_PARAMS += KBUILD_VERBOSE=1 -C $(KERNEL_SOURCES) M=$(PWD)
241
242
#
243
# NVIDIA sanity checks.
244
#
245
246
.PHONY: suser-sanity-check rmmod-sanity-check build-sanity-checks
247
248
suser-sanity-check:
249
	@if ! $(CONFTEST) suser_sanity_check; then exit 1; fi
250
251
rmmod-sanity-check:
252
	@if ! $(CONFTEST) rmmod_sanity_check; then exit 1; fi
253
254
build-sanity-checks:
255
	@if ! $(CONFTEST) cc_version_check 		full_output; then exit 1; fi
256
	@if ! $(CONFTEST) rivafb_sanity_check 	full_output; then exit 1; fi
257
	@if ! $(CONFTEST) nvidiafb_sanity_check full_output; then exit 1; fi
258
	@if ! $(CONFTEST) xen_sanity_check 		full_output; then exit 1; fi
259
260
#
261
# Build the NVIDIA kernel module using Linux KBUILD. This target is used by
262
# the "package-install" target below.
263
#
264
265
module: build-sanity-checks
266
	@if [ -z "$(PATCHLEVEL)" ]; then \
267
	 echo "failed to determine PATCHLEVEL!"; \
268
	 exit 1; \
269
	fi; \
270
	echo "NVIDIA: calling KBUILD..."; \
271
	echo "make CC=$(CC) $(KBUILD_PARAMS) modules"; \
272
	make "CC=$(CC)" $(KBUILD_PARAMS) modules; \
273
	echo "NVIDIA: left KBUILD."; \
274
	if ! [ -f $(MODULE_OBJECT) ]; then \
275
	 echo "$(MODULE_OBJECT) failed to build!"; \
276
	 exit 1; \
277
	fi
278
279
#
280
# Build the NVIDIA kernel module with KBUILD. Verify that the user posesses
281
# sufficient privileges. Rebuild the module dependency file.
282
#
283
284
module-install: suser-sanity-check module
285
	@mkdir -p $(MODULE_ROOT)/video; \
286
	install -m 0664 -o root -g root $(MODULE_OBJECT) $(MODULE_ROOT)/video; \
287
	PATH="$(PATH):/bin:/sbin" depmod -ae;
288
289
#
290
# This target builds, then installs, then creates device nodes and inserts
291
# the module, if successful.
292
#
293
294
package-install: module-install rmmod-sanity-check
295
	PATH="$(PATH):/bin:/sbin" modprobe $(MODULE_NAME) && \
296
	echo "$(MODULE_OBJECT) installed successfully.";
297
298
#
299
# Build an object file suitable for further processing by the installer and
300
# inclusion as a precompiled kernel interface file.
301
#
302
303
$(KERNEL_GLUE_NAME): module
304
	$(LD) $(EXTRA_LDFLAGS) -r -o $(KERNEL_GLUE_NAME) $(KERNEL_GLUE_OBJS)
305
306
#
307
# Support hack, KBUILD isn't prepared to clean up after external modules.
308
#
309
310
clean:
311
	@ $(RM) -f $(RESMAN_GLUE_OBJS) $(KERNEL_GLUE_OBJS)
312
	@ $(RM) -f build-in.o nv-linux.o *.d .*.{cmd,flags}
313
	@ $(RM) -f $(MODULE_NAME).{o,ko,mod.{o,c}} $(VERSION_HEADER) *~
314
	@ $(RM) -f patches.h
315
	@ $(RM) -f conftest*.c conftest.h
316
	@ $(RM) -rf Modules.symvers .tmp_versions
317
318
#
319
# This target just prints the kernel module filename (for use by the
320
# installer)
321
#
322
323
print-module-filename:
324
	@ echo $(MODULE_OBJECT)
325
326
#
327
# Linux 2.4 KBUILD requires the inclusion of Rules.make; Linux 2.6's KBUILD
328
# includes dependencies automatically.
329
#
330
331
ifeq ($(PATCHLEVEL), 4)
332
include $(KERNEL_SOURCES)/Rules.make
333
endif
(-)usr-patched1.orig/src/nv/Makefile.nvidia (-1 / +4 lines)
Lines 62-68 Link Here
62
	smp_call_function \
62
	smp_call_function \
63
	proc_dir_entry \
63
	proc_dir_entry \
64
	scatterlist \
64
	scatterlist \
65
	file_operations
65
	file_operations \
66
	proc_create_data \
67
	pde_data \
68
	proc_remove
66
69
67
DEFINES+=$(EXTRA_DEFINES)
70
DEFINES+=$(EXTRA_DEFINES)
68
71
(-)usr-patched1.orig/src/nv/Makefile.nvidia.orig (+133 lines)
Line 0 Link Here
1
# This Makefile is automatically generated; do not edit
2
# Generated on 'swio-display-x86-rh72-02.nvidia.com' on Fri Aug 31 14:52:31 PDT 2012
3
4
MODULE_NAME := nvidia
5
6
LINUX_MODULE=nv-linux.o
7
DEFINES=-D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -DNVRM -DNV_VERSION_STRING=\"96.43.23\"
8
INCLUDES=-I.
9
10
OBJECTS=nv.o nv-vm.o os-agp.o os-interface.o os-registry.o nv-i2c.o 
11
HEADERS=os-agp.h os-interface.h nv-linux.h nv-misc.h nv-memdbg.h nv-vm.h nv.h rmretval.h cpuopsys.h nvtypes.h nvreadme.h $(VERSION_HDR) conftest.h patches.h
12
13
CFLAGS=-Wall -Wimplicit -Wreturn-type -Wswitch -Wformat -Wchar-subscripts -Wparentheses -Wpointer-arith -Wno-multichar -Werror -O -UDEBUG -U_DEBUG -DNDEBUG -MD $(DEFINES) $(INCLUDES) -Wsign-compare -Wno-cast-qual -Wno-error
14
15
CORE_OBJECTS=nv-kernel.o
16
17
#
18
# Determine location of the Linux kernel source tree. Allow users to override
19
# the default (i.e. automatically determined) kernel source location with the
20
# SYSSRC directive; this new directive replaces NVIDIA's SYSINCLUDE.
21
#
22
23
ifdef SYSSRC
24
 KERNEL_SOURCES := $(SYSSRC)
25
 KERNEL_HEADERS := $(KERNEL_SOURCES)/include
26
else
27
 ifdef SYSINCLUDE
28
 KERNEL_HEADERS := $(SYSINCLUDE)
29
 KERNEL_SOURCES := $(KERNEL_HEADERS)/..
30
 else
31
 KERNEL_UNAME := $(shell uname -r)
32
 KERNEL_SOURCES := /lib/modules/$(KERNEL_UNAME)/build
33
 KERNEL_HEADERS := $(KERNEL_SOURCES)/include
34
 endif
35
endif
36
37
CC ?= cc
38
HOST_CC ?= $(CC)
39
OBJDUMP ?= objdump
40
CONFTEST := /bin/sh ./conftest.sh "$(CC)" "$(HOST_CC)" $(KERNEL_SOURCES) $(KERNEL_SOURCES)
41
42
KERNEL_UNAME ?= $(shell $(CONFTEST) get_uname)
43
MODULE_ROOT := /lib/modules/$(KERNEL_UNAME)/kernel/drivers
44
45
ifeq ($(shell echo $(NVDEBUG)),1)
46
 ifeq ($(shell test -z $(RMDEBUG) && echo yes),yes)
47
 RMDEBUG=1
48
 endif
49
endif
50
51
ifeq ($(shell echo $(RMDEBUG)),1)
52
CFLAGS += -DDEBUG -g 
53
endif
54
55
INCLUDES += -I$(KERNEL_HEADERS)
56
57
COMPILE_TESTS = \
58
	remap_page_range \
59
	vmap \
60
	change_page_attr \
61
	i2c_adapter \
62
	smp_call_function \
63
	proc_dir_entry \
64
	scatterlist \
65
	file_operations
66
67
DEFINES+=$(EXTRA_DEFINES)
68
69
# allow build parameters to be passed in through the environment
70
ifdef BUILD_PARAMS
71
 DEFINES+=-D$(BUILD_PARAMS)
72
endif
73
74
VERSION_HDR=nv_compiler.h
75
76
all: install
77
78
install: package-install
79
80
.PHONY: suser-sanity-check rmmod-sanity-check build-sanity-checks
81
82
suser-sanity-check:
83
	@if ! $(CONFTEST) suser_sanity_check; then exit; fi
84
85
rmmod-sanity-check:
86
	@if ! $(CONFTEST) rmmod_sanity_check; then exit; fi
87
88
build-sanity-checks:
89
	@if ! $(CONFTEST) cc_version_check 	 full_output; then exit; fi
90
	@if ! $(CONFTEST) rivafb_sanity_check full_output; then exit; fi
91
92
module: build-sanity-checks $(LINUX_MODULE) $(CORE_OBJECTS)
93
	$(LD) -r -o $(MODULE_NAME).o $(LINUX_MODULE) $(CORE_OBJECTS)
94
95
package-install: module suser-sanity-check rmmod-sanity-check
96
	mkdir -p $(MODULE_ROOT)/video && \
97
	install -m 0664 -o root -g root $(MODULE_NAME).o \
98
	 $(MODULE_ROOT)/video/$(MODULE_NAME).o && \
99
	PATH="$(PATH):/bin:/sbin" depmod -a && \
100
		PATH="$(PATH):/bin:/sbin" modprobe $(MODULE_NAME) && \
101
	echo "$(MODULE_NAME).o installed successfully."; \
102
103
$(VERSION_HDR): 
104
	@ echo \#define NV_COMPILER \"`$(CC) -v 2>&1 | tail -n 1`\" > $@
105
106
$(LINUX_MODULE): $(OBJECTS)
107
	$(LD) -r -o $@ $(OBJECTS)
108
109
conftest.h:
110
	@if ! $(CONFTEST) compile_tests $(COMPILE_TESTS); then exit; fi
111
112
patches.h:
113
	@if ! $(CONFTEST) patch_check; then exit; fi
114
115
%.o: %.c $(HEADERS)
116
	$(CC) -c $(CFLAGS) $<
117
118
# debug tool to preprocess the file and leave .i to make it easier to untangle #defines
119
%.i: %.c
120
	$(CC) $(CFLAGS) -E $< > $@
121
122
%.s: %.c
123
	$(CC) $(CFLAGS) -S $< > $@
124
125
clean:
126
	@ $(RM) $(OBJECTS) $(LINUX_MODULE) $(VERSION_HDR) *.d NVdriver $(MODULE_NAME).o
127
	@ $(RM) patches.h
128
	@ $(RM) conftest*.c conftest.h
129
130
print-module-filename:
131
	@echo "$(MODULE_NAME).o"
132
133
-include $(OBJECTS:%.o=%.d)
(-)usr-patched1.orig/src/nv/conftest.sh (+93 lines)
Lines 1208-1213 Link Here
1208
            fi
1208
            fi
1209
        ;;
1209
        ;;
1210
1210
1211
        proc_create_data)
1212
            #
1213
            # Determine if the proc_create_data() function is present.
1214
            #
1215
            echo "$CONFTEST_PREAMBLE
1216
            #include <linux/proc_fs.h>
1217
            void conftest_proc_create_data(void) {
1218
                proc_create_data();
1219
            }" > conftest$$.c
1220
1221
            $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
1222
            rm -f conftest$$.c
1223
1224
            if [ -f conftest$$.o ]; then
1225
                rm -f conftest$$.o
1226
                echo "#undef NV_PROC_CREATE_DATA_PRESENT" >> conftest.h
1227
                return
1228
            else
1229
                echo "#define NV_PROC_CREATE_DATA_PRESENT" >> conftest.h
1230
                return
1231
            fi
1232
        ;;
1233
1234
1235
        pde_data)
1236
            #
1237
            # Determine if the PDE_DATA() function is present.
1238
            #
1239
            echo "$CONFTEST_PREAMBLE
1240
            #include <linux/proc_fs.h>
1241
            void conftest_PDE_DATA(void) {
1242
                PDE_DATA();
1243
            }" > conftest$$.c
1244
1245
            $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
1246
            rm -f conftest$$.c
1247
1248
            if [ -f conftest$$.o ]; then
1249
                rm -f conftest$$.o
1250
                echo "#undef NV_PDE_DATA_PRESENT" >> conftest.h
1251
                return
1252
            else
1253
                echo "#define NV_PDE_DATA_PRESENT" >> conftest.h
1254
                return
1255
            fi
1256
        ;;
1257
1258
        proc_remove)
1259
            #
1260
            # Determine if the proc_remove() function is present.
1261
            #
1262
            echo "$CONFTEST_PREAMBLE
1263
            #include <linux/proc_fs.h>
1264
            void conftest_proc_remove(void) {
1265
                proc_remove();
1266
            }" > conftest$$.c
1267
1268
            $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
1269
            rm -f conftest$$.c
1270
1271
            if [ -f conftest$$.o ]; then
1272
                rm -f conftest$$.o
1273
                echo "#undef NV_PROC_REMOVE_PRESENT" >> conftest.h
1274
                return
1275
            else
1276
                echo "#define NV_PROC_REMOVE_PRESENT" >> conftest.h
1277
                return
1278
            fi
1279
        ;;
1280
1281
        get_num_physpages)
1282
            #
1283
            # Determine if the get_num_physpages() function is present.
1284
            #
1285
            echo "$CONFTEST_PREAMBLE
1286
            #include <linux/mm.h>
1287
            void conftest_get_num_physpages(void) {
1288
                get_num_physpages(NULL);
1289
            }" > conftest$$.c
1290
1291
            $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
1292
            rm -f conftest$$.c
1293
1294
            if [ -f conftest$$.o ]; then
1295
                rm -f conftest$$.o
1296
                echo "#undef NV_GET_NUM_PHYSPAGES_PRESENT" >> conftest.h
1297
                return
1298
            else
1299
                echo "#define NV_GET_NUM_PHYSPAGES_PRESENT" >> conftest.h
1300
                return
1301
            fi
1302
        ;;
1303
1211
    esac
1304
    esac
1212
}
1305
}
1213
1306
(-)usr-patched1.orig/src/nv/conftest.sh.orig (-3 / +10 lines)
Lines 128-133 Link Here
128
        if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]; then
128
        if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]; then
129
            MACH_CFLAGS="$MACH_CFLAGS -I$HEADERS/asm-x86/mach-default"
129
            MACH_CFLAGS="$MACH_CFLAGS -I$HEADERS/asm-x86/mach-default"
130
            MACH_CFLAGS="$MACH_CFLAGS -I$SOURCES/arch/x86/include/asm/mach-default"
130
            MACH_CFLAGS="$MACH_CFLAGS -I$SOURCES/arch/x86/include/asm/mach-default"
131
            MACH_CFLAGS="$MACH_CFLAGS -I$HEADERS/arch/x86/include/uapi"
131
        fi
132
        fi
132
        if [ "$XEN_PRESENT" != "0" ]; then
133
        if [ "$XEN_PRESENT" != "0" ]; then
133
            MACH_CFLAGS="-I$HEADERS/asm-$ARCH/mach-xen $MACH_CFLAGS"
134
            MACH_CFLAGS="-I$HEADERS/asm-$ARCH/mach-xen $MACH_CFLAGS"
Lines 137-152 Link Here
137
        if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]; then
138
        if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]; then
138
            MACH_CFLAGS="$MACH_CFLAGS -I$HEADERS/asm-x86/mach-default"
139
            MACH_CFLAGS="$MACH_CFLAGS -I$HEADERS/asm-x86/mach-default"
139
            MACH_CFLAGS="$MACH_CFLAGS -I$SOURCES/arch/x86/include/asm/mach-default"
140
            MACH_CFLAGS="$MACH_CFLAGS -I$SOURCES/arch/x86/include/asm/mach-default"
141
            MACH_CFLAGS="$MACH_CFLAGS -I$HEADERS/arch/x86/include/uapi"
140
        fi
142
        fi
141
        if [ "$XEN_PRESENT" != "0" ]; then
143
        if [ "$XEN_PRESENT" != "0" ]; then
142
            MACH_CFLAGS="-I$HEADERS/asm/mach-xen $MACH_CFLAGS"
144
            MACH_CFLAGS="-I$HEADERS/asm/mach-xen $MACH_CFLAGS"
143
        fi
145
        fi
144
    fi
146
    fi
145
147
146
    CFLAGS="$BASE_CFLAGS $MACH_CFLAGS $OUTPUT_CFLAGS -I$HEADERS $AUTOCONF_CFLAGS"
148
    CFLAGS="$BASE_CFLAGS $MACH_CFLAGS $OUTPUT_CFLAGS $AUTOCONF_CFLAGS"
149
    CFLAGS="$CFLAGS -I$HEADERS -I$HEADERS/uapi -I$OUTPUT/include/generated/uapi"
147
150
148
    if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]; then
151
    if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]; then
149
        CFLAGS="$CFLAGS -I$SOURCES/arch/x86/include -I$OUTPUT/arch/x86/include/generated"
152
        CFLAGS="$CFLAGS -I$SOURCES/arch/x86/include"
153
        CFLAGS="$CFLAGS -I$SOURCES/arch/x86/include/uapi"
154
        CFLAGS="$CFLAGS -I$OUTPUT/arch/x86/include/generated"
155
        CFLAGS="$CFLAGS -I$OUTPUT/arch/x86/include/generated/uapi"
150
    fi
156
    fi
151
    if [ -n "$BUILD_PARAMS" ]; then
157
    if [ -n "$BUILD_PARAMS" ]; then
152
        CFLAGS="$CFLAGS -D$BUILD_PARAMS"
158
        CFLAGS="$CFLAGS -D$BUILD_PARAMS"
Lines 1407-1413 Link Here
1407
        FILE="linux/version.h"
1413
        FILE="linux/version.h"
1408
        SELECTED_MAKEFILE=""
1414
        SELECTED_MAKEFILE=""
1409
1415
1410
        if [ -f $HEADERS/$FILE -o -f $OUTPUT/include/$FILE ]; then
1416
        if [ -f $HEADERS/$FILE -o -f $OUTPUT/include/$FILE -o \
1417
             -f $OUTPUT/include/generated/uapi/$FILE ]; then
1411
            #
1418
            #
1412
            # We are either looking at a configured kernel source
1419
            # We are either looking at a configured kernel source
1413
            # tree or at headers shipped for a specific kernel.
1420
            # tree or at headers shipped for a specific kernel.
(-)usr-patched1.orig/src/nv/nv-i2c.c (-11 / +4 lines)
Lines 285-292 Link Here
285
BOOL NV_API_CALL nv_i2c_del_adapter(nv_state_t *nv, void *data)
285
BOOL NV_API_CALL nv_i2c_del_adapter(nv_state_t *nv, void *data)
286
{
286
{
287
    struct i2c_adapter *pI2cAdapter = (struct i2c_adapter *)data;
287
    struct i2c_adapter *pI2cAdapter = (struct i2c_adapter *)data;
288
    int osstatus = 0;
289
    BOOL wasReleased = FALSE;
290
288
291
#if defined(KERNEL_2_4)
289
#if defined(KERNEL_2_4)
292
    if (!NV_WEAK_SYMBOL_PRESENT(i2c_add_adapter))
290
    if (!NV_WEAK_SYMBOL_PRESENT(i2c_add_adapter))
Lines 297-312 Link Here
297
295
298
    if (!pI2cAdapter) return FALSE;
296
    if (!pI2cAdapter) return FALSE;
299
297
300
    // attempt release with the OS
298
    // release with the OS
301
    osstatus = i2c_del_adapter(pI2cAdapter);
299
    i2c_del_adapter(pI2cAdapter);
300
    os_free_mem(pI2cAdapter);
302
301
303
    if (!osstatus)
302
    return TRUE;
304
    {
305
        os_free_mem(pI2cAdapter);
306
        wasReleased = TRUE;
307
    }
308
309
    return wasReleased;
310
}
303
}
311
304
312
#else // (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
305
#else // (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
(-)usr-patched1.orig/src/nv/nv-linux.h (+1 lines)
Lines 140-145 Link Here
140
140
141
#ifdef CONFIG_PROC_FS
141
#ifdef CONFIG_PROC_FS
142
#include <linux/proc_fs.h>
142
#include <linux/proc_fs.h>
143
#include <linux/seq_file.h>
143
#endif
144
#endif
144
145
145
#ifdef CONFIG_MTRR
146
#ifdef CONFIG_MTRR
(-)usr-patched1.orig/src/nv/nv-linux.h.orig (+1286 lines)
Line 0 Link Here
1
/* _NVRM_COPYRIGHT_BEGIN_
2
 *
3
 * Copyright 2001 by NVIDIA Corporation.  All rights reserved.  All
4
 * information contained herein is proprietary and confidential to NVIDIA
5
 * Corporation.  Any use, reproduction, or disclosure without the written
6
 * permission of NVIDIA Corporation is prohibited.
7
 *
8
 * _NVRM_COPYRIGHT_END_
9
 */
10
11
12
#ifndef _NV_LINUX_H_
13
#define _NV_LINUX_H_
14
15
#include "nv.h"
16
#include "conftest.h"
17
18
#if defined(NV_GENERATED_AUTOCONF_H_PRESENT)
19
#include <generated/autoconf.h>
20
#else
21
#include <linux/autoconf.h>
22
#endif
23
24
#include <linux/version.h>
25
#include <linux/utsname.h>
26
27
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 7)
28
#  error This driver does not support 2.4 kernels older than 2.4.7!
29
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
30
#  define KERNEL_2_4
31
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
32
#  error This driver does not support 2.5 kernels!
33
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 7, 0)
34
#  define KERNEL_2_6
35
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
36
#  define KERNEL_3
37
#else
38
#  error This driver does not support development kernels!
39
#endif
40
41
#if defined(KERNEL_2_4)
42
#define NV_KMEM_CACHE_CREATE_PRESENT
43
#define NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT 6
44
#define NV_IRQ_HANDLER_T_TAKES_PTREGS
45
#endif
46
47
#if defined (CONFIG_SMP) && !defined (__SMP__)
48
#define __SMP__
49
#endif
50
51
#if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS)
52
#  define MODVERSIONS
53
#endif
54
55
#if defined(MODVERSIONS) && defined(KERNEL_2_4)
56
#include <linux/modversions.h>
57
#endif
58
59
#if defined(KERNEL_2_4) && !defined(EXPORT_SYMTAB)
60
#define EXPORT_SYMTAB
61
#endif
62
63
#include <linux/kernel.h>
64
#include <linux/module.h>
65
#include <linux/kmod.h>
66
67
#include <linux/mm.h>
68
69
#if !defined(VM_RESERVED)
70
#define VM_RESERVED    0x00000000
71
#endif
72
#if !defined(VM_DONTEXPAND)
73
#define VM_DONTEXPAND  0x00000000
74
#endif
75
#if !defined(VM_DONTDUMP)
76
#define VM_DONTDUMP    0x00000000
77
#endif
78
79
#include <linux/init.h>             /* module_init, module_exit         */
80
#include <linux/types.h>            /* pic_t, size_t, __u32, etc        */
81
#include <linux/errno.h>            /* error codes                      */
82
#include <linux/list.h>             /* circular linked list             */
83
#include <linux/stddef.h>           /* NULL, offsetof                   */
84
#include <linux/wait.h>             /* wait queues                      */
85
#include <linux/string.h>           /* strchr(), strpbrk()              */
86
#include <linux/ctype.h>            /* isspace(), etc                   */
87
88
#include <linux/slab.h>             /* kmalloc, kfree, etc              */
89
#include <linux/vmalloc.h>          /* vmalloc, vfree, etc              */
90
91
#include <linux/poll.h>             /* poll_wait                        */
92
#include <linux/delay.h>            /* mdelay, udelay                   */
93
94
#if !defined(KERNEL_2_4)
95
#include <linux/sched.h>            /* suser(), capable() replacement   */
96
#include <linux/moduleparam.h>      /* module_param()                   */
97
#include <asm/tlbflush.h>           /* flush_tlb(), flush_tlb_all()     */
98
#include <asm/kmap_types.h>         /* page table entry lookup          */
99
#endif
100
101
#include <linux/pci.h>              /* pci_find_class, etc              */
102
#include <linux/interrupt.h>        /* tasklets, interrupt helpers      */
103
#include <linux/timer.h>
104
105
#include <asm/div64.h>              /* do_div()                         */
106
#if defined(NV_ASM_SYSTEM_H_PRESENT)
107
#include <asm/system.h>             /* cli, sli, save_flags             */
108
#endif
109
#include <asm/io.h>                 /* ioremap, virt_to_phys            */
110
#include <asm/uaccess.h>            /* access_ok                        */
111
#include <asm/page.h>               /* PAGE_OFFSET                      */
112
#include <asm/pgtable.h>            /* pte bit definitions              */
113
114
#if defined(NVCPU_X86_64) && !defined(KERNEL_2_4) && !defined(HAVE_COMPAT_IOCTL)
115
#include <linux/syscalls.h>         /* sys_ioctl()                      */
116
#include <linux/ioctl32.h>          /* register_ioctl32_conversion()    */
117
#endif
118
119
#if defined(NVCPU_X86_64) && defined(KERNEL_2_4)
120
#include <asm/ioctl32.h>            /* sys_ioctl() (ioctl32)            */
121
#endif
122
123
#if !defined(NV_FILE_OPERATIONS_HAS_IOCTL) && \
124
  !defined(NV_FILE_OPERATIONS_HAS_UNLOCKED_IOCTL)
125
#error "struct file_operations compile test likely failed!"
126
#endif
127
128
#if defined(CONFIG_VGA_ARB)
129
#include <linux/vgaarb.h>
130
#endif
131
132
#include <linux/spinlock.h>
133
#if defined(NV_LINUX_SEMAPHORE_H_PRESENT)
134
#include <linux/semaphore.h>
135
#else
136
#include <asm/semaphore.h>
137
#endif
138
#include <linux/completion.h>
139
#include <linux/highmem.h>
140
141
#ifdef CONFIG_PROC_FS
142
#include <linux/proc_fs.h>
143
#endif
144
145
#ifdef CONFIG_MTRR
146
#include <asm/mtrr.h>
147
#endif
148
149
#ifdef CONFIG_KDB
150
#include <linux/kdb.h>
151
#include <asm/kdb.h>
152
#endif
153
154
#if defined(CONFIG_X86_REMOTE_DEBUG)
155
#include <linux/gdb.h>
156
#endif
157
158
#if defined (CONFIG_AGP) || defined (CONFIG_AGP_MODULE)
159
#define AGPGART
160
#include <linux/agp_backend.h>
161
#include <linux/agpgart.h>
162
#endif
163
164
#if defined(NVCPU_X86) || defined(NVCPU_X86_64)
165
#define NV_ENABLE_PAT_SUPPORT
166
#endif
167
168
#define NV_PAT_MODE_DISABLED    0
169
#define NV_PAT_MODE_KERNEL      1
170
#define NV_PAT_MODE_BUILTIN     2
171
172
extern int nv_pat_mode;
173
174
#if defined(CONFIG_HOTPLUG_CPU)
175
#include <linux/cpu.h>              /* CPU hotplug support              */
176
#include <linux/notifier.h>         /* struct notifier_block, etc       */
177
#endif
178
179
#if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
180
#include <linux/i2c.h>
181
#endif
182
183
#if defined(KERNEL_2_4) || \
184
    (NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT == 6)
185
#define NV_ACPI_WALK_NAMESPACE(type, args...) acpi_walk_namespace(type, args)
186
#elif (NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT == 7)
187
#define NV_ACPI_WALK_NAMESPACE(type, start_object, max_depth, \
188
        user_function, args...) \
189
    acpi_walk_namespace(type, start_object, max_depth, \
190
            user_function, NULL, args)
191
#else
192
#error "NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT value unrecognized!"
193
#endif
194
195
#if defined(CONFIG_PREEMPT_RT)
196
typedef atomic_spinlock_t         nv_spinlock_t;
197
#define NV_SPIN_LOCK_INIT(lock)   atomic_spin_lock_init(lock)
198
#define NV_SPIN_LOCK_IRQ(lock)    atomic_spin_lock_irq(lock)
199
#define NV_SPIN_UNLOCK_IRQ(lock)  atomic_spin_unlock_irq(lock)
200
#define NV_SPIN_LOCK_IRQSAVE(lock,flags) atomic_spin_lock_irqsave(lock,flags)
201
#define NV_SPIN_UNLOCK_IRQRESTORE(lock,flags) \
202
  atomic_spin_unlock_irqrestore(lock,flags)
203
#define NV_SPIN_LOCK(lock)        atomic_spin_lock(lock)
204
#define NV_SPIN_UNLOCK(lock)      atomic_spin_unlock(lock)
205
#define NV_SPIN_UNLOCK_WAIT(lock) atomic_spin_unlock_wait(lock)
206
#else
207
typedef spinlock_t                nv_spinlock_t;
208
#define NV_SPIN_LOCK_INIT(lock)   spin_lock_init(lock)
209
#define NV_SPIN_LOCK_IRQ(lock)    spin_lock_irq(lock)
210
#define NV_SPIN_UNLOCK_IRQ(lock)  spin_unlock_irq(lock)
211
#define NV_SPIN_LOCK_IRQSAVE(lock,flags) spin_lock_irqsave(lock,flags)
212
#define NV_SPIN_UNLOCK_IRQRESTORE(lock,flags) spin_unlock_irqrestore(lock,flags)
213
#define NV_SPIN_LOCK(lock)        spin_lock(lock)
214
#define NV_SPIN_UNLOCK(lock)      spin_unlock(lock)
215
#define NV_SPIN_UNLOCK_WAIT(lock) spin_unlock_wait(lock)
216
#endif
217
218
#if defined(NVCPU_X86)
219
#ifndef write_cr4
220
#define write_cr4(x) __asm__ ("movl %0,%%cr4" :: "r" (x));
221
#endif
222
223
#ifndef read_cr4
224
#define read_cr4()                                  \
225
 ({                                                 \
226
      unsigned int __cr4;                           \
227
      __asm__ ("movl %%cr4,%0" : "=r" (__cr4));     \
228
      __cr4;                                        \
229
  })
230
#endif
231
232
#ifndef wbinvd
233
#define wbinvd() __asm__ __volatile__("wbinvd" ::: "memory");
234
#endif
235
#endif /* defined(NVCPU_X86) */
236
237
#ifndef get_cpu
238
#define get_cpu() smp_processor_id()
239
#define put_cpu()
240
#endif
241
242
#if !defined(unregister_hotcpu_notifier)
243
#define unregister_hotcpu_notifier unregister_cpu_notifier
244
#endif
245
#if !defined(register_hotcpu_notifier)
246
#define register_hotcpu_notifier register_cpu_notifier
247
#endif
248
249
#if !defined (list_for_each)
250
#define list_for_each(pos, head) \
251
        for (pos = (head)->next; pos != (head); pos = (pos)->next)
252
#endif
253
254
#if !defined(pmd_large)
255
#define pmd_large(_pmd) \
256
    ((pmd_val(_pmd) & (_PAGE_PSE|_PAGE_PRESENT)) == (_PAGE_PSE|_PAGE_PRESENT))
257
#endif
258
259
#if !defined(page_count) && defined(KERNEL_2_4)
260
#define page_count(page) (atomic_read(&(page)->count))
261
#endif
262
263
#define NV_GET_PAGE_COUNT(page_ptr) \
264
    (unsigned int)page_count(NV_GET_PAGE_STRUCT(page_ptr->phys_addr))
265
266
#if !defined(__GFP_COMP)
267
#define __GFP_COMP 0
268
#endif
269
270
#if !defined(DEBUG) && defined(__GFP_NOWARN)
271
#define NV_GFP_KERNEL (GFP_KERNEL | __GFP_NOWARN)
272
#define NV_GFP_ATOMIC (GFP_ATOMIC | __GFP_NOWARN)
273
#else
274
#define NV_GFP_KERNEL (GFP_KERNEL)
275
#define NV_GFP_ATOMIC (GFP_ATOMIC)
276
#endif
277
278
#if defined(GFP_DMA32)
279
/*
280
 * GFP_DMA32 is similar to GFP_DMA, but instructs the Linux zone
281
 * allocator to allocate memory from the first 4GB on platforms
282
 * such as Linux/x86-64; the alternative is to use an IOMMU such
283
 * as the one implemented with the K8 GART, if available.
284
 */
285
#define NV_GFP_DMA32 (NV_GFP_KERNEL | GFP_DMA32)
286
#else
287
#define NV_GFP_DMA32 (NV_GFP_KERNEL)
288
#endif
289
290
#define CACHE_FLUSH()  asm volatile("wbinvd":::"memory")
291
#define WRITE_COMBINE_FLUSH() asm volatile("sfence":::"memory")
292
293
#if !defined(IRQF_SHARED)
294
#define IRQF_SHARED SA_SHIRQ
295
#endif
296
297
#define NV_MAX_RECURRING_WARNING_MESSAGES 10
298
299
/* add support for iommu.
300
 * On the x86-64 platform, the driver may need to remap system
301
 * memory pages via AMD K8/Intel VT-d IOMMUs if a given
302
 * GPUs addressing capabilities are limited such that it can
303
 * not access the original page directly. Examples of this
304
 * are legacy PCI-E devices.
305
 */
306
#if (defined(NVCPU_X86_64) && !defined(GFP_DMA32)) || defined(CONFIG_DMAR)
307
#define NV_SG_MAP_BUFFERS 1
308
extern int nv_swiotlb;
309
310
#if defined(CONFIG_DMAR)
311
#define NV_INTEL_IOMMU 1
312
#else
313
/*
314
 * Limit use of IOMMU/SWIOTLB space to 60 MB, leaving 4 MB for the rest of 
315
 * the system (assuming a 64 MB IOMMU/SWIOTLB).
316
 * This is not required if Intel VT-d IOMMU is used to remap pages. 
317
 */
318
#define NV_NEED_REMAP_CHECK 1
319
#define NV_REMAP_LIMIT_DEFAULT  (60 * 1024 * 1024)
320
#endif
321
#endif
322
323
/* add support for software i/o tlb support.
324
 * normally, you'd expect this to be transparent, but unfortunately this is not
325
 * the case. for starters, the sw io tlb is a pool of pre-allocated pages that
326
 * are < 32-bits. when we ask to remap a page through this sw io tlb, we are
327
 * returned one of these pages, which means we have 2 different pages, rather
328
 * than 2 mappings to the same page. secondly, this pre-allocated pool is very
329
 * tiny, and the kernel panics when it is exhausted. try to warn the user that
330
 * they need to boost the size of their pool.
331
 */
332
#if defined(CONFIG_SWIOTLB) && !defined(GFP_DMA32)
333
#define NV_SWIOTLB 1
334
#endif
335
336
/*
337
 * early 2.6 kernels changed their swiotlb codepath, running into a
338
 * latent bug that returns virtual addresses when it should return
339
 * physical addresses. we try to gracefully account for that, by 
340
 * comparing the returned address to what should be it's virtual
341
 * equivalent. this should hopefully account for when the bug is 
342
 * fixed in the core kernel.
343
 */
344
#if defined(NV_SWIOTLB) && !defined(KERNEL_2_4)
345
#define NV_FIXUP_SWIOTLB_VIRT_ADDR_BUG(dma_addr) \
346
    if ((dma_addr) == ((dma_addr) | PAGE_OFFSET)) \
347
        (dma_addr) = __pa((dma_addr))
348
#else
349
#define NV_FIXUP_SWIOTLB_VIRT_ADDR_BUG(dma_addr)
350
#endif
351
352
#if !defined(KERNEL_2_4) && defined(NV_SG_INIT_TABLE_PRESENT)
353
#define NV_SG_INIT_TABLE(sgl, nents) \
354
    sg_init_table(sgl, nents)
355
#else
356
#define NV_SG_INIT_TABLE(sgl, nents) \
357
    memset(sgl, 0, (sizeof(*(sgl)) * (nents)));
358
#endif
359
360
#ifndef NVWATCH
361
362
/* various memory tracking/debugging techniques
363
 * disabled for retail builds, enabled for debug builds
364
 */
365
366
// allow an easy way to convert all debug printfs related to memory
367
// management back and forth between 'info' and 'errors'
368
#if defined(NV_DBG_MEM)
369
#define NV_DBG_MEMINFO NV_DBG_ERRORS
370
#else
371
#define NV_DBG_MEMINFO NV_DBG_INFO
372
#endif
373
374
#ifdef DEBUG
375
#define NV_ENABLE_MEM_TRACKING 1
376
#endif
377
378
#if defined(NV_ENABLE_MEM_TRACKING)
379
#define NV_MEM_TRACKING_PAD_SIZE(size)   ((size) += sizeof(void *))
380
#define NV_MEM_TRACKING_HIDE_SIZE(ptr, size)            \
381
    if ((ptr) && *(ptr)) {                              \
382
        U008 *__ptr;                                    \
383
        *(unsigned long *) *(ptr) = (size);             \
384
        __ptr = *(ptr); __ptr += sizeof(void *);        \
385
        *(ptr) = (void *) __ptr;                        \
386
    }
387
#define NV_MEM_TRACKING_RETRIEVE_SIZE(ptr, size)        \
388
    {                                                   \
389
        U008 *__ptr = (ptr); __ptr -= sizeof(void *);   \
390
        (ptr) = (void *) __ptr;                         \
391
        size = *(unsigned long *) (ptr);                \
392
    }
393
#else
394
#define NV_MEM_TRACKING_PAD_SIZE(size)
395
#define NV_MEM_TRACKING_HIDE_SIZE(ptr, size)
396
#define NV_MEM_TRACKING_RETRIEVE_SIZE(ptr, size)  ((size) = 0)
397
#endif
398
399
400
/* poor man's memory allocation tracker.
401
 * main intention is just to see how much memory is being used to recognize
402
 * when memory usage gets out of control or if memory leaks are happening
403
 */
404
405
/* keep track of memory usage */
406
#if defined(NV_ENABLE_MEM_TRACKING)
407
408
/* print out a running tally of memory allocation amounts, disabled by default */
409
// #define POOR_MANS_MEM_CHECK 1
410
411
412
/* slightly more advanced memory allocation tracker.
413
 * track who's allocating memory and print out a list of currently allocated
414
 * memory at key points in the driver
415
 */
416
417
#define MEMDBG_ALLOC(a,b) (a = kmalloc(b, NV_GFP_ATOMIC))
418
#define MEMDBG_FREE(a)    (kfree(a))
419
420
#include "nv-memdbg.h"
421
422
#undef MEMDBG_ALLOC
423
#undef MEMDBG_FREE
424
425
/* print out list of memory allocations */
426
/* default to enabled for now */
427
#define LIST_MEM_CHECK 1
428
429
/* decide which memory types to apply mem trackers to */
430
#define VM_CHECKER 1
431
#define KM_CHECKER 1
432
433
#endif  /* NV_ENABLE_MEM_TRACKING */
434
435
#if defined(VM_CHECKER)
436
/* kernel virtual memory usage/allocation information */
437
extern U032 vm_usage;
438
extern struct mem_track_t *vm_list;
439
extern nv_spinlock_t vm_lock;
440
441
#  if defined(POOR_MANS_MEM_CHECK)
442
#    define VM_PRINT(str, args...)   printk(str, ##args)
443
#  else
444
#    define VM_PRINT(str, args...)
445
#  endif
446
#  if defined(LIST_MEM_CHECK)
447
#    define VM_ADD_MEM(a,b,c,d)      nv_add_mem(&vm_list, a, b, c, d)
448
#    define VM_FREE_MEM(a,b,c,d)     nv_free_mem(&vm_list, a, b, c, d)
449
#  else
450
#    define VM_ADD_MEM(a,b,c,d)
451
#    define VM_FREE_MEM(a,b,c,d)
452
#  endif
453
#  define VM_ALLOC_RECORD(ptr, size, name)                                   \
454
        if (ptr != NULL)                                                     \
455
        {                                                                    \
456
            NV_SPIN_LOCK(&vm_lock);                                          \
457
            vm_usage += size;                                                \
458
            VM_PRINT("NVRM: %s (0x%p: 0x%x): VM usage is now 0x%x bytes\n",  \
459
                name, (void *)ptr, size, vm_usage);                          \
460
            VM_ADD_MEM(ptr, size, __FILE__, __LINE__);                       \
461
            NV_SPIN_UNLOCK(&vm_lock);                                        \
462
        }
463
#  define VM_FREE_RECORD(ptr, size, name)                                    \
464
        if (ptr != NULL)                                                     \
465
        {                                                                    \
466
            NV_SPIN_LOCK(&vm_lock);                                          \
467
            vm_usage -= size;                                                \
468
            VM_PRINT("NVRM: %s (0x%p: 0x%x): VM usage is now 0x%x bytes\n",  \
469
                name, (void *)ptr, size, vm_usage);                          \
470
            VM_FREE_MEM(ptr, size, __FILE__, __LINE__);                      \
471
            NV_SPIN_UNLOCK(&vm_lock);                                        \
472
        }
473
#else
474
#  define VM_ALLOC_RECORD(a,b,c)
475
#  define VM_FREE_RECORD(a,b,c)
476
#endif
477
478
#if defined(KM_CHECKER)
479
/* kernel logical memory usage/allocation information */
480
extern U032 km_usage;
481
extern struct mem_track_t *km_list;
482
extern nv_spinlock_t km_lock;
483
484
#  if defined(POOR_MANS_MEM_CHECK)
485
#    define KM_PRINT(str, args...)   printk(str, ##args)
486
#  else
487
#    define KM_PRINT(str, args...)
488
#  endif
489
#  if defined(LIST_MEM_CHECK)
490
#    define KM_ADD_MEM(a,b,c,d)      nv_add_mem(&km_list, a, b, c, d)
491
#    define KM_FREE_MEM(a,b,c,d)     nv_free_mem(&km_list, a, b, c, d)
492
#  else
493
#    define KM_ADD_MEM(a,b,c,d)
494
#    define KM_FREE_MEM(a,b,c,d)
495
#  endif
496
#  define KM_ALLOC_RECORD(ptr, size, name)                                   \
497
        if (ptr != NULL)                                                     \
498
        {                                                                    \
499
            unsigned long __eflags;                                          \
500
            NV_SPIN_LOCK_IRQSAVE(&km_lock, __eflags);                        \
501
            km_usage += size;                                                \
502
            KM_PRINT("NVRM: %s (0x%p: 0x%x): KM usage is now 0x%x bytes\n",  \
503
                name, (void *)ptr, size, km_usage);                          \
504
            KM_ADD_MEM(ptr, size, __FILE__, __LINE__);                       \
505
            NV_SPIN_UNLOCK_IRQRESTORE(&km_lock, __eflags);                   \
506
        }
507
#  define KM_FREE_RECORD(ptr, size, name)                                    \
508
        if (ptr != NULL)                                                     \
509
        {                                                                    \
510
            unsigned long __eflags;                                          \
511
            NV_SPIN_LOCK_IRQSAVE(&km_lock, __eflags);                        \
512
            km_usage -= size;                                                \
513
            KM_PRINT("NVRM: %s (0x%p: 0x%x): KM usage is now 0x%x bytes\n",  \
514
                name, (void *)ptr, size, km_usage);                          \
515
            KM_FREE_MEM(ptr, size, __FILE__, __LINE__);                      \
516
            NV_SPIN_UNLOCK_IRQRESTORE(&km_lock, __eflags);                   \
517
        }
518
#else
519
#  define KM_ALLOC_RECORD(a,b,c)
520
#  define KM_FREE_RECORD(a,b,c)
521
#endif
522
523
#define NV_VMALLOC(ptr, size, cached)                                   \
524
    {                                                                   \
525
        pgprot_t __prot = (cached) ? PAGE_KERNEL : PAGE_KERNEL_NOCACHE; \
526
        (ptr) = __vmalloc(size, GFP_KERNEL, __prot);                    \
527
        VM_ALLOC_RECORD(ptr, size, "vm_vmalloc");                       \
528
    }
529
530
#define NV_VFREE(ptr, size)                         \
531
    {                                               \
532
        VM_FREE_RECORD(ptr, size, "vm_vfree");      \
533
        vfree((void *) (ptr));                      \
534
    }
535
536
#define NV_IOREMAP(ptr, physaddr, size) \
537
    { \
538
        (ptr) = ioremap(physaddr, size); \
539
        VM_ALLOC_RECORD(ptr, size, "vm_ioremap"); \
540
    }
541
542
#define NV_IOREMAP_NOCACHE(ptr, physaddr, size) \
543
    { \
544
        (ptr) = ioremap_nocache(physaddr, size); \
545
        VM_ALLOC_RECORD(ptr, size, "vm_ioremap_nocache"); \
546
    }
547
548
#if defined(NV_IOREMAP_CACHE_PRESENT)
549
#define NV_IOREMAP_CACHE(ptr, physaddr, size)            \
550
    {                                                    \
551
        (ptr) = ioremap_cache(physaddr, size);           \
552
        VM_ALLOC_RECORD(ptr, size, "vm_ioremap_cache");  \
553
    }
554
#else
555
#define NV_IOREMAP_CACHE NV_IOREMAP
556
#endif
557
558
#if defined(NV_IOREMAP_WC_PRESENT)
559
#define NV_IOREMAP_WC(ptr, physaddr, size)            \
560
    {                                                 \
561
        (ptr) = ioremap_wc(physaddr, size);           \
562
        VM_ALLOC_RECORD(ptr, size, "vm_ioremap_wc");  \
563
    }
564
#else
565
#define NV_IOREMAP_WC NV_IOREMAP_NOCACHE
566
#endif
567
568
#define NV_IOUNMAP(ptr, size) \
569
    { \
570
        VM_FREE_RECORD(ptr, size, "vm_iounmap"); \
571
        iounmap(ptr); \
572
    }
573
574
/* only use this because GFP_KERNEL may sleep..
575
 * GFP_ATOMIC is ok, it won't sleep
576
 */
577
#define NV_KMALLOC(ptr, size) \
578
    { \
579
        (ptr) = kmalloc(size, NV_GFP_KERNEL); \
580
        KM_ALLOC_RECORD(ptr, size, "km_alloc"); \
581
    }
582
583
#define NV_KMALLOC_ATOMIC(ptr, size) \
584
    { \
585
        (ptr) = kmalloc(size, NV_GFP_ATOMIC); \
586
        KM_ALLOC_RECORD(ptr, size, "km_alloc_atomic"); \
587
    }  
588
589
590
#define NV_KFREE(ptr, size) \
591
    { \
592
        KM_FREE_RECORD(ptr, size, "km_free"); \
593
        kfree((void *) (ptr)); \
594
    }
595
596
#define NV_GET_FREE_PAGES(ptr, order, gfp_mask)      \
597
    {                                                \
598
        (ptr) = __get_free_pages(gfp_mask, order);   \
599
    }
600
601
#define NV_FREE_PAGES(ptr, order)                    \
602
    {                                                \
603
        free_pages(ptr, order);                      \
604
    }
605
606
#if defined(NV_KMEM_CACHE_CREATE_PRESENT)
607
#if (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 6)
608
#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type)            \
609
    {                                                           \
610
        kmem_cache = kmem_cache_create(name, sizeof(type),      \
611
                        0, 0, NULL, NULL);                      \
612
    }
613
#elif (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 5)
614
#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type)            \
615
    {                                                           \
616
        kmem_cache = kmem_cache_create(name, sizeof(type),      \
617
                        0, 0, NULL);                            \
618
    }
619
#else
620
#error "NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT value unrecognized!"
621
#endif
622
#define NV_KMEM_CACHE_DESTROY(kmem_cache)                       \
623
    {                                                           \
624
        kmem_cache_destroy(kmem_cache);                         \
625
        kmem_cache = NULL;                                      \
626
    }
627
#else
628
#error "NV_KMEM_CACHE_CREATE() undefined (kmem_cache_create() unavailable)!"
629
#endif
630
631
#define NV_KMEM_CACHE_ALLOC(ptr, kmem_cache, type)              \
632
    {                                                           \
633
        (ptr) = kmem_cache_alloc(kmem_cache, GFP_KERNEL);       \
634
    }
635
636
#define NV_KMEM_CACHE_FREE(ptr, type, kmem_cache)               \
637
    {                                                           \
638
        kmem_cache_free(kmem_cache, ptr);                       \
639
    }
640
641
#if defined(NV_VMAP_PRESENT)
642
#if (NV_VMAP_ARGUMENT_COUNT == 2)
643
#define NV_VMAP_KERNEL(ptr, pages, count, prot)                         \
644
    {                                                                   \
645
        (ptr) = (unsigned long)vmap(pages, count);                      \
646
        VM_ALLOC_RECORD((void *)ptr, (count) * PAGE_SIZE, "vm_vmap");   \
647
    }
648
#elif (NV_VMAP_ARGUMENT_COUNT == 4)
649
#ifndef VM_MAP
650
#define VM_MAP  0
651
#endif
652
#define NV_VMAP_KERNEL(ptr, pages, count, prot)                         \
653
    {                                                                   \
654
        (ptr) = (unsigned long)vmap(pages, count, VM_MAP, prot);        \
655
        VM_ALLOC_RECORD((void *)ptr, (count) * PAGE_SIZE, "vm_vmap");   \
656
    }
657
#else
658
#error "NV_VMAP_ARGUMENT_COUNT value unrecognized!"
659
#endif
660
#else
661
#if defined(NV_SG_MAP_BUFFERS)
662
#error "NV_VMAP() undefined (vmap() unavailable)!"
663
#endif
664
#endif /* NV_VMAP_PRESENT */
665
666
#define NV_VUNMAP_KERNEL(ptr, count)                                    \
667
    {                                                                   \
668
        VM_FREE_RECORD((void *)ptr, (count) * PAGE_SIZE, "vm_vunmap");  \
669
        vunmap((void *)(ptr));                                          \
670
    }
671
672
#define NV_VMAP(addr, pages, count, cached)                             \
673
    {                                                                   \
674
        pgprot_t __prot = (cached) ? PAGE_KERNEL : PAGE_KERNEL_NOCACHE; \
675
        void *__ptr = nv_vmap(pages, count, __prot);                    \
676
        (addr) = (unsigned long)__ptr;                                  \
677
    }
678
679
#define NV_VUNMAP(addr, count) nv_vunmap((void *)addr, count)
680
681
682
#endif /* !defined NVWATCH */
683
684
#if defined(NV_SMP_CALL_FUNCTION_PRESENT)
685
#if (NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT == 4)
686
#define NV_SMP_CALL_FUNCTION(func, info, wait)               \
687
    ({                                                       \
688
        int __ret = smp_call_function(func, info, 1, wait);  \
689
        __ret;                                               \
690
     })
691
#elif (NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT == 3)
692
#define NV_SMP_CALL_FUNCTION(func, info, wait)               \
693
    ({                                                       \
694
        int __ret = smp_call_function(func, info, wait);     \
695
        __ret;                                               \
696
     })
697
#else
698
#error "NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT value unrecognized!"
699
#endif
700
#elif defined(CONFIG_SMP)
701
#error "NV_SMP_CALL_FUNCTION() undefined (smp_call_function() unavailable)!"
702
#endif
703
704
#if defined(NV_ON_EACH_CPU_PRESENT)
705
#if (NV_ON_EACH_CPU_ARGUMENT_COUNT == 4)
706
#define NV_ON_EACH_CPU(func, info, wait)               \
707
    ({                                                 \
708
        int __ret = on_each_cpu(func, info, 1, wait);  \
709
        __ret;                                         \
710
     })
711
#elif (NV_ON_EACH_CPU_ARGUMENT_COUNT == 3)
712
#define NV_ON_EACH_CPU(func, info, wait)               \
713
    ({                                                 \
714
        int __ret = on_each_cpu(func, info, wait);     \
715
        __ret;                                         \
716
     })
717
#else
718
#error "NV_ON_EACH_CPU_ARGUMENT_COUNT value unrecognized!"
719
#endif
720
#elif !defined(KERNEL_2_4) && defined(CONFIG_SMP)
721
#error "NV_ON_EACH_CPU() undefined (on_each_cpu() unavailable)!"
722
#endif
723
724
static inline int nv_execute_on_all_cpus(void (*func)(void *info), void *info)
725
{
726
    int ret = 0;
727
#if !defined(CONFIG_SMP)
728
    func(info);
729
#elif defined(KERNEL_2_4)
730
#if defined(preempt_disable)
731
    preempt_disable();
732
#endif
733
    ret = NV_SMP_CALL_FUNCTION(func, info, 1);
734
    func(info);
735
#if defined(preempt_enable)
736
    preempt_enable();
737
#endif
738
#else
739
    ret = NV_ON_EACH_CPU(func, info, 1);
740
#endif
741
    return ret;
742
}
743
744
#if defined(CONFIG_PREEMPT_RT)
745
#define NV_INIT_MUTEX(mutex) semaphore_init(mutex)
746
#else
747
#define NV_INIT_MUTEX(mutex)                       \
748
    {                                              \
749
        struct semaphore __mutex =                 \
750
            __SEMAPHORE_INITIALIZER(*(mutex), 1);  \
751
        *(mutex) = __mutex;                        \
752
    }
753
#endif
754
755
#if defined (KERNEL_2_4)
756
#  define NV_IS_SUSER()                 suser()
757
#  define NV_PCI_DEVICE_NAME(dev)       ((dev)->name)
758
#  define NV_NUM_CPUS()                 smp_num_cpus
759
#  define NV_CLI()                      __cli()
760
#  define NV_SAVE_FLAGS(eflags)         __save_flags(eflags)
761
#  define NV_RESTORE_FLAGS(eflags)      __restore_flags(eflags)
762
#  define NV_MAY_SLEEP()                (!in_interrupt())
763
#  define NV_MODULE_PARAMETER(x)        MODULE_PARM(x, "i")
764
#  define NV_MODULE_STRING_PARAMETER(x) MODULE_PARM(x, "s")
765
#endif
766
767
#if !defined(KERNEL_2_4)
768
#  define NV_IS_SUSER()                 capable(CAP_SYS_ADMIN)
769
#  define NV_PCI_DEVICE_NAME(dev)       ((dev)->pretty_name)
770
#  define NV_NUM_CPUS()                 num_online_cpus()
771
#  define NV_CLI()                      local_irq_disable()
772
#  define NV_SAVE_FLAGS(eflags)         local_save_flags(eflags)
773
#  define NV_RESTORE_FLAGS(eflags)      local_irq_restore(eflags)
774
#  define NV_MAY_SLEEP()                (!irqs_disabled() && !in_interrupt() && !in_atomic())
775
#  define NV_MODULE_PARAMETER(x)        module_param(x, int, 0)
776
#  define NV_MODULE_STRING_PARAMETER(x) module_param(x, charp, 0)
777
#  undef  MODULE_PARM
778
#endif
779
780
#if defined(NV_SIGNAL_STRUCT_HAS_RLIM)
781
/* per-process rlimit settings */
782
#define NV_TASK_STRUCT_RLIM(current)  ((current)->signal->rlim)
783
#else
784
/* per-thread rlimit settings */
785
#define NV_TASK_STRUCT_RLIM(current)  ((current)->rlim)
786
#endif
787
788
#define NV_GET_PAGE_STRUCT(phys_page) virt_to_page(__va(phys_page))
789
#define NV_VMA_PGOFF(vma)             ((vma)->vm_pgoff)
790
#define NV_VMA_SIZE(vma)              ((vma)->vm_end - (vma)->vm_start)
791
#define NV_VMA_OFFSET(vma)            (((NvU64)(vma)->vm_pgoff) << PAGE_SHIFT)
792
#define NV_VMA_PRIVATE(vma)           ((vma)->vm_private_data)
793
#define NV_VMA_FILE(vma)              ((vma)->vm_file)
794
795
#define NV_DEVICE_NUMBER(x)           minor((x)->i_rdev)
796
#define NV_IS_CONTROL_DEVICE(x)       (minor((x)->i_rdev) == 255)
797
798
#define NV_PCI_DISABLE_DEVICE(dev)                            \
799
    {                                                         \
800
        NvU16 __cmd[2];                                       \
801
        pci_read_config_word((dev), PCI_COMMAND, &__cmd[0]);  \
802
        pci_disable_device(dev);                              \
803
        pci_read_config_word((dev), PCI_COMMAND, &__cmd[1]);  \
804
        __cmd[1] |= PCI_COMMAND_MEMORY;                       \
805
        pci_write_config_word((dev), PCI_COMMAND,             \
806
                (__cmd[1] | (__cmd[0] & PCI_COMMAND_IO)));    \
807
    }
808
809
#define NV_PCI_RESOURCE_START(dev, bar) pci_resource_start(dev, (bar))
810
#define NV_PCI_RESOURCE_SIZE(dev, bar)  pci_resource_len(dev, (bar))
811
#define NV_PCI_RESOURCE_FLAGS(dev, bar) pci_resource_flags(dev, (bar))
812
#define NV_PCI_RESOURCE_VALID(dev, bar) \
813
    (NV_PCI_RESOURCE_START(dev, bar) != 0 && NV_PCI_RESOURCE_SIZE(dev, bar) != 0)
814
815
#define NV_PCI_BUS_NUMBER(dev)        (dev)->bus->number
816
#define NV_PCI_DEVFN(dev)             (dev)->devfn
817
#define NV_PCI_SLOT_NUMBER(dev)       PCI_SLOT(NV_PCI_DEVFN(dev))
818
819
#if defined(NV_PCI_GET_CLASS_PRESENT)
820
#define NV_PCI_DEV_PUT(dev)                    pci_dev_put(dev)
821
#define NV_PCI_GET_DEVICE(vendor,device,from)  pci_get_device(vendor,device,from)
822
#define NV_PCI_GET_SLOT(bus,devfn)                                       \
823
   ({                                                                    \
824
        struct pci_dev *__dev = NULL;                                    \
825
        while ((__dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, __dev)))  \
826
        {                                                                \
827
            if (NV_PCI_BUS_NUMBER(__dev) == bus                          \
828
                    && NV_PCI_DEVFN(__dev) == devfn) break;              \
829
        }                                                                \
830
        __dev;                                                           \
831
    })
832
#define NV_PCI_GET_CLASS(class,from)           pci_get_class(class,from)
833
#else
834
#define NV_PCI_DEV_PUT(dev)
835
#define NV_PCI_GET_DEVICE(vendor,device,from)  pci_find_device(vendor,device,from)
836
#define NV_PCI_GET_SLOT(bus,devfn)             pci_find_slot(bus,devfn)
837
#define NV_PCI_GET_CLASS(class,from)           pci_find_class(class,from)
838
#endif
839
840
#define NV_PRINT_AT(nv_debug_level,at)                                                   \
841
    {                                                                                    \
842
        nv_printf(nv_debug_level,                                                        \
843
            "NVRM: VM: %s: 0x%p, %d page(s), count = %d, flags = 0x%08x, 0x%p, 0x%p\n",  \
844
            __FUNCTION__, at, at->num_pages, NV_ATOMIC_READ(at->usage_count),            \
845
            at->flags, at->key_mapping, at->page_table);                                 \
846
    }
847
848
#define NV_PRINT_VMA(nv_debug_level,vma)                                            \
849
    {                                                                               \
850
        nv_printf(nv_debug_level,                                                   \
851
            "NVRM: VM: %s: 0x%lx - 0x%lx, 0x%08x bytes @ 0x%016llx, 0x%p, 0x%p\n",  \
852
            __FUNCTION__, vma->vm_start, vma->vm_end, NV_VMA_SIZE(vma),             \
853
            NV_VMA_OFFSET(vma), NV_VMA_PRIVATE(vma), NV_VMA_FILE(vma));             \
854
    }
855
856
/*
857
 * On Linux 2.6, we support both APM and ACPI power management. On Linux
858
 * 2.4, we support APM, only. ACPI support has been back-ported to the
859
 * Linux 2.4 kernel, but the Linux 2.4 driver model is not sufficient for
860
 * full ACPI support: it may work with some systems, but not reliably
861
 * enough for us to officially support this configuration.
862
 *
863
 * We support two Linux kernel power managment interfaces: the original
864
 * pm_register()/pm_unregister() on Linux 2.4 and the device driver model
865
 * backed PCI driver power management callbacks introduced with Linux
866
 * 2.6.
867
 *
868
 * The code below determines which interface to support on this kernel
869
 * version, if any; if built for Linux 2.6, it will also determine if the
870
 * kernel comes with ACPI or APM power management support.
871
 */
872
#if !defined(KERNEL_2_4) && defined(CONFIG_PM)
873
#define NV_PM_SUPPORT_DEVICE_DRIVER_MODEL
874
#if (defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)) && !defined(CONFIG_ACPI)
875
#define NV_PM_SUPPORT_NEW_STYLE_APM
876
#endif
877
#endif
878
879
/*
880
 * On Linux 2.6 kernels >= 2.6.11, the PCI subsystem provides a new 
881
 * interface that allows PCI drivers to determine the correct power state
882
 * for a given system power state; our suspend/resume callbacks now use
883
 * this interface and operate on PCI power state defines.
884
 *
885
 * Define these new PCI power state #define's here for compatibility with
886
 * older Linux 2.6 kernels.
887
 */
888
#if !defined(KERNEL_2_4) && !defined(PCI_D0)
889
#define PCI_D0 PM_SUSPEND_ON
890
#define PCI_D3hot PM_SUSPEND_MEM
891
#endif
892
893
#if !defined(KERNEL_2_4) && !defined(NV_PM_MESSAGE_T_PRESENT)
894
typedef u32 pm_message_t;
895
#endif
896
897
#if defined(KERNEL_2_4) && (defined(CONFIG_APM) || defined(CONFIG_APM_MODULE))
898
#include <linux/pm.h>
899
#define NV_PM_SUPPORT_OLD_STYLE_APM
900
#endif
901
902
#ifndef minor
903
# define minor(x) MINOR(x)
904
#endif
905
906
#if defined(cpu_relax)
907
#define NV_CPU_RELAX() cpu_relax()
908
#else
909
#define NV_CPU_RELAX() barrier()
910
#endif
911
912
#ifndef IRQ_RETVAL
913
typedef void irqreturn_t;
914
#define IRQ_RETVAL(a)
915
#endif
916
917
#ifndef PCI_CAP_ID_EXP
918
#define PCI_CAP_ID_EXP 0x10
919
#endif
920
921
#if defined(NV_VM_INSERT_PAGE_PRESENT)
922
#define NV_VM_INSERT_PAGE(vma, addr, page) \
923
    vm_insert_page(vma, addr, page)
924
#endif
925
#if defined(NV_REMAP_PFN_RANGE_PRESENT)
926
#define NV_REMAP_PAGE_RANGE(from, offset, x...) \
927
    remap_pfn_range(vma, from, ((offset) >> PAGE_SHIFT), x)
928
#elif defined(NV_REMAP_PAGE_RANGE_PRESENT)
929
#if (NV_REMAP_PAGE_RANGE_ARGUMENT_COUNT == 5)
930
#define NV_REMAP_PAGE_RANGE(x...) remap_page_range(vma, x)
931
#elif (NV_REMAP_PAGE_RANGE_ARGUMENT_COUNT == 4)
932
#define NV_REMAP_PAGE_RANGE(x...) remap_page_range(x)
933
#else
934
#error "NV_REMAP_PAGE_RANGE_ARGUMENT_COUNT value unrecognized!"
935
#endif
936
#else
937
#error "NV_REMAP_PAGE_RANGE() undefined!"
938
#endif
939
940
#define NV_PGD_OFFSET(address, kernel, mm)              \
941
   ({                                                   \
942
        struct mm_struct *__mm = (mm);                  \
943
        pgd_t *__pgd;                                   \
944
        if (!kernel)                                    \
945
            __pgd = pgd_offset(__mm, address);          \
946
        else                                            \
947
            __pgd = pgd_offset_k(address);              \
948
        __pgd;                                          \
949
    })
950
951
#define NV_PGD_PRESENT(pgd)                             \
952
   ({                                                   \
953
         if ((pgd != NULL) &&                           \
954
             (pgd_bad(*pgd) || pgd_none(*pgd)))         \
955
            /* static */ pgd = NULL;                    \
956
         pgd != NULL;                                   \
957
    })
958
959
#if defined(pmd_offset_map)
960
#define NV_PMD_OFFSET(address, pgd)                     \
961
   ({                                                   \
962
        pmd_t *__pmd;                                   \
963
        __pmd = pmd_offset_map(pgd, address);           \
964
   })
965
#define NV_PMD_UNMAP(pmd) pmd_unmap(pmd);
966
#else
967
#if defined(PUD_SHIFT) /* 4-level pgtable */
968
#define NV_PMD_OFFSET(address, pgd)                     \
969
   ({                                                   \
970
        pmd_t *__pmd = NULL;                            \
971
        pud_t *__pud;                                   \
972
        __pud = pud_offset(pgd, address);               \
973
        if ((__pud != NULL) &&                          \
974
            !(pud_bad(*__pud) || pud_none(*__pud)))     \
975
            __pmd = pmd_offset(__pud, address);         \
976
        __pmd;                                          \
977
    })
978
#else /* 3-level pgtable */
979
#define NV_PMD_OFFSET(address, pgd)                     \
980
   ({                                                   \
981
        pmd_t *__pmd;                                   \
982
        __pmd = pmd_offset(pgd, address);               \
983
    })
984
#endif
985
#define NV_PMD_UNMAP(pmd)
986
#endif
987
988
#define NV_PMD_PRESENT(pmd)                             \
989
   ({                                                   \
990
        if ((pmd != NULL) &&                            \
991
            (pmd_bad(*pmd) || pmd_none(*pmd)))          \
992
        {                                               \
993
            NV_PMD_UNMAP(pmd);                          \
994
            pmd = NULL; /* mark invalid */              \
995
        }                                               \
996
        pmd != NULL;                                    \
997
    })
998
999
#if defined(pte_offset_atomic)
1000
#define NV_PTE_OFFSET(address, pmd)                     \
1001
   ({                                                   \
1002
        pte_t *__pte;                                   \
1003
        __pte = pte_offset_atomic(pmd, address);        \
1004
        NV_PMD_UNMAP(pmd); __pte;                       \
1005
    })
1006
#define NV_PTE_UNMAP(pte) pte_kunmap(pte);
1007
#elif defined(pte_offset)
1008
#define NV_PTE_OFFSET(address, pmd)                     \
1009
   ({                                                   \
1010
        pte_t *__pte;                                   \
1011
        __pte = pte_offset(pmd, address);               \
1012
        NV_PMD_UNMAP(pmd); __pte;                       \
1013
    })
1014
#define NV_PTE_UNMAP(pte)
1015
#else
1016
#define NV_PTE_OFFSET(address, pmd)                     \
1017
   ({                                                   \
1018
        pte_t *__pte;                                   \
1019
        __pte = pte_offset_map(pmd, address);           \
1020
        NV_PMD_UNMAP(pmd); __pte;                       \
1021
    })
1022
#define NV_PTE_UNMAP(pte) pte_unmap(pte);
1023
#endif
1024
1025
#define NV_PTE_PRESENT(pte)                             \
1026
   ({                                                   \
1027
        if ((pte != NULL) && !pte_present(*pte))        \
1028
        {                                               \
1029
            NV_PTE_UNMAP(pte);                          \
1030
            pte = NULL; /* mark invalid */              \
1031
        }                                               \
1032
        pte != NULL;                                    \
1033
    })
1034
1035
#define NV_PTE_VALUE(pte)                               \
1036
   ({                                                   \
1037
        unsigned long __pte_value = pte_val(*pte);      \
1038
        NV_PTE_UNMAP(pte);                              \
1039
        __pte_value;                                    \
1040
    })
1041
1042
1043
#define NV_PAGE_ALIGN(addr)             ( ((addr) + PAGE_SIZE - 1) / PAGE_SIZE)
1044
#define NV_MASK_OFFSET(addr)            ( (addr) & (PAGE_SIZE - 1) )
1045
1046
#if defined(NVCPU_X86) || defined(NVCPU_X86_64)
1047
/* this isn't defined in some older kernel header files */
1048
#define NV_CPU_INTERRUPT_FLAGS_BIT (1<<9)
1049
#else
1050
#error define NV_CPU_INTERRUPT_FLAGS_BIT
1051
#endif
1052
1053
static inline int NV_IRQL_IS_RAISED(void)
1054
    {
1055
        unsigned long int eflags;
1056
        NV_SAVE_FLAGS(eflags);
1057
        return !(eflags & NV_CPU_INTERRUPT_FLAGS_BIT);
1058
    }
1059
 
1060
static inline int nv_calc_order(unsigned int size)
1061
    {
1062
        int order = 0;
1063
        while ( ((1 << order) * PAGE_SIZE) < (size))
1064
        {
1065
            order++;
1066
        }
1067
        return order;
1068
    }
1069
1070
/* mark memory UC-, rather than UC (don't use _PAGE_PWT) */
1071
static inline pgprot_t pgprot_noncached_weak(pgprot_t old_prot)
1072
    {
1073
        pgprot_t new_prot = old_prot;
1074
        if (boot_cpu_data.x86 > 3)
1075
            new_prot = __pgprot(pgprot_val(old_prot) | _PAGE_PCD);
1076
        return new_prot;
1077
    }
1078
1079
#if !defined (pgprot_noncached)
1080
static inline pgprot_t pgprot_noncached(pgprot_t old_prot)
1081
    {
1082
        pgprot_t new_prot = old_prot;
1083
        if (boot_cpu_data.x86 > 3)
1084
            new_prot = __pgprot(pgprot_val(old_prot) | _PAGE_PCD | _PAGE_PWT);
1085
        return new_prot;
1086
    }
1087
#endif
1088
#if defined(KERNEL_2_4) && defined(NVCPU_X86) && !defined(pfn_to_page)
1089
#define pfn_to_page(pfn) (mem_map + (pfn))
1090
#endif
1091
1092
/*
1093
 * An allocated bit of memory using NV_MEMORY_ALLOCATION_OFFSET
1094
 *   looks like this in the driver
1095
 */
1096
1097
typedef struct nv_pte_t {
1098
    unsigned long   phys_addr;
1099
    unsigned long   virt_addr;
1100
    dma_addr_t      dma_addr;
1101
#ifdef NV_SG_MAP_BUFFERS
1102
    struct scatterlist sg_list;
1103
#endif
1104
#if defined(NV_SWIOTLB)
1105
    unsigned long   orig_phys_addr;
1106
    unsigned long   orig_virt_addr;
1107
#endif
1108
    unsigned int    page_count;
1109
} nv_pte_t;
1110
1111
typedef struct nv_alloc_s {
1112
    struct nv_alloc_s *next;    
1113
    atomic_t       usage_count;
1114
    unsigned int   flags;
1115
    unsigned int   num_pages;
1116
    unsigned int   order;
1117
    unsigned int   size;
1118
    nv_pte_t     **page_table;          /* list of physical pages allocated */
1119
    void          *key_mapping;         /* mapping used as a key for finding this nv_alloc_t */
1120
    void          *file;
1121
    unsigned int   pid;
1122
    void          *priv_data;
1123
    nv_state_t    *nv;
1124
} nv_alloc_t;
1125
1126
1127
#define NV_ALLOC_TYPE_PCI      (1<<0)
1128
#define NV_ALLOC_TYPE_AGP      (1<<1)
1129
#define NV_ALLOC_TYPE_CONTIG   (1<<2)
1130
1131
#define NV_ALLOC_MAPPING_SHIFT      16
1132
#define NV_ALLOC_MAPPING(flags)     (((flags)>>NV_ALLOC_MAPPING_SHIFT)&0xff)
1133
#define NV_ALLOC_ENC_MAPPING(flags) ((flags)<<NV_ALLOC_MAPPING_SHIFT)
1134
1135
#define NV_ALLOC_MAPPING_CACHED(flags) (NV_ALLOC_MAPPING(flags) == NV_MEMORY_CACHED)
1136
1137
#define NV_ALLOC_MAPPING_AGP(flags)     ((flags) & NV_ALLOC_TYPE_AGP)
1138
#define NV_ALLOC_MAPPING_CONTIG(flags)  ((flags) & NV_ALLOC_TYPE_CONTIG)
1139
1140
static inline U032 nv_alloc_init_flags(int cached, int agp, int contig)
1141
{
1142
    U032 flags = NV_ALLOC_ENC_MAPPING(cached);
1143
    if (agp)    flags |= NV_ALLOC_TYPE_AGP;
1144
    else        flags |= NV_ALLOC_TYPE_PCI;
1145
    if (contig && !agp) flags |= NV_ALLOC_TYPE_CONTIG;
1146
    return flags;
1147
}
1148
1149
/* linux-specific version of old nv_state_t */
1150
/* this is a general os-specific state structure. the first element *must* be
1151
   the general state structure, for the generic unix-based code */
1152
typedef struct {
1153
    nv_state_t nv_state;
1154
    atomic_t usage_count;
1155
1156
    struct pci_dev *dev;
1157
    void *agp_bridge;
1158
    nv_alloc_t *alloc_queue;
1159
1160
    /* keep track of any pending bottom halfes */
1161
    struct tasklet_struct tasklet;
1162
1163
    /* get a timer callback every second */
1164
    struct timer_list rc_timer;
1165
1166
    /* per-device locking mechanism for access to core rm */
1167
    nv_spinlock_t rm_lock;
1168
    int rm_lock_cpu;
1169
    int rm_lock_count;
1170
1171
    /* lock for linux-specific data, not used by core rm */
1172
    struct semaphore ldata_lock;
1173
1174
    /* lock for linux-specific alloc queue */
1175
    struct semaphore at_lock;
1176
} nv_linux_state_t;
1177
1178
/*
1179
 * file-private data
1180
 * hide a pointer to our data structures in a file-private ptr
1181
 * there are times we need to grab this data back from the file
1182
 * data structure..
1183
 */
1184
1185
typedef struct nvidia_event
1186
{
1187
    struct nvidia_event *next;
1188
    nv_event_t event;
1189
} nvidia_event_t;
1190
1191
typedef struct
1192
{
1193
    void *nvptr;
1194
    nvidia_event_t *event_head;
1195
    nvidia_event_t *event_tail;
1196
    nv_spinlock_t fp_lock;
1197
    wait_queue_head_t waitqueue;
1198
} nv_file_private_t;
1199
1200
#define FILE_PRIVATE(filep)     ((filep)->private_data)
1201
1202
#define NV_GET_NVFP(filep)      ((nv_file_private_t *) FILE_PRIVATE(filep))
1203
1204
/* for the card devices */
1205
#define NVL_FROM_FILEP(filep)   (NV_GET_NVFP(filep)->nvptr)
1206
1207
#define NV_GET_NVL_FROM_NV_STATE(nv) \
1208
    ((nv_linux_state_t *) nv->os_state)
1209
1210
#define NV_STATE_PTR(nvl)   (&((nvl)->nv_state))
1211
1212
1213
#define NV_ATOMIC_SET(data,val)         atomic_set(&(data), (val))
1214
#define NV_ATOMIC_INC(data)             atomic_inc(&(data))
1215
#define NV_ATOMIC_DEC(data)             atomic_dec(&(data))
1216
#define NV_ATOMIC_DEC_AND_TEST(data)    atomic_dec_and_test(&(data))
1217
#define NV_ATOMIC_READ(data)            atomic_read(&(data))
1218
1219
extern int nv_update_memory_types;
1220
1221
/*
1222
 * Using change_page_attr() on early Linux/x86-64 2.6 kernels may
1223
 * result in a BUG() being triggered. The underlying problem
1224
 * actually exists on multiple architectures and kernels, but only
1225
 * the above check for the condition and trigger a BUG().
1226
 *
1227
 * Note that this is a due to a bug in the Linux kernel, not an
1228
 * NVIDIA driver bug (it can also be triggered by AGPGART).
1229
 *
1230
 * We therefore need to determine at runtime if change_page_attr()
1231
 * can be used safely on these kernels.
1232
 */
1233
#if defined(NV_CHANGE_PAGE_ATTR_PRESENT) && defined(NVCPU_X86_64) && \
1234
  !defined(KERNEL_2_4) && \
1235
  (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11))
1236
#define NV_CHANGE_PAGE_ATTR_BUG_PRESENT
1237
#endif
1238
1239
#if defined(NVCPU_X86) || defined(NVCPU_X86_64)
1240
/*
1241
 * On Linux/x86-64 (and recent Linux/x86) kernels, the PAGE_KERNEL
1242
 * and PAGE_KERNEL_NOCACHE protection bit masks include _PAGE_NX
1243
 * to indicate that the no-execute protection page feature is used
1244
 * for the page in question.
1245
 *
1246
 * We need to be careful to mask out _PAGE_NX when the host system
1247
 * doesn't support this feature or when it's disabled: the kernel
1248
 * may not do this in its implementation of the change_page_attr()
1249
 * interface.
1250
 */
1251
#ifndef X86_FEATURE_NX
1252
#define X86_FEATURE_NX (1*32+20)
1253
#endif
1254
#ifndef boot_cpu_has
1255
#define boot_cpu_has(x) test_bit(x, boot_cpu_data.x86_capability)
1256
#endif
1257
#ifndef MSR_EFER
1258
#define MSR_EFER 0xc0000080
1259
#endif
1260
#ifndef EFER_NX
1261
#define EFER_NX (1 << 11)
1262
#endif
1263
#ifndef _PAGE_NX
1264
#define _PAGE_NX ((NvU64)1 << 63)
1265
#endif
1266
extern NvU64 __nv_supported_pte_mask;
1267
#endif
1268
1269
#if defined(DEBUG)
1270
#define NV_ASSERT(message, condition)                               \
1271
do                                                                  \
1272
{                                                                   \
1273
    if (!(condition))                                               \
1274
    {                                                               \
1275
        nv_printf(NV_DBG_ERRORS, "NVRM: ASSERT: %s\n", message);    \
1276
        os_dbg_breakpoint();                                        \
1277
    }                                                               \
1278
}                                                                   \
1279
while (0)
1280
#else
1281
#define NV_ASSERT(message, condition)
1282
#endif /* DEBUG */
1283
1284
int nv_verify_page_mappings(nv_pte_t *, unsigned int);
1285
1286
#endif  /* _NV_LINUX_H_ */
(-)usr-patched1.orig/src/nv/nv.c (-241 / +266 lines)
Lines 163-168 Link Here
163
/* lock-related functions that should only be called from this file */
163
/* lock-related functions that should only be called from this file */
164
static void nv_lock_init_locks(nv_state_t *nv);
164
static void nv_lock_init_locks(nv_state_t *nv);
165
165
166
#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
167
#define NV_SET_PROC_ENTRY_OWNER(entry) ((entry)->owner = THIS_MODULE)
168
#else
169
#define NV_SET_PROC_ENTRY_OWNER(entry)
170
#endif
171
172
#if defined(NV_PROC_CREATE_DATA_PRESENT)
173
# define NV_CREATE_PROC_ENTRY(name,mode,parent,fops,__data) \
174
    proc_create_data(name, __mode, parent, fops, __data)
175
#else
176
# define NV_CREATE_PROC_ENTRY(name,mode,parent,fops,__data) \
177
   ({                                                       \
178
        struct proc_dir_entry *__entry;                     \
179
        __entry = create_proc_entry(name, mode, parent);    \
180
        if (__entry != NULL)                                \
181
        {                                                   \
182
            NV_SET_PROC_ENTRY_OWNER(__entry);               \
183
            __entry->proc_fops = fops;                      \
184
            __entry->data = (__data);                       \
185
        }                                                   \
186
        __entry;                                            \
187
    })
188
#endif
189
190
#define NV_CREATE_PROC_FILE(filename,parent,__name,__data)               \
191
   ({                                                                    \
192
        struct proc_dir_entry *__entry;                                  \
193
        int __mode = (S_IFREG | S_IRUGO);                                \
194
        const struct file_operations *fops = &nv_kern_##__name##_fops; \
195
        if (fops->write != 0)                                            \
196
            __mode |= S_IWUSR;                                           \
197
        __entry = NV_CREATE_PROC_ENTRY(filename, __mode, parent, fops,   \
198
            __data);                                                     \
199
        __entry;                                                         \
200
    })
201
202
/*
203
 * proc_mkdir_mode exists in Linux 2.6.9, but isn't exported until Linux 3.0.
204
 * Use the older interface instead unless the newer interface is necessary.
205
 */
206
#if defined(NV_PROC_REMOVE_PRESENT)
207
# define NV_PROC_MKDIR_MODE(name, mode, parent)                \
208
    proc_mkdir_mode(name, mode, parent)
209
#else
210
# define NV_PROC_MKDIR_MODE(name, mode, parent)                \
211
   ({                                                          \
212
        struct proc_dir_entry *__entry;                        \
213
        __entry = create_proc_entry(name, mode, parent);       \
214
        if (__entry != NULL)                                   \
215
            NV_SET_PROC_ENTRY_OWNER(__entry);                  \
216
        __entry;                                               \
217
    })
218
#endif
219
220
#define NV_CREATE_PROC_DIR(name,parent)                        \
221
   ({                                                          \
222
        struct proc_dir_entry *__entry;                        \
223
        int __mode = (S_IFDIR | S_IRUGO | S_IXUGO);            \
224
        __entry = NV_PROC_MKDIR_MODE(name, __mode, parent);    \
225
        __entry;                                               \
226
    })
227
228
#if defined(NV_PDE_DATA_PRESENT)
229
# define NV_PDE_DATA(inode) PDE_DATA(inode)
230
#else
231
# define NV_PDE_DATA(inode) PDE(inode)->data
232
#endif
233
234
#define NV_DEFINE_PROCFS_SINGLE_FILE(__name)                                  \
235
    static int nv_kern_open_##__name(                                         \
236
        struct inode *inode,                                                  \
237
        struct file *filep                                                    \
238
    )                                                                         \
239
    {                                                                         \
240
        return single_open(filep, nv_kern_read_##__name,                      \
241
            NV_PDE_DATA(inode));                                              \
242
    }                                                                         \
243
                                                                              \
244
    static const struct file_operations nv_kern_##__name##_fops = {           \
245
        .owner      = THIS_MODULE,                                            \
246
        .open       = nv_kern_open_##__name,                                  \
247
        .read       = seq_read,                                               \
248
        .llseek     = seq_lseek,                                              \
249
        .release    = single_release,                                         \
250
    };
166
251
167
/***
252
/***
168
 *** EXPORTS to Linux Kernel
253
 *** EXPORTS to Linux Kernel
Lines 190-202 Link Here
190
static int    nv_kern_apm_event(struct pm_dev *, pm_request_t, void *);
275
static int    nv_kern_apm_event(struct pm_dev *, pm_request_t, void *);
191
#endif
276
#endif
192
277
193
static int    nv_kern_read_cardinfo(char *, char **, off_t off, int, int *, void *);
194
static int    nv_kern_read_status(char *, char **, off_t off, int, int *, void *);
195
static int    nv_kern_read_registry(char *, char **, off_t off, int, int *, void *);       
196
static int    nv_kern_read_agpinfo(char *, char **, off_t off, int, int *, void *);
197
static int    nv_kern_read_version(char *, char **, off_t off, int, int *, void *);
198
static int    nv_kern_read_text_file(char *, char **, off_t off, int, int *, void *);
199
200
int           nv_kern_ctl_open(struct inode *, struct file *);
278
int           nv_kern_ctl_open(struct inode *, struct file *);
201
int           nv_kern_ctl_close(struct inode *, struct file *);
279
int           nv_kern_ctl_close(struct inode *, struct file *);
202
unsigned int  nv_kern_ctl_poll(struct file *, poll_table *);
280
unsigned int  nv_kern_ctl_poll(struct file *, poll_table *);
Lines 490-645 Link Here
490
    return NULL;
568
    return NULL;
491
}
569
}
492
570
493
static void nvos_proc_create(void)
571
static int
572
nv_kern_read_text_file(
573
    struct seq_file *s,
574
    void *v
575
)
494
{
576
{
495
#ifdef CONFIG_PROC_FS
577
    return seq_puts(s, s->private);
496
    struct pci_dev *dev;
497
    U032 j, i = 0;
498
    char name[6];
499
500
    struct proc_dir_entry *entry;
501
    struct proc_dir_entry *proc_nvidia_agp, *proc_nvidia_cards;
502
503
    /* world readable directory */
504
    int d_flags = S_IFDIR | S_IRUGO | S_IXUGO;
505
506
    /* world readable file */
507
    int flags = S_IFREG | S_IRUGO;
508
509
    nv_state_t *nv;
510
    nv_linux_state_t *nvl;
511
512
    proc_nvidia = create_proc_entry("driver/nvidia", d_flags, NULL);
513
    if (!proc_nvidia)
514
        goto failed;
515
516
    proc_nvidia_cards = create_proc_entry("cards", d_flags, proc_nvidia);
517
    if (!proc_nvidia_cards)
518
        goto failed;
519
520
    proc_nvidia_warnings = create_proc_entry("warnings", d_flags, proc_nvidia);
521
    if (!proc_nvidia_warnings)
522
        goto failed;
523
524
    proc_nvidia_patches = create_proc_entry("patches", d_flags, proc_nvidia);
525
    if (!proc_nvidia_patches)
526
        goto failed;
527
528
    /*
529
     * Set the module owner to ensure that the reference
530
     * count reflects accesses to the proc files.
531
     */
532
#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
533
    proc_nvidia->owner = THIS_MODULE;
534
    proc_nvidia_cards->owner = THIS_MODULE;
535
    proc_nvidia_warnings->owner = THIS_MODULE;
536
    proc_nvidia_patches->owner = THIS_MODULE;
537
#endif
538
539
    for (j = 0; j < num_nv_devices; j++)
540
    {
541
        nvl = &nv_linux_devices[j];
542
        nv = NV_STATE_PTR(nvl);
543
544
        dev = nv_get_pci_device(nv);
545
        if (!dev)
546
            break;
547
548
        sprintf(name, "%d", i++);
549
        entry = create_proc_entry(name, flags, proc_nvidia_cards);
550
        if (!entry) {
551
            NV_PCI_DEV_PUT(dev);
552
            goto failed;
553
        }
554
555
        entry->data = nv;
556
        entry->read_proc = nv_kern_read_cardinfo;
557
#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
558
        entry->owner = THIS_MODULE;
559
#endif
560
561
        if (nvos_find_agp_capability(dev)) {
562
            /*
563
             * Create the /proc/driver/nvidia/agp/{status,host-bridge,card}
564
             * entries now that we know there's AGP hardware.
565
             */
566
            entry = create_proc_entry("agp", d_flags, proc_nvidia);
567
            if (!entry) {
568
                NV_PCI_DEV_PUT(dev);
569
                goto failed;
570
            }
571
572
#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
573
            entry->owner = THIS_MODULE;
574
#endif
575
            proc_nvidia_agp = entry;
576
577
            entry = create_proc_entry("status", flags, proc_nvidia_agp);
578
            if (!entry) {
579
                NV_PCI_DEV_PUT(dev);
580
                goto failed;
581
            }
582
583
            entry->data = nv;
584
            entry->read_proc = nv_kern_read_status;
585
#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
586
            entry->owner = THIS_MODULE;
587
#endif
588
589
            entry = create_proc_entry("host-bridge", flags, proc_nvidia_agp);
590
            if (!entry) {
591
                NV_PCI_DEV_PUT(dev);
592
                goto failed;
593
            }
594
595
            entry->data = NULL;
596
            entry->read_proc = nv_kern_read_agpinfo;
597
#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
598
            entry->owner = THIS_MODULE;
599
#endif
600
601
            entry = create_proc_entry("card", flags, proc_nvidia_agp);
602
            if (!entry) {
603
                NV_PCI_DEV_PUT(dev);
604
                goto failed;
605
            }
606
607
            entry->data = nv;
608
            entry->read_proc = nv_kern_read_agpinfo;
609
#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
610
            entry->owner = THIS_MODULE;
611
#endif
612
        }
613
614
        NV_PCI_DEV_PUT(dev);
615
    }
616
617
    entry = create_proc_entry("version", flags, proc_nvidia);
618
    if (!entry)
619
        goto failed;
620
621
    entry->read_proc = nv_kern_read_version;
622
#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
623
    entry->owner = THIS_MODULE;
624
#endif
625
626
    entry = create_proc_entry("registry", flags, proc_nvidia);
627
    if (!entry)
628
        goto failed;
629
630
    entry->read_proc = nv_kern_read_registry;
631
#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
632
    entry->owner = THIS_MODULE;
633
#endif
634
635
    return;
636
637
failed:
638
    nv_printf(NV_DBG_ERRORS, "NVRM: failed to create /proc entries!\n");
639
    nvos_proc_remove_all(proc_nvidia);
640
#endif
641
}
578
}
642
579
580
NV_DEFINE_PROCFS_SINGLE_FILE(text_file);
581
643
static void
582
static void
644
nvos_proc_add_text_file(
583
nvos_proc_add_text_file(
645
    struct proc_dir_entry *parent,
584
    struct proc_dir_entry *parent,
Lines 647-672 Link Here
647
    const char *text
586
    const char *text
648
)
587
)
649
{
588
{
650
#ifdef CONFIG_PROC_FS
589
    NV_CREATE_PROC_FILE(filename, parent, text_file, (void *)text);
651
    struct proc_dir_entry *entry;
652
653
    /* world readable file */
654
    int flags = S_IFREG | S_IRUGO;
655
656
    entry = create_proc_entry(filename, flags, parent);
657
    if (!entry) return;
658
659
    entry->data = (void *)text;
660
    entry->read_proc = nv_kern_read_text_file;
661
#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
662
    entry->owner = THIS_MODULE;
663
#endif
664
#endif
665
}
590
}
666
591
667
#ifdef CONFIG_PROC_FS
592
#ifdef CONFIG_PROC_FS
668
static void nvos_proc_remove_all(struct proc_dir_entry *entry)
593
static void nvos_proc_remove_all(struct proc_dir_entry *entry)
669
{
594
{
595
#if defined(NV_PROC_REMOVE_PRESENT)
596
    proc_remove(entry);
597
#else
670
    while (entry) {
598
    while (entry) {
671
        struct proc_dir_entry *next = entry->next;
599
        struct proc_dir_entry *next = entry->next;
672
        if (entry->subdir)
600
        if (entry->subdir)
Lines 676-681 Link Here
676
            break;
604
            break;
677
        entry = next;
605
        entry = next;
678
    }
606
    }
607
#endif
679
}
608
}
680
#endif
609
#endif
681
610
Lines 2847-2864 Link Here
2847
}
2776
}
2848
2777
2849
static int
2778
static int
2850
nv_kern_read_cardinfo(char *page, char **start, off_t off,
2779
nv_kern_read_cardinfo(
2851
        int count, int *eof, void *data)
2780
    struct seq_file *s,
2781
    void *v
2782
)
2852
{
2783
{
2784
    nv_state_t *nv = s->private;
2853
    struct pci_dev *dev;
2785
    struct pci_dev *dev;
2854
    char *type, *fmt, tmpstr[NV_DEVICE_NAME_LENGTH];
2786
    char *type, *fmt, tmpstr[NV_DEVICE_NAME_LENGTH];
2855
    int len = 0, status;
2787
    int status;
2856
    U032 vbios_rev1, vbios_rev2, vbios_rev3, vbios_rev4, vbios_rev5;
2788
    U032 vbios_rev1, vbios_rev2, vbios_rev3, vbios_rev4, vbios_rev5;
2857
2789
2858
    nv_state_t *nv;
2859
    nv = (nv_state_t *) data;
2860
    *eof = 1;
2861
2862
    dev = nv_get_pci_device(nv);
2790
    dev = nv_get_pci_device(nv);
2863
    if (!dev)
2791
    if (!dev)
2864
        return 0;
2792
        return 0;
Lines 2868-2928 Link Here
2868
        strcpy (tmpstr, "Unknown");
2796
        strcpy (tmpstr, "Unknown");
2869
    }
2797
    }
2870
    
2798
    
2871
    len += sprintf(page+len, "Model: \t\t %s\n", tmpstr);
2799
    seq_printf(s, "Model: \t\t %s\n", tmpstr);
2872
    len += sprintf(page+len, "IRQ:   \t\t %d\n", nv->interrupt_line);
2800
    seq_printf(s, "IRQ:   \t\t %d\n", nv->interrupt_line);
2873
2801
2874
    status = rm_get_vbios_version(nv, &vbios_rev1, &vbios_rev2,
2802
    status = rm_get_vbios_version(nv, &vbios_rev1, &vbios_rev2,
2875
                                  &vbios_rev3, &vbios_rev4, &vbios_rev5);
2803
                                  &vbios_rev3, &vbios_rev4, &vbios_rev5);
2876
2804
2877
    if (status < 0) {
2805
    if (status < 0) {
2878
        /* before rm_init_adapter */
2806
        /* before rm_init_adapter */
2879
        len += sprintf(page+len, "Video BIOS: \t ??.??.??.??.??\n");
2807
        seq_printf(s, "Video BIOS: \t ??.??.??.??.??\n");
2880
    } else {
2808
    } else {
2881
        fmt = "Video BIOS: \t %02x.%02x.%02x.%02x.%02x\n";
2809
        fmt = "Video BIOS: \t %02x.%02x.%02x.%02x.%02x\n";
2882
        len += sprintf(page+len, fmt, vbios_rev1, vbios_rev2, vbios_rev3,
2810
        seq_printf(s, fmt, vbios_rev1, vbios_rev2, vbios_rev3, vbios_rev4,
2883
                                                  vbios_rev4, vbios_rev5);
2811
                   vbios_rev5);
2884
    }
2812
    }
2885
2813
2886
    if (nvos_find_agp_capability(dev)) type = "AGP";
2814
    if (nvos_find_agp_capability(dev)) type = "AGP";
2887
    else if (nvos_find_pci_express_capability(dev)) type = "PCI-E";
2815
    else if (nvos_find_pci_express_capability(dev)) type = "PCI-E";
2888
    else type = "PCI";
2816
    else type = "PCI";
2889
    len += sprintf(page+len, "Card Type: \t %s\n", type);
2817
    seq_printf(s, "Card Type: \t %s\n", type);
2890
2818
2891
    // Report the number of bits set in dev->dma_mask
2819
    // Report the number of bits set in dev->dma_mask
2892
    len += sprintf(page+len, "DMA Size: \t %d bits\n",
2820
    seq_printf(s, "DMA Size: \t %d bits\n", nv_count_bits(dev->dma_mask));
2893
     nv_count_bits(dev->dma_mask));
2821
    seq_printf(s, "DMA Mask: \t 0x%llx\n", dev->dma_mask);
2894
    len += sprintf(page+len, "DMA Mask: \t 0x%llx\n", dev->dma_mask);
2895
2822
2896
    NV_PCI_DEV_PUT(dev);
2823
    NV_PCI_DEV_PUT(dev);
2897
    return len;
2824
    return 0;
2898
}
2825
}
2899
2826
2827
NV_DEFINE_PROCFS_SINGLE_FILE(cardinfo);
2828
2900
static int
2829
static int
2901
nv_kern_read_version(char *page, char **start, off_t off,
2830
nv_kern_read_version(
2902
        int count, int *eof, void *data)
2831
    struct seq_file *s,
2832
    void *v
2833
)
2903
{
2834
{
2904
    int len = 0;
2835
    seq_printf(s, "NVRM version: %s\n", pNVRM_ID);
2905
    *eof = 1;
2836
    seq_printf(s, "GCC version:  %s\n", NV_COMPILER);
2906
    
2837
2907
    len += sprintf(page+len, "NVRM version: %s\n", pNVRM_ID);
2838
    return 0;
2908
    len += sprintf(page+len, "GCC version:  %s\n", NV_COMPILER);
2909
    
2910
    return len;
2911
}
2839
}
2912
2840
2841
NV_DEFINE_PROCFS_SINGLE_FILE(version);
2842
2913
static int
2843
static int
2914
nv_kern_read_agpinfo(char *page, char **start, off_t off,
2844
nv_kern_read_agpinfo(
2915
        int count, int *eof, void *data)
2845
    struct seq_file *s,
2916
{
2846
    void *v
2847
)
2848
 {
2849
    nv_state_t *nv = s->private;
2917
    struct pci_dev *dev;
2850
    struct pci_dev *dev;
2918
    char   *fw, *sba;
2851
    char   *fw, *sba;
2919
    u8     cap_ptr;
2852
    u8     cap_ptr;
2920
    u32    status, command, agp_rate;
2853
    u32    status, command, agp_rate;
2921
    int    len = 0;
2922
    
2923
    nv_state_t *nv;
2924
    nv = (nv_state_t *) data;
2925
    *eof = 1;
2926
2854
2927
    if (nv) {
2855
    if (nv) {
2928
        dev = nv_get_pci_device(nv);
2856
        dev = nv_get_pci_device(nv);
Lines 2933-2945 Link Here
2933
        if (!dev)
2861
        if (!dev)
2934
            return 0;
2862
            return 0;
2935
2863
2936
        len += sprintf(page+len, "Host Bridge: \t ");
2864
        seq_printf(s, "Host Bridge: \t ");
2937
2865
2938
#if defined(CONFIG_PCI_NAMES)
2866
#if defined(CONFIG_PCI_NAMES)
2939
        len += sprintf(page+len, "%s\n", NV_PCI_DEVICE_NAME(dev));
2867
        seq_printf(s, "%s\n", NV_PCI_DEVICE_NAME(dev));
2940
#else
2868
#else
2941
        len += sprintf(page+len, "PCI device %04x:%04x\n",
2869
        seq_printf(s, "PCI device %04x:%04x\n", dev->vendor, dev->device);
2942
                dev->vendor, dev->device);
2943
#endif
2870
#endif
2944
    }
2871
    }
2945
2872
Lines 2952-2991 Link Here
2952
    fw  = (status & 0x00000010) ? "Supported" : "Not Supported";
2879
    fw  = (status & 0x00000010) ? "Supported" : "Not Supported";
2953
    sba = (status & 0x00000200) ? "Supported" : "Not Supported";
2880
    sba = (status & 0x00000200) ? "Supported" : "Not Supported";
2954
2881
2955
    len += sprintf(page+len, "Fast Writes: \t %s\n", fw);
2882
    seq_printf(s, "Fast Writes: \t %s\n", fw);
2956
    len += sprintf(page+len, "SBA: \t\t %s\n", sba);
2883
    seq_printf(s, "SBA: \t\t %s\n", sba);
2957
2884
2958
    agp_rate = status & 0x7;
2885
    agp_rate = status & 0x7;
2959
    if (status & 0x8) // agp 3.0
2886
    if (status & 0x8) // agp 3.0
2960
        agp_rate <<= 2;
2887
        agp_rate <<= 2;
2961
2888
2962
    len += sprintf(page+len, "AGP Rates: \t %s%s%s%s\n",
2889
    seq_printf(s, "AGP Rates: \t %s%s%s%s\n",
2963
            (agp_rate & 0x00000008) ? "8x " : "",
2890
            (agp_rate & 0x00000008) ? "8x " : "",
2964
            (agp_rate & 0x00000004) ? "4x " : "",
2891
            (agp_rate & 0x00000004) ? "4x " : "",
2965
            (agp_rate & 0x00000002) ? "2x " : "",
2892
            (agp_rate & 0x00000002) ? "2x " : "",
2966
            (agp_rate & 0x00000001) ? "1x " : "");
2893
            (agp_rate & 0x00000001) ? "1x " : "");
2967
2894
2968
    len += sprintf(page+len, "Registers: \t 0x%08x:0x%08x\n", status, command);
2895
    seq_printf(s, "Registers: \t 0x%08x:0x%08x\n", status, command);
2969
2896
2970
    NV_PCI_DEV_PUT(dev);
2897
    NV_PCI_DEV_PUT(dev);
2971
    return len;
2898
    return 0;
2972
}
2899
}
2973
2900
2901
NV_DEFINE_PROCFS_SINGLE_FILE(agpinfo);
2902
2974
static int
2903
static int
2975
nv_kern_read_status(char *page, char **start, off_t off,
2904
nv_kern_read_agp_status(
2976
        int count, int *eof, void *data)
2905
    struct seq_file *s,
2977
{
2906
    void *v
2907
)
2908
 {
2909
    nv_state_t *nv = s->private;
2978
    struct pci_dev *dev;
2910
    struct pci_dev *dev;
2979
    char   *fw, *sba, *drv;
2911
    char   *fw, *sba, *drv;
2980
    int    len = 0;
2981
    u8     cap_ptr;
2912
    u8     cap_ptr;
2982
    u32    scratch;
2913
    u32    scratch;
2983
    u32    status, command, agp_rate;
2914
    u32    status, command, agp_rate;
2984
2915
2985
    nv_state_t *nv;
2986
    nv = (nv_state_t *) data;
2987
    *eof = 1;
2988
2989
    dev = nvos_get_agp_device_by_class(PCI_CLASS_BRIDGE_HOST);
2916
    dev = nvos_get_agp_device_by_class(PCI_CLASS_BRIDGE_HOST);
2990
    if (!dev)
2917
    if (!dev)
2991
        return 0;
2918
        return 0;
Lines 3006-3015 Link Here
3006
    command &= scratch;
2933
    command &= scratch;
3007
2934
3008
    if (NV_AGP_ENABLED(nv) && (command & 0x100)) {
2935
    if (NV_AGP_ENABLED(nv) && (command & 0x100)) {
3009
        len += sprintf(page+len, "Status: \t Enabled\n");
2936
        seq_printf(s, "Status: \t Enabled\n");
3010
2937
3011
        drv = NV_OSAGP_ENABLED(nv) ? "AGPGART" : "NVIDIA";
2938
        drv = NV_OSAGP_ENABLED(nv) ? "AGPGART" : "NVIDIA";
3012
        len += sprintf(page+len, "Driver: \t %s\n", drv);
2939
        seq_printf(s, "Driver: \t %s\n", drv);
3013
2940
3014
        // mask off agp rate. 
2941
        // mask off agp rate. 
3015
        // If this is agp 3.0, we need to shift the value
2942
        // If this is agp 3.0, we need to shift the value
Lines 3017-3033 Link Here
3017
        if (status & 0x8) // agp 3.0
2944
        if (status & 0x8) // agp 3.0
3018
            agp_rate <<= 2;
2945
            agp_rate <<= 2;
3019
2946
3020
        len += sprintf(page+len, "AGP Rate: \t %dx\n", agp_rate);
2947
        seq_printf(s, "AGP Rate: \t %dx\n", agp_rate);
3021
2948
3022
        fw = (command & 0x00000010) ? "Enabled" : "Disabled";
2949
        fw = (command & 0x00000010) ? "Enabled" : "Disabled";
3023
        len += sprintf(page+len, "Fast Writes: \t %s\n", fw);
2950
        seq_printf(s, "Fast Writes: \t %s\n", fw);
3024
2951
3025
        sba = (command & 0x00000200) ? "Enabled" : "Disabled";
2952
        sba = (command & 0x00000200) ? "Enabled" : "Disabled";
3026
        len += sprintf(page+len, "SBA: \t\t %s\n", sba);
2953
        seq_printf(s, "SBA: \t\t %s\n", sba);
3027
    } else {
2954
    } else {
3028
        int agp_config = 0;
2955
        int agp_config = 0;
3029
2956
3030
        len += sprintf(page+len, "Status: \t Disabled\n\n");
2957
        seq_printf(s, "Status: \t Disabled\n\n");
3031
2958
3032
        /*
2959
        /*
3033
         * If we find AGP is disabled, but the RM registry indicates it
2960
         * If we find AGP is disabled, but the RM registry indicates it
Lines 3041-3047 Link Here
3041
        rm_read_registry_dword(nv, "NVreg", "XNvAGP", &agp_config);
2968
        rm_read_registry_dword(nv, "NVreg", "XNvAGP", &agp_config);
3042
2969
3043
        if (agp_config != NVOS_AGP_CONFIG_DISABLE_AGP && NV_AGP_FAILED(nv)) {
2970
        if (agp_config != NVOS_AGP_CONFIG_DISABLE_AGP && NV_AGP_FAILED(nv)) {
3044
            len += sprintf(page+len,
2971
            seq_printf(s,
3045
                  "AGP initialization failed, please check the ouput  \n"
2972
                  "AGP initialization failed, please check the ouput  \n"
3046
                  "of the 'dmesg' command and/or your system log file \n"
2973
                  "of the 'dmesg' command and/or your system log file \n"
3047
                  "for additional information on this problem.        \n");
2974
                  "for additional information on this problem.        \n");
Lines 3049-3083 Link Here
3049
    }
2976
    }
3050
2977
3051
    NV_PCI_DEV_PUT(dev);
2978
    NV_PCI_DEV_PUT(dev);
3052
    return len;
2979
    return 0;
3053
}
2980
}
3054
2981
2982
NV_DEFINE_PROCFS_SINGLE_FILE(agp_status);
2983
3055
extern nv_parm_t nv_parms[];
2984
extern nv_parm_t nv_parms[];
3056
extern char *NVreg_RegistryDwords;
2985
extern char *NVreg_RegistryDwords;
3057
2986
3058
static int
2987
static int
3059
nv_kern_read_registry(char *page, char **start, off_t off,
2988
nv_kern_read_registry(
3060
        int count, int *eof, void *data)
2989
    struct seq_file *s,
2990
    void *v
2991
)
3061
{
2992
{
3062
    unsigned int i, len = 0;
2993
    unsigned int i;
3063
    nv_parm_t *entry;
2994
    nv_parm_t *entry;
3064
    *eof = 1;
3065
2995
3066
    for (i = 0; (entry = &nv_parms[i])->name != NULL; i++)
2996
    for (i = 0; (entry = &nv_parms[i])->name != NULL; i++)
3067
        len += sprintf(page+len, "%s: %u\n", entry->name, *entry->data);
2997
        seq_printf(s, "%s: %u\n", entry->name, *entry->data);
3068
2998
3069
    len += sprintf(page+len, "RegistryDwords: \"%s\"\n",
2999
    seq_printf(s, "RegistryDwords: \"%s\"\n",
3070
                (NVreg_RegistryDwords != NULL) ? NVreg_RegistryDwords : "");
3000
               (NVreg_RegistryDwords != NULL) ? NVreg_RegistryDwords : "");
3071
3001
3072
    return len;
3002
    return 0;
3073
}
3003
}
3074
3004
3075
static int
3005
NV_DEFINE_PROCFS_SINGLE_FILE(registry);
3076
nv_kern_read_text_file(char *page, char **start, off_t off,
3006
3077
        int count, int *eof, void *data)
3007
static void nvos_proc_create(void)
3078
{
3008
{
3079
    *eof = 1;
3009
#ifdef CONFIG_PROC_FS
3080
    return sprintf(page, "%s", (char *)data);
3010
    struct pci_dev *dev;
3011
    U032 j, i = 0;
3012
    char name[6];
3013
3014
    struct proc_dir_entry *entry;
3015
    struct proc_dir_entry *proc_nvidia_agp, *proc_nvidia_cards;
3016
3017
    nv_state_t *nv;
3018
    nv_linux_state_t *nvl;
3019
3020
    proc_nvidia = NV_CREATE_PROC_DIR("driver/nvidia", NULL);
3021
    if (!proc_nvidia)
3022
        goto failed;
3023
3024
    proc_nvidia_cards = NV_CREATE_PROC_DIR("cards", proc_nvidia);
3025
    if (!proc_nvidia_cards)
3026
        goto failed;
3027
3028
    proc_nvidia_warnings = NV_CREATE_PROC_DIR("warnings", proc_nvidia);
3029
    if (!proc_nvidia_warnings)
3030
        goto failed;
3031
3032
    proc_nvidia_patches = NV_CREATE_PROC_DIR("patches", proc_nvidia);
3033
    if (!proc_nvidia_patches)
3034
        goto failed;
3035
3036
    for (j = 0; j < num_nv_devices; j++)
3037
    {
3038
        nvl = &nv_linux_devices[j];
3039
        nv = NV_STATE_PTR(nvl);
3040
3041
        dev = nv_get_pci_device(nv);
3042
        if (!dev)
3043
            break;
3044
3045
        sprintf(name, "%d", i++);
3046
        entry = NV_CREATE_PROC_FILE(name, proc_nvidia_cards, cardinfo, nv);
3047
        if (!entry) {
3048
            NV_PCI_DEV_PUT(dev);
3049
            goto failed;
3050
        }
3051
3052
        if (nvos_find_agp_capability(dev)) {
3053
            /*
3054
             * Create the /proc/driver/nvidia/agp/{status,host-bridge,card}
3055
             * entries now that we know there's AGP hardware.
3056
             */
3057
            entry = NV_CREATE_PROC_DIR("agp", proc_nvidia);
3058
            if (!entry) {
3059
                NV_PCI_DEV_PUT(dev);
3060
                goto failed;
3061
            }
3062
3063
#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
3064
            entry->owner = THIS_MODULE;
3065
#endif
3066
            proc_nvidia_agp = entry;
3067
3068
            entry = NV_CREATE_PROC_FILE("status", proc_nvidia_agp, agp_status,
3069
                nv);
3070
            if (!entry) {
3071
                NV_PCI_DEV_PUT(dev);
3072
                goto failed;
3073
            }
3074
3075
            entry = NV_CREATE_PROC_FILE("host-bridge", proc_nvidia_agp, agpinfo,
3076
                NULL);
3077
            if (!entry) {
3078
                NV_PCI_DEV_PUT(dev);
3079
                goto failed;
3080
            }
3081
3082
            entry = NV_CREATE_PROC_FILE("card", proc_nvidia_agp, agpinfo, nv);
3083
            if (!entry) {
3084
                NV_PCI_DEV_PUT(dev);
3085
                goto failed;
3086
            }
3087
        }
3088
3089
        NV_PCI_DEV_PUT(dev);
3090
    }
3091
3092
    entry = NV_CREATE_PROC_FILE("version", proc_nvidia, version, NULL);
3093
    if (!entry)
3094
        goto failed;
3095
3096
    entry = NV_CREATE_PROC_FILE("registry", proc_nvidia, registry, NULL);
3097
    if (!entry)
3098
        goto failed;
3099
3100
    return;
3101
3102
failed:
3103
    nv_printf(NV_DBG_ERRORS, "NVRM: failed to create /proc entries!\n");
3104
    nvos_proc_remove_all(proc_nvidia);
3105
#endif
3081
}
3106
}
3082
3107
3083
/***
3108
/***
(-)usr-patched1.orig/src/nv/nv.c.orig (-2 / +1 lines)
Lines 2348-2356 Link Here
2348
        NV_PRINT_AT(NV_DBG_MEMINFO, at);
2348
        NV_PRINT_AT(NV_DBG_MEMINFO, at);
2349
        nv_vm_list_page_count(&at->page_table[i], pages);
2349
        nv_vm_list_page_count(&at->page_table[i], pages);
2350
2350
2351
        /* prevent the swapper from swapping it out */
2352
        /* mark the memory i/o so the buffers aren't dumped on core dumps */
2353
        vma->vm_flags |= (VM_IO | VM_LOCKED | VM_RESERVED);
2351
        vma->vm_flags |= (VM_IO | VM_LOCKED | VM_RESERVED);
2352
        vma->vm_flags |= (VM_DONTEXPAND | VM_DONTDUMP);
2354
    }
2353
    }
2355
2354
2356
    NV_VMA_FILE(vma) = file;
2355
    NV_VMA_FILE(vma) = file;
(-)usr-patched1.orig/src/nv/os-interface.c (-1 / +9 lines)
Lines 261-267 Link Here
261
261
262
NvU64 NV_API_CALL os_get_system_memory_size(void)
262
NvU64 NV_API_CALL os_get_system_memory_size(void)
263
{
263
{
264
    return ((NvU64) num_physpages * PAGE_SIZE) / RM_PAGE_SIZE;
264
    NvU64 num_pages;
265
266
#if defined(NV_GET_NUM_PHYSPAGES_PRESENT)
267
    num_pages = get_num_physpages();
268
#else
269
    num_pages = num_physpages;
270
#endif
271
272
    return ((num_pages * PAGE_SIZE) / RM_PAGE_SIZE);
265
}
273
}
266
274
267
//
275
//

Return to bug 510020