Advertisement
Guest User

kernel-5.6.patch

a guest
Apr 6th, 2020
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 11.48 KB | None | 0 0
  1. diff --git a/Makefile b/Makefile
  2. index 125a690..7575e44 100644
  3. --- a/Makefile
  4. +++ b/Makefile
  5. @@ -114,6 +114,7 @@ COMPILE_TESTS = \
  6.     nvmap_support \
  7.     acpi_evaluate_integer \
  8.     ioremap_cache \
  9. +   ioremap_nocache \
  10.     ioremap_wc \
  11.     proc_dir_entry \
  12.     INIT_WORK \
  13. @@ -132,6 +133,7 @@ COMPILE_TESTS = \
  14.     proc_create_data \
  15.     pde_data \
  16.     proc_remove \
  17. +   proc_ops \
  18.     sg_table \
  19.     pm_vt_switch_required \
  20.     pci_save_state \
  21. @@ -148,8 +150,10 @@ COMPILE_TESTS = \
  22.     vm_fault_has_address \
  23.     drm_driver_unload_has_int_return_type \
  24.     drm_legacy_pci_init \
  25. +   drm_pci_init \
  26.     timer_setup \
  27.     do_gettimeofday \
  28. +   timeval \
  29.     drm_gem_object_put_unlocked \
  30.     drm_driver_legacy_feature_bit_present \
  31.     drm_driver_prime_flag_present
  32. diff --git a/conftest.sh b/conftest.sh
  33. index b7a85f0..08b20cd 100755
  34. --- a/conftest.sh
  35. +++ b/conftest.sh
  36. @@ -1188,6 +1188,19 @@ compile_test() {
  37.              compile_check_conftest "$CODE" "NV_IOREMAP_CACHE_PRESENT" "" "functions"
  38.          ;;
  39.  
  40. +        ioremap_nocache)
  41. +            #
  42. +            # Determine if the ioremap_nocache() function is present.
  43. +            #
  44. +            CODE="
  45. +            #include <asm/io.h>
  46. +            void conftest_ioremap_nocache(void) {
  47. +                ioremap_nocache();
  48. +            }"
  49. +
  50. +            compile_check_conftest "$CODE" "NV_IOREMAP_NOCACHE_PRESENT" "" "functions"
  51. +        ;;
  52. +
  53.          ioremap_wc)
  54.              #
  55.              # Determine if the ioremap_wc() function is present.
  56. @@ -1607,6 +1620,19 @@ compile_test() {
  57.              compile_check_conftest "$CODE" "NV_PROC_REMOVE_PRESENT" "" "functions"
  58.          ;;
  59.  
  60. +        proc_ops)
  61. +            #
  62. +            # Determine if struct proc_ops is present.
  63. +            #
  64. +            CODE="
  65. +            #include <linux/proc_fs.h>
  66. +            void conftest_proc_ops(void) {
  67. +                struct proc_ops pops;
  68. +            }"
  69. +
  70. +            compile_check_conftest "$CODE" "NV_PROC_OPS_PRESENT" "" "types"
  71. +        ;;
  72. +
  73.          vm_operations_struct)
  74.              #
  75.              # Determine if the 'vm_operations_struct' structure has
  76. @@ -2066,6 +2092,28 @@ compile_test() {
  77.              compile_check_conftest "$CODE" "NV_DRM_LEGACY_PCI_INIT_PRESENT" "" "functions"
  78.          ;;
  79.  
  80. +        drm_pci_init)
  81. +            #
  82. +            # Determine if drm_pci_init() is present. drm_pci_init() was
  83. +            # deprecated and renamed to drm_legacy_pci_init by:
  84. +            #
  85. +            #  2017-05-24  10631d724deff712343d96dd3017cd323349f761
  86. +            #
  87. +            CODE="
  88. +            #if defined(NV_DRM_DRMP_H_PRESENT)
  89. +            #include <drm/drmP.h>
  90. +            #endif
  91. +
  92. +            #if defined(NV_DRM_DRM_PCI_H_PRESENT)
  93. +            #include <drm/drm_pci.h>
  94. +            #endif
  95. +            void conftest_drm_pci_init(void) {
  96. +                drm_pci_init();
  97. +            }"
  98. +
  99. +            compile_check_conftest "$CODE" "NV_DRM_PCI_INIT_PRESENT" "" "functions"
  100. +        ;;
  101. +
  102.          timer_setup)
  103.              #
  104.              # Determine if the function timer_setup() is present.
  105. @@ -2109,6 +2157,22 @@ compile_test() {
  106.              compile_check_conftest "$CODE" "NV_DO_GETTIMEOFDAY_PRESENT" "" "functions"
  107.          ;;
  108.  
  109. +       timeval)
  110. +            #
  111. +            # Determine if timeval is present.
  112. +            #
  113. +            CODE="
  114. +            #include <linux/time.h>
  115. +            #if defined(NV_LINUX_KTIME_H_PRESENT)
  116. +            #include <linux/ktime.h>
  117. +            #endif
  118. +            void conftest_timeval(void) {
  119. +                struct timeval tv;
  120. +            }"
  121. +
  122. +            compile_check_conftest "$CODE" "NV_TIMEVAL_PRESENT" "" "types"
  123. +        ;;
  124. +
  125.          drm_gem_object_put_unlocked)
  126.              #
  127.              # Determine if the function drm_gem_object_put_unlocked() is present.
  128. diff --git a/nv-drm.c b/nv-drm.c
  129. index 0d1cdbf..4e6fa48 100644
  130. --- a/nv-drm.c
  131. +++ b/nv-drm.c
  132. @@ -47,7 +47,61 @@
  133.  #include <drm/drm_gem.h>
  134.  #endif
  135.  
  136. -#if defined(NV_DRM_LEGACY_PCI_INIT_PRESENT)
  137. +#if !defined(NV_DRM_LEGACY_PCI_INIT_PRESENT) && !defined(NV_DRM_PCI_INIT_PRESENT)
  138. +static int nv_drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
  139. +{
  140. +   struct pci_dev *pdev = NULL;
  141. +   const struct pci_device_id *pid;
  142. +   int i;
  143. +
  144. +   DRM_DEBUG("\n");
  145. +
  146. +   if (WARN_ON(!(driver->driver_features & DRIVER_LEGACY)))
  147. +       return -EINVAL;
  148. +
  149. +   /* If not using KMS, fall back to stealth mode manual scanning. */
  150. +   INIT_LIST_HEAD(&driver->legacy_dev_list);
  151. +   for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
  152. +       pid = &pdriver->id_table[i];
  153. +
  154. +       /* Loop around setting up a DRM device for each PCI device
  155. +        * matching our ID and device class.  If we had the internal
  156. +        * function that pci_get_subsys and pci_get_class used, we'd
  157. +        * be able to just pass pid in instead of doing a two-stage
  158. +        * thing.
  159. +        */
  160. +       pdev = NULL;
  161. +       while ((pdev =
  162. +           pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
  163. +                      pid->subdevice, pdev)) != NULL) {
  164. +           if ((pdev->class & pid->class_mask) != pid->class)
  165. +               continue;
  166. +
  167. +           /* stealth mode requires a manual probe */
  168. +           pci_dev_get(pdev);
  169. +           drm_get_pci_dev(pdev, pid, driver);
  170. +       }
  171. +   }
  172. +   return 0;
  173. +}
  174. +
  175. +static void nv_drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
  176. +{
  177. +   struct drm_device *dev, *tmp;
  178. +   DRM_DEBUG("\n");
  179. +
  180. +   if (!(driver->driver_features & DRIVER_LEGACY)) {
  181. +       WARN_ON(1);
  182. +   } else {
  183. +       list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
  184. +                    legacy_dev_list) {
  185. +           list_del(&dev->legacy_dev_list);
  186. +           drm_put_dev(dev);
  187. +       }
  188. +   }
  189. +   DRM_INFO("Module unloaded\n");
  190. +}
  191. +#elif defined(NV_DRM_LEGACY_PCI_INIT_PRESENT)
  192.  #define nv_drm_pci_init drm_legacy_pci_init
  193.  #define nv_drm_pci_exit drm_legacy_pci_exit
  194.  #else
  195. diff --git a/nv-linux.h b/nv-linux.h
  196. index b90eb95..1d709a3 100644
  197. --- a/nv-linux.h
  198. +++ b/nv-linux.h
  199. @@ -688,11 +688,15 @@ extern nv_spinlock_t km_lock;
  200.          VM_ALLOC_RECORD(ptr, size, "vm_ioremap"); \
  201.      }
  202.  
  203. +#if defined(NV_IOREMAP_NOCACHE_PRESENT)
  204.  #define NV_IOREMAP_NOCACHE(ptr, physaddr, size) \
  205.      { \
  206.          (ptr) = ioremap_nocache(physaddr, size); \
  207.          VM_ALLOC_RECORD(ptr, size, "vm_ioremap_nocache"); \
  208.      }
  209. +#else
  210. +#define NV_IOREMAP_NOCACHE NV_IOREMAP
  211. +#endif
  212.  
  213.  #if defined(NV_IOREMAP_CACHE_PRESENT)
  214.  #define NV_IOREMAP_CACHE(ptr, physaddr, size)            \
  215. @@ -1989,6 +1993,19 @@ extern NvU32 nv_assign_gpu_count;
  216.      })
  217.  #endif
  218.  
  219. +#if defined(NV_PROC_OPS_PRESENT)
  220. +#define NV_CREATE_PROC_FILE(filename,parent,__name,__data)               \
  221. +   ({                                                                    \
  222. +        struct proc_dir_entry *__entry;                                  \
  223. +        int mode = (S_IFREG | S_IRUGO);                                  \
  224. +        const struct proc_ops *fops = &nv_procfs_##__name##_fops;        \
  225. +        if (fops->proc_write != 0)                                       \
  226. +            mode |= S_IWUSR;                                             \
  227. +        __entry = NV_CREATE_PROC_ENTRY(filename, mode, parent, fops,     \
  228. +            __data);                                                     \
  229. +        __entry;                                                         \
  230. +    })
  231. +#else
  232.  #define NV_CREATE_PROC_FILE(filename,parent,__name,__data)               \
  233.     ({                                                                    \
  234.          struct proc_dir_entry *__entry;                                  \
  235. @@ -2000,6 +2017,7 @@ extern NvU32 nv_assign_gpu_count;
  236.              __data);                                                     \
  237.          __entry;                                                         \
  238.      })
  239. +#endif
  240.  
  241.  /*
  242.   * proc_mkdir_mode exists in Linux 2.6.9, but isn't exported until Linux 3.0.
  243. @@ -2041,6 +2059,24 @@ extern NvU32 nv_assign_gpu_count;
  244.      remove_proc_entry(entry->name, entry->parent);
  245.  #endif
  246.  
  247. +#if defined(NV_PROC_OPS_PRESENT)
  248. +#define NV_DEFINE_PROCFS_SINGLE_FILE(__name)                                  \
  249. +    static int nv_procfs_open_##__name(                                       \
  250. +        struct inode *inode,                                                  \
  251. +        struct file *filep                                                    \
  252. +    )                                                                         \
  253. +    {                                                                         \
  254. +        return single_open(filep, nv_procfs_read_##__name,                    \
  255. +            NV_PDE_DATA(inode));                                              \
  256. +    }                                                                         \
  257. +                                                                              \
  258. +    static const struct proc_ops nv_procfs_##__name##_fops = {                \
  259. +        .proc_open       = nv_procfs_open_##__name,                           \
  260. +        .proc_read       = seq_read,                                          \
  261. +        .proc_lseek     = seq_lseek,                                          \
  262. +        .proc_release    = single_release,                                    \
  263. +    };
  264. +#else
  265.  #define NV_DEFINE_PROCFS_SINGLE_FILE(__name)                                  \
  266.      static int nv_procfs_open_##__name(                                       \
  267.          struct inode *inode,                                                  \
  268. @@ -2058,6 +2094,7 @@ extern NvU32 nv_assign_gpu_count;
  269.          .llseek     = seq_lseek,                                              \
  270.          .release    = single_release,                                         \
  271.      };
  272. +#endif
  273.  
  274.  #endif  /* CONFIG_PROC_FS */
  275.  
  276. diff --git a/nv-procfs.c b/nv-procfs.c
  277. index ebca3e8..110cce1 100644
  278. --- a/nv-procfs.c
  279. +++ b/nv-procfs.c
  280. @@ -409,6 +409,15 @@ done:
  281.      return ((status < 0) ? status : (int)count);
  282.  }
  283.  
  284. +#if defined(NV_PROC_OPS_PRESENT)
  285. +static struct proc_ops nv_procfs_registry_fops = {
  286. +    .proc_open    = nv_procfs_open_registry,
  287. +    .proc_read    = seq_read,
  288. +    .proc_write   = nv_procfs_write_file,
  289. +    .proc_lseek   = seq_lseek,
  290. +    .proc_release = nv_procfs_close_registry,
  291. +};
  292. +#else
  293.  static struct file_operations nv_procfs_registry_fops = {
  294.      .owner   = THIS_MODULE,
  295.      .open    = nv_procfs_open_registry,
  296. @@ -417,6 +426,7 @@ static struct file_operations nv_procfs_registry_fops = {
  297.      .llseek  = seq_lseek,
  298.      .release = nv_procfs_close_registry,
  299.  };
  300. +#endif
  301.  
  302.  static int
  303.  nv_procfs_read_unbind_lock(
  304. @@ -538,6 +548,15 @@ done:
  305.      return rc;
  306.  }
  307.  
  308. +#if defined(NV_PROC_OPS_PRESENT)
  309. +static struct proc_ops nv_procfs_unbind_lock_fops = {
  310. +    .proc_open    = nv_procfs_open_unbind_lock,
  311. +    .proc_read    = seq_read,
  312. +    .proc_write   = nv_procfs_write_file,
  313. +    .proc_lseek   = seq_lseek,
  314. +    .proc_release = nv_procfs_close_unbind_lock,
  315. +};
  316. +#else
  317.  static struct file_operations nv_procfs_unbind_lock_fops = {
  318.      .owner   = THIS_MODULE,
  319.      .open    = nv_procfs_open_unbind_lock,
  320. @@ -546,6 +565,7 @@ static struct file_operations nv_procfs_unbind_lock_fops = {
  321.      .llseek  = seq_lseek,
  322.      .release = nv_procfs_close_unbind_lock,
  323.  };
  324. +#endif
  325.  
  326.  static int
  327.  nv_procfs_read_text_file(
  328. diff --git a/nv-time.h b/nv-time.h
  329. index a34ceb2..c904913 100644
  330. --- a/nv-time.h
  331. +++ b/nv-time.h
  332. @@ -28,6 +28,10 @@
  333.  #include <linux/ktime.h>
  334.  #endif
  335.  
  336. +#if !defined(NV_TIMEVAL_PRESENT)
  337. +#define timeval __kernel_old_timeval
  338. +#endif
  339. +
  340.  static inline void nv_gettimeofday(struct timeval *tv)
  341.  {
  342.  #ifdef NV_DO_GETTIMEOFDAY_PRESENT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement