From a7dc815fa5bb37ecbff2fef007cffe14b9d833f2 Mon Sep 17 00:00:00 2001 From: Xiaojun Ji Date: Fri, 3 Nov 2023 16:17:54 +0800 Subject: [PATCH] moto_swap: Add SWP_SYNCHRONOUS_IO cmd for ioctl Currently, swap_slot_has_sync_io() will always return true to skip readahead since ramboost2.0 is SWP_SYNCHRONOUS_IO Change-Id: I84a495f3de464e8c68ccd3d43de2c0b44f3e3fb2 Reviewed-on: https://gerrit.mot.com/2784761 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Yonghui Jia Reviewed-by: Zhangqing Huang Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- drivers/moto_swap/zram-5.4/zram_drv.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/moto_swap/zram-5.4/zram_drv.c b/drivers/moto_swap/zram-5.4/zram_drv.c index 7abdf6e8823b..ac5ce3275e17 100644 --- a/drivers/moto_swap/zram-5.4/zram_drv.c +++ b/drivers/moto_swap/zram-5.4/zram_drv.c @@ -1752,6 +1752,22 @@ static void zram_slot_free_notify(struct block_device *bdev, zram_slot_unlock(zram, index); } +static int zram_ioctl(struct block_device *bdev, fmode_t mode, + unsigned int cmd, unsigned long index) +{ + struct zram *zram; + int has_sync_io = 1; + + if (cmd != SWP_SYNCHRONOUS_IO) return -EINVAL; + + zram = bdev->bd_disk->private_data; + zram_slot_lock(zram, index); + has_sync_io = zram_test_flag(zram, index, ZRAM_WB) ? 0 : 1; + zram_slot_unlock(zram, index); + + return has_sync_io; +} + static int zram_rw_page(struct block_device *bdev, sector_t sector, struct page *page, unsigned int op) { @@ -1944,6 +1960,7 @@ static int zram_open(struct block_device *bdev, fmode_t mode) static const struct block_device_operations zram_devops = { .open = zram_open, .swap_slot_free_notify = zram_slot_free_notify, + .ioctl = zram_ioctl, .rw_page = zram_rw_page, .owner = THIS_MODULE };