[PATCH v7 2/3] ufs: set QUEUE_FLAG_LIMIT_BIO_SIZE

From: Changheun Lee
Date: Mon Apr 12 2021 - 23:13:07 EST


Set QUEUE_FLAG_LIMIT_BIO_SIZE queue flag to limit bio max size to
queue max sectors size for UFS device.

Signed-off-by: Changheun Lee <nanich.lee@xxxxxxxxxxx>
---
drivers/scsi/scsi_lib.c | 2 ++
drivers/scsi/ufs/ufshcd.c | 1 +
include/scsi/scsi_host.h | 2 ++
3 files changed, 5 insertions(+)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 7d52a11e1b61..73ce6ba7903a 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1838,6 +1838,8 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
* Devices that require a bigger alignment can increase it later.
*/
blk_queue_dma_alignment(q, max(4, dma_get_cache_alignment()) - 1);
+
+ blk_queue_set_limit_bio_size(q, shost->limit_bio_size);
}
EXPORT_SYMBOL_GPL(__scsi_init_queue);

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index d3d05e997c13..000eb5ab022e 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -9313,6 +9313,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
host->max_channel = UFSHCD_MAX_CHANNEL;
host->unique_id = host->host_no;
host->max_cmd_len = UFS_CDB_SIZE;
+ host->limit_bio_size = true;

hba->max_pwr_info.is_valid = false;

diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index e30fd963b97d..486f61588717 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -607,6 +607,8 @@ struct Scsi_Host {
unsigned int max_segment_size;
unsigned long dma_boundary;
unsigned long virt_boundary_mask;
+ unsigned int limit_bio_size;
+
/*
* In scsi-mq mode, the number of hardware queues supported by the LLD.
*
--
2.29.0