Re: [PATCH 2/8] scsi: take the DMA max mapping size into account

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/17/19 5:19 AM, Christoph Hellwig wrote:
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 <hch@xxxxxx>
---
  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);

Does dma_max_mapping_size() return a value in bytes? Is shost->max_sectors a number of sectors? If so, are you sure that "<< SECTOR_SHIFT" is the proper conversion? Shouldn't that be ">> SECTOR_SHIFT" instead?

Additionally, how about adding a comment above dma_max_mapping_size() that documents the unit of the returned number?

Thanks,

Bart.



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux