Skip to content

Commit

Permalink
scsi: scsi_transport_sas: cap shost opt_sectors according to DMA opti…
Browse files Browse the repository at this point in the history
…mal limit

Streaming DMA mappings may be considerably slower when mappings go through
an IOMMU and the total mapping length is somewhat long. This is because the
IOMMU IOVA code allocates and free an IOVA for each mapping, which may
affect performance.

For performance reasons set the request queue max_sectors from
dma_opt_mapping_size(), which knows this mapping limit.

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
John Garry authored and Christoph Hellwig committed Jul 19, 2022
1 parent 608128d commit 4cbfca5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/scsi/scsi_transport_sas.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ static int sas_host_setup(struct transport_container *tc, struct device *dev,
{
struct Scsi_Host *shost = dev_to_shost(dev);
struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
struct device *dma_dev = shost->dma_dev;

INIT_LIST_HEAD(&sas_host->rphy_list);
mutex_init(&sas_host->lock);
Expand All @@ -236,6 +237,11 @@ static int sas_host_setup(struct transport_container *tc, struct device *dev,
dev_printk(KERN_ERR, dev, "fail to a bsg device %d\n",
shost->host_no);

if (dma_dev->dma_mask) {
shost->opt_sectors = min_t(unsigned int, shost->max_sectors,
dma_opt_mapping_size(dma_dev) >> SECTOR_SHIFT);
}

return 0;
}

Expand Down

0 comments on commit 4cbfca5

Please sign in to comment.