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 <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2992552
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2023-10-06 10:22:33 +01:00
committed by mobile promotions
parent 635466f751
commit 35ac3d9d5e

View File

@@ -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_max_hw_sectors(vblkdev->queue, max_io_bytes / SECTOR_SIZE);
blk_queue_flag_set(QUEUE_FLAG_NONROT, vblkdev->queue); 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) 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)) || (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); blk_queue_flag_set(QUEUE_FLAG_SECERASE, vblkdev->queue);
#endif #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_SECURE_ERASE_OP_F)
|| (vblkdev->config.blk_config.req_ops_supported & VS_BLK_ERASE_OP_F)) || (vblkdev->config.blk_config.req_ops_supported & VS_BLK_ERASE_OP_F))
&& vblkdev->config.phys_dev == VSC_DEV_UFS)) { && 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); blk_queue_flag_set(QUEUE_FLAG_DISCARD, vblkdev->queue);
#endif #endif
blk_queue_max_discard_sectors(vblkdev->queue, 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->fops = &vblk_ops;
vblkdev->gd->queue = vblkdev->queue; vblkdev->gd->queue = vblkdev->queue;
vblkdev->gd->private_data = vblkdev; 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; vblkdev->gd->flags |= GENHD_FL_EXT_DEVT;
#endif #endif
@@ -1210,7 +1216,7 @@ static void setup_device(struct vblk_dev *vblkdev)
* requests are not supported */ * requests are not supported */
if (!(vblkdev->config.blk_config.req_ops_supported & if (!(vblkdev->config.blk_config.req_ops_supported &
VS_BLK_READ_OP_F)) { 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; vblkdev->gd->flags |= GENHD_FL_NO_PART_SCAN;
#endif #endif
} }