Advertisement
Viterzgir

0011-fix-compile-on-5.18.patch

May 14th, 2022
1,143
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. This fixes building 304.108 legacy diviers on 5.18+ kernels as 5.18 kernel introduced:
  2.  
  3. Rename dma-buf-map to iosys-map [1]
  4. Remove the deprecated "pci-dma-compat.h" in PCI API [2]
  5. Eliminate acpi_bus_get_device() in ACPI/bus [3]
  6.  
  7. [1] https://github.com/torvalds/linux/commit/7938f4218168ae9fc4bdddb15976f9ebbae41999
  8. [2] https://github.com/torvalds/linux/commit/7968778914e53788a01c2dee2692cab157de9ac0
  9. [3] https://github.com/torvalds/linux/commit/ac2a3feefad549814f5e7cca30be07a255c8494a
  10.  
  11. Patch developed(c) by Piotr Oniszczuk <piotr.oniszczuk@gmail.com>
  12.  
  13. diff --speed-large-files --no-dereference --minimal -Naur NVIDIA-Linux-x86_64-340.108/kernel/nv-acpi.c NVIDIA-Linux-x86_64-340.108/kernel/nv-acpi.c
  14. --- NVIDIA-Linux-x86_64-340.108/kernel/nv-acpi.c    2019-12-11 23:04:24.000000000 +0100
  15. +++ NVIDIA-Linux-x86_64-340.108/kernel/nv-acpi.c    2022-05-12 12:59:18.003229087 +0200
  16. @@ -577,9 +577,11 @@
  17.          {
  18.              if (!nvif_parent_gpu_handle) /* unknown error */
  19.                  break;
  20. -            
  21. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  22. +            device = acpi_fetch_acpi_dev(nvif_parent_gpu_handle);
  23. +#else
  24.              retVal = acpi_bus_get_device(nvif_parent_gpu_handle, &device);
  25. -
  26. +#endif
  27.              if (ACPI_FAILURE(retVal) || !device)
  28.                  break;
  29.  
  30. @@ -652,8 +654,11 @@
  31.      if (nvif_parent_gpu_handle == NULL)
  32.          return;
  33.  
  34. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  35. +    device = acpi_fetch_acpi_dev(nvif_parent_gpu_handle);
  36. +#else
  37.      acpi_bus_get_device(nvif_parent_gpu_handle, &device);
  38. -
  39. +#endif
  40.      nv_uninstall_notifier(device, nv_acpi_event);
  41.      nvif_parent_gpu_handle = NULL;
  42.  
  43. @@ -1212,7 +1217,11 @@
  44.      if (!dev_handle)
  45.          return RM_ERR_INVALID_ARGUMENT;
  46.  
  47. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  48. +    device = acpi_fetch_acpi_dev(dev_handle);
  49. +#else
  50.      status = acpi_bus_get_device(dev_handle, &device);
  51. +#endif
  52.  
  53.      if (ACPI_FAILURE(status) || !device)
  54.          return RM_ERR_INVALID_ARGUMENT;
  55. diff --speed-large-files --no-dereference --minimal -Naur NVIDIA-Linux-x86_64-340.108/kernel/nv-dma.c NVIDIA-Linux-x86_64-340.108/kernel/nv-dma.c
  56. --- NVIDIA-Linux-x86_64-340.108/kernel/nv-dma.c 2019-12-11 23:04:24.000000000 +0100
  57. +++ NVIDIA-Linux-x86_64-340.108/kernel/nv-dma.c 2022-05-12 12:45:30.363233712 +0200
  58. @@ -136,10 +136,17 @@
  59.          return status;
  60.      }
  61.  
  62. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  63. +    dma_map->sg_map_count = dma_map_sg(&dma_map->dev->dev,
  64. +            NV_DMA_MAP_SCATTERLIST(dma_map),
  65. +            NV_DMA_MAP_SCATTERLIST_LENGTH(dma_map),
  66. +            DMA_BIDIRECTIONAL);
  67. +#else
  68.      dma_map->sg_map_count = pci_map_sg(dma_map->dev,
  69.              NV_DMA_MAP_SCATTERLIST(dma_map),
  70.              NV_DMA_MAP_SCATTERLIST_LENGTH(dma_map),
  71.              PCI_DMA_BIDIRECTIONAL);
  72. +#endif
  73.      if (dma_map->sg_map_count == 0)
  74.      {
  75.          nv_printf(NV_DBG_ERRORS,
  76. @@ -211,8 +218,13 @@
  77.  
  78.      if (dma_map->sg_map_count != 0)
  79.      {
  80. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  81. +        dma_unmap_sg(&dma_map->dev->dev, NV_DMA_MAP_SCATTERLIST(dma_map),
  82. +                NV_DMA_MAP_SCATTERLIST_LENGTH(dma_map), DMA_BIDIRECTIONAL);
  83. +#else
  84.          pci_unmap_sg(dma_map->dev, NV_DMA_MAP_SCATTERLIST(dma_map),
  85.                  NV_DMA_MAP_SCATTERLIST_LENGTH(dma_map), PCI_DMA_BIDIRECTIONAL);
  86. +#endif
  87.      }
  88.  
  89.      *priv = dma_map->user_pages;
  90. diff --speed-large-files --no-dereference --minimal -Naur NVIDIA-Linux-x86_64-340.108/kernel/nv-drm.c NVIDIA-Linux-x86_64-340.108/kernel/nv-drm.c
  91. --- NVIDIA-Linux-x86_64-340.108/kernel/nv-drm.c 2022-05-12 13:03:49.996560918 +0200
  92. +++ NVIDIA-Linux-x86_64-340.108/kernel/nv-drm.c 2022-05-12 12:02:14.576581485 +0200
  93. @@ -381,9 +381,15 @@
  94.      return nv_gem_prime_get_sg_table(gem);
  95.  }
  96.  
  97. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  98. +static int nv_drm_gem_vmap(struct drm_gem_object *gem,
  99. +                           struct iosys_map *map)
  100. +{
  101. +#else
  102.  static int nv_drm_gem_vmap(struct drm_gem_object *gem,
  103.                             struct dma_buf_map *map)
  104.  {
  105. +#endif
  106.      map->vaddr = nv_gem_prime_vmap(gem);
  107.      if (map->vaddr == NULL) {
  108.          return -ENOMEM;
  109. @@ -392,9 +398,15 @@
  110.      return 0;
  111.  }
  112.  
  113. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
  114. +static void nv_drm_gem_vunmap(struct drm_gem_object *gem,
  115. +                              struct iosys_map *map)
  116. +{
  117. +#else
  118.  static void nv_drm_gem_vunmap(struct drm_gem_object *gem,
  119.                                struct dma_buf_map *map)
  120.  {
  121. +#endif
  122.      nv_gem_prime_vunmap(gem, map->vaddr);
  123.      map->vaddr = NULL;
  124.  }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement