From 35ac3d9d5e4c5508afa3a2a1932d22e3a86d17a6 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Fri, 6 Oct 2023 10:22:33 +0100 Subject: [PATCH] block: virtual-storage: Drop version checks for flags In Linux v5.17, the GENHD_FL_EXT_DEVT and GENHD_FL_NO_PART_SCAN were removed and in Linux v5.19, the flags QUEUE_FLAG_SECERASE and QUEUE_FLAG_DISCARD were removed. Rather than using kernel version checks, simply check if the flag is defined. This is beneficial for working with 3rd party Linux kernels that may have backported changes from upstream. Although the Tegra virtual-storage can be compiled for v5.19 kernels, it still needs to be fixed properly for v5.19 kernels. Add some dev_WARN prints to warn if these flags are not supported so that it will be clear that this is not expected to work. Bug 4119327 Bug 4311184 Change-Id: I7f7585b238ad45b26fb1d0df42b338c904ce87e7 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2992552 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/block/tegra_virt_storage/tegra_hv_vblk.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/block/tegra_virt_storage/tegra_hv_vblk.c b/drivers/block/tegra_virt_storage/tegra_hv_vblk.c index e561f805..19f24dee 100644 --- a/drivers/block/tegra_virt_storage/tegra_hv_vblk.c +++ b/drivers/block/tegra_virt_storage/tegra_hv_vblk.c @@ -1165,9 +1165,12 @@ static void setup_device(struct vblk_dev *vblkdev) blk_queue_max_hw_sectors(vblkdev->queue, max_io_bytes / SECTOR_SIZE); blk_queue_flag_set(QUEUE_FLAG_NONROT, vblkdev->queue); -#if KERNEL_VERSION(5, 19, 0) > LINUX_VERSION_CODE if ((vblkdev->config.blk_config.req_ops_supported & VS_BLK_SECURE_ERASE_OP_F) || (vblkdev->config.blk_config.req_ops_supported & VS_BLK_ERASE_OP_F)) +#if defined(QUEUE_FLAG_SECERASE) /* Removed in Linux 5.19 */ + /* + * FIXME: Support for Linux v5.19+ kernels + */ blk_queue_flag_set(QUEUE_FLAG_SECERASE, vblkdev->queue); #endif @@ -1175,7 +1178,10 @@ static void setup_device(struct vblk_dev *vblkdev) || (((vblkdev->config.blk_config.req_ops_supported & VS_BLK_SECURE_ERASE_OP_F) || (vblkdev->config.blk_config.req_ops_supported & VS_BLK_ERASE_OP_F)) && vblkdev->config.phys_dev == VSC_DEV_UFS)) { -#if KERNEL_VERSION(5, 19, 0) > LINUX_VERSION_CODE +#if defined(QUEUE_FLAG_DISCARD) /* Removed in Linux v5.19 */ + /* + * FIXME: Support for Linux v5.19+ kernels + */ blk_queue_flag_set(QUEUE_FLAG_DISCARD, vblkdev->queue); #endif blk_queue_max_discard_sectors(vblkdev->queue, @@ -1202,7 +1208,7 @@ static void setup_device(struct vblk_dev *vblkdev) vblkdev->gd->fops = &vblk_ops; vblkdev->gd->queue = vblkdev->queue; vblkdev->gd->private_data = vblkdev; -#if KERNEL_VERSION(5, 16, 0) >= LINUX_VERSION_CODE +#if defined(GENHD_FL_EXT_DEVT) /* Removed in Linux v5.17 */ vblkdev->gd->flags |= GENHD_FL_EXT_DEVT; #endif @@ -1210,7 +1216,7 @@ static void setup_device(struct vblk_dev *vblkdev) * requests are not supported */ if (!(vblkdev->config.blk_config.req_ops_supported & VS_BLK_READ_OP_F)) { -#if KERNEL_VERSION(5, 16, 0) >= LINUX_VERSION_CODE +#if defined(GENHD_FL_NO_PART_SCAN) /* Removed in Linux v5.17 */ vblkdev->gd->flags |= GENHD_FL_NO_PART_SCAN; #endif }