Skip to content

Commit a8cf59a

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
scsi: communicate max segment size to the DMA mapping code
When a host driver sets a maximum segment size we should not only propagate that setting to the block layer, which can merge segments, but also to the DMA mapping layer which can merge segments as well. Fixes: 50c2e91 ("scsi: introduce a max_segment_size host_template parameters") Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 9e8f1c7 commit a8cf59a

File tree

5 files changed

+20
-29
lines changed

5 files changed

+20
-29
lines changed

drivers/ata/pata_macio.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,10 @@ static struct scsi_host_template pata_macio_sht = {
915915
.sg_tablesize = MAX_DCMDS,
916916
/* We may not need that strict one */
917917
.dma_boundary = ATA_DMA_BOUNDARY,
918+
/* Not sure what the real max is but we know it's less than 64K, let's
919+
* use 64K minus 256
920+
*/
921+
.max_segment_size = MAX_DBDMA_SEG,
918922
.slave_configure = pata_macio_slave_config,
919923
};
920924

@@ -1044,11 +1048,6 @@ static int pata_macio_common_init(struct pata_macio_priv *priv,
10441048
/* Make sure we have sane initial timings in the cache */
10451049
pata_macio_default_timings(priv);
10461050

1047-
/* Not sure what the real max is but we know it's less than 64K, let's
1048-
* use 64K minus 256
1049-
*/
1050-
dma_set_max_seg_size(priv->dev, MAX_DBDMA_SEG);
1051-
10521051
/* Allocate libata host for 1 port */
10531052
memset(&pinfo, 0, sizeof(struct ata_port_info));
10541053
pmac_macio_calc_timing_masks(priv, &pinfo);

drivers/ata/sata_inic162x.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,15 @@ struct inic_port_priv {
245245

246246
static struct scsi_host_template inic_sht = {
247247
ATA_BASE_SHT(DRV_NAME),
248-
.sg_tablesize = LIBATA_MAX_PRD, /* maybe it can be larger? */
249-
.dma_boundary = INIC_DMA_BOUNDARY,
248+
.sg_tablesize = LIBATA_MAX_PRD, /* maybe it can be larger? */
249+
250+
/*
251+
* This controller is braindamaged. dma_boundary is 0xffff like others
252+
* but it will lock up the whole machine HARD if 65536 byte PRD entry
253+
* is fed. Reduce maximum segment size.
254+
*/
255+
.dma_boundary = INIC_DMA_BOUNDARY,
256+
.max_segment_size = 65536 - 512,
250257
};
251258

252259
static const int scr_map[] = {
@@ -868,17 +875,6 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
868875
return rc;
869876
}
870877

871-
/*
872-
* This controller is braindamaged. dma_boundary is 0xffff
873-
* like others but it will lock up the whole machine HARD if
874-
* 65536 byte PRD entry is fed. Reduce maximum segment size.
875-
*/
876-
rc = dma_set_max_seg_size(&pdev->dev, 65536 - 512);
877-
if (rc) {
878-
dev_err(&pdev->dev, "failed to set the maximum segment size\n");
879-
return rc;
880-
}
881-
882878
rc = init_controller(hpriv->mmio_base, hpriv->cached_hctl);
883879
if (rc) {
884880
dev_err(&pdev->dev, "failed to initialize controller\n");

drivers/firewire/sbp2.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,10 +1144,6 @@ static int sbp2_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
11441144
if (device->is_local)
11451145
return -ENODEV;
11461146

1147-
if (dma_get_max_seg_size(device->card->device) > SBP2_MAX_SEG_SIZE)
1148-
WARN_ON(dma_set_max_seg_size(device->card->device,
1149-
SBP2_MAX_SEG_SIZE));
1150-
11511147
shost = scsi_host_alloc(&scsi_driver_template, sizeof(*tgt));
11521148
if (shost == NULL)
11531149
return -ENOMEM;
@@ -1610,6 +1606,7 @@ static struct scsi_host_template scsi_driver_template = {
16101606
.eh_abort_handler = sbp2_scsi_abort,
16111607
.this_id = -1,
16121608
.sg_tablesize = SG_ALL,
1609+
.max_segment_size = SBP2_MAX_SEG_SIZE,
16131610
.can_queue = 1,
16141611
.sdev_attrs = sbp2_scsi_sysfs_attrs,
16151612
};

drivers/scsi/aacraid/linit.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,11 +1747,10 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
17471747
shost->max_sectors = (shost->sg_tablesize * 8) + 112;
17481748
}
17491749

1750-
error = dma_set_max_seg_size(&pdev->dev,
1751-
(aac->adapter_info.options & AAC_OPT_NEW_COMM) ?
1752-
(shost->max_sectors << 9) : 65536);
1753-
if (error)
1754-
goto out_deinit;
1750+
if (aac->adapter_info.options & AAC_OPT_NEW_COMM)
1751+
shost->max_segment_size = shost->max_sectors << 9;
1752+
else
1753+
shost->max_segment_size = 65536;
17551754

17561755
/*
17571756
* Firmware printf works only with older firmware.

drivers/scsi/scsi_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,8 +1842,8 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
18421842
blk_queue_segment_boundary(q, shost->dma_boundary);
18431843
dma_set_seg_boundary(dev, shost->dma_boundary);
18441844

1845-
blk_queue_max_segment_size(q,
1846-
min(shost->max_segment_size, dma_get_max_seg_size(dev)));
1845+
blk_queue_max_segment_size(q, shost->max_segment_size);
1846+
dma_set_max_seg_size(dev, shost->max_segment_size);
18471847

18481848
/*
18491849
* Set a reasonable default alignment: The larger of 32-byte (dword),

0 commit comments

Comments
 (0)