Advertisement
Guest User

nVidia-319.32-LK310.patch

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