-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdkms.conf.in
294 lines (276 loc) · 9.17 KB
/
dkms.conf.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
#
# Global options
#
PACKAGE_NAME="@PACKAGE_NAME@"
PACKAGE_VERSION="@PACKAGE_VERSION@"
SHS_DKMS_AUX_DIR="@SHS_DKMS_AUX_DIR@"
#
# SHS DKMS variables
#
SHS_DKMS_PACKAGEROOT="${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}"
SHS_DKMS_BUILDROOT="${SHS_DKMS_PACKAGEROOT}/build"
#
# CXI driver optional auxiliary dkms configuration
#
SHS_DKMS_AUX_CONF=${SHS_DKMS_AUX_DIR}/${PACKAGE_NAME}-aux.conf
if [ -f ${SHS_DKMS_AUX_CONF} ] && [ -r ${SHS_DKMS_AUX_CONF} ]
then
. ${SHS_DKMS_AUX_CONF}
fi
#
# The CXI driver has optional support for AMD, Intel, and Nvidia GPUs
# including support for nvidia and nvidia-open driver variants.
#
# By default the "latest version" of each GPU installed in DKMS will
# be included.
#
# If nvidia and nvidia-open are both installed, then the one with the
# highest version among them will be chosen.
#
# If nvidia and nvidia-open are both installed with same version,
# then nvidia will be used.
#
# _IF_ a different version of the GPU is needed _OR_ support for a
# GPU disabled, then set the appropriate variable in the auxililiary
# dkms configuration file.
# (its location is ${SHS_DKMS_AUX_CONF})
#
if [ ${DISABLE_GPU_AMD:-0} -eq 0 ]
then
if [ -z "${PATH_GPU_AMD}" ]
then
#
# Find newest candidate directory that contains an 'include'
# subdirectory - sometimes uninstall can leave behind an empty
# directory in /usr/src
#
paths="$(find ${source_tree} -mindepth 1 -maxdepth 1 -name 'amdgpu-*' 2>/dev/null)"
if [ -n "${paths}" ]
then
tmp=$(find ${paths} -mindepth 1 -maxdepth 1 -type d -name include 2>/dev/null | sort --version-sort | tail -1)
PATH_GPU_AMD=${tmp%/*}
fi
elif [ ! -d "${PATH_GPU_AMD}" ]
then
printf 'dkms.conf: ERROR: PATH_GPU_AMD="%s" is not a path to a directory\n' "${PATH_GPU_AMD}"
unset PATH_GPU_AMD
fi
else
unset PATH_GPU_AMD
fi
if [ ${DISABLE_GPU_INTEL:-0} -eq 0 ]
then
if [ -z "${PATH_GPU_INTEL}" ]
then
#
# Find newest candidate directory that contains an 'include'
# subdirectory - sometimes uninstall can leave behind an empty
# directory in /usr/src
#
paths="$(find ${source_tree} -mindepth 1 -maxdepth 1 -name 'intel-dmabuf-*' 2>/dev/null)"
if [ -n "${paths}" ]
then
tmp=$(find ${paths} -mindepth 1 -maxdepth 1 -type d -name include 2>/dev/null | sort --version-sort | tail -1)
PATH_GPU_INTEL=${tmp%/*}
fi
elif [ ! -d "${PATH_GPU_INTEL}" ]
then
printf 'dkms.conf: ERROR: PATH_GPU_INTEL="%s" is not a path to a directory\n' "${PATH_GPU_INTEL}"
unset PATH_GPU_INTEL
fi
else
unset PATH_GPU_INTEL
fi
if [ ${DISABLE_GPU_NVIDIA:-0} -eq 0 ]
then
if [ -z "${PATH_GPU_NVIDIA}" ]
then
#
# 'sort --version-sort' does not just pick out and sort on version
# substrings. It sorts on then entire string, then versions among
# the same base strings. Mixing ${source_tree}/kernel-modules and
# ${source_tree} without kernel-modules will make it harder to get
# the newest version. Splitting into two groups, prioritizing
# ${source_tree}/kernel-modules, finds highest version with ease
# if both variations are present (which is fairly unlikely).
#
#
# Find newest candidate directory that contains an 'nvidia'
# subdirectory - sometimes uninstall can leave behind an empty
# directory in /usr/src
#
for dir in $(find ${source_tree}/kernel-modules -mindepth 1 -maxdepth 1 -name 'nvidia-*' \! -name 'nvidia-open-*' 2>/dev/null | sort --version-sort)
do
if [ -d ${dir}/nvidia ]
then
PATH_GPU_NVIDIA=${dir}/nvidia
elif [ -d ${dir}/kernel-open/nvidia ]
then
PATH_GPU_NVIDIA=${dir}/kernel-open/nvidia
fi
done
#
# If nothing has been found ${source_tree}/kernel-modules,
# then look for the nvidia kernel modules in just ${source_tree}.
#
if [ -z "${PATH_GPU_NVIDIA}" ]
then
for dir in $(find ${source_tree} -mindepth 1 -maxdepth 1 -name 'nvidia-*' \! -name 'nvidia-open-*' 2>/dev/null | sort --version-sort)
do
if [ -d ${dir}/nvidia ]
then
PATH_GPU_NVIDIA=${dir}/nvidia
elif [ -d ${dir}/kernel-open/nvidia ]
then
PATH_GPU_NVIDIA=${dir}/kernel-open/nvidia
fi
done
fi
elif [ ! -d "${PATH_GPU_NVIDIA}" ]
then
printf 'dkms.conf: ERROR: PATH_GPU_NVIDIA="%s" is not a path to a directory\n' "${PATH_GPU_NVIDIA}"
unset PATH_GPU_NVIDIA
fi
else
unset PATH_GPU_NVIDIA
fi
if [ ${DISABLE_GPU_NVIDIA_OPEN:-0} -eq 0 ]
then
if [ -z "${PATH_GPU_NVIDIA_OPEN}" ]
then
#
# Find newest candidate directory that contains an 'nvidia'
# subdirectory - sometimes uninstall can leave behind an empty
# directoryin /usr/src
#
for dir in $(find ${source_tree}/kernel-modules -mindepth 1 -maxdepth 1 -name 'nvidia-open-*' 2>/dev/null | sort --version-sort)
do
if [ -d ${dir}/nvidia ]
then
PATH_GPU_NVIDIA=${dir}/nvidia
elif [ -d ${dir}/kernel-open/nvidia ]
then
PATH_GPU_NVIDIA=${dir}/kernel-open/nvidia
fi
done
#
# If nothing has been found ${source_tree}/kernel-modules,
# this may not be a COS system, then look for the nvidia
# kernel modulesin the normal place
#
if [ -z "${PATH_GPU_NVIDIA_OPEN}" ]
then
for dir in $(find ${source_tree} -mindepth 1 -maxdepth 1 -name 'nvidia-open-*' 2>/dev/null | sort --version-sort)
do
if [ -d ${dir}/nvidia ]
then
PATH_GPU_NVIDIA=${dir}/nvidia
elif [ -d ${dir}/kernel-open/nvidia ]
then
PATH_GPU_NVIDIA=${dir}/kernel-open/nvidia
fi
done
fi
elif [ ! -d "${PATH_GPU_NVIDIA_OPEN}" ]
then
printf 'dkms.conf: ERROR: PATH_GPU_NVIDIA_OPEN="%s" is not a path to a directory\n' "${PATH_GPU_NVIDIA_OPEN}"
unset PATH_GPU_NVIDIA_OPEN
fi
else
unset PATH_GPU_NVIDIA_OPEN
fi
#
# If both nvidia and nvidia-open paths have been found,
# then pick highest version of the two, unsetting the other path.
#
if [ -n "${PATH_GPU_NVIDIA}" ] && [ -n "${PATH_GPU_NVIDIA_OPEN}" ]
then
nvidia_version=$(echo "${PATH_GPU_NVIDIA}" | sed -e 's,^.*/nvidia-\([^/]*\)/.*$,\1,g')
nvidia_open_version=$(echo "${PATH_GPU_NVIDIA_OPEN}" | sed -e 's,^.*/nvidia-open-\([^/]*\)/.*$,\1,g')
version=$(printf '%s\n%s\n' "${nvidia_version}" "${nvidia_open_version}" | sort --version-sort | tail -1)
if [ "${version}" = "${nvidia_version}" ]
then
unset PATH_GPU_NVIDIA_OPEN
elif [ "${version}" = "${nvidia_open_version}" ]
then
unset PATH_GPU_NVIDIA
else
printf 'dkms.conf: ERROR: version not identifiable among "%s" and "%s"\n' "${PATH_GPU_NVIDIA}" "${PATH_GPU_NVIDIA_OPEN}"
printf 'dkms.conf: ERROR: versions "%s" and "%s" deterimined "%s"\n' "${nvidia_version}" "${nvidia_open_version}" "${version}"
unset PATH_GPU_NVIDIA
unset PATH_GPU_NVIDIA_OPEN
fi
fi
#
# dependencies
#
BUILD_DEPENDS=("cray-slingshot-base-link" "sl-driver")
if [ -n "${PATH_GPU_AMD}" ]
then
BUILD_DEPENDS+=("amdgpu")
fi
if [ -n "${PATH_GPU_INTEL}" ]
then
BUILD_DEPENDS+=("intel-dmabuf")
fi
if [ -n "${PATH_GPU_NVIDIA}" ]
then
BUILD_DEPENDS+=("nvidia")
fi
if [ -n "${PATH_GPU_NVIDIA_OPEN}" ]
then
BUILD_DEPENDS+=("nvidia-open")
fi
#
# Use the Module.symvers stored in the DKMS tree for our dependencies
#
SLINGSHOT_BASE_LINK_SYMVERS=${dkms_tree}/cray-slingshot-base-link/kernel-${kernelver}-${arch}/module/Module.symvers
SL_SYMVERS=${dkms_tree}/sl-driver/kernel-${kernelver}-${arch}/module/Module.symvers.sl
SHS_MAKE_ARGS="\
-C ${kernel_source_dir}\
M=${SHS_DKMS_BUILDROOT}/cxi\
NO_BUILD_TESTS=1\
FIRMWARE_CASSINI_DIR=/usr/include\
CASSINI_HEADERS_DIR=/usr/include\
SLINGSHOT_BASE_LINK_DIR=/usr/include\
SL_DIR=/usr/include\
AMDGPU_DIR=${PATH_GPU_AMD}\
INTEL_DMABUF_DIR=${PATH_GPU_INTEL}\
NVIDIA_DIR=${PATH_GPU_NVIDIA}\
KBUILD_EXTRA_SYMBOLS='${SLINGSHOT_BASE_LINK_SYMVERS} ${SL_SYMVERS}'\
"
MAKE="'make' --jobs=${parallel_jobs} ${SHS_MAKE_ARGS} modules"
CLEAN="'make' --jobs=${parallel_jobs} ${SHS_MAKE_ARGS} clean"
AUTOINSTALL='yes'
#
# cxi-ss1.ko
#
BUILT_MODULE_LOCATION[0]=cxi
DEST_MODULE_LOCATION[0]=/extra
BUILT_MODULE_NAME[0]=cxi-ss1
DEST_MODULE_NAME[0]=cxi-ss1
STRIP[0]=no
#
# cxi-eth.ko
#
BUILT_MODULE_LOCATION[1]=cxi
DEST_MODULE_LOCATION[1]=/extra
BUILT_MODULE_NAME[1]=cxi-eth
DEST_MODULE_NAME[1]=cxi-eth
STRIP[1]=no
#
# cxi-user.ko
#
BUILT_MODULE_LOCATION[2]=cxi
DEST_MODULE_LOCATION[2]=/extra
BUILT_MODULE_NAME[2]=cxi-user
DEST_MODULE_NAME[2]=cxi-user
STRIP[2]=no
#
# Post-build hook to copy our Module.symvers into the DKMS tree
# so that other modules can build against it
#
POST_BUILD="dkms.post_build.sh ${SHS_DKMS_BUILDROOT}/cxi ${SHS_DKMS_PACKAGEROOT}"