From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: [PATCH 2/8] scsi: take the DMA max mapping size into account Date: Mon, 17 Jun 2019 14:19:54 +0200 Message-ID: <20190617122000.22181-3-hch@lst.de> References: <20190617122000.22181-1-hch@lst.de> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20190617122000.22181-1-hch@lst.de> Sender: linux-kernel-owner@vger.kernel.org To: "Martin K . Petersen" Cc: Sagi Grimberg , Max Gurtovoy , Bart Van Assche , linux-rdma@vger.kernel.org, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: linux-rdma@vger.kernel.org We need to limit the devices max_sectors to what the DMA mapping implementation can support. If not we risk running out of swiotlb buffers easily. Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_lib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index d333bb6b1c59..f233bfd84cd7 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1768,6 +1768,8 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q) blk_queue_max_integrity_segments(q, shost->sg_prot_tablesize); } + 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); if (shost->unchecked_isa_dma) blk_queue_bounce_limit(q, BLK_BOUNCE_ISA); -- 2.20.1