Skip to content

Commit

Permalink
scsi: core: cap shost max_sectors according to DMA limits only once
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
John Garry authored and Christoph Hellwig committed Jul 19, 2022
1 parent 6d9870b commit bb7d128
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 5 additions & 0 deletions drivers/scsi/hosts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bb7d128

Please sign in to comment.