Skip to content

Commit 50c2e91

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
scsi: introduce a max_segment_size host_template parameters
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>
1 parent 2a3d4eb commit 50c2e91

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

drivers/scsi/be2iscsi/be_main.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,6 @@ static char const *cqe_desc[] = {
214214
"CXN_KILLED_IMM_DATA_RCVD"
215215
};
216216

217-
static int beiscsi_slave_configure(struct scsi_device *sdev)
218-
{
219-
blk_queue_max_segment_size(sdev->request_queue, 65536);
220-
return 0;
221-
}
222-
223217
static int beiscsi_eh_abort(struct scsi_cmnd *sc)
224218
{
225219
struct iscsi_task *abrt_task = (struct iscsi_task *)sc->SCp.ptr;
@@ -393,7 +387,6 @@ static struct scsi_host_template beiscsi_sht = {
393387
.proc_name = DRV_NAME,
394388
.queuecommand = iscsi_queuecommand,
395389
.change_queue_depth = scsi_change_queue_depth,
396-
.slave_configure = beiscsi_slave_configure,
397390
.target_alloc = iscsi_target_alloc,
398391
.eh_timed_out = iscsi_eh_cmd_timed_out,
399392
.eh_abort_handler = beiscsi_eh_abort,
@@ -404,6 +397,7 @@ static struct scsi_host_template beiscsi_sht = {
404397
.can_queue = BE2_IO_DEPTH,
405398
.this_id = -1,
406399
.max_sectors = BEISCSI_MAX_SECTORS,
400+
.max_segment_size = 65536,
407401
.cmd_per_lun = BEISCSI_CMD_PER_LUN,
408402
.vendor_id = SCSI_NL_VID_TYPE_PCI | BE_VENDOR_ID,
409403
.track_queue_depth = 1,

drivers/scsi/hosts.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
464464
else
465465
shost->max_sectors = SCSI_DEFAULT_MAX_SECTORS;
466466

467+
if (sht->max_segment_size)
468+
shost->max_segment_size = sht->max_segment_size;
469+
else
470+
shost->max_segment_size = BLK_MAX_SEGMENT_SIZE;
471+
467472
/*
468473
* assume a 4GB boundary, if not set
469474
*/

drivers/scsi/scsi_debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3973,7 +3973,6 @@ static int scsi_debug_slave_configure(struct scsi_device *sdp)
39733973
return 1; /* no resources, will be marked offline */
39743974
}
39753975
sdp->hostdata = devip;
3976-
blk_queue_max_segment_size(sdp->request_queue, -1U);
39773976
if (sdebug_no_uld)
39783977
sdp->no_uld_attach = 1;
39793978
config_cdb_len(sdp);
@@ -5851,6 +5850,7 @@ static struct scsi_host_template sdebug_driver_template = {
58515850
.sg_tablesize = SG_MAX_SEGMENTS,
58525851
.cmd_per_lun = DEF_CMD_PER_LUN,
58535852
.max_sectors = -1U,
5853+
.max_segment_size = -1U,
58545854
.module = THIS_MODULE,
58555855
.track_queue_depth = 1,
58565856
};

drivers/scsi/scsi_lib.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,8 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
22272227
blk_queue_segment_boundary(q, shost->dma_boundary);
22282228
dma_set_seg_boundary(dev, shost->dma_boundary);
22292229

2230-
blk_queue_max_segment_size(q, dma_get_max_seg_size(dev));
2230+
blk_queue_max_segment_size(q,
2231+
min(shost->max_segment_size, dma_get_max_seg_size(dev)));
22312232

22322233
if (shost->use_clustering == DISABLE_CLUSTERING)
22332234
q->limits.cluster = 0;

include/scsi/scsi_host.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,11 @@ struct scsi_host_template {
364364
*/
365365
unsigned int max_sectors;
366366

367+
/*
368+
* Maximum size in bytes of a single segment.
369+
*/
370+
unsigned int max_segment_size;
371+
367372
/*
368373
* DMA scatter gather segment boundary limit. A segment crossing this
369374
* boundary will be split in two.
@@ -603,6 +608,7 @@ struct Scsi_Host {
603608
short unsigned int sg_tablesize;
604609
short unsigned int sg_prot_tablesize;
605610
unsigned int max_sectors;
611+
unsigned int max_segment_size;
606612
unsigned long dma_boundary;
607613
/*
608614
* In scsi-mq mode, the number of hardware queues supported by the LLD.

0 commit comments

Comments
 (0)