scsi: introduce a max_segment_size host_template parameters
authorChristoph Hellwig <hch@lst.de>
Thu, 13 Dec 2018 15:17:03 +0000 (16:17 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 19 Dec 2018 04:13:12 +0000 (23:13 -0500)
This allows the host driver to indicate the maximum supported
segment size in a nice an easy way, so that the driver doesn't
have to worry about DMA-layer imposed limitations.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/be2iscsi/be_main.c
drivers/scsi/hosts.c
drivers/scsi/scsi_debug.c
drivers/scsi/scsi_lib.c
include/scsi/scsi_host.h

index c4108b17d5ab1132b9e42acec58a44f713f7f017..39f3820572b44ef0dc0f679a703ad1c8df0b597d 100644 (file)
@@ -214,12 +214,6 @@ static char const *cqe_desc[] = {
        "CXN_KILLED_IMM_DATA_RCVD"
 };
 
-static int beiscsi_slave_configure(struct scsi_device *sdev)
-{
-       blk_queue_max_segment_size(sdev->request_queue, 65536);
-       return 0;
-}
-
 static int beiscsi_eh_abort(struct scsi_cmnd *sc)
 {
        struct iscsi_task *abrt_task = (struct iscsi_task *)sc->SCp.ptr;
@@ -393,7 +387,6 @@ static struct scsi_host_template beiscsi_sht = {
        .proc_name = DRV_NAME,
        .queuecommand = iscsi_queuecommand,
        .change_queue_depth = scsi_change_queue_depth,
-       .slave_configure = beiscsi_slave_configure,
        .target_alloc = iscsi_target_alloc,
        .eh_timed_out = iscsi_eh_cmd_timed_out,
        .eh_abort_handler = beiscsi_eh_abort,
@@ -404,6 +397,7 @@ static struct scsi_host_template beiscsi_sht = {
        .can_queue = BE2_IO_DEPTH,
        .this_id = -1,
        .max_sectors = BEISCSI_MAX_SECTORS,
+       .max_segment_size = 65536,
        .cmd_per_lun = BEISCSI_CMD_PER_LUN,
        .vendor_id = SCSI_NL_VID_TYPE_PCI | BE_VENDOR_ID,
        .track_queue_depth = 1,
index ea4b0bb0c1cd4e6b12748256741afae339311591..e8148ba414a3d03a8eb52bcec525b22ad4dc3a31 100644 (file)
@@ -464,6 +464,11 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
        else
                shost->max_sectors = SCSI_DEFAULT_MAX_SECTORS;
 
+       if (sht->max_segment_size)
+               shost->max_segment_size = sht->max_segment_size;
+       else
+               shost->max_segment_size = BLK_MAX_SEGMENT_SIZE;
+
        /*
         * assume a 4GB boundary, if not set
         */
index 53ba417bef8a50d1a3d0716d83648823d659e5ab..57d418d7d74e2f38543877b95ed4aa17ba3d8bc1 100644 (file)
@@ -3973,7 +3973,6 @@ static int scsi_debug_slave_configure(struct scsi_device *sdp)
                        return 1;  /* no resources, will be marked offline */
        }
        sdp->hostdata = devip;
-       blk_queue_max_segment_size(sdp->request_queue, -1U);
        if (sdebug_no_uld)
                sdp->no_uld_attach = 1;
        config_cdb_len(sdp);
@@ -5851,6 +5850,7 @@ static struct scsi_host_template sdebug_driver_template = {
        .sg_tablesize =         SG_MAX_SEGMENTS,
        .cmd_per_lun =          DEF_CMD_PER_LUN,
        .max_sectors =          -1U,
+       .max_segment_size =     -1U,
        .module =               THIS_MODULE,
        .track_queue_depth =    1,
 };
index f6900e0b30249d6386863f5db41465cced0fa01b..2d4fd6b4bd922baf9f743e2b8c62309ac4ddb9be 100644 (file)
@@ -2227,7 +2227,8 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
        blk_queue_segment_boundary(q, shost->dma_boundary);
        dma_set_seg_boundary(dev, shost->dma_boundary);
 
-       blk_queue_max_segment_size(q, dma_get_max_seg_size(dev));
+       blk_queue_max_segment_size(q,
+               min(shost->max_segment_size, dma_get_max_seg_size(dev)));
 
        if (shost->use_clustering == DISABLE_CLUSTERING)
                q->limits.cluster = 0;
index 7dc534c794dc11391eb87ae107dab92c0548bf13..834204681ca359c3712d623e9018c8a5cea61d83 100644 (file)
@@ -364,6 +364,11 @@ struct scsi_host_template {
         */
        unsigned int max_sectors;
 
+       /*
+        * Maximum size in bytes of a single segment.
+        */
+       unsigned int max_segment_size;
+
        /*
         * DMA scatter gather segment boundary limit. A segment crossing this
         * boundary will be split in two.
@@ -603,6 +608,7 @@ struct Scsi_Host {
        short unsigned int sg_tablesize;
        short unsigned int sg_prot_tablesize;
        unsigned int max_sectors;
+       unsigned int max_segment_size;
        unsigned long dma_boundary;
        /*
         * In scsi-mq mode, the number of hardware queues supported by the LLD.