Lines 60-119
Link Here
|
60 |
__entry; \ |
60 |
__entry; \ |
61 |
}) |
61 |
}) |
62 |
|
62 |
|
63 |
#define NV_CREATE_PROC_FILE(name,parent,__read_proc, \ |
63 |
#define NV_PROC_RW (S_IFREG|S_IRUGO|S_IWUSR) |
64 |
__write_proc,__fops,__data) \ |
64 |
#define NV_PROC_RO (S_IFREG|S_IRUGO) |
65 |
({ \ |
|
|
66 |
struct proc_dir_entry *__entry; \ |
67 |
int __mode = (S_IFREG | S_IRUGO); \ |
68 |
if ((NvUPtr)(__write_proc) != 0) \ |
69 |
__mode |= S_IWUSR; \ |
70 |
__entry = NV_CREATE_PROC_ENTRY(name, __mode, parent); \ |
71 |
if (__entry != NULL) \ |
72 |
{ \ |
73 |
if ((NvUPtr)(__read_proc) != 0) \ |
74 |
__entry->read_proc = (__read_proc); \ |
75 |
if ((NvUPtr)(__write_proc) != 0) \ |
76 |
{ \ |
77 |
__entry->write_proc = (__write_proc); \ |
78 |
__entry->proc_fops = (__fops); \ |
79 |
} \ |
80 |
__entry->data = (__data); \ |
81 |
} \ |
82 |
__entry; \ |
83 |
}) |
84 |
|
65 |
|
85 |
#define NV_CREATE_PROC_DIR(name,parent) \ |
66 |
#define NV_CREATE_PROC_DIR(name,parent) \ |
86 |
({ \ |
67 |
({ \ |
87 |
struct proc_dir_entry *__entry; \ |
68 |
struct proc_dir_entry *__entry; \ |
88 |
int __mode = (S_IFDIR | S_IRUGO | S_IXUGO); \ |
69 |
int __mode = (S_IFDIR | S_IRUGO | S_IXUGO); \ |
89 |
__entry = NV_CREATE_PROC_ENTRY(name, __mode, parent); \ |
70 |
__entry = proc_mkdir_mode(name, __mode, parent); \ |
90 |
__entry; \ |
71 |
__entry; \ |
91 |
}) |
72 |
}) |
92 |
|
73 |
|
|
|
74 |
#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,9,255) |
75 |
static inline void *PDE_DATA(const struct inode *inode) { |
76 |
return PDE(inode)->data; |
77 |
} |
78 |
#endif |
79 |
|
93 |
#define NV_PROC_WRITE_BUFFER_SIZE (64 * RM_PAGE_SIZE) |
80 |
#define NV_PROC_WRITE_BUFFER_SIZE (64 * RM_PAGE_SIZE) |
94 |
|
81 |
|
95 |
static int |
82 |
static int |
96 |
nv_procfs_read_gpu_info( |
83 |
nv_procfs_show_gpu_info( |
97 |
char *page, |
84 |
struct seq_file *m, |
98 |
char **start, |
85 |
void *v |
99 |
off_t off, |
|
|
100 |
int count, |
101 |
int *eof, |
102 |
void *data |
103 |
) |
86 |
) |
104 |
{ |
87 |
{ |
105 |
nv_state_t *nv = data; |
88 |
nv_state_t *nv = m->private; |
106 |
nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv); |
89 |
nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv); |
107 |
struct pci_dev *dev = nvl->dev; |
90 |
struct pci_dev *dev = nvl->dev; |
108 |
char *type, *fmt, tmpstr[NV_DEVICE_NAME_LENGTH]; |
91 |
char *type, *fmt, tmpstr[NV_DEVICE_NAME_LENGTH]; |
109 |
int len = 0, status; |
92 |
int status; |
110 |
NvU8 *uuid; |
93 |
NvU8 *uuid; |
111 |
NvU32 vbios_rev1, vbios_rev2, vbios_rev3, vbios_rev4, vbios_rev5; |
94 |
NvU32 vbios_rev1, vbios_rev2, vbios_rev3, vbios_rev4, vbios_rev5; |
112 |
NvU32 fpga_rev1, fpga_rev2, fpga_rev3; |
95 |
NvU32 fpga_rev1, fpga_rev2, fpga_rev3; |
113 |
nv_stack_t *sp = NULL; |
96 |
nv_stack_t *sp = NULL; |
114 |
|
97 |
|
115 |
*eof = 1; |
|
|
116 |
|
117 |
NV_KMEM_CACHE_ALLOC_STACK(sp); |
98 |
NV_KMEM_CACHE_ALLOC_STACK(sp); |
118 |
if (sp == NULL) |
99 |
if (sp == NULL) |
119 |
{ |
100 |
{ |
Lines 134-164
Link Here
|
134 |
if (rm_get_device_name(sp, nv, dev->device, dev->subsystem_vendor, |
115 |
if (rm_get_device_name(sp, nv, dev->device, dev->subsystem_vendor, |
135 |
dev->subsystem_device, NV_DEVICE_NAME_LENGTH, |
116 |
dev->subsystem_device, NV_DEVICE_NAME_LENGTH, |
136 |
tmpstr) != RM_OK) |
117 |
tmpstr) != RM_OK) |
137 |
{ |
118 |
{ |
138 |
strcpy (tmpstr, "Unknown"); |
119 |
strcpy (tmpstr, "Unknown"); |
139 |
} |
120 |
} |
140 |
} |
121 |
} |
141 |
|
122 |
|
142 |
len += sprintf(page+len, "Model: \t\t %s\n", tmpstr); |
123 |
seq_printf(m, "Model: \t\t %s\n", tmpstr); |
143 |
len += sprintf(page+len, "IRQ: \t\t %d\n", nv->interrupt_line); |
124 |
seq_printf(m, "IRQ: \t\t %d\n", nv->interrupt_line); |
144 |
|
125 |
|
145 |
if (NV_IS_GVI_DEVICE(nv)) |
126 |
if (NV_IS_GVI_DEVICE(nv)) |
146 |
{ |
127 |
{ |
147 |
status = rm_gvi_get_firmware_version(sp, nv, &fpga_rev1, &fpga_rev2, |
128 |
status = rm_gvi_get_firmware_version(sp, nv, &fpga_rev1, &fpga_rev2, |
148 |
&fpga_rev3); |
129 |
&fpga_rev3); |
149 |
if (status != RM_OK) |
130 |
if (status != RM_OK) |
150 |
len += sprintf(page+len, "Firmware: \t ????.??.??\n"); |
131 |
seq_printf(m, "Firmware: \t ????.??.??\n"); |
151 |
else |
132 |
else |
152 |
{ |
133 |
{ |
153 |
fmt = "Firmware: \t %x.%x.%x\n"; |
134 |
fmt = "Firmware: \t %x.%x.%x\n"; |
154 |
len += sprintf(page+len, fmt, fpga_rev1, fpga_rev2, fpga_rev3); |
135 |
seq_printf(m, fmt, fpga_rev1, fpga_rev2, fpga_rev3); |
155 |
} |
136 |
} |
156 |
} |
137 |
} |
157 |
else |
138 |
else |
158 |
{ |
139 |
{ |
159 |
if (rm_get_gpu_uuid(sp, nv, &uuid, NULL) == RM_OK) |
140 |
if (rm_get_gpu_uuid(sp, nv, &uuid, NULL) == RM_OK) |
160 |
{ |
141 |
{ |
161 |
len += sprintf(page+len, "GPU UUID: \t %s\n", (char *)uuid); |
142 |
seq_printf(m, "GPU UUID: \t %s\n", (char *)uuid); |
162 |
os_free_mem(uuid); |
143 |
os_free_mem(uuid); |
163 |
} |
144 |
} |
164 |
|
145 |
|
Lines 166-177
Link Here
|
166 |
&vbios_rev3, &vbios_rev4, |
147 |
&vbios_rev3, &vbios_rev4, |
167 |
&vbios_rev5) != RM_OK) |
148 |
&vbios_rev5) != RM_OK) |
168 |
{ |
149 |
{ |
169 |
len += sprintf(page+len, "Video BIOS: \t ??.??.??.??.??\n"); |
150 |
seq_printf(m, "Video BIOS: \t ??.??.??.??.??\n"); |
170 |
} |
151 |
} |
171 |
else |
152 |
else |
172 |
{ |
153 |
{ |
173 |
fmt = "Video BIOS: \t %02x.%02x.%02x.%02x.%02x\n"; |
154 |
fmt = "Video BIOS: \t %02x.%02x.%02x.%02x.%02x\n"; |
174 |
len += sprintf(page+len, fmt, vbios_rev1, vbios_rev2, vbios_rev3, |
155 |
seq_printf(m, fmt, vbios_rev1, vbios_rev2, vbios_rev3, |
175 |
vbios_rev4, vbios_rev5); |
156 |
vbios_rev4, vbios_rev5); |
176 |
} |
157 |
} |
177 |
} |
158 |
} |
Lines 180-191
Link Here
|
180 |
type = "PCI-E"; |
161 |
type = "PCI-E"; |
181 |
else |
162 |
else |
182 |
type = "PCI"; |
163 |
type = "PCI"; |
183 |
len += sprintf(page+len, "Bus Type: \t %s\n", type); |
164 |
seq_printf(m, "Bus Type: \t %s\n", type); |
184 |
|
165 |
|
185 |
len += sprintf(page+len, "DMA Size: \t %d bits\n", |
166 |
seq_printf(m, "DMA Size: \t %d bits\n", |
186 |
nv_count_bits(dev->dma_mask)); |
167 |
nv_count_bits(dev->dma_mask)); |
187 |
len += sprintf(page+len, "DMA Mask: \t 0x%llx\n", dev->dma_mask); |
168 |
seq_printf(m, "DMA Mask: \t 0x%llx\n", dev->dma_mask); |
188 |
len += sprintf(page+len, "Bus Location: \t %04x:%02x.%02x.%x\n", |
169 |
seq_printf(m, "Bus Location: \t %04x:%02x.%02x.%x\n", |
189 |
nv->domain, nv->bus, nv->slot, PCI_FUNC(dev->devfn)); |
170 |
nv->domain, nv->bus, nv->slot, PCI_FUNC(dev->devfn)); |
190 |
#if defined(DEBUG) |
171 |
#if defined(DEBUG) |
191 |
do |
172 |
do |
Lines 193-199
Link Here
|
193 |
int j; |
174 |
int j; |
194 |
for (j = 0; j < NV_GPU_NUM_BARS; j++) |
175 |
for (j = 0; j < NV_GPU_NUM_BARS; j++) |
195 |
{ |
176 |
{ |
196 |
len += sprintf(page+len, "BAR%u: \t\t 0x%llx (%lluMB)\n", |
177 |
seq_printf(m, "BAR%u: \t\t 0x%llx (%lluMB)\n", |
197 |
j, nv->bars[j].address, (nv->bars[j].size >> 20)); |
178 |
j, nv->bars[j].address, (nv->bars[j].size >> 20)); |
198 |
} |
179 |
} |
199 |
} while (0); |
180 |
} while (0); |
Lines 201-226
Link Here
|
201 |
|
182 |
|
202 |
NV_KMEM_CACHE_FREE_STACK(sp); |
183 |
NV_KMEM_CACHE_FREE_STACK(sp); |
203 |
|
184 |
|
204 |
return len; |
185 |
return 0; |
205 |
} |
186 |
} |
206 |
|
187 |
|
207 |
static int |
188 |
static int |
208 |
nv_procfs_read_version( |
189 |
nv_procfs_open_gpu_info( |
209 |
char *page, |
190 |
struct inode *inode, |
210 |
char **start, |
191 |
struct file *file |
211 |
off_t off, |
192 |
) |
212 |
int count, |
193 |
{ |
213 |
int *eof, |
194 |
return single_open(file, nv_procfs_show_gpu_info, PDE_DATA(inode)); |
214 |
void *data |
195 |
} |
|
|
196 |
|
197 |
static const struct file_operations nv_procfs_gpu_info_fops = { |
198 |
.owner = THIS_MODULE, |
199 |
.open = nv_procfs_open_gpu_info, |
200 |
.read = seq_read, |
201 |
.llseek = seq_lseek, |
202 |
.release = single_release, |
203 |
}; |
204 |
|
205 |
static int |
206 |
nv_procfs_show_version( |
207 |
struct seq_file *m, |
208 |
void *v |
209 |
) |
210 |
{ |
211 |
seq_printf(m, "NVRM version: %s\n", pNVRM_ID); |
212 |
seq_printf(m, "GCC version: %s\n", NV_COMPILER); |
213 |
|
214 |
return 0; |
215 |
} |
216 |
|
217 |
static int |
218 |
nv_procfs_open_version( |
219 |
struct inode *inode, |
220 |
struct file *file |
221 |
) |
222 |
{ |
223 |
return single_open(file, nv_procfs_show_version, NULL); |
224 |
} |
225 |
|
226 |
static const struct file_operations nv_procfs_version_fops = { |
227 |
.owner = THIS_MODULE, |
228 |
.open = nv_procfs_open_version, |
229 |
.read = seq_read, |
230 |
.llseek = seq_lseek, |
231 |
.release = single_release, |
232 |
}; |
233 |
|
234 |
static int |
235 |
nv_procfs_show_registry( |
236 |
struct seq_file *m, |
237 |
void *v |
238 |
) |
239 |
{ |
240 |
nv_state_t *nv = m->private; |
241 |
nv_linux_state_t *nvl = NULL; |
242 |
char *registry_keys; |
243 |
|
244 |
if (nv != NULL) |
245 |
nvl = NV_GET_NVL_FROM_NV_STATE(nv); |
246 |
registry_keys = ((nvl != NULL) ? |
247 |
nvl->registry_keys : nv_registry_keys); |
248 |
|
249 |
seq_printf(m, "Binary: \"%s\"\n", registry_keys); |
250 |
|
251 |
return 0; |
252 |
} |
253 |
|
254 |
static ssize_t |
255 |
nv_procfs_write_registry( |
256 |
struct file *file, |
257 |
const char __user *buffer, |
258 |
size_t count, |
259 |
loff_t *pos |
215 |
) |
260 |
) |
216 |
{ |
261 |
{ |
217 |
int len = 0; |
262 |
int status = 0; |
218 |
*eof = 1; |
263 |
nv_file_private_t *nvfp = NV_GET_FILE_PRIVATE(file); |
|
|
264 |
char *proc_buffer; |
265 |
unsigned long bytes_left; |
266 |
|
267 |
down(&nvfp->fops_sp_lock[NV_FOPS_STACK_INDEX_PROCFS]); |
268 |
|
269 |
bytes_left = (NV_PROC_WRITE_BUFFER_SIZE - nvfp->off - 1); |
270 |
|
271 |
if (count == 0) |
272 |
{ |
273 |
status = -EINVAL; |
274 |
goto done; |
275 |
} |
276 |
else if ((bytes_left == 0) || (count > bytes_left)) |
277 |
{ |
278 |
status = -ENOSPC; |
279 |
goto done; |
280 |
} |
281 |
|
282 |
proc_buffer = &((char *)nvfp->data)[nvfp->off]; |
283 |
|
284 |
if (copy_from_user(proc_buffer, buffer, count)) |
285 |
{ |
286 |
nv_printf(NV_DBG_ERRORS, "NVRM: failed to copy in proc data!\n"); |
287 |
status = -EFAULT; |
288 |
} |
289 |
else |
290 |
{ |
291 |
nvfp->proc_data = PDE_DATA(file->f_inode); |
292 |
nvfp->off += count; |
293 |
} |
219 |
|
294 |
|
220 |
len += sprintf(page+len, "NVRM version: %s\n", pNVRM_ID); |
295 |
done: |
221 |
len += sprintf(page+len, "GCC version: %s\n", NV_COMPILER); |
296 |
up(&nvfp->fops_sp_lock[NV_FOPS_STACK_INDEX_PROCFS]); |
222 |
|
297 |
|
223 |
return len; |
298 |
return ((status < 0) ? status : count); |
224 |
} |
299 |
} |
225 |
|
300 |
|
226 |
static int |
301 |
static int |
Lines 233-239
Link Here
|
233 |
nv_stack_t *sp = NULL; |
308 |
nv_stack_t *sp = NULL; |
234 |
|
309 |
|
235 |
if (0 == (file->f_mode & FMODE_WRITE)) |
310 |
if (0 == (file->f_mode & FMODE_WRITE)) |
236 |
return 0; |
311 |
return single_open(file, nv_procfs_show_registry, PDE_DATA(inode)); |
237 |
|
312 |
|
238 |
nvfp = nv_alloc_file_private(); |
313 |
nvfp = nv_alloc_file_private(); |
239 |
if (nvfp == NULL) |
314 |
if (nvfp == NULL) |
Lines 282-287
Link Here
|
282 |
RM_STATUS rm_status; |
357 |
RM_STATUS rm_status; |
283 |
int rc = 0; |
358 |
int rc = 0; |
284 |
|
359 |
|
|
|
360 |
if (0 == (file->f_mode & FMODE_WRITE)) |
361 |
return single_release(inode, file); |
362 |
|
285 |
nvfp = NV_GET_FILE_PRIVATE(file); |
363 |
nvfp = NV_GET_FILE_PRIVATE(file); |
286 |
if (nvfp == NULL) |
364 |
if (nvfp == NULL) |
287 |
return 0; |
365 |
return 0; |
Lines 346-466
Link Here
|
346 |
return rc; |
424 |
return rc; |
347 |
} |
425 |
} |
348 |
|
426 |
|
349 |
static struct file_operations nv_procfs_registry_fops = { |
427 |
static const struct file_operations nv_procfs_registry_fops = { |
350 |
.open = nv_procfs_open_registry, |
428 |
.open = nv_procfs_open_registry, |
|
|
429 |
.read = seq_read, |
430 |
.llseek = seq_lseek, |
431 |
.write = nv_procfs_write_registry, |
351 |
.release = nv_procfs_close_registry, |
432 |
.release = nv_procfs_close_registry, |
352 |
}; |
433 |
}; |
353 |
|
434 |
|
354 |
static int |
435 |
static int |
355 |
nv_procfs_read_params( |
436 |
nv_procfs_show_params( |
356 |
char *page, |
437 |
struct seq_file *m, |
357 |
char **start, |
438 |
void *v |
358 |
off_t off, |
|
|
359 |
int count, |
360 |
int *eof, |
361 |
void *data |
362 |
) |
439 |
) |
363 |
{ |
440 |
{ |
364 |
unsigned int i; |
441 |
unsigned int i; |
365 |
int len = 0; |
|
|
366 |
nv_parm_t *entry; |
442 |
nv_parm_t *entry; |
367 |
|
443 |
|
368 |
*eof = 1; |
|
|
369 |
|
444 |
|
370 |
for (i = 0; (entry = &nv_parms[i])->name != NULL; i++) |
445 |
for (i = 0; (entry = &nv_parms[i])->name != NULL; i++) |
371 |
len += sprintf(page+len, "%s: %u\n", entry->name, *entry->data); |
446 |
seq_printf(m, "%s: %u\n", entry->name, *entry->data); |
372 |
|
447 |
|
373 |
len += sprintf(page+len, "RegistryDwords: \"%s\"\n", |
448 |
seq_printf(m, "RegistryDwords: \"%s\"\n", |
374 |
(NVreg_RegistryDwords != NULL) ? NVreg_RegistryDwords : ""); |
449 |
(NVreg_RegistryDwords != NULL) ? NVreg_RegistryDwords : ""); |
375 |
len += sprintf(page+len, "RmMsg: \"%s\"\n", |
450 |
seq_printf(m, "RmMsg: \"%s\"\n", |
376 |
(NVreg_RmMsg != NULL) ? NVreg_RmMsg : ""); |
451 |
(NVreg_RmMsg != NULL) ? NVreg_RmMsg : ""); |
377 |
return len; |
452 |
return 0; |
378 |
} |
453 |
} |
379 |
|
454 |
|
380 |
static int |
455 |
static int |
381 |
nv_procfs_read_registry( |
456 |
nv_procfs_open_params( |
382 |
char *page, |
457 |
struct inode *inode, |
383 |
char **start, |
458 |
struct file *file |
384 |
off_t off, |
459 |
) |
385 |
int count, |
|
|
386 |
int *eof, |
387 |
void *data |
388 |
) |
389 |
{ |
460 |
{ |
390 |
nv_state_t *nv = data; |
461 |
return single_open(file, nv_procfs_show_params, NULL); |
391 |
nv_linux_state_t *nvl = NULL; |
462 |
} |
392 |
char *registry_keys; |
|
|
393 |
|
463 |
|
394 |
if (nv != NULL) |
464 |
static const struct file_operations nv_procfs_params_fops = { |
395 |
nvl = NV_GET_NVL_FROM_NV_STATE(nv); |
465 |
.owner = THIS_MODULE, |
396 |
registry_keys = ((nvl != NULL) ? |
466 |
.open = nv_procfs_open_params, |
397 |
nvl->registry_keys : nv_registry_keys); |
467 |
.read = seq_read, |
|
|
468 |
.llseek = seq_lseek, |
469 |
.release = single_release, |
470 |
}; |
398 |
|
471 |
|
399 |
*eof = 1; |
|
|
400 |
return sprintf(page, "Binary: \"%s\"\n", registry_keys); |
401 |
} |
402 |
|
472 |
|
403 |
static int |
473 |
static int |
404 |
nv_procfs_write_registry( |
474 |
nv_procfs_show_text_file( |
405 |
struct file *file, |
475 |
struct seq_file *m, |
406 |
const char *buffer, |
476 |
void *v |
407 |
unsigned long count, |
|
|
408 |
void *data |
409 |
) |
477 |
) |
410 |
{ |
478 |
{ |
411 |
int status = 0; |
479 |
seq_printf(m, "%s", (char *)m->private); |
412 |
nv_file_private_t *nvfp = NV_GET_FILE_PRIVATE(file); |
|
|
413 |
char *proc_buffer; |
414 |
unsigned long bytes_left; |
415 |
|
416 |
down(&nvfp->fops_sp_lock[NV_FOPS_STACK_INDEX_PROCFS]); |
417 |
|
418 |
bytes_left = (NV_PROC_WRITE_BUFFER_SIZE - nvfp->off - 1); |
419 |
|
480 |
|
420 |
if (count == 0) |
481 |
return 0; |
421 |
{ |
|
|
422 |
status = -EINVAL; |
423 |
goto done; |
424 |
} |
425 |
else if ((bytes_left == 0) || (count > bytes_left)) |
426 |
{ |
427 |
status = -ENOSPC; |
428 |
goto done; |
429 |
} |
430 |
|
431 |
proc_buffer = &((char *)nvfp->data)[nvfp->off]; |
432 |
|
433 |
if (copy_from_user(proc_buffer, buffer, count)) |
434 |
{ |
435 |
nv_printf(NV_DBG_ERRORS, "NVRM: failed to copy in proc data!\n"); |
436 |
status = -EFAULT; |
437 |
} |
438 |
else |
439 |
{ |
440 |
nvfp->proc_data = data; |
441 |
nvfp->off += count; |
442 |
} |
443 |
|
444 |
done: |
445 |
up(&nvfp->fops_sp_lock[NV_FOPS_STACK_INDEX_PROCFS]); |
446 |
|
447 |
return ((status < 0) ? status : (int)count); |
448 |
} |
482 |
} |
449 |
|
483 |
|
450 |
static int |
484 |
static int |
451 |
nv_procfs_read_text_file( |
485 |
nv_procfs_open_text_file( |
452 |
char *page, |
486 |
struct inode *inode, |
453 |
char **start, |
487 |
struct file *file |
454 |
off_t off, |
|
|
455 |
int count, |
456 |
int *eof, |
457 |
void *data |
458 |
) |
488 |
) |
459 |
{ |
489 |
{ |
460 |
*eof = 1; |
490 |
return single_open(file, nv_procfs_show_text_file, PDE_DATA(inode)); |
461 |
return sprintf(page, "%s", (char *)data); |
|
|
462 |
} |
491 |
} |
463 |
|
492 |
|
|
|
493 |
static const struct file_operations nv_procfs_text_fops = { |
494 |
.owner = THIS_MODULE, |
495 |
.open = nv_procfs_open_text_file, |
496 |
.read = seq_read, |
497 |
.llseek = seq_lseek, |
498 |
.release = single_release, |
499 |
}; |
500 |
|
464 |
static void |
501 |
static void |
465 |
nv_procfs_add_text_file( |
502 |
nv_procfs_add_text_file( |
466 |
struct proc_dir_entry *parent, |
503 |
struct proc_dir_entry *parent, |
Lines 469-490
Link Here
|
469 |
const char *text |
506 |
const char *text |
470 |
) |
507 |
) |
471 |
{ |
508 |
{ |
472 |
NV_CREATE_PROC_FILE(filename, parent, |
509 |
proc_create_data(filename, NV_PROC_RO, parent, &nv_procfs_text_fops, (void *)text); |
473 |
nv_procfs_read_text_file, NULL, NULL, (void *)text); |
|
|
474 |
} |
475 |
|
476 |
static void nv_procfs_unregister_all(struct proc_dir_entry *entry) |
477 |
{ |
478 |
while (entry) |
479 |
{ |
480 |
struct proc_dir_entry *next = entry->next; |
481 |
if (entry->subdir) |
482 |
nv_procfs_unregister_all(entry->subdir); |
483 |
remove_proc_entry(entry->name, entry->parent); |
484 |
if (entry == proc_nvidia) |
485 |
break; |
486 |
entry = next; |
487 |
} |
488 |
} |
510 |
} |
489 |
#endif |
511 |
#endif |
490 |
|
512 |
|
Lines 513-538
Link Here
|
513 |
if (!proc_nvidia) |
535 |
if (!proc_nvidia) |
514 |
goto failed; |
536 |
goto failed; |
515 |
|
537 |
|
516 |
entry = NV_CREATE_PROC_FILE("params", proc_nvidia, |
538 |
entry = proc_create("params", NV_PROC_RO, proc_nvidia, &nv_procfs_params_fops); |
517 |
nv_procfs_read_params, NULL, NULL, NULL); |
|
|
518 |
if (!entry) |
539 |
if (!entry) |
519 |
goto failed; |
540 |
goto failed; |
520 |
|
541 |
|
521 |
/* |
542 |
entry = proc_create("registry", NV_PROC_RW, proc_nvidia, &nv_procfs_registry_fops); |
522 |
* entry->proc_fops originally points to a constant |
|
|
523 |
* structure, so to add more methods for the |
524 |
* binary registry write path, we need to replace the |
525 |
* said entry->proc_fops with a new fops structure. |
526 |
* However, in preparation for this, we need to preserve |
527 |
* the procfs read() and write() operations. |
528 |
*/ |
529 |
nv_procfs_registry_fops.read = entry->proc_fops->read; |
530 |
nv_procfs_registry_fops.write = entry->proc_fops->write; |
531 |
|
532 |
entry = NV_CREATE_PROC_FILE("registry", proc_nvidia, |
533 |
nv_procfs_read_registry, |
534 |
nv_procfs_write_registry, |
535 |
&nv_procfs_registry_fops, NULL); |
536 |
if (!entry) |
543 |
if (!entry) |
537 |
goto failed; |
544 |
goto failed; |
538 |
|
545 |
|
Lines 553-560
Link Here
|
553 |
|
560 |
|
554 |
nv_procfs_add_text_file(proc_nvidia_patches, "README", __README_patches); |
561 |
nv_procfs_add_text_file(proc_nvidia_patches, "README", __README_patches); |
555 |
|
562 |
|
556 |
entry = NV_CREATE_PROC_FILE("version", proc_nvidia, |
563 |
entry = proc_create("version", NV_PROC_RO, proc_nvidia, &nv_procfs_version_fops); |
557 |
nv_procfs_read_version, NULL, NULL, NULL); |
|
|
558 |
if (!entry) |
564 |
if (!entry) |
559 |
goto failed; |
565 |
goto failed; |
560 |
|
566 |
|
Lines 571-585
Link Here
|
571 |
if (!proc_nvidia_gpu) |
577 |
if (!proc_nvidia_gpu) |
572 |
goto failed; |
578 |
goto failed; |
573 |
|
579 |
|
574 |
entry = NV_CREATE_PROC_FILE("information", proc_nvidia_gpu, |
580 |
entry = proc_create_data("information", NV_PROC_RO, proc_nvidia_gpu, &nv_procfs_gpu_info_fops, nv); |
575 |
nv_procfs_read_gpu_info, NULL, NULL, nv); |
|
|
576 |
if (!entry) |
581 |
if (!entry) |
577 |
goto failed; |
582 |
goto failed; |
578 |
|
583 |
|
579 |
entry = NV_CREATE_PROC_FILE("registry", proc_nvidia_gpu, |
584 |
entry = proc_create_data("registry", NV_PROC_RW, proc_nvidia_gpu, &nv_procfs_registry_fops, nv); |
580 |
nv_procfs_read_registry, |
|
|
581 |
nv_procfs_write_registry, |
582 |
&nv_procfs_registry_fops, nv); |
583 |
if (!entry) |
585 |
if (!entry) |
584 |
goto failed; |
586 |
goto failed; |
585 |
} |
587 |
} |
Lines 587-593
Link Here
|
587 |
return 0; |
589 |
return 0; |
588 |
#if defined(CONFIG_PROC_FS) |
590 |
#if defined(CONFIG_PROC_FS) |
589 |
failed: |
591 |
failed: |
590 |
nv_procfs_unregister_all(proc_nvidia); |
592 |
remove_proc_subtree("nvidia", proc_nvidia); |
591 |
return -1; |
593 |
return -1; |
592 |
#endif |
594 |
#endif |
593 |
} |
595 |
} |
Lines 595-600
Link Here
|
595 |
void nv_unregister_procfs(void) |
597 |
void nv_unregister_procfs(void) |
596 |
{ |
598 |
{ |
597 |
#if defined(CONFIG_PROC_FS) |
599 |
#if defined(CONFIG_PROC_FS) |
598 |
nv_procfs_unregister_all(proc_nvidia); |
600 |
remove_proc_subtree("nvidia", proc_nvidia); |
599 |
#endif |
601 |
#endif |
600 |
} |
602 |
} |