Re: [PATCH v7 2/3] ufs: set QUEUE_FLAG_LIMIT_BIO_SIZE

From: Bart Van Assche
Date: Tue Apr 13 2021 - 12:14:09 EST


On 4/12/21 7:55 PM, Changheun Lee wrote:
> 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.
> *

This patch should have been split into one patch for the SCSI core and
another patch for the UFS driver.

I see an issue with this patch: a new attribute has been introduced in
struct Scsi_Host but it is not used by the SCSI core. That seems weird
to me.

Another comment I have about this patch is why to restrict the BIO size
(blk_queue_set_limit_bio_size(q, shost->limit_bio_size)) only for UFS
devices? Aren't all block devices, including NVMe devices, expected to
benefit from limiting the BIO size if no stacking is involved? How about
the following approach?
* In blk_queue_max_hw_sectors(), set the maximum BIO size to
max_hw_sectors. As you may know blk_queue_max_hw_sectors() may be
called by any block driver (stacking and non-stacking).
* In blk_stack_limits(), set the maximum BIO size to UINT_MAX. Stacking
block drivers must call blk_stack_limits().

Thanks,

Bart.