Merge tag 'dma-mapping-5.20-2022-08-06' of git://git.infradead.org/users/hch/dma...
[platform/kernel/linux-starfive.git] / drivers / scsi / sd.c
index 6f7a39b..8f79fa6 100644 (file)
@@ -3297,6 +3297,13 @@ static int sd_revalidate_disk(struct gendisk *disk)
                                      (sector_t)BLK_DEF_MAX_SECTORS);
        }
 
+       /*
+        * Limit default to SCSI host optimal sector limit if set. There may be
+        * an impact on performance for when the size of a request exceeds this
+        * host limit.
+        */
+       rw_max = min_not_zero(rw_max, sdp->host->opt_sectors);
+
        /* Do not exceed controller limit */
        rw_max = min(rw_max, queue_max_hw_sectors(q));