-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathconftest.sh
More file actions
3315 lines (2968 loc) · 122 KB
/
Copy pathconftest.sh
File metadata and controls
3315 lines (2968 loc) · 122 KB
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
PATH="${PATH}:/bin:/sbin:/usr/bin"
# make sure we are in the directory containing this script
SCRIPTDIR=`dirname $0`
cd $SCRIPTDIR
CC="$1"
ARCH=$2
SOURCES=$3
HEADERS=$SOURCES/include
OUTPUT=$4
XEN_PRESENT=1
PREEMPT_RT_PRESENT=0
# VGX_BUILD parameter defined only for VGX builds (vGPU Host driver)
# VGX_KVM_BUILD parameter defined only vGPU builds on KVM hypervisor
# GRID_BUILD parameter defined only for GRID builds (GRID Guest driver)
# GRID_BUILD_CSP parameter defined only for GRID CSP builds (GRID Guest driver for CSPs)
test_xen() {
#
# Determine if the target kernel is a Xen kernel. It used to be
# sufficient to check for CONFIG_XEN, but the introduction of
# modular para-virtualization (CONFIG_PARAVIRT, etc.) and
# Xen guest support, it is no longer possible to determine the
# target environment at build time. Therefore, if both
# CONFIG_XEN and CONFIG_PARAVIRT are present, text_xen() treats
# the kernel as a stand-alone kernel.
#
if ! test_configuration_option CONFIG_XEN ||
test_configuration_option CONFIG_PARAVIRT; then
XEN_PRESENT=0
fi
}
append_conftest() {
#
# Echo data from stdin: this is a transitional function to make it easier
# to port conftests from drivers with parallel conftest generation to
# older driver versions
#
while read LINE; do
echo ${LINE}
done
}
test_header_presence() {
#
# Determine if the given header file (which may or may not be
# present) is provided by the target kernel.
#
# Input:
# $1: relative file path
#
# This routine creates an upper case, underscore version of each of the
# relative file paths, and uses that as the token to either define or
# undefine in a C header file. For example, linux/fence.h becomes
# NV_LINUX_FENCE_H_PRESENT, and that is either defined or undefined, in the
# output (which goes to stdout, just like the rest of this file).
TEST_CFLAGS="-E -M $CFLAGS"
file="$1"
file_define=LG_`echo $file | tr '/.\-a-z' '___A-Z'`_PRESENT
CODE="#include <$file>"
if echo "$CODE" | $CC $TEST_CFLAGS - > /dev/null 2>&1; then
echo "#define $file_define"
else
# If preprocessing failed, it could have been because the header
# file under test is not present, or because it is present but
# depends upon the inclusion of other header files. Attempting
# preprocessing again with -MG will ignore a missing header file
# but will still fail if the header file is present.
if echo "$CODE" | $CC $TEST_CFLAGS -MG - > /dev/null 2>&1; then
echo "#undef $file_define"
else
echo "#define $file_define"
fi
fi
}
build_cflags() {
ISYSTEM=`$CC -print-file-name=include 2> /dev/null`
BASE_CFLAGS="-O2 -D__KERNEL__ \
-DKBUILD_BASENAME=\"#conftest$$\" -DKBUILD_MODNAME=\"#conftest$$\" \
-nostdinc -isystem $ISYSTEM \
-Wno-implicit-function-declaration -Wno-strict-prototypes"
if [ "$OUTPUT" != "$SOURCES" ]; then
OUTPUT_CFLAGS="-I$OUTPUT/include2 -I$OUTPUT/include"
if [ -f "$OUTPUT/include/generated/autoconf.h" ]; then
AUTOCONF_FILE="$OUTPUT/include/generated/autoconf.h"
else
AUTOCONF_FILE="$OUTPUT/include/linux/autoconf.h"
fi
else
if [ -f "$HEADERS/generated/autoconf.h" ]; then
AUTOCONF_FILE="$HEADERS/generated/autoconf.h"
else
AUTOCONF_FILE="$HEADERS/linux/autoconf.h"
fi
fi
test_xen
if [ "$XEN_PRESENT" != "0" ]; then
MACH_CFLAGS="-I$HEADERS/asm/mach-xen"
fi
KERNEL_ARCH="$ARCH"
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]; then
if [ -d "$SOURCES/arch/x86" ]; then
KERNEL_ARCH="x86"
fi
fi
SOURCE_HEADERS="$HEADERS"
SOURCE_ARCH_HEADERS="$SOURCES/arch/$KERNEL_ARCH/include"
OUTPUT_HEADERS="$OUTPUT/include"
OUTPUT_ARCH_HEADERS="$OUTPUT/arch/$KERNEL_ARCH/include"
# Look for mach- directories on this arch, and add it to the list of
# includes if that platform is enabled in the configuration file, which
# may have a definition like this:
# #define CONFIG_ARCH_<MACHUPPERCASE> 1
for _mach_dir in `ls -1d $SOURCES/arch/$KERNEL_ARCH/mach-* 2>/dev/null`; do
_mach=`echo $_mach_dir | \
sed -e "s,$SOURCES/arch/$KERNEL_ARCH/mach-,," | \
tr 'a-z' 'A-Z'`
grep "CONFIG_ARCH_$_mach \+1" $AUTOCONF_FILE > /dev/null 2>&1
if [ $? -eq 0 ]; then
MACH_CFLAGS="$MACH_CFLAGS -I$_mach_dir/include"
fi
done
if [ "$ARCH" = "arm" ]; then
MACH_CFLAGS="$MACH_CFLAGS -D__LINUX_ARM_ARCH__=7"
fi
# Add the mach-default includes (only found on x86/older kernels)
MACH_CFLAGS="$MACH_CFLAGS -I$SOURCE_HEADERS/asm-$KERNEL_ARCH/mach-default"
MACH_CFLAGS="$MACH_CFLAGS -I$SOURCE_ARCH_HEADERS/asm/mach-default"
CFLAGS="$BASE_CFLAGS $MACH_CFLAGS $OUTPUT_CFLAGS -include $AUTOCONF_FILE"
CFLAGS="$CFLAGS -I$SOURCE_HEADERS"
CFLAGS="$CFLAGS -I$SOURCE_HEADERS/uapi"
CFLAGS="$CFLAGS -I$SOURCE_HEADERS/xen"
CFLAGS="$CFLAGS -I$OUTPUT_HEADERS/generated/uapi"
CFLAGS="$CFLAGS -I$SOURCE_ARCH_HEADERS"
CFLAGS="$CFLAGS -I$SOURCE_ARCH_HEADERS/uapi"
CFLAGS="$CFLAGS -I$OUTPUT_ARCH_HEADERS/generated"
CFLAGS="$CFLAGS -I$OUTPUT_ARCH_HEADERS/generated/uapi"
if [ -n "$BUILD_PARAMS" ]; then
CFLAGS="$CFLAGS -D$BUILD_PARAMS"
fi
# Check if gcc supports asm goto and set CC_HAVE_ASM_GOTO if it does.
# Older kernels perform this check and set this flag in Kbuild, and since
# conftest.sh runs outside of Kbuild it ends up building without this flag.
# Starting with commit e9666d10a5677a494260d60d1fa0b73cc7646eb3 this test
# is done within Kconfig, and the preprocessor flag is no longer needed.
GCC_GOTO_SH="$SOURCES/build/gcc-goto.sh"
if [ -f "$GCC_GOTO_SH" ]; then
# Newer versions of gcc-goto.sh don't print anything on success, but
# this is okay, since it's no longer necessary to set CC_HAVE_ASM_GOTO
# based on the output of those versions of gcc-goto.sh.
if [ `/bin/sh "$GCC_GOTO_SH" "$CC"` = "y" ]; then
CFLAGS="$CFLAGS -DCC_HAVE_ASM_GOTO"
fi
fi
#
# If CONFIG_HAVE_FENTRY is enabled and gcc supports -mfentry flags then set
# CC_USING_FENTRY and add -mfentry into cflags.
#
# linux/ftrace.h file indirectly gets included into the conftest source and
# fails to get compiled, because conftest.sh runs outside of Kbuild it ends
# up building without -mfentry and CC_USING_FENTRY flags.
#
grep "CONFIG_HAVE_FENTRY \+1" $AUTOCONF_FILE > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "" > conftest$$.c
$CC -mfentry -c -x c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
CFLAGS="$CFLAGS -mfentry -DCC_USING_FENTRY"
fi
fi
grep "CONFIG_AS_HAS_EXPLICIT_RELOCS \+1" $AUTOCONF_FILE > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "" > conftest$$.c
$CC -mexplicit-relocs -c -x c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
CFLAGS="$CFLAGS -mexplicit-relocs"
fi
fi
#
# If CONFIG_CPU_LOONGSON64 is enabled then reset _LOONGARCH_ISA to
# _LOONGARCH_ISA_LOONGARCH64.
#
grep "CONFIG_CPU_LOONGSON64 \+1" $AUTOCONF_FILE > /dev/null 2>&1
if [ $? -eq 0 ]; then
CFLAGS="$CFLAGS -U_LOONGARCH_ISA -D_LOONGARCH_ISA=_LOONGARCH_ISA_LOONGARCH64"
fi
}
CONFTEST_PREAMBLE="#include \"conftest/headers.h\"
#if defined(LG_LINUX_KCONFIG_H_PRESENT)
#include <linux/kconfig.h>
#endif
#if defined(LG_GENERATED_AUTOCONF_H_PRESENT)
#include <generated/autoconf.h>
#else
#include <linux/autoconf.h>
#endif
#if defined(CONFIG_XEN) && \
defined(CONFIG_XEN_INTERFACE_VERSION) && !defined(__XEN_INTERFACE_VERSION__)
#define __XEN_INTERFACE_VERSION__ CONFIG_XEN_INTERFACE_VERSION
#endif
#if defined(CONFIG_KASAN) && defined(CONFIG_ARM64)
#if defined(CONFIG_KASAN_SW_TAGS)
#define KASAN_SHADOW_SCALE_SHIFT 4
#else
#define KASAN_SHADOW_SCALE_SHIFT 3
#endif
#endif"
test_configuration_option() {
#
# Check to see if the given configuration option is defined
#
get_configuration_option $1 >/dev/null 2>&1
return $?
}
set_configuration() {
#
# Set a specific configuration option. This function is called to always
# enable a configuration, in order to verify whether the test code for that
# configuration is no longer required and the corresponding
# conditionally-compiled code in the driver can be removed.
#
DEF="$1"
if [ "$3" = "" ]
then
VAL=""
CAT="$2"
else
VAL="$2"
CAT="$3"
fi
echo "#define ${DEF} ${VAL}" | append_conftest "${CAT}"
}
unset_configuration() {
#
# Un-set a specific configuration option. This function is called to
# always disable a configuration, in order to verify whether the test
# code for that configuration is no longer required and the corresponding
# conditionally-compiled code in the driver can be removed.
#
DEF="$1"
CAT="$2"
echo "#undef ${DEF}" | append_conftest "${CAT}"
}
compile_check_conftest() {
#
# Compile the current conftest C file and check+output the result
#
CODE="$1"
DEF="$2"
VAL="$3"
CAT="$4"
echo "$CONFTEST_PREAMBLE
$CODE" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
if [ "${CAT}" = "functions" ]; then
#
# The logic for "functions" compilation tests is inverted compared to
# other compilation steps: if the function is present, the code
# snippet will fail to compile because the function call won't match
# the prototype. If the function is not present, the code snippet
# will produce an object file with the function as an unresolved
# symbol.
#
echo "#undef ${DEF}" | append_conftest "${CAT}"
else
echo "#define ${DEF} ${VAL}" | append_conftest "${CAT}"
fi
return
else
if [ "${CAT}" = "functions" ]; then
echo "#define ${DEF} ${VAL}" | append_conftest "${CAT}"
else
echo "#undef ${DEF}" | append_conftest "${CAT}"
fi
return
fi
}
export_symbol_present_conftest() {
#
# Check Module.symvers to see whether the given symbol is present.
#
SYMBOL="$1"
TAB=' '
if grep -e "${TAB}${SYMBOL}${TAB}.*${TAB}EXPORT_SYMBOL\(_GPL\)\?\s*\$" \
"$OUTPUT/Module.symvers" >/dev/null 2>&1; then
echo "#define LS_IS_EXPORT_SYMBOL_PRESENT_$SYMBOL 1" |
append_conftest "symbols"
else
# May be a false negative if Module.symvers is absent or incomplete,
# or if the Module.symvers format changes.
echo "#define LS_IS_EXPORT_SYMBOL_PRESENT_$SYMBOL 0" |
append_conftest "symbols"
fi
}
export_symbol_gpl_conftest() {
#
# Check Module.symvers to see whether the given symbol is present and its
# export type is GPL-only (including deprecated GPL-only symbols).
#
SYMBOL="$1"
TAB=' '
if grep -e "${TAB}${SYMBOL}${TAB}.*${TAB}EXPORT_\(UNUSED_\)*SYMBOL_GPL\s*\$" \
"$OUTPUT/Module.symvers" >/dev/null 2>&1; then
echo "#define LG_IS_EXPORT_SYMBOL_GPL_$SYMBOL 1" |
append_conftest "symbols"
else
# May be a false negative if Module.symvers is absent or incomplete,
# or if the Module.symvers format changes.
echo "#define LG_IS_EXPORT_SYMBOL_GPL_$SYMBOL 0" |
append_conftest "symbols"
fi
}
get_configuration_option() {
#
# Print the value of given configuration option, if defined
#
RET=1
OPTION=$1
OLD_FILE="linux/autoconf.h"
NEW_FILE="generated/autoconf.h"
FILE=""
if [ -f $HEADERS/$NEW_FILE -o -f $OUTPUT/include/$NEW_FILE ]; then
FILE=$NEW_FILE
elif [ -f $HEADERS/$OLD_FILE -o -f $OUTPUT/include/$OLD_FILE ]; then
FILE=$OLD_FILE
fi
if [ -n "$FILE" ]; then
#
# We are looking at a configured source tree; verify
# that its configuration includes the given option
# via a compile check, and print the option's value.
#
if [ -f $HEADERS/$FILE ]; then
INCLUDE_DIRECTORY=$HEADERS
elif [ -f $OUTPUT/include/$FILE ]; then
INCLUDE_DIRECTORY=$OUTPUT/include
else
return 1
fi
echo "#include <$FILE>
#ifndef $OPTION
#error $OPTION not defined!
#endif
$OPTION
" > conftest$$.c
$CC -E -P -I$INCLUDE_DIRECTORY -o conftest$$ conftest$$.c > /dev/null 2>&1
if [ -e conftest$$ ]; then
tr -d '\r\n\t ' < conftest$$
RET=$?
fi
rm -f conftest$$.c conftest$$
else
CONFIG=$OUTPUT/.config
if [ -f $CONFIG ] && grep "^$OPTION=" $CONFIG; then
grep "^$OPTION=" $CONFIG | cut -f 2- -d "="
RET=$?
fi
fi
return $RET
}
check_for_ib_peer_memory_symbols() {
kernel_dir="$1"
module_symvers="${kernel_dir}/Module.symvers"
sym_ib_register="ib_register_peer_memory_client"
sym_ib_unregister="ib_unregister_peer_memory_client"
tab=' '
# Return 0 for true(no errors), 1 for false
if [ ! -f "${module_symvers}" ]; then
return 1
fi
if grep -e "${tab}${sym_ib_register}${tab}.*${tab}EXPORT_SYMBOL.*\$" \
"${module_symvers}" > /dev/null 2>&1 &&
grep -e "${tab}${sym_ib_unregister}${tab}.*${tab}EXPORT_SYMBOL.*\$" \
"${module_symvers}" > /dev/null 2>&1; then
return 0
else
return 1
fi
}
compile_test() {
case "$1" in
drm_driver_prime_flag_present)
#
# Determine whether driver feature flag DRIVER_PRIME is present.
#
# The DRIVER_PRIME flag was added by commit 3248877ea179 (drm:
# base prime/dma-buf support (v5)) in v3.4 (2011-11-25) and is
# removed by commit 0424fdaf883a ("drm/prime: Actually remove
# DRIVER_PRIME everywhere") in v5.4.
#
# DRIVER_PRIME define is changed to enum value by commit
# 0e2a933b02c9 (drm: Switch DRIVER_ flags to an enum) in v5.1
# (2019-01-29).
#
CODE="
#if defined(LG_DRM_DRM_DRV_H_PRESENT)
#include <drm/drm_drv.h>
#endif
unsigned int drm_driver_prime_flag_present_conftest(void) {
return DRIVER_PRIME;
}"
compile_check_conftest "$CODE" "LG_DRM_DRIVER_PRIME_FLAG_PRESENT" "" "types"
;;
pwm_add_table)
#
# Determine whether pwm_add_table function is exported in kernel.
#
export_symbol_gpl_conftest "pwm_add_table"
;;
drm_driver_irq_shared_flag_present)
#
# Determine whether driver feature flag DRIVER_IRQ_SHARED is present.
#
# The DRIVER_IRQ_SHARED flag is removed by commit 1ff494813baf
# ("drm/irq: Ditch DRIVER_IRQ_SHARED") in v5.1-rc1.
#
CODE="
#if defined(LG_DRM_DRM_DRV_H_PRESENT)
#include <drm/drm_drv.h>
#endif
unsigned int drm_driver_irq_shared_flag_present_conftest(void) {
return DRIVER_IRQ_SHARED;
}"
compile_check_conftest "$CODE" "LG_DRM_DRIVER_IRQ_SHARED_FLAG_PRESENT" "" "types"
;;
drm_sched_stop)
#
# Determine if the drm_sched_stop() function is present.
#
# Added by commit 222b5f044159 ("drm/sched: Refactor
# ring mirror list handling") in v5.1-rc1.
#
CODE="
#include <drm/gpu_scheduler.h>
void conftest_drm_sched_stop(void) {
drm_sched_stop();
}"
compile_check_conftest "$CODE" "LG_DRM_SCHED_STOP_PRESENT" "" "functions"
;;
ttm_bo_populate)
#
# Determine if the ttm_bo_populate() function is present.
#
# commit id: fc5d96670eb2540d2572a14351e82ffe45d5ac11
# commit msg: drm/ttm: Move swapped objects off the manager's LRU list
# in v6.13-rc1
#
CODE="
#include <drm/ttm/ttm_bo.h>
typeof(ttm_bo_populate) conftest_ttm_bo_populate;
int conftest_ttm_bo_populate(struct ttm_buffer_object *bo,
struct ttm_operation_ctx *ctx) {
return 0;
}"
compile_check_conftest "$CODE" "LG_TTM_BO_POPULATE" "" "type"
;;
hrtimer_init)
#
# Determine if the hrtimer_init() function is present.
#
# commit id: 9779489a31d77a7b9cb6f20d2d2caced4e29dbe6
# commit msg: hrtimers: Delete hrtimer_init()
# in v6.15-rc1
#
CODE="
#include <linux/hrtimer.h>
typeof(hrtimer_init) conftest_hrtimer_init;
void conftest_hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
enum hrtimer_mode mode) {
return;
}"
compile_check_conftest "$CODE" "LG_HRTIMER_INIT" "" "type"
;;
drm_do_get_edid)
#
# Determine if the drm_do_get_edid() function is present.
#
# commit id: 3dbfbd101a5844f851da9ae6e90f59753c10ff42
# drm/edid: remove drm_do_get_edid()
# in v6.13
#
CODE="
#include <drm/drm_edid.h>
typeof(drm_do_get_edid) conftest_drm_do_get_edid;
struct edid *conftest_drm_do_get_edid(struct drm_connector *connector,
int (*get_edid_block) (void *data, u8 *buf, unsigned int block, size_t len),
void *context) {
return NULL;
}"
compile_check_conftest "$CODE" "LG_DRM_DO_GET_EDID" "" "type"
;;
drm_get_format_info_has_pixel_format)
#
# Determine if the drm_get_format_info() has pixel_format argument.
#
# commit id: 0e7d5874fb6b80c44be3cfbcf1cf356e81d91232
# drm: Pass pixel_format+modifier directly to drm_get_format_info()
# in v6.17
#
CODE="
#include <drm/drm_fourcc.h>
typeof(drm_get_format_info) conftest_drm_get_format_info;
const struct drm_format_info *conftest_drm_get_format_info(struct drm_device *dev,
u32 pixel_format, u64 modifier) {
return NULL;
}"
compile_check_conftest "$CODE" "LG_DRM_GET_FORMAT_INFO_HAS_PIXEL_FORMAT" "" "type"
;;
drm_sched_job_cleanup)
#
# Determine if the drm_sched_job_cleanup() function is present.
#
#
CODE="
#include <drm/gpu_scheduler.h>
void conftest_drm_sched_job_cleanup(void) {
drm_sched_job_cleanup();
}"
compile_check_conftest "$CODE" "LG_DRM_SCHED_JOB_CLEANUP_PRESENT" "" "functions"
;;
pwm_apply_state)
#
# Determine if the pwm_apply_state() function is present.
#
# Added by commit 222b5f044159 ("drm/sched: Refactor
# ring mirror list handling") in v5.1-rc1.
#
CODE="
#include <linux/pwm.h>
int conftest_pwm_apply_state(void) {
return pwm_apply_state();
}"
compile_check_conftest "$CODE" "LG_PWM_APPLY_STATE" "" "functions"
;;
drm_fb_helper_fill_info)
#
# Determine if the drm_fb_helper_fill_info() function is present.
#
# Added by commit 3df3116ab4b1 ("drm/fb-helper: Add
# fill_info() functions") in v5.2-rc1.
#
CODE="
#if defined(LG_DRM_DRM_FB_HELPER_H_PRESENT)
#include <drm/drm_fb_helper.h>
#endif
void conftest_drm_fb_helper_fill_info(void) {
drm_fb_helper_fill_info();
}"
compile_check_conftest "$CODE" "LG_DRM_FB_HELPER_FILL_INFO_PRESENT" "" "functions"
;;
ttm_bo_device_init)
#
# Determine if the ttm_bo_device_init() function has
# 'glob' parameter.
#
# ttm_bo_device_init() removed 'glob' parameter by
# commit a64f784bb14a ("drm/ttm: initialize globals
# during device init (v2)") in v5.0-rc1.
#
CODE="
#include <drm/ttm/ttm_bo_driver.h>
int conftest_ttm_bo_device_init_has_glob_arg(void) {
return
ttm_bo_device_init(
NULL, /* struct ttm_bo_device *bdev */
NULL, /* struct ttm_bo_global *glob */
NULL, /* struct ttm_bo_driver *driver */
NULL, /* struct address_space *mapping */
0, /* uint64_t file_page_offset */
0 /* need_dma32 */);
}"
compile_check_conftest "$CODE" "LG_TTM_BO_DEVICE_INIT_HAS_GLOB_ARG" "" "types"
;;
ttm_eu_reserve_buffers)
#
# Determine if the function ttm_eu_reserve_buffers() has
# 'del_lru' parameter.
#
# ttm_eu_reserve_buffers() removed 'del_lru' parameter by
# commit 6e58ab7ac7fa ("drm/ttm: Make LRU removal optional v2")
# in v5.3-rc1.
#
CODE="
#include <drm/ttm/ttm_execbuf_util.h>
int conftest_ttm_eu_reserve_buffers_has_del_lru_arg(void) {
return
ttm_eu_reserve_buffers(
NULL, /* struct ww_acquire_ctx *ticket */
NULL, /* struct list_head *list */
0, /* bool intr */
NULL, /* struct list_head *dups */
0 /* bool del_lru */);
}"
compile_check_conftest "$CODE" "LG_TTM_EU_RESERVE_BUFFERS_HAS_DEL_LRU_ARG" "" "types"
;;
drm_syncobj_find_fence)
#
# Determine if the function drm_syncobj_find_fence() has
# 'point' and 'flags' parameters.
#
# drm_syncobj_find_fence() added 'point' parameter by
# commit 0a6730ea27b6 ("drm: expand drm_syncobj_find
# fence to support timeline point v2") in v4.20-rc1.
#
# drm_syncobj_find_fence() added 'flags' parameter by
# commit 649fdce23cdf ("drm: add flags to drm_syncobj_find_fence")
# in v5.0-rc1.
#
CODE="
#include <drm/drm_syncobj.h>
int conftest_drm_syncobj_find_fence(void) {
return
drm_syncobj_find_fence(
NULL, /* struct drm_file *file_private */
0, /* u32 handle */
0, /* u64 point */
0, /* u64 flags */
NULL /* struct dma_fence **fence */);
}"
compile_check_conftest "$CODE" "LG_DRM_SYNCOBJ_FIND_FENCE_HAS_FLAGS_ARG" "" "types"
;;
ttm_bo_move_to_lru_tail_has_bulk_arg)
#
# Determine if the function ttm_bo_move_to_lru_tail() has
# 'bulk' parameter.
#
# ttm_bo_move_to_lru_tail() added 'bulk' parameter by
# commit 9a2779528edd ("drm/ttm: revise ttm_bo_move_to_lru_tail to
# support bulk moves") in v4.20-rc1.
#
CODE="
#include <drm/ttm/ttm_bo_api.h>
void conftest_ttm_bo_move_to_lru_tail_has_bulk_arg(void) {
(void) ttm_bo_move_to_lru_tail(NULL, NULL);
}"
compile_check_conftest "$CODE" "LG_TTM_BO_MOVE_TO_LRU_TAIL_HAS_BULK_ARG" "" "types"
;;
loongson_screen_state)
#
# Determine if loongson_screen_state exist.
# This function is added in loongson kernel v4.19.
# commit id: 2cc57f6171f7264bf5e9f09cce9f5042e07598ad
#
CODE="
#include <linux/cpufreq.h>
typeof(loongson_screen_state) conftest_loongson_screen_state;
void conftest_loongson_screen_state(int state) {
return ;
}"
compile_check_conftest "$CODE" "LG_LOONGSON_SCREEN_STATE" "" "types"
;;
pwm_request)
#
# Determine if pwm_request function exist.
# commit msg: pwm: Delete deprecated functions pwm_request() and pwm_free()
# commit id: 0af4d704ba8e5ee632b6e65015ffe4d229c1a9a9.
# changed in v6.3-rc7
#
CODE="
#include <linux/pwm.h>
typeof(pwm_request) conftest_pwm_request;
struct pwm_device *conftest_pwm_request(int pwm, const char *label) {
return NULL;
}"
compile_check_conftest "$CODE" "LG_PWM_REQUEST" "" "types"
;;
atomic_check)
#
# Determine if atomic_check function has drm_crtc_state arg.
# commit msg: drm/atomic: Pass the full state to CRTC atomic_check
# commit id: 29b77ad7b9ca8c87152a1a9e8188970fb2a93df4.
# changed in v5.10-rc2
#
CODE="
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_crtc.h>
static const struct drm_crtc_helper_funcs *funcs;
typeof(*funcs->atomic_check) conftest_atomic_check;
int conftest_atomic_check(struct drm_crtc *crtc,
struct drm_crtc_state *state) {
return 0;
}"
compile_check_conftest "$CODE" "LG_ATOMIC_CHECK_HAS_CRTC_STATE_ARG" "" "types"
;;
mmu_notifier_ops_invalidate_range_start_has_range_arg)
#
# Determine if mmu_notifier_ops.invalidate_range_start takes (mn, range),
# or just (mn) args. Acronym keys:
# mn: struct mmu_notifier *
# range: const struct mmu_notifier_range *
#
# The range arg was removed from mmu_notifier_ops.invalidate_range_start
# by commit 5d6527a784f7 ("mm/mmu_notifier: use structure for
# invalidate_range_start/end callback") in v5.0-rc1.
#
echo "$CONFTEST_PREAMBLE
#include <linux/mmu_notifier.h>
static const struct mmu_notifier_ops *ops;
typeof(*ops->invalidate_range_start) conftest_mmu_notifier_invalidate_range_start_has_range_arg;
int conftest_mmu_notifier_invalidate_range_start_has_range_arg(
struct mmu_notifier *mn, const struct mmu_notifier_range *range) {
return 0;
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
echo "#define LG_MMU_NOTIFIER_INVALIDATE_RANGE_START_HAS_RANGE_ARG" | append_conftest "types"
else
echo "#undef LG_MMU_NOTIFIER_INVALIDATE_RANGE_START_HAS_RANGE_ARG" | append_conftest "types"
fi
;;
mmu_notifier_put)
#
# Determine if mmu_notifier_put() is present.
#
# mmu_notifier_unregister_no_release() is removed
# by commit c96245148c1e ("mm/mmu_notifiers: remove unregister_no_release") in v5.3-rc6.
#
CODE="
#include <linux/mmu_notifier.h>
void conftest_mmu_notifier_put(void) {
mmu_notifier_put();
}"
compile_check_conftest "$CODE" "LG_MMU_NOTIFIER_PUT_PRESENT" "" "functions"
;;
mmu_notifier_unregister_no_release)
#
# Determine if mmu_notifier_unregister_no_release() is present.
#
# mmu_notifier_unregister_no_release() is removed
# by commit c96245148c1e ("mm/mmu_notifiers: remove unregister_no_release") in v5.3-rc6.
#
CODE="
#include <linux/mmu_notifier.h>
void conftest_mmu_notifier_unregister_no_release(void) {
mmu_notifier_unregister_no_release();
}"
compile_check_conftest "$CODE" "LG_MMU_NOTIFIER_UNREGISTER_NO_RELEASE" "" "functions"
;;
mmu_notifier_unregister)
#
# Determine if mmu_notifier_unregister() is present.
#
# mmu_notifier_unregister_no_release() is removed
# by commit c96245148c1e ("mm/mmu_notifiers: remove unregister_no_release") in v5.3-rc6.
#
CODE="
#include <linux/mmu_notifier.h>
void conftest_mmu_notifier_unregister(void) {
mmu_notifier_unregister();
}"
compile_check_conftest "$CODE" "LG_MMU_NOTIFIER_UNREGISTER" "" "functions"
;;
drm_hdmi_avi_infoframe_from_display_mode)
#
# Determine if the function drm_hdmi_avi_infoframe_from_display_mode()
# has 'connector' parameter.
#
# drm_hdmi_avi_infoframe_from_display_mode() added 'connector' parameter
# by commit 13d0add333af ("drm/edid: Pass connector to AVI infoframe
# functions") in v5.1-rc1.
#
CODE="
#include <drm/drm_edid.h>
typeof(drm_hdmi_avi_infoframe_from_display_mode) conftest_drm_hdmi_avi_infoframe_from_display_mode_has_connector_arg;
int conftest_drm_hdmi_avi_infoframe_from_display_mode_has_connector_arg(
struct hdmi_avi_infoframe *frame,
struct drm_connector *connector,
const struct drm_display_mode *mode) {
return 0;
}"
compile_check_conftest "$CODE" "LG_DRM_HDMI_AVI_INFOFRAME_FROM_DISPLAY_MODE_HAS_CONNECTOR_ARG" "" "types"
;;
drm_fb_helper_single_add_all_connectors)
#
# Determine if the function drm_fb_helper_single_add_all_connectors exist
#
# drm/fb-helper: Remove drm_fb_helper_connector
# commit e5852bee90d6cb7d9bd2c635c056e7746f137e06
# in v5.2-rc4.
#
CODE="
#include <drm/drm_fb_helper.h>
typeof(drm_fb_helper_single_add_all_connectors) conftest_drm_fb_helper_single_add_all_connectors;
int conftest_drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) {
return 0;
}"
compile_check_conftest "$CODE" "LG_DRM_FB_HELPER_SINGLE_ADD_ALL_CONNECTORS" "" "types"
;;
drm_hdmi_avi_infoframe_from_display_mode_const_conn)
#
# Determine if the function drm_hdmi_avi_infoframe_from_display_mode()
# has 'const struct connector' parameter.
#
# drm_hdmi_avi_infoframe_from_display_mode() added 'connector' parameter
# by commit 192a3aa0e4e20e1087baa29183c5d64d48716fa9 ("drm/edid: Constify
# connector argument to infoframe functions") in v5.8-rc3.
#
CODE="
#include <drm/drm_edid.h>
typeof(drm_hdmi_avi_infoframe_from_display_mode) conftest_drm_hdmi_avi_infoframe_from_display_mode_has_connector_arg;
int conftest_drm_hdmi_avi_infoframe_from_display_mode_has_connector_arg(
struct hdmi_avi_infoframe *frame,
const struct drm_connector *connector,
const struct drm_display_mode *mode) {
return 0;
}"
compile_check_conftest "$CODE" "LG_DRM_HDMI_AVI_INFOFRAME_FROM_DISPLAY_MODE_HAS_CONST_CONNECTOR_ARG" "" "types"
;;
ttm_buffer_object_has_base)
#
# Determine if the ttm_buffer_object has an base member.
#
# Added by commit 8eb8833e7ed3 ("drm/ttm: add gem base object")
# in v5.4-rc1.
CODE="
#include <drm/ttm/ttm_bo_api.h>
int conftest_ttm_buffer_object_has_base(void) {
return offsetof(struct ttm_buffer_object, base);
}"
compile_check_conftest "$CODE" "LG_TTM_BUFFER_OBJECT_HAS_BASE" "" "types"
;;
drm_driver_has_date)
#
# Determine if the drm_driver has an date member.
#
# drm: remove driver date from struct drm_driver and all drivers
# commit: 7fb8af6798e8d013017e4607505f58d9942fd671
# in v6.14
CODE="
#include <drm/drm_drv.h>
int conftest_drm_driver_has_date(void) {
return offsetof(struct drm_driver, date);
}"
compile_check_conftest "$CODE" "LG_DRM_DRIVER_HAS_DATE" "" "types"
;;
mode_config_has_fb_modifiers)
#
# Determine if the mode_config has an fb_modifiers_not_supported member.
#
# Added by commit 2af104290da5e4858e8caefa068827d7392c6a09
# ("drm: introduce fb_modifiers_not_supported flag in mode_config")
# in vLinux 5.17-rc3.
CODE="
#include <drm/drm_mode_config.h>
int conftest_mode_config_has_fb_modifiers(void) {
return offsetof(struct drm_mode_config, fb_modifiers_not_supported);
}"
compile_check_conftest "$CODE" "LG_MODE_CONFIG_HAS_FB_MODIFIERS" "" "types"
;;
dma_resv_replace_fences)
#
# Determine if the dma_resv_replace_fences() exist.
#
# Added by commit 548e7432dc2da475a18077b612e8d55b8ff51891
# ("dma-buf: add dma_resv_replace_fences v2")
# in v5.18-rc1