diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-01-01 11:00:10 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-01-11 19:29:22 -0500 |
commit | 465ff3185e0cb76d46137335a4d21d0d9d3ac8a2 (patch) | |
tree | 171068cd7d99600cd094c2eb72bac712649fd9eb /drivers | |
parent | 11c3e689f1c3a73e3af7b0ea767b1b0626da8033 (diff) |
[SCSI] relax scsi dma alignment
This patch relaxes the default SCSI DMA alignment from 512 bytes to 4
bytes. I remember from previous discussions that usb and firewire have
sector size alignment requirements, so I upped their alignments in the
respective slave allocs.
The reason for doing this is so that we don't get such a huge amount of
copy overhead in bio_copy_user() for udev. (basically all inquiries it
issues can now be directly mapped).
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/libata-scsi.c | 5 | ||||
-rw-r--r-- | drivers/firewire/fw-sbp2.c | 6 | ||||
-rw-r--r-- | drivers/ieee1394/sbp2.c | 6 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 8 | ||||
-rw-r--r-- | drivers/usb/storage/scsiglue.c | 20 |
5 files changed, 34 insertions, 11 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 264ae60e3fd8..4bb268b9aaeb 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -824,6 +824,9 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev) | |||
824 | * requests. | 824 | * requests. |
825 | */ | 825 | */ |
826 | sdev->max_device_blocked = 1; | 826 | sdev->max_device_blocked = 1; |
827 | |||
828 | /* set the min alignment */ | ||
829 | blk_queue_update_dma_alignment(sdev->request_queue, ATA_DMA_PAD_SZ - 1); | ||
827 | } | 830 | } |
828 | 831 | ||
829 | static void ata_scsi_dev_config(struct scsi_device *sdev, | 832 | static void ata_scsi_dev_config(struct scsi_device *sdev, |
@@ -878,7 +881,7 @@ int ata_scsi_slave_config(struct scsi_device *sdev) | |||
878 | if (dev) | 881 | if (dev) |
879 | ata_scsi_dev_config(sdev, dev); | 882 | ata_scsi_dev_config(sdev, dev); |
880 | 883 | ||
881 | return 0; /* scsi layer doesn't check return value, sigh */ | 884 | return 0; |
882 | } | 885 | } |
883 | 886 | ||
884 | /** | 887 | /** |
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c index 624ff3e082f6..c2169d215bf7 100644 --- a/drivers/firewire/fw-sbp2.c +++ b/drivers/firewire/fw-sbp2.c | |||
@@ -1238,6 +1238,12 @@ static int sbp2_scsi_slave_alloc(struct scsi_device *sdev) | |||
1238 | 1238 | ||
1239 | sdev->allow_restart = 1; | 1239 | sdev->allow_restart = 1; |
1240 | 1240 | ||
1241 | /* | ||
1242 | * Update the dma alignment (minimum alignment requirements for | ||
1243 | * start and end of DMA transfers) to be a sector | ||
1244 | */ | ||
1245 | blk_queue_update_dma_alignment(sdev->request_queue, 511); | ||
1246 | |||
1241 | if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36) | 1247 | if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36) |
1242 | sdev->inquiry_len = 36; | 1248 | sdev->inquiry_len = 36; |
1243 | 1249 | ||
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index b83d254bc86e..1eda11abeb1e 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c | |||
@@ -1963,6 +1963,12 @@ static int sbp2scsi_slave_alloc(struct scsi_device *sdev) | |||
1963 | lu->sdev = sdev; | 1963 | lu->sdev = sdev; |
1964 | sdev->allow_restart = 1; | 1964 | sdev->allow_restart = 1; |
1965 | 1965 | ||
1966 | /* | ||
1967 | * Update the dma alignment (minimum alignment requirements for | ||
1968 | * start and end of DMA transfers) to be a sector | ||
1969 | */ | ||
1970 | blk_queue_update_dma_alignment(sdev->request_queue, 511); | ||
1971 | |||
1966 | if (lu->workarounds & SBP2_WORKAROUND_INQUIRY_36) | 1972 | if (lu->workarounds & SBP2_WORKAROUND_INQUIRY_36) |
1967 | sdev->inquiry_len = 36; | 1973 | sdev->inquiry_len = 36; |
1968 | return 0; | 1974 | return 0; |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index db52222885b7..de601370c05b 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -1668,6 +1668,14 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost, | |||
1668 | 1668 | ||
1669 | if (!shost->use_clustering) | 1669 | if (!shost->use_clustering) |
1670 | clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); | 1670 | clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); |
1671 | |||
1672 | /* | ||
1673 | * set a reasonable default alignment on word boundaries: the | ||
1674 | * host and device may alter it using | ||
1675 | * blk_queue_update_dma_alignment() later. | ||
1676 | */ | ||
1677 | blk_queue_dma_alignment(q, 0x03); | ||
1678 | |||
1671 | return q; | 1679 | return q; |
1672 | } | 1680 | } |
1673 | EXPORT_SYMBOL(__scsi_alloc_queue); | 1681 | EXPORT_SYMBOL(__scsi_alloc_queue); |
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 7c9593b7b04e..dd8b13ef2414 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c | |||
@@ -81,6 +81,16 @@ static int slave_alloc (struct scsi_device *sdev) | |||
81 | */ | 81 | */ |
82 | sdev->inquiry_len = 36; | 82 | sdev->inquiry_len = 36; |
83 | 83 | ||
84 | /* Scatter-gather buffers (all but the last) must have a length | ||
85 | * divisible by the bulk maxpacket size. Otherwise a data packet | ||
86 | * would end up being short, causing a premature end to the data | ||
87 | * transfer. Since high-speed bulk pipes have a maxpacket size | ||
88 | * of 512, we'll use that as the scsi device queue's DMA alignment | ||
89 | * mask. Guaranteeing proper alignment of the first buffer will | ||
90 | * have the desired effect because, except at the beginning and | ||
91 | * the end, scatter-gather buffers follow page boundaries. */ | ||
92 | blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1)); | ||
93 | |||
84 | /* | 94 | /* |
85 | * The UFI spec treates the Peripheral Qualifier bits in an | 95 | * The UFI spec treates the Peripheral Qualifier bits in an |
86 | * INQUIRY result as reserved and requires devices to set them | 96 | * INQUIRY result as reserved and requires devices to set them |
@@ -100,16 +110,6 @@ static int slave_configure(struct scsi_device *sdev) | |||
100 | { | 110 | { |
101 | struct us_data *us = host_to_us(sdev->host); | 111 | struct us_data *us = host_to_us(sdev->host); |
102 | 112 | ||
103 | /* Scatter-gather buffers (all but the last) must have a length | ||
104 | * divisible by the bulk maxpacket size. Otherwise a data packet | ||
105 | * would end up being short, causing a premature end to the data | ||
106 | * transfer. Since high-speed bulk pipes have a maxpacket size | ||
107 | * of 512, we'll use that as the scsi device queue's DMA alignment | ||
108 | * mask. Guaranteeing proper alignment of the first buffer will | ||
109 | * have the desired effect because, except at the beginning and | ||
110 | * the end, scatter-gather buffers follow page boundaries. */ | ||
111 | blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); | ||
112 | |||
113 | /* Many devices have trouble transfering more than 32KB at a time, | 113 | /* Many devices have trouble transfering more than 32KB at a time, |
114 | * while others have trouble with more than 64K. At this time we | 114 | * while others have trouble with more than 64K. At this time we |
115 | * are limiting both to 32K (64 sectores). | 115 | * are limiting both to 32K (64 sectores). |