mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
block: virtual-storage: Remove kernel version checks
Rather than using kernel version checks to determine which kernel APIs to use, add the necessary tests to the conftest script to determine which kernel APIs are present in the kernel. 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 4221847 Change-Id: Iec2c793ce408dab1cf7e5118c019dfe656dfa87c Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2992630 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
a0eaae1775
commit
dc189dfb94
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include <nvidia/conftest.h>
|
#include <nvidia/conftest.h>
|
||||||
|
|
||||||
#include <linux/version.h>
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/moduleparam.h>
|
#include <linux/moduleparam.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
@@ -137,7 +136,7 @@ int vblk_submit_ioctl_req(struct block_device *bdev,
|
|||||||
rq->completion_data = (void *)ioctl_req;
|
rq->completion_data = (void *)ioctl_req;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if KERNEL_VERSION(5, 17, 0) <= LINUX_VERSION_CODE
|
#if defined(NV_BLK_EXECUTE_RQ_HAS_NO_GENDISK_ARG) /* Linux v5.17 */
|
||||||
blk_execute_rq(rq, 0);
|
blk_execute_rq(rq, 0);
|
||||||
#else
|
#else
|
||||||
blk_execute_rq(vblkdev->gd, rq, 0);
|
blk_execute_rq(vblkdev->gd, rq, 0);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include <nvidia/conftest.h>
|
#include <nvidia/conftest.h>
|
||||||
|
|
||||||
#include <linux/version.h>
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/moduleparam.h>
|
#include <linux/moduleparam.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
@@ -1186,9 +1185,9 @@ static void setup_device(struct vblk_dev *vblkdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* And the gendisk structure. */
|
/* And the gendisk structure. */
|
||||||
#if KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE
|
#if defined(NV_BLK_MQ_ALLOC_DISK_FOR_QUEUE_PRESENT) /* Linux v6.0 */
|
||||||
vblkdev->gd = blk_mq_alloc_disk_for_queue(vblkdev->queue, NULL);
|
vblkdev->gd = blk_mq_alloc_disk_for_queue(vblkdev->queue, NULL);
|
||||||
#elif KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE
|
#elif defined(NV___ALLOC_DISK_NODE_HAS_LKCLASS_ARG) /* Linux v5.15 */
|
||||||
vblkdev->gd = __alloc_disk_node(vblkdev->queue, NUMA_NO_NODE, NULL);
|
vblkdev->gd = __alloc_disk_node(vblkdev->queue, NUMA_NO_NODE, NULL);
|
||||||
#else
|
#else
|
||||||
vblkdev->gd = __alloc_disk_node(VBLK_MINORS, NUMA_NO_NODE);
|
vblkdev->gd = __alloc_disk_node(VBLK_MINORS, NUMA_NO_NODE);
|
||||||
@@ -1238,7 +1237,7 @@ static void setup_device(struct vblk_dev *vblkdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_capacity(vblkdev->gd, (vblkdev->size / SECTOR_SIZE));
|
set_capacity(vblkdev->gd, (vblkdev->size / SECTOR_SIZE));
|
||||||
#if KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE
|
#if defined(NV_DEVICE_ADD_DISK_HAS_INT_RETURN_TYPE) /* Linux v5.15 */
|
||||||
if (device_add_disk(vblkdev->device, vblkdev->gd, NULL)) {
|
if (device_add_disk(vblkdev->device, vblkdev->gd, NULL)) {
|
||||||
dev_err(vblkdev->device, "Error adding disk!\n");
|
dev_err(vblkdev->device, "Error adding disk!\n");
|
||||||
return;
|
return;
|
||||||
@@ -1465,8 +1464,10 @@ static int tegra_hv_vblk_remove(struct platform_device *pdev)
|
|||||||
put_disk(vblkdev->gd);
|
put_disk(vblkdev->gd);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if KERNEL_VERSION(5, 19, 0) >= LINUX_VERSION_CODE
|
|
||||||
if (vblkdev->queue)
|
if (vblkdev->queue)
|
||||||
|
#if defined(NV_BLK_MQ_DESTROY_QUEUE_PRESENT) /* Linux v6.0 */
|
||||||
|
blk_mq_destroy_queue(vblkdev->queue);
|
||||||
|
#else
|
||||||
blk_cleanup_queue(vblkdev->queue);
|
blk_cleanup_queue(vblkdev->queue);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -88,12 +88,17 @@ endef
|
|||||||
# provided by the module-specific Kbuild files.
|
# provided by the module-specific Kbuild files.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += __alloc_disk_node_has_lkclass_arg
|
||||||
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += blk_execute_rq_has_no_gendisk_arg
|
||||||
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += blk_mq_alloc_disk_for_queue
|
||||||
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += blk_mq_destroy_queue
|
||||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += block_device_operations_open_has_gendisk_arg
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += block_device_operations_open_has_gendisk_arg
|
||||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += block_device_operations_release_has_no_mode_arg
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += block_device_operations_release_has_no_mode_arg
|
||||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += bus_type_struct_remove_has_int_return_type
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += bus_type_struct_remove_has_int_return_type
|
||||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += class_create_has_no_owner_arg
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += class_create_has_no_owner_arg
|
||||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += class_struct_devnode_has_const_dev_arg
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += class_struct_devnode_has_const_dev_arg
|
||||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += define_semaphore_has_number_arg
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += define_semaphore_has_number_arg
|
||||||
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += device_add_disk_has_int_return_type
|
||||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_thermal_of_zone_register
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_thermal_of_zone_register
|
||||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += disk_check_media_change
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += disk_check_media_change
|
||||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_framebuffers
|
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_framebuffers
|
||||||
|
|||||||
@@ -6329,6 +6329,76 @@ compile_test() {
|
|||||||
compile_check_conftest "$CODE" "NV_CRYPTO_PRESENT" "" "symbols"
|
compile_check_conftest "$CODE" "NV_CRYPTO_PRESENT" "" "symbols"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
__alloc_disk_node_has_lkclass_arg)
|
||||||
|
#
|
||||||
|
# Determine if the function __alloc_disk_node() has an 'lkclass'
|
||||||
|
# argument.
|
||||||
|
#
|
||||||
|
# In Linux v5.15, commit 4dcc4874deb4 ("block: cleanup the lockdep
|
||||||
|
# handling in *alloc_disk") added the 'lkclass' argument to the
|
||||||
|
# __alloc_disk_node() function.
|
||||||
|
#
|
||||||
|
CODE="
|
||||||
|
#include <linux/genhd.h>
|
||||||
|
struct gendisk *conftest___alloc_disk_node_has_lkclass_arg(
|
||||||
|
struct request_queue *q) {
|
||||||
|
return __alloc_disk_node(q, 0, NULL);
|
||||||
|
}"
|
||||||
|
|
||||||
|
compile_check_conftest "$CODE" "NV___ALLOC_DISK_NODE_HAS_LKCLASS_ARG" "" "types"
|
||||||
|
;;
|
||||||
|
|
||||||
|
blk_execute_rq_has_no_gendisk_arg)
|
||||||
|
#
|
||||||
|
# Determine if the function blk_execute_rq() has an argument of
|
||||||
|
# type 'gendisk'.
|
||||||
|
#
|
||||||
|
# In Linux v5.17, commit b84ba30b6c7a ("block: remove the gendisk
|
||||||
|
# argument to blk_execute_rq") removed the 'gendisk' argument from
|
||||||
|
# the blk_execute_rq().
|
||||||
|
#
|
||||||
|
CODE="
|
||||||
|
#include <linux/blk-mq.h>
|
||||||
|
void conftest_blk_execute_rq_has_no_gendisk_arg(struct request *r) {
|
||||||
|
blk_execute_rq(r, false);
|
||||||
|
}"
|
||||||
|
|
||||||
|
compile_check_conftest "$CODE" "NV_BLK_EXECUTE_RQ_HAS_NO_GENDISK_ARG" "" "types"
|
||||||
|
;;
|
||||||
|
|
||||||
|
blk_mq_alloc_disk_for_queue)
|
||||||
|
#
|
||||||
|
# Determine if function blk_mq_alloc_disk_for_queue() is present.
|
||||||
|
#
|
||||||
|
# In Linux v6.0, commit 6f8191fdf41d ("block: simplify disk shutdown")
|
||||||
|
# added the function blk_mq_alloc_disk_for_queue() and removed
|
||||||
|
# __alloc_disk_node().
|
||||||
|
#
|
||||||
|
CODE="
|
||||||
|
#include <linux/blk-mq.h>
|
||||||
|
void conftest_blk_mq_alloc_disk_for_queue(void) {
|
||||||
|
blk_mq_alloc_disk_for_queue();
|
||||||
|
}"
|
||||||
|
|
||||||
|
compile_check_conftest "$CODE" "NV_BLK_MQ_ALLOC_DISK_FOR_QUEUE_PRESENT" "" "functions"
|
||||||
|
;;
|
||||||
|
|
||||||
|
blk_mq_destroy_queue)
|
||||||
|
#
|
||||||
|
# Determine whether function blk_mq_destroy_queue() is present.
|
||||||
|
#
|
||||||
|
# In Linux v6.0, commit 6f8191fdf41d ("block: simplify disk shutdown")
|
||||||
|
# renamed the function blk_cleanup_disk() to blk_mq_destroy_queue().
|
||||||
|
#
|
||||||
|
CODE="
|
||||||
|
#include <linux/blk-mq.h>
|
||||||
|
void conftest_blk_mq_destroy_queue(void) {
|
||||||
|
blk_mq_destroy_queue();
|
||||||
|
}"
|
||||||
|
|
||||||
|
compile_check_conftest "$CODE" "NV_BLK_MQ_DESTROY_QUEUE_PRESENT" "" "functions"
|
||||||
|
;;
|
||||||
|
|
||||||
block_device_operations_open_has_gendisk_arg)
|
block_device_operations_open_has_gendisk_arg)
|
||||||
#
|
#
|
||||||
# Determine if the 'open' function pointer from the
|
# Determine if the 'open' function pointer from the
|
||||||
@@ -6444,6 +6514,24 @@ compile_test() {
|
|||||||
compile_check_conftest "$CODE" "NV_DEFINE_SEMAPHORE_HAS_NUMBER_ARG" "" "types"
|
compile_check_conftest "$CODE" "NV_DEFINE_SEMAPHORE_HAS_NUMBER_ARG" "" "types"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
device_add_disk_has_int_return_type)
|
||||||
|
#
|
||||||
|
# Determine if the function device_add_disk() returns an integer.
|
||||||
|
#
|
||||||
|
# In Linux v5.15, commit 83cbce957446 ("block: add error handling
|
||||||
|
# for device_add_disk / add_disk") updated the function
|
||||||
|
# device_add_disk() to return an integer.
|
||||||
|
#
|
||||||
|
CODE="
|
||||||
|
#include <linux/blkdev.h>
|
||||||
|
int conftest_device_add_disk_has_int_return_type(struct device *dev,
|
||||||
|
struct gendisk *disk) {
|
||||||
|
return device_add_disk(dev, disk, NULL);
|
||||||
|
}"
|
||||||
|
|
||||||
|
compile_check_conftest "$CODE" "NV_DEVICE_ADD_DISK_HAS_INT_RETURN_TYPE" "" "types"
|
||||||
|
;;
|
||||||
|
|
||||||
devm_thermal_of_zone_register)
|
devm_thermal_of_zone_register)
|
||||||
#
|
#
|
||||||
# Determine whether devm_thermal_of_zone_register is present.
|
# Determine whether devm_thermal_of_zone_register is present.
|
||||||
|
|||||||
Reference in New Issue
Block a user