gpu: host1x: Add conftest support

Instead of relying on kernel version to determine if certain functions
or structure are present in the kernel, use the conftest.sh script to
test which functions, structures, etc are present at compile time. This
is beneficial for working with 3rd party Linux kernels that may have
back-ported upstream changes into their kernel and so the kernel version
checks do not work.

Bug 4119327

Change-Id: I56281fa5d95862338bd8a43d6e22225c27590462
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2984422
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2023-09-24 15:40:41 +01:00
committed by mobile promotions
parent 5a26b0ef9d
commit ae64ed46c8
4 changed files with 28 additions and 4 deletions

View File

@@ -88,6 +88,7 @@ endef
# provided by the module-specific Kbuild files.
#
NV_CONFTEST_FUNCTION_COMPILE_TESTS += class_struct_devnode_has_const_dev_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_thermal_of_zone_register
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_framebuffers_has_drm_driver_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_driver_struct_has_irq_enabled_arg

View File

@@ -6293,6 +6293,26 @@ compile_test() {
compile_check_conftest "$CODE" "NV_CRYPTO_PRESENT" "" "symbols"
;;
class_struct_devnode_has_const_dev_arg)
#
# Determine if the 'class' structure devnode function pointer
# has const 'struct dev' argument.
#
# Commit 43a7206b0963 ("driver core: class: make class_register()
# take a const *") updated the class_register function to take a
# const class structure in Linux v6.2.
#
CODE="
#include <linux/device.h>
#include <linux/device/class.h>
#include <linux/types.h>
void conftest_class_struct_devnode_has_const_dev_arg(struct class *c) {
char *(*fn)(const struct device *dev, umode_t *mode) = c->devnode;
}"
compile_check_conftest "$CODE" "NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG" "" "types"
;;
devm_thermal_of_zone_register)
#
# Determine whether devm_thermal_of_zone_register is present.