scsi: core: cap shost max_sectors according to DMA limits only once
authorJohn Garry <john.garry@huawei.com>
Thu, 14 Jul 2022 11:15:26 +0000 (19:15 +0800)
committerChristoph Hellwig <hch@lst.de>
Tue, 19 Jul 2022 04:05:47 +0000 (06:05 +0200)
The shost->max_sectors is repeatedly capped according to the host DMA
mapping limit for each sdev in __scsi_init_queue(). This is unnecessary, so
set only once when adding the host.

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/scsi/hosts.c
drivers/scsi/scsi_lib.c

index 8352f90d997dfa600a454f1c9cb570c4865849b2..d04bd2c7c9f151cd4d3b15f1c2eb4964f3681669 100644 (file)
@@ -236,6 +236,11 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
 
        shost->dma_dev = dma_dev;
 
+       if (dma_dev->dma_mask) {
+               shost->max_sectors = min_t(unsigned int, shost->max_sectors,
+                               dma_max_mapping_size(dma_dev) >> SECTOR_SHIFT);
+       }
+
        error = scsi_mq_setup_tags(shost);
        if (error)
                goto fail;
index 6ffc9e4258a8052c0b05083a86361033185620c0..6ce8acea322a391a3b79e1cb62d58b2f39f62290 100644 (file)
@@ -1884,10 +1884,6 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
                blk_queue_max_integrity_segments(q, shost->sg_prot_tablesize);
        }
 
-       if (dev->dma_mask) {
-               shost->max_sectors = min_t(unsigned int, shost->max_sectors,
-                               dma_max_mapping_size(dev) >> SECTOR_SHIFT);
-       }
        blk_queue_max_hw_sectors(q, shost->max_sectors);
        blk_queue_segment_boundary(q, shost->dma_boundary);
        dma_set_seg_boundary(dev, shost->dma_boundary);