1 --- NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/common/inc/nv-linux.h.orig 2020-12-22 11:58:13.756901968 +0100
2 +++ NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/common/inc/nv-linux.h 2020-12-22 12:34:56.069935099 +0100
4 * device. So if SWIOTLB is enabled, we should avoid making
7 -static inline NvBool nv_dma_maps_swiotlb(struct pci_dev *dev)
9 +nv_dma_maps_swiotlb(struct pci_dev *dev)
11 NvBool swiotlb_in_use = NV_FALSE;
12 #if defined(CONFIG_SWIOTLB)
14 * get_dma_ops() interface.
16 #if defined(NV_GET_DMA_OPS_PRESENT)
17 - #if defined(NV_DMA_MAP_OPS_PRESENT) || defined(NV_SWIOTLB_DMA_OPS_PRESENT)
19 * The __attribute__ ((unused)) is necessary because in at least one
20 * case, *none* of the preprocessor branches below are taken, and
21 @@ -1324,14 +1324,11 @@
22 * happen with the (NV_IS_EXPORT_SYMBOL_PRESENT_swiotlb_map_sg_attrs == 1)
25 - const struct dma_map_ops *ops __attribute__ ((unused)) = get_dma_ops(&dev->dev);
27 - const struct dma_mapping_ops *ops __attribute__ ((unused)) = get_dma_ops(&dev->dev);
29 + const struct dma_map_ops *ops __attribute__ ((unused)) = get_dma_ops(&dev->dev);
31 const struct dma_mapping_ops *ops __attribute__ ((unused)) = dma_ops;
33 - #if defined(NV_DMA_MAP_OPS_PRESENT) || defined(NV_SWIOTLB_DMA_OPS_PRESENT)
36 * The switch from dma_mapping_ops -> dma_map_ops coincided with the
37 * switch from swiotlb_map_sg -> swiotlb_map_sg_attrs.
39 * NV_IS_EXPORT_SYMBOL_PRESENT_swiotlb_dma_ops == 0) does
40 * nothing, and ends up dropping us out to the last line of this function,
41 * effectively returning false. The nearly-human-readable version of that
42 - * case is "Either struct dma_map_ops or struct swiotlb_dma_ops is present
43 - * (NV_DMA_MAP_OPS_PRESENT or NV_SWIOTLB_DMA_OPS_PRESENT is defined) but
44 - * neither swiotlb_map_sg_attrs nor swiotlb_dma_ops is present".
45 + * case is "struct swiotlb_dma_ops is present (NV_SWIOTLB_DMA_OPS_PRESENT
46 + * is defined) but neither swiotlb_map_sg_attrs nor swiotlb_dma_ops is
49 * That can happen on kernels that fall within below range:
51 @@ -1378,17 +1375,6 @@
52 * we just return NV_FALSE and in nv_compute_gfp_mask() we check for
53 * whether swiotlb could possibly be used (outside of swiotlb=force).
56 - swiotlb_in_use = (ops->map_sg == swiotlb_map_sg);
58 - #elif defined(NVCPU_X86_64)
60 - * Fallback for old 2.6 kernels - if the DMA operations infrastructure
61 - * isn't in place, use the swiotlb flag. Before dma_ops was added, this
62 - * flag used to be exported. It still exists in modern kernels but is no
65 - swiotlb_in_use = (swiotlb == 1);
69 diff --color -ur NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/common/inc/nv-linux.h NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/common/inc/nv-linux.h
70 --- NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/common/inc/nv-linux.h 2020-12-22 12:36:18.220333393 +0100
71 +++ NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/common/inc/nv-linux.h 2020-12-22 12:43:57.293884303 +0100
73 #include <linux/dma-mapping.h>
76 +#if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT)
77 +#include <linux/dma-map-ops.h>
80 #if defined(CONFIG_SWIOTLB) && defined(NVCPU_AARCH64)
81 #include <linux/swiotlb.h>
83 diff --color -ur NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/conftest.sh NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/conftest.sh
84 --- NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/conftest.sh 2020-12-22 12:36:18.166999801 +0100
85 +++ NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/conftest.sh 2020-12-22 12:43:18.766880222 +0100
87 FILES="$FILES linux/fence.h"
88 FILES="$FILES linux/ktime.h"
89 FILES="$FILES linux/dma-resv.h"
90 + FILES="$FILES linux/dma-map-ops.h"
92 # Arch specific headers which need testing
93 FILES_ARCH="asm/book3s/64/hash-64k.h"
94 @@ -2097,8 +2098,20 @@
96 # Determine if the get_dma_ops() function is present.
98 + # The structure was made available to all architectures by commit
99 + # e1c7e324539a ("dma-mapping: always provide the dma_map_ops
100 + # based implementation") in v4.5
102 + # Commit 0a0f0d8be76d ("dma-mapping: split <linux/dma-mapping.h>")
103 + # in v5.10-rc1 (2020-09-22), moved get_dma_ops() function
104 + # prototype from <linux/dma-mapping.h> to <linux/dma-map-ops.h>.
107 + #if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT)
108 + #include <linux/dma-map-ops.h>
110 #include <linux/dma-mapping.h>
112 void conftest_get_dma_ops(void) {
115 diff --color -ur NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/conftest.sh NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/conftest.sh
116 --- NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/conftest.sh 2020-12-22 13:14:54.092636780 +0100
117 +++ NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/conftest.sh 2020-12-22 13:17:31.066679257 +0100
118 @@ -4244,6 +4244,30 @@
120 compile_check_conftest "$CODE" "NV_VGA_TRYGET_PRESENT" "" "functions"
123 + drm_prime_pages_to_sg_has_drm_device_arg)
125 + # Determine if drm_prime_pages_to_sg() has 'dev' argument.
127 + # drm_prime_pages_to_sg() is updated to take 'dev' argument by commit
128 + # 707d561f77b5 ("drm: allow limiting the scatter list size.").
131 + #if defined(NV_DRM_DRMP_H_PRESENT)
132 + #include <drm/drmP.h>
134 + #if defined(NV_DRM_DRM_PRIME_H_PRESENT)
135 + #include <drm/drm_prime.h>
138 + struct sg_table *drm_prime_pages_to_sg(struct drm_device *dev,
139 + struct page **pages,
140 + unsigned int nr_pages) {
144 + compile_check_conftest "$CODE" "NV_DRM_PRIME_PAGES_TO_SG_HAS_DRM_DEVICE_ARG" "" "types"
149 diff --color -ur NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
150 --- NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c 2020-05-14 14:29:25.000000000 +0200
151 +++ NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c 2020-12-22 13:18:37.296993224 +0100
155 #include "nvidia-drm-gem-user-memory.h"
156 +#include "nvidia-drm-helper.h"
157 #include "nvidia-drm-ioctl.h"
161 struct nv_drm_gem_object *nv_gem)
163 struct nv_drm_gem_user_memory *nv_user_memory = to_nv_user_memory(nv_gem);
164 + struct drm_gem_object *gem = &nv_gem->base;
166 - return drm_prime_pages_to_sg(nv_user_memory->pages,
167 - nv_user_memory->pages_count);
168 + return nv_drm_prime_pages_to_sg(gem->dev,
169 + nv_user_memory->pages,
170 + nv_user_memory->pages_count);
173 static void *__nv_drm_gem_user_memory_prime_vmap(
174 diff --color -ur NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/nvidia-drm/nvidia-drm-helper.h NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/nvidia-drm/nvidia-drm-helper.h
175 --- NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/nvidia-drm/nvidia-drm-helper.h 2020-05-14 14:29:24.000000000 +0200
176 +++ NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/nvidia-drm/nvidia-drm-helper.h 2020-12-22 13:18:10.323531096 +0100
181 +#if defined(NV_DRM_DRM_PRIME_H_PRESENT)
182 +#include <drm/drm_prime.h>
185 +static inline struct sg_table*
186 +nv_drm_prime_pages_to_sg(struct drm_device *dev,
187 + struct page **pages, unsigned int nr_pages)
189 +#if defined(NV_DRM_PRIME_PAGES_TO_SG_HAS_DRM_DEVICE_ARG)
190 + return drm_prime_pages_to_sg(dev, pages, nr_pages);
192 + return drm_prime_pages_to_sg(pages, nr_pages);
196 #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
199 diff --color -ur NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/nvidia-drm/nvidia-drm.Kbuild NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/nvidia-drm/nvidia-drm.Kbuild
200 --- NVIDIA-Linux-x86_64-390.138-no-compat32.orig/kernel/nvidia-drm/nvidia-drm.Kbuild 2020-05-14 11:37:09.000000000 +0200
201 +++ NVIDIA-Linux-x86_64-390.138-no-compat32/kernel/nvidia-drm/nvidia-drm.Kbuild 2020-12-22 13:32:37.631385816 +0100
203 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_prime_export_has_dev_arg
204 NV_CONFTEST_TYPE_COMPILE_TESTS += vm_fault_t
205 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_object_has_resv
206 +NV_CONFTEST_TYPE_COMPILE_TESTS += drm_prime_pages_to_sg_has_drm_device_arg