diff mbox series

[v3,8/9] scsi: core: Set BLK_SUB_PAGE_SEGMENTS for small max_segment_size values

Message ID 20230118225447.2809787-9-bvanassche@acm.org
State New
Headers show
Series Add support for segments smaller than one page | expand

Commit Message

Bart Van Assche Jan. 18, 2023, 10:54 p.m. UTC
The block layer only accepts max_segment_size values smaller than the
page size if the QUEUE_FLAG_SUB_PAGE_SEGMENTS flag is set. Hence this
patch.

Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_lib.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Christoph Hellwig Jan. 19, 2023, 5:38 a.m. UTC | #1
> +	if (shost->max_segment_size && shost->max_segment_size < PAGE_SIZE)
> +		blk_queue_flag_set(QUEUE_FLAG_SUB_PAGE_SEGMENTS, q);

Independ of me really not wanting this code at all if we can avoid it:
this has no business in the SCSI midlayer or drivers.  Once the config
option is enabled, setting the flag should happen inside
blk_queue_max_segment_size.
Bart Van Assche Jan. 19, 2023, 5:27 p.m. UTC | #2
On 1/18/23 21:38, Christoph Hellwig wrote:
>> +	if (shost->max_segment_size && shost->max_segment_size < PAGE_SIZE)
>> +		blk_queue_flag_set(QUEUE_FLAG_SUB_PAGE_SEGMENTS, q);
> 
> Independ of me really not wanting this code at all if we can avoid it:
> this has no business in the SCSI midlayer or drivers.  Once the config
> option is enabled, setting the flag should happen inside
> blk_queue_max_segment_size.

Hi Christoph,

Thanks for having taken a look. I will move this code into the block layer.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 9ed1ebcb7443..91f2e7f787d8 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1876,6 +1876,9 @@  void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
 {
 	struct device *dev = shost->dma_dev;
 
+	if (shost->max_segment_size && shost->max_segment_size < PAGE_SIZE)
+		blk_queue_flag_set(QUEUE_FLAG_SUB_PAGE_SEGMENTS, q);
+
 	/*
 	 * this limit is imposed by hardware restrictions
 	 */